Resolved all of the phpcs errors
This commit is contained in:
parent
4120fe1cd8
commit
7f44e23813
|
@ -1,17 +1,15 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate product functionality
|
||||
*
|
||||
* @author WooCommerce
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( class_exists( 'WC_Admin_Duplicate_Product', false ) ) {
|
||||
return new WC_Admin_Duplicate_Product();
|
||||
}
|
||||
|
@ -87,12 +85,10 @@ class WC_Admin_Duplicate_Product {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_GET['post'] ) ) {
|
||||
$notify_url = wp_nonce_url( admin_url( 'edit.php?post_type=product&action=duplicate_product&post=' . absint( $_GET['post'] ) ), 'woocommerce-duplicate-product_' . $_GET['post'] );
|
||||
?>
|
||||
<div id="duplicate-action"><a class="submitduplicate duplication" href="<?php echo esc_url( $notify_url ); ?>"><?php esc_html_e( 'Copy to a new draft', 'woocommerce' ); ?></a></div>
|
||||
<?php
|
||||
}
|
||||
$notify_url = wp_nonce_url( admin_url( 'edit.php?post_type=product&action=duplicate_product&post=' . absint( $post->ID ) ), 'woocommerce-duplicate-product_' . $post->ID );
|
||||
?>
|
||||
<div id="duplicate-action"><a class="submitduplicate duplication" href="<?php echo esc_url( $notify_url ); ?>"><?php esc_html_e( 'Copy to a new draft', 'woocommerce' ); ?></a></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,7 +107,7 @@ class WC_Admin_Duplicate_Product {
|
|||
|
||||
if ( false === $product ) {
|
||||
/* translators: %s: product id */
|
||||
wp_die( sprintf( esc_html__( 'Product creation failed, could not find original product: %s', 'woocommerce' ), $product_id ) );
|
||||
wp_die( sprintf( esc_html__( 'Product creation failed, could not find original product: %s', 'woocommerce' ), esc_html( $product_id ) ) );
|
||||
}
|
||||
|
||||
$duplicate = $this->product_duplicate( $product );
|
||||
|
@ -120,7 +116,7 @@ class WC_Admin_Duplicate_Product {
|
|||
do_action( 'woocommerce_product_duplicate', $duplicate, $product );
|
||||
wc_do_deprecated_action( 'woocommerce_duplicate_product', array( $duplicate->get_id(), $this->get_product_to_duplicate( $product_id ) ), '3.0', 'Use woocommerce_product_duplicate action instead.' );
|
||||
|
||||
// Redirect to the edit screen for the new draft page
|
||||
// Redirect to the edit screen for the new draft page.
|
||||
wp_redirect( admin_url( 'post.php?action=edit&post=' . $duplicate->get_id() ) );
|
||||
exit;
|
||||
}
|
||||
|
@ -128,15 +124,20 @@ class WC_Admin_Duplicate_Product {
|
|||
/**
|
||||
* Function to create the duplicate of the product.
|
||||
*
|
||||
* @param WC_Product $product
|
||||
* @return WC_Product
|
||||
* @param WC_Product $product The product to duplicate.
|
||||
* @return WC_Product The duplicate.
|
||||
*/
|
||||
public function product_duplicate( $product ) {
|
||||
// Filter to allow us to unset/remove data we don't want to copy to the duplicate. @since 2.6
|
||||
/**
|
||||
* Filter to allow us to unset/remove data we don't want to copy to the duplicate.
|
||||
*
|
||||
* @since 2.6
|
||||
*/
|
||||
$meta_to_exclude = array_filter( apply_filters( 'woocommerce_duplicate_product_exclude_meta', array() ) );
|
||||
|
||||
$duplicate = clone $product;
|
||||
$duplicate->set_id( 0 );
|
||||
/* translators: %s contains the name of the original product. */
|
||||
$duplicate->set_name( sprintf( esc_html__( '%s (Copy)', 'woocommerce' ), $duplicate->get_name() ) );
|
||||
$duplicate->set_total_sales( 0 );
|
||||
if ( '' !== $product->get_sku( 'edit' ) ) {
|
||||
|
@ -153,7 +154,11 @@ class WC_Admin_Duplicate_Product {
|
|||
$duplicate->delete_meta_data( $meta_key );
|
||||
}
|
||||
|
||||
// This action can be used to modify the object further before it is created - it will be passed by reference. @since 3.0
|
||||
/**
|
||||
* This action can be used to modify the object further before it is created - it will be passed by reference.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
do_action( 'woocommerce_product_duplicate_before_save', $duplicate, $product );
|
||||
|
||||
// Save parent product.
|
||||
|
@ -176,7 +181,11 @@ class WC_Admin_Duplicate_Product {
|
|||
$child_duplicate->delete_meta_data( $meta_key );
|
||||
}
|
||||
|
||||
// This action can be used to modify the object further before it is created - it will be passed by reference. @since 3.0
|
||||
/**
|
||||
* This action can be used to modify the object further before it is created - it will be passed by reference.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
do_action( 'woocommerce_product_duplicate_before_save', $child_duplicate, $child );
|
||||
|
||||
$child_duplicate->save();
|
||||
|
@ -193,7 +202,7 @@ class WC_Admin_Duplicate_Product {
|
|||
* Get a product from the database to duplicate.
|
||||
*
|
||||
* @deprecated 3.0.0
|
||||
* @param mixed $id
|
||||
* @param mixed $id The ID of the product to duplicate.
|
||||
* @return object|bool
|
||||
* @see duplicate_product
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue