WC_Admin_Duplicate_Product::dupe_link
Show the "Duplicate" link in admin products list.
Метод класса: WC_Admin_Duplicate_Product{}
Хуки из метода
Возвращает
Массив.
Использование
$WC_Admin_Duplicate_Product = new WC_Admin_Duplicate_Product(); $WC_Admin_Duplicate_Product->dupe_link( $actions, $post );
- $actions(массив) (обязательный)
- Array of actions.
- $post(WP_Post) (обязательный)
- Post object.
Код WC_Admin_Duplicate_Product::dupe_link() WC Admin Duplicate Product::dupe link WC 10.3.5
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;
}