WooCommerce - Allow editors to duplicate products (if editors already can edit products)
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Allow editors to duplicate products if they can already edit them
*
*/
function woo_duplicate_product_link_row($actions, $post) {
if ( function_exists( 'duplicate_post_plugin_activation' ) )
return $actions;
if ( ! current_user_can( 'delete_pages' ) ) return $actions;
if ( $post->post_type != 'product' )
return $actions;
$actions['duplicate'] = '<a href="' . wp_nonce_url( admin_url( 'admin.php?action=duplicate_product&post=' . $post->ID ), 'woocommerce-duplicate-product_' . $post->ID ) . '" title="' . __( 'Make a duplicate from this product', 'woocommerce' )
. '" rel="permalink">' . __( 'Duplicate', 'woocommerce' ) . '</a>';
return $actions;
}
add_filter( 'post_row_actions', 'woo_duplicate_product_link_row',10,2 );
add_filter( 'page_row_actions', 'woo_duplicate_product_link_row',10,2 );