WC_Admin_Duplicate_Product::dupe_link()
Show the "Duplicate" link in admin products list.
Method of the class: WC_Admin_Duplicate_Product{}
Hooks from the method
Return
Array
.
Usage
$WC_Admin_Duplicate_Product = new WC_Admin_Duplicate_Product(); $WC_Admin_Duplicate_Product->dupe_link( $actions, $post );
- $actions(array) (required)
- Array of actions.
- $post(WP_Post) (required)
- Post object.
WC_Admin_Duplicate_Product::dupe_link() WC Admin Duplicate Product::dupe link code WC 9.7.1
public function dupe_link( $actions, $post ) { global $the_product; if ( ! current_user_can( apply_filters( 'woocommerce_duplicate_product_capability', 'manage_woocommerce' ) ) ) { return $actions; } if ( 'product' !== $post->post_type ) { return $actions; } // Add Class to Delete Permanently link in row actions. if ( empty( $the_product ) || $the_product->get_id() !== $post->ID ) { $the_product = wc_get_product( $post ); } if ( $the_product && ProductStatus::PUBLISH === $the_product->get_status() && 0 < $the_product->get_total_sales() ) { $actions['trash'] = sprintf( '<a href="%s" class="submitdelete trash-product" aria-label="%s">%s</a>', get_delete_post_link( $the_product->get_id(), '', false ), /* translators: %s: post title */ esc_attr( sprintf( __( 'Move “%s” to the Trash', 'woocommerce' ), $the_product->get_name() ) ), esc_html__( 'Trash', 'woocommerce' ) ); } $actions['duplicate'] = '<a href="' . wp_nonce_url( admin_url( 'edit.php?post_type=product&action=duplicate_product&post=' . $post->ID ), 'woocommerce-duplicate-product_' . $post->ID ) . '" aria-label="' . esc_attr__( 'Make a duplicate from this product', 'woocommerce' ) . '" rel="permalink">' . esc_html__( 'Duplicate', 'woocommerce' ) . '</a>'; return $actions; }