PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-universal.php +28 -26 13.6.2 → 16.3-a.7 View file →
@@ -11,9 +11,9 @@
11 11 /**
12 12 * Bail if accessed directly
13 13 */
14 14 if ( ! defined( 'ABSPATH' ) ) {
15 - exit;
15 + exit( 0 );
16 16 }
17 17
18 18 /**
19 19 * Class Jetpack_WooCommerce_Analytics_Universal
@@ -94,10 +94,16 @@
94 94 *
95 95 * @deprecated 13.3
96 96 */
97 97 public function remove_from_cart() {
98 - $common_props = $this->render_properties_as_js(
99 - $this->get_common_properties()
98 + $common_props = wp_json_encode(
99 + array_merge(
100 + array(
101 + '_en' => 'woocommerceanalytics_remove_from_cart',
102 + ),
103 + $this->get_common_properties()
104 + ),
105 + JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP
100 106 );
101 107
102 108 // We listen at div.woocommerce because the cart 'form' contents get forcibly
103 109 // updated and subsequent removals from cart would then not have this click
@@ -105,19 +111,13 @@
105 111 wc_enqueue_js(
106 112 "jQuery( 'div.woocommerce' ).on( 'click', 'a.remove', function() {
107 113 var productID = jQuery( this ).data( 'product_id' );
108 114 var quantity = jQuery( this ).parent().parent().find( '.qty' ).val()
109 - var productDetails = {
110 - 'id': productID,
111 - 'quantity': quantity ? quantity : '1',
112 - };
113 - _wca.push( {
114 - '_en': 'woocommerceanalytics_remove_from_cart',
115 - 'pi': productDetails.id,
116 - 'pq': productDetails.quantity, " .
117 - $common_props . '
118 - } );
119 - } );'
115 + var common_props = $common_props;
116 + common_props.pi = productID;
117 + common_props.pq = quantity ? quantity : '1';
118 + _wca.push( common_props );
119 + } );"
120 120 );
121 121 }
122 122
123 123 /**
@@ -353,18 +353,16 @@
353 353 $checkout_page_contains_checkout_shortcode = '0';
354 354
355 355 $order_source = $order->get_created_via();
356 356 if ( 'store-api' === $order_source ) {
357 - $checkout_page_contains_checkout_block = '1';
358 - $checkout_page_contains_checkout_shortcode = '0';
357 + $checkout_page_contains_checkout_block = '1';
359 358 } elseif ( 'checkout' === $order_source ) {
360 - $checkout_page_contains_checkout_block = '0';
361 359 $checkout_page_contains_checkout_shortcode = '1';
362 360 }
363 361
364 362 // loop through products in the order and queue a purchase event.
365 363 foreach ( $order->get_items() as $order_item ) {
366 - // @phan-suppress-next-line PhanUndeclaredMethodInCallable,PhanUndeclaredMethod -- Checked before being called. See also https://github.com/phan/phan/issues/1204.
364 + // @phan-suppress-next-line PhanUndeclaredMethod -- Checked before being called. See also https://github.com/phan/phan/issues/1204.
367 365 $product_id = is_callable( array( $order_item, 'get_product_id' ) ) ? $order_item->get_product_id() : -1;
368 366
369 367 $order_items = $order->get_items();
370 368 $order_items_count = 0;
@@ -403,10 +401,16 @@
403 401 *
404 402 * @deprecated 13.3
405 403 */
406 404 public function remove_from_cart_via_quantity() {
407 - $common_props = $this->render_properties_as_js(
408 - $this->get_common_properties()
405 + $common_props = wp_json_encode(
406 + array_merge(
407 + array(
408 + '_en' => 'woocommerceanalytics_remove_from_cart',
409 + ),
410 + $this->get_common_properties()
411 + ),
412 + JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP
409 413 );
410 414
411 415 wc_enqueue_js(
412 416 "
@@ -415,16 +419,14 @@
415 419 cartItems.each( function( item ) {
416 420 var qty = jQuery( this ).find( 'input.qty' );
417 421 if ( qty && qty.val() === '0' ) {
418 422 var productID = jQuery( this ).find( '.product-remove a' ).data( 'product_id' );
419 - _wca.push( {
420 - '_en': 'woocommerceanalytics_remove_from_cart',
421 - 'pi': productID, " .
422 - $common_props . '
423 - } );
423 + var common_props = $common_props;
424 + common_props.pi = productID;
425 + _wca.push( common_props );
424 426 }
425 427 } );
426 - } );'
428 + } );"
427 429 );
428 430 }
429 431
430 432 /**