Plugin Author
WPCava
(@actionphp)
Hello,
You can now duplicate from the admin bar on the front end.
All the best,
Jean Paul
WPGem.com
Thanks mate!
Unfortunately, it didn’t work for me.
So based on your function and my themes (Flatsome) admin edit bar function I re-wrote it:
/**
* Add «Duplicate this product in
* admin toolbar
*/
function ross_admin_bar_link() {
if(is_product()){
global $wp_admin_bar;
global $post;
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
return;
}
$duplicate_url = wp_nonce_url( admin_url( 'edit.php?post_type=product&action=duplicate_product&post=' . $post->ID ), 'woocommerce-duplicate-product_' . $post->ID );
$wp_admin_bar->add_menu( array(
'parent' => 'edit',
'id' => 'wedp_admin_bar_button',
'title' => 'Duplicate this product',
'href' => $duplicate_url,
'meta' => [
'target' => '_blank',
]
) );
}
}
add_action( 'wp_before_admin_bar_render', 'ross_admin_bar_link', 30);
Not sure is it correct syntaxis but works