plugin updates

This commit is contained in:
Tony Volpe
2024-07-16 13:57:46 +00:00
parent 41f50eacc4
commit 8f93917880
1529 changed files with 259452 additions and 25451 deletions

View File

@@ -29,7 +29,8 @@ class WC_Products_Tracking {
add_action( 'load-edit.php', array( $this, 'track_products_view' ), 10 );
add_action( 'load-edit-tags.php', array( $this, 'track_categories_and_tags_view' ), 10, 2 );
add_action( 'edit_post', array( $this, 'track_product_updated' ), 10, 2 );
add_action( 'wp_after_insert_post', array( $this, 'track_product_published' ), 10, 4 );
add_action( 'woocommerce_new_product', array( $this, 'track_product_published' ), 10, 3 );
add_action( 'woocommerce_update_product', array( $this, 'track_product_published' ), 10, 3 );
add_action( 'created_product_cat', array( $this, 'track_product_category_created' ) );
add_action( 'edited_product_cat', array( $this, 'track_product_category_updated' ) );
add_action( 'add_meta_boxes_product', array( $this, 'track_product_updated_client_side' ), 10 );
@@ -125,7 +126,7 @@ class WC_Products_Tracking {
}
/* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */
$source = apply_filters( 'woocommerce_product_source', self::TRACKS_SOURCE );
$source = apply_filters( 'woocommerce_product_source', self::is_importing() ? 'import' : self::TRACKS_SOURCE );
$properties = array(
'product_id' => $product_id,
'source' => $source,
@@ -303,24 +304,21 @@ class WC_Products_Tracking {
/**
* Send a Tracks event when a product is published.
*
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
* @param bool $update Whether this is an existing post being updated.
* @param null|WP_Post $post_before Null for new posts, the WP_Post object prior
* to the update for updated posts.
* @param int $product_id Product ID.
* @param WC_Product $product Product object.
* @param array $changes Product changes.
*/
public function track_product_published( $post_id, $post, $update, $post_before ) {
public function track_product_published( $product_id, $product, $changes = null ) {
if (
'product' !== $post->post_type ||
'publish' !== $post->post_status ||
( $post_before && 'publish' === $post_before->post_status )
! isset( $product ) ||
'product' !== $product->post_type ||
'publish' !== $product->get_status( 'edit' ) ||
( $changes && ! isset( $changes['status'] ) )
) {
return;
}
$product = wc_get_product( $post_id );
$product_type_options = self::get_product_type_options( $post_id );
$product_type_options = self::get_product_type_options( $product_id );
$product_type_options_string = self::get_product_type_options_string( $product_type_options );
$properties = array(
@@ -334,14 +332,14 @@ class WC_Products_Tracking {
'is_virtual' => $product->is_virtual() ? 'yes' : 'no',
'manage_stock' => $product->get_manage_stock() ? 'yes' : 'no',
'menu_order' => $product->get_menu_order() ? 'yes' : 'no',
'product_id' => $post_id,
'product_id' => $product_id,
'product_gallery' => count( $product->get_gallery_image_ids() ),
'product_image' => $product->get_image_id() ? 'yes' : 'no',
'product_type' => $product->get_type(),
'product_type_options' => $product_type_options_string,
'purchase_note' => $product->get_purchase_note() ? 'yes' : 'no',
'sale_price' => $product->get_sale_price() ? 'yes' : 'no',
'source' => apply_filters( 'woocommerce_product_source', self::TRACKS_SOURCE ),
'source' => apply_filters( 'woocommerce_product_source', self::is_importing() ? 'import' : self::TRACKS_SOURCE ),
'short_description' => $product->get_short_description() ? 'yes' : 'no',
'tags' => count( $product->get_tag_ids() ),
'upsells' => ! empty( $product->get_upsell_ids() ) ? 'yes' : 'no',
@@ -546,4 +544,19 @@ class WC_Products_Tracking {
}
WCAdminAssets::register_script( 'wp-admin-scripts', 'add-term-tracking', false );
}
/**
* Check if the current process is importing products.
*
* @return bool True if importing, false otherwise.
*/
private function is_importing() {
// phpcs:disable WordPress.Security.NonceVerification.Missing
// Check if the current request is a product import.
if ( isset( $_POST['action'] ) && 'woocommerce_do_ajax_product_import' === $_POST['action'] ) {
return true;
}
return false;
// phpcs:enable
}
}