<?php
add_filter('post_row_actions', 'custom_clone_product_action', 10, 2);
function custom_clone_product_action($actions, $post)
{
// Restrict the action to limited set of posts
if ($post->post_type != 'wc-products') {
return $actions;
}
$post_id = $post->ID;
// // Restrict action by user capabilitites
if (!current_user_can('edit_wc_product', $post_id)) {
return $actions;
}
// // Create a nonce & add an action
$nonce = wp_create_nonce('wc_clone_action_nonce');
$actions['wc_clone_action_nonce'] = '<a class="clone-this" href="#clone-product" data-code="' . esc_attr($nonce) . '" data-id="' . esc_attr($post_id) . '">Clone Product</a>';
return $actions;
}