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 +59 -26 13.2.4 → 16.3-a.7 View file →
@@ -1,8 +1,10 @@
1 1 <?php
2 2 /**
3 3 * Jetpack_WooCommerce_Analytics_Universal
4 4 *
5 + * @deprecated 13.3
6 + *
5 7 * @package automattic/jetpack
6 8 * @author Automattic
7 9 */
8 10
@@ -9,14 +11,16 @@
9 11 /**
10 12 * Bail if accessed directly
11 13 */
12 14 if ( ! defined( 'ABSPATH' ) ) {
13 - exit;
15 + exit( 0 );
14 16 }
15 17
16 18 /**
17 19 * Class Jetpack_WooCommerce_Analytics_Universal
18 20 * Filters and Actions added to Store pages to perform analytics
21 + *
22 + * @deprecated 13.3
19 23 */
20 24 class Jetpack_WooCommerce_Analytics_Universal {
21 25
22 26 /**
@@ -25,8 +29,10 @@
25 29 use Jetpack_WooCommerce_Analytics_Trait;
26 30
27 31 /**
28 32 * Jetpack_WooCommerce_Analytics_Universal constructor.
33 + *
34 + * @deprecated 13.3
29 35 */
30 36 public function __construct() {
31 37 $this->find_cart_checkout_content_sources();
32 38 $this->additional_blocks_on_cart_page = $this->get_additional_blocks_on_page( 'cart' );
@@ -59,8 +65,10 @@
59 65 }
60 66
61 67 /**
62 68 * On product lists or other non-product pages, add an event listener to "Add to Cart" button click
69 + *
70 + * @deprecated 13.3
63 71 */
64 72 public function loop_session_events() {
65 73 // Check for previous events queued in session data.
66 74 if ( is_object( WC()->session ) ) {
@@ -82,12 +90,20 @@
82 90 }
83 91
84 92 /**
85 93 * On the cart page, add an event listener for removal of product click
94 + *
95 + * @deprecated 13.3
86 96 */
87 97 public function remove_from_cart() {
88 - $common_props = $this->render_properties_as_js(
89 - $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
90 106 );
91 107
92 108 // We listen at div.woocommerce because the cart 'form' contents get forcibly
93 109 // updated and subsequent removals from cart would then not have this click
@@ -95,19 +111,13 @@
95 111 wc_enqueue_js(
96 112 "jQuery( 'div.woocommerce' ).on( 'click', 'a.remove', function() {
97 113 var productID = jQuery( this ).data( 'product_id' );
98 114 var quantity = jQuery( this ).parent().parent().find( '.qty' ).val()
99 - var productDetails = {
100 - 'id': productID,
101 - 'quantity': quantity ? quantity : '1',
102 - };
103 - _wca.push( {
104 - '_en': 'woocommerceanalytics_remove_from_cart',
105 - 'pi': productDetails.id,
106 - 'pq': productDetails.quantity, " .
107 - $common_props . '
108 - } );
109 - } );'
115 + var common_props = $common_props;
116 + common_props.pi = productID;
117 + common_props.pq = quantity ? quantity : '1';
118 + _wca.push( common_props );
119 + } );"
110 120 );
111 121 }
112 122
113 123 /**
@@ -112,12 +122,14 @@
112 122
113 123 /**
114 124 * Adds the product ID to the remove product link (for use by remove_from_cart above) if not present
115 125 *
126 + * @deprecated 13.3
127 + *
116 128 * @param string $url Full HTML a tag of the link to remove an item from the cart.
117 129 * @param string $key Unique Key ID for a cart item.
118 130 *
119 - * @return mixed.
131 + * @return string
120 132 */
121 133 public function remove_from_cart_attributes( $url, $key ) {
122 134 if ( str_contains( $url, 'data-product_id' ) ) {
123 135 return $url;
@@ -138,8 +150,10 @@
138 150 /**
139 151 * Get the selected shipping option for a cart item. If the name cannot be found in the options table, the method's
140 152 * ID will be used.
141 153 *
154 + * @deprecated 13.3
155 + *
142 156 * @param string $cart_item_key the cart item key.
143 157 *
144 158 * @return mixed|bool
145 159 */
@@ -180,8 +194,10 @@
180 194 }
181 195
182 196 /**
183 197 * On the Checkout page, trigger an event for each product in the cart
198 + *
199 + * @deprecated 13.3
184 200 */
185 201 public function checkout_process() {
186 202 global $post;
187 203 $checkout_page_id = wc_get_page_id( 'checkout' );
@@ -293,8 +309,10 @@
293 309
294 310 /**
295 311 * After the checkout process, fire an event for each item in the order
296 312 *
313 + * @deprecated 13.3
314 + *
297 315 * @param string $order_id Order Id.
298 316 */
299 317 public function order_process( $order_id ) {
300 318 $order = wc_get_order( $order_id );
@@ -335,17 +353,16 @@
335 353 $checkout_page_contains_checkout_shortcode = '0';
336 354
337 355 $order_source = $order->get_created_via();
338 356 if ( 'store-api' === $order_source ) {
339 - $checkout_page_contains_checkout_block = '1';
340 - $checkout_page_contains_checkout_shortcode = '0';
357 + $checkout_page_contains_checkout_block = '1';
341 358 } elseif ( 'checkout' === $order_source ) {
342 - $checkout_page_contains_checkout_block = '0';
343 359 $checkout_page_contains_checkout_shortcode = '1';
344 360 }
345 361
346 362 // loop through products in the order and queue a purchase event.
347 363 foreach ( $order->get_items() as $order_item ) {
364 + // @phan-suppress-next-line PhanUndeclaredMethod -- Checked before being called. See also https://github.com/phan/phan/issues/1204.
348 365 $product_id = is_callable( array( $order_item, 'get_product_id' ) ) ? $order_item->get_product_id() : -1;
349 366
350 367 $order_items = $order->get_items();
351 368 $order_items_count = 0;
@@ -380,12 +397,20 @@
380 397
381 398 /**
382 399 * Listen for clicks on the "Update Cart" button to know if an item has been removed by
383 400 * updating its quantity to zero
401 + *
402 + * @deprecated 13.3
384 403 */
385 404 public function remove_from_cart_via_quantity() {
386 - $common_props = $this->render_properties_as_js(
387 - $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
388 413 );
389 414
390 415 wc_enqueue_js(
391 416 "
@@ -394,16 +419,14 @@
394 419 cartItems.each( function( item ) {
395 420 var qty = jQuery( this ).find( 'input.qty' );
396 421 if ( qty && qty.val() === '0' ) {
397 422 var productID = jQuery( this ).find( '.product-remove a' ).data( 'product_id' );
398 - _wca.push( {
399 - '_en': 'woocommerceanalytics_remove_from_cart',
400 - 'pi': productID, " .
401 - $common_props . '
402 - } );
423 + var common_props = $common_props;
424 + common_props.pi = productID;
425 + _wca.push( common_props );
403 426 }
404 427 } );
405 - } );'
428 + } );"
406 429 );
407 430 }
408 431
409 432 /**
@@ -408,8 +431,10 @@
408 431
409 432 /**
410 433 * Gets the inner blocks of a block.
411 434 *
435 + * @deprecated 13.3
436 + *
412 437 * @param array $inner_blocks The inner blocks.
413 438 *
414 439 * @return array
415 440 */
@@ -426,8 +451,10 @@
426 451
427 452 /**
428 453 * Track adding items to the cart.
429 454 *
455 + * @deprecated 13.3
456 + *
430 457 * @param string $cart_item_key Cart item key.
431 458 * @param int $product_id Product added to cart.
432 459 * @param int $quantity Quantity added to cart.
433 460 * @param int $variation_id Product variation.
@@ -448,8 +475,10 @@
448 475
449 476 /**
450 477 * Track in-session data.
451 478 *
479 + * @deprecated 13.3
480 + *
452 481 * @param int $product_id Product ID.
453 482 * @param int $quantity Quantity.
454 483 * @param string $event Fired event.
455 484 */
@@ -487,8 +516,10 @@
487 516
488 517 /**
489 518 * Save createaccount post data to be used in $this->order_process.
490 519 *
520 + * @deprecated 13.3
521 + *
491 522 * @param array $data post data from the checkout page.
492 523 *
493 524 * @return array
494 525 */
@@ -504,8 +535,10 @@
504 535 }
505 536
506 537 /**
507 538 * Capture the create account event. Similar to save_checkout_post_data but works with Store API.
539 + *
540 + * @deprecated 13.3
508 541 *
509 542 * @param int $customer_id Customer ID.
510 543 * @param array $new_customer_data New customer data.
511 544 */