PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
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-trait.php +41 -38 13.2.4 → 16.3-a.5 View file →
@@ -1,8 +1,10 @@
1 1 <?php
2 2 /**
3 3 * Jetpack_WooCommerce_Analytics_Trait
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 * Jetpack_WooCommerce_Analytics_Trait
18 20 * Common functionality for WooCommerce Analytics classes.
21 + *
22 + * @deprecated 13.3
19 23 */
20 24 trait Jetpack_WooCommerce_Analytics_Trait {
21 25
22 26 /**
@@ -56,8 +60,10 @@
56 60
57 61 /**
58 62 * Format Cart Items or Order Items to an array
59 63 *
64 + * @deprecated 13.3
65 + *
60 66 * @param array|WC_Order_Item[] $items Cart Items or Order Items.
61 67 */
62 68 protected function format_items_to_json( $items ) {
63 69 $products = array();
@@ -82,13 +88,15 @@
82 88 }
83 89 $products[] = $data;
84 90 }
85 91
86 - return wp_json_encode( $products );
92 + return wp_json_encode( $products, JSON_UNESCAPED_SLASHES );
87 93 }
88 94
89 95 /**
90 96 * Get Cart/Checkout page view shared data
97 + *
98 + * @deprecated 13.3
91 99 */
92 100 protected function get_cart_checkout_shared_data() {
93 101 $cart = WC()->cart;
94 102
@@ -132,8 +140,10 @@
132 140 /**
133 141 * Gets the content of the cart/checkout page or where the cart/checkout page is ultimately derived from if using a template.
134 142 * This method sets the class properties $checkout_content_source and $cart_content_source.
135 143 *
144 + * @deprecated 13.3
145 + *
136 146 * @return void Does not return, but sets class properties.
137 147 */
138 148 public function find_cart_checkout_content_sources() {
139 149
@@ -203,21 +213,8 @@
203 213 $cart_template = get_block_template( 'woocommerce/woocommerce//cart' );
204 214 }
205 215 }
206 216
207 - if ( function_exists( 'gutenberg_get_block_template' ) ) {
208 - $checkout_template = gutenberg_get_block_template( 'woocommerce/woocommerce//page-checkout' );
209 - $cart_template = gutenberg_get_block_template( 'woocommerce/woocommerce//page-cart' );
210 -
211 - if ( ! $checkout_template ) {
212 - $checkout_template = gutenberg_get_block_template( 'woocommerce/woocommerce//checkout' );
213 - }
214 -
215 - if ( ! $cart_template ) {
216 - $cart_template = gutenberg_get_block_template( 'woocommerce/woocommerce//cart' );
217 - }
218 - }
219 -
220 217 if ( ! empty( $checkout_template->content ) ) {
221 218 // Checkout template is in use, but we need to see if the page-content-wrapper is in use, or if the template is being used directly.
222 219 $this->checkout_content_source = $checkout_template->content;
223 220 $is_using_page_content = str_contains( $checkout_template->content, '<!-- wp:woocommerce/page-content-wrapper {"page":"checkout"}' );
@@ -259,8 +256,10 @@
259 256
260 257 /**
261 258 * Default event properties which should be included with all events.
262 259 *
260 + * @deprecated 13.3
261 + *
263 262 * @return array Array of standard event props.
264 263 */
265 264 public function get_common_properties() {
266 265 $site_info = array(
@@ -278,29 +277,13 @@
278 277 $cart_checkout_info = $this->get_cart_checkout_info();
279 278 return array_merge( $site_info, $cart_checkout_info );
280 279 }
281 280
282 - /**
283 - * Render tracks event properties as string of JavaScript object props.
284 - *
285 - * @param array $properties Array of key/value pairs.
286 - * @return string String of the form "key1: value1, key2: value2, " (etc).
287 - */
288 - private function render_properties_as_js( $properties ) {
289 - $js_args_string = '';
290 - foreach ( $properties as $key => $value ) {
291 - if ( is_array( $value ) ) {
292 - $js_args_string = $js_args_string . "'$key': " . wp_json_encode( $value ) . ',';
293 - } else {
294 - $js_args_string = $js_args_string . "'$key': '" . esc_js( $value ) . "', ";
295 - }
296 - }
297 - return $js_args_string;
298 - }
299 -
300 281 /**
301 282 * Record an event with optional product and custom properties.
302 283 *
284 + * @deprecated 13.3
285 + *
303 286 * @param string $event_name The name of the event to record.
304 287 * @param array $properties Optional array of (key => value) event properties.
305 288 * @param integer $product_id The id of the product relating to the event.
306 289 *
@@ -313,8 +296,10 @@
313 296
314 297 /**
315 298 * Gather relevant product information
316 299 *
300 + * @deprecated 13.3
301 + *
317 302 * @param \WC_Product $product product.
318 303 * @return array
319 304 */
320 305 public function get_product_details( $product ) {
@@ -329,8 +314,10 @@
329 314
330 315 /**
331 316 * Gets product categories or varation attributes as a formatted concatenated string
332 317 *
318 + * @deprecated 13.3
319 + *
333 320 * @param object $product WC_Product.
334 321 * @return string
335 322 */
336 323 public function get_product_categories_concatenated( $product ) {
@@ -357,8 +344,10 @@
357 344
358 345 /**
359 346 * Compose event properties.
360 347 *
348 + * @deprecated 13.3
349 + *
361 350 * @param string $event_name The name of the event to record.
362 351 * @param array $properties Optional array of (key => value) event properties.
363 352 * @param integer $product_id Optional id of the product relating to the event.
364 353 *
@@ -391,22 +380,26 @@
391 380 $properties
392 381 )
393 382 );
394 383
395 - $js = "{'_en': '" . esc_js( $event_name ) . "'";
396 -
397 384 if ( isset( $product_details ) ) {
398 385 $all_props = array_merge( $all_props, $product_details );
399 386 }
400 387
401 - $js .= ',' . $this->render_properties_as_js( $all_props ) . '}';
402 -
403 - return $js;
388 + return wp_json_encode(
389 + array_merge(
390 + array( '_en' => $event_name ),
391 + $all_props
392 + ),
393 + JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP
394 + );
404 395 }
405 396
406 397 /**
407 398 * Get the current user id
408 399 *
400 + * @deprecated 13.3
401 + *
409 402 * @return int
410 403 */
411 404 public function get_user_id() {
412 405 if ( is_user_logged_in() ) {
@@ -419,8 +412,10 @@
419 412
420 413 /**
421 414 * Gets the IDs of additional blocks on the Cart/Checkout pages or templates.
422 415 *
416 + * @deprecated 13.3
417 + *
423 418 * @param string $cart_or_checkout Whether to get blocks on the cart or checkout page.
424 419 * @return array All inner blocks on the page.
425 420 */
426 421 public function get_additional_blocks_on_page( $cart_or_checkout = 'cart' ) {
@@ -490,8 +485,10 @@
490 485
491 486 /**
492 487 * Gets an array containing the block or shortcode use properties for the Cart page.
493 488 *
489 + * @deprecated 13.3
490 + *
494 491 * @return array An array containing the block or shortcode use properties for the Cart page.
495 492 */
496 493 public function get_cart_page_block_usage() {
497 494 $new_info = array();
@@ -508,8 +505,10 @@
508 505
509 506 /**
510 507 * Gets an array containing the block or shortcode use properties for the Checkout page.
511 508 *
509 + * @deprecated 13.3
510 + *
512 511 * @return array An array containing the block or shortcode use properties for the Checkout page.
513 512 */
514 513 public function get_checkout_page_block_usage() {
515 514 $new_info = array();
@@ -531,8 +530,10 @@
531 530 *
532 531 * Note: similar code is in a WooCommerce core PR:
533 532 * https://github.com/woocommerce/woocommerce/pull/25932
534 533 *
534 + * @deprecated 13.3
535 + *
535 536 * @return array
536 537 */
537 538 public function get_cart_checkout_info() {
538 539 $info = array_merge(
@@ -546,8 +547,10 @@
546 547 * Search a specific post for text content.
547 548 *
548 549 * Note: similar code is in a WooCommerce core PR:
549 550 * https://github.com/woocommerce/woocommerce/pull/25932
551 + *
552 + * @deprecated 13.3
550 553 *
551 554 * @param integer $post_id The id of the post to search.
552 555 * @param string $text The text to search for.
553 556 * @return integer 1 if post contains $text (otherwise 0).