← All changes
|
modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-my-account.php
+44
-9
13.1.5
→
16.3-beta
View file →
| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Jetpack_WooCommerce_Analytics_My_Account |
| 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_My_Account |
| 18 | 20 | * Filters and Actions added to My Account pages to perform analytics |
| 21 | + * | |
| 22 | + * @deprecated 13.3 | |
| 19 | 23 | */ |
| 20 | 24 | class Jetpack_WooCommerce_Analytics_My_Account { |
| 21 | 25 | |
| 22 | 26 | use Jetpack_WooCommerce_Analytics_Trait; |
| @@ -22,8 +26,10 @@ | ||
| 22 | 26 | use Jetpack_WooCommerce_Analytics_Trait; |
| 23 | 27 | |
| 24 | 28 | /** |
| 25 | 29 | * Jetpack_WooCommerce_Analytics_My_Account constructor. |
| 30 | + * | |
| 31 | + * @deprecated 13.3 | |
| 26 | 32 | */ |
| 27 | 33 | public function __construct() { |
| 28 | 34 | |
| 29 | 35 | add_action( 'woocommerce_account_content', array( $this, 'track_tabs' ) ); |
| @@ -44,8 +50,10 @@ | ||
| 44 | 50 | * Track my account tabs, we only trigger an event if a tab is viewed. |
| 45 | 51 | * |
| 46 | 52 | * We also track other events here, like order number clicks, order action clicks, |
| 47 | 53 | * address clicks, payment method add and delete. |
| 54 | + * | |
| 55 | + * @deprecated 13.3 | |
| 48 | 56 | */ |
| 49 | 57 | public function track_tabs() { |
| 50 | 58 | global $wp; |
| 51 | 59 | |
| @@ -136,8 +144,10 @@ | ||
| 136 | 144 | |
| 137 | 145 | /** |
| 138 | 146 | * Track address save events, this can only come from the my account page. |
| 139 | 147 | * |
| 148 | + * @deprecated 13.3 | |
| 149 | + * | |
| 140 | 150 | * @param int $customer_id The customer id. |
| 141 | 151 | * @param string $load_address The address type (billing, shipping). |
| 142 | 152 | */ |
| 143 | 153 | public function track_save_address( $customer_id, $load_address ) { |
| @@ -145,8 +155,10 @@ | ||
| 145 | 155 | } |
| 146 | 156 | |
| 147 | 157 | /** |
| 148 | 158 | * Track payment method add events, this can only come from the my account page. |
| 159 | + * | |
| 160 | + * @deprecated 13.3 | |
| 149 | 161 | */ |
| 150 | 162 | public function track_add_payment_method() { |
| 151 | 163 | if ( isset( $_POST['woocommerce_add_payment_method'] ) && isset( $_POST['payment_method'] ) ) { |
| 152 | 164 | |
| @@ -162,8 +174,10 @@ | ||
| 162 | 174 | } |
| 163 | 175 | |
| 164 | 176 | /** |
| 165 | 177 | * Track payment method delete events. |
| 178 | + * | |
| 179 | + * @deprecated 13.3 | |
| 166 | 180 | */ |
| 167 | 181 | public function track_delete_payment_method() { |
| 168 | 182 | global $wp; |
| 169 | 183 | if ( isset( $wp->query_vars['delete-payment-method'] ) ) { |
| @@ -173,8 +187,10 @@ | ||
| 173 | 187 | } |
| 174 | 188 | |
| 175 | 189 | /** |
| 176 | 190 | * Track order cancel events. |
| 191 | + * | |
| 192 | + * @deprecated 13.3 | |
| 177 | 193 | */ |
| 178 | 194 | public function track_order_cancel_event() { |
| 179 | 195 | if ( isset( $_GET['_wca_initiator'] ) && ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), 'woocommerce-cancel_order' ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 180 | 196 | $this->queue_event( 'woocommerceanalytics_my_account_order_action_click', array( 'action' => 'cancel' ) ); |
| @@ -182,8 +198,10 @@ | ||
| 182 | 198 | } |
| 183 | 199 | |
| 184 | 200 | /** |
| 185 | 201 | * Track order pay events. |
| 202 | + * | |
| 203 | + * @deprecated 13.3 | |
| 186 | 204 | */ |
| 187 | 205 | public function track_order_pay_event() { |
| 188 | 206 | if ( isset( $_GET['_wca_initiator'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended |
| 189 | 207 | $this->record_event( 'woocommerceanalytics_my_account_order_action_click', array( 'action' => 'pay' ) ); |
| @@ -191,8 +209,10 @@ | ||
| 191 | 209 | } |
| 192 | 210 | |
| 193 | 211 | /** |
| 194 | 212 | * Track account details save events, this can only come from the my account page. |
| 213 | + * | |
| 214 | + * @deprecated 13.3 | |
| 195 | 215 | */ |
| 196 | 216 | public function track_save_account_details() { |
| 197 | 217 | $this->queue_event( 'woocommerceanalytics_my_account_details_save' ); |
| 198 | 218 | } |
| @@ -198,12 +218,21 @@ | ||
| 198 | 218 | } |
| 199 | 219 | |
| 200 | 220 | /** |
| 201 | 221 | * Track logout events. |
| 222 | + * | |
| 223 | + * @deprecated 13.3 | |
| 202 | 224 | */ |
| 203 | 225 | public function track_logouts() { |
| 204 | - $common_props = $this->render_properties_as_js( | |
| 205 | - $this->get_common_properties() | |
| 226 | + $common_props = wp_json_encode( | |
| 227 | + array_merge( | |
| 228 | + array( | |
| 229 | + '_en' => 'woocommerceanalytics_my_account_tab_click', | |
| 230 | + 'tab' => 'logout', | |
| 231 | + ), | |
| 232 | + $this->get_common_properties() | |
| 233 | + ), | |
| 234 | + JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP | |
| 206 | 235 | ); |
| 207 | 236 | |
| 208 | 237 | wc_enqueue_js( |
| 209 | 238 | " |
| @@ -209,16 +238,12 @@ | ||
| 209 | 238 | " |
| 210 | 239 | jQuery(document).ready(function($) { |
| 211 | 240 | // Attach event listener to the logout link |
| 212 | 241 | jQuery('.woocommerce-MyAccount-navigation-link--customer-logout').on('click', function() { |
| 213 | - _wca.push({ | |
| 214 | - '_en': 'woocommerceanalytics_my_account_tab_click', | |
| 215 | - 'tab': 'logout'," . | |
| 216 | - $common_props . ' | |
| 217 | - }); | |
| 242 | + _wca.push($common_props); | |
| 218 | 243 | }); |
| 219 | 244 | }); |
| 220 | - ' | |
| 245 | + " | |
| 221 | 246 | ); |
| 222 | 247 | } |
| 223 | 248 | |
| 224 | 249 | /** |
| @@ -223,8 +248,10 @@ | ||
| 223 | 248 | |
| 224 | 249 | /** |
| 225 | 250 | * Add referrer prop to my account action links |
| 226 | 251 | * |
| 252 | + * @deprecated 13.3 | |
| 253 | + * | |
| 227 | 254 | * @param array $actions My account action links. |
| 228 | 255 | * @return array |
| 229 | 256 | */ |
| 230 | 257 | public function add_initiator_prop_to_my_account_action_links( $actions ) { |
| @@ -249,8 +276,10 @@ | ||
| 249 | 276 | * Add an initiator prop to the order url. |
| 250 | 277 | * |
| 251 | 278 | * The get_view_order_url is used in a lot of places, |
| 252 | 279 | * so we want to limit it just to my account page. |
| 280 | + * | |
| 281 | + * @deprecated 13.3 | |
| 253 | 282 | */ |
| 254 | 283 | public function add_initiator_prop_to_order_urls() { |
| 255 | 284 | add_filter( |
| 256 | 285 | 'woocommerce_get_view_order_url', |
| @@ -276,8 +305,10 @@ | ||
| 276 | 305 | |
| 277 | 306 | /** |
| 278 | 307 | * Add initiator to query vars |
| 279 | 308 | * |
| 309 | + * @deprecated 13.3 | |
| 310 | + * | |
| 280 | 311 | * @param array $query_vars Query vars. |
| 281 | 312 | * @return array |
| 282 | 313 | */ |
| 283 | 314 | public function add_initiator_param_to_query_vars( $query_vars ) { |
| @@ -288,8 +319,10 @@ | ||
| 288 | 319 | /** |
| 289 | 320 | * Record all queued up events in session. |
| 290 | 321 | * |
| 291 | 322 | * This is called on every page load, and will record all events that were queued up in session. |
| 323 | + * | |
| 324 | + * @deprecated 13.3 | |
| 292 | 325 | */ |
| 293 | 326 | public function trigger_queued_events() { |
| 294 | 327 | if ( is_object( WC()->session ) ) { |
| 295 | 328 | $events = WC()->session->get( 'wca_queued_events', array() ); |
| @@ -308,8 +341,10 @@ | ||
| 308 | 341 | } |
| 309 | 342 | |
| 310 | 343 | /** |
| 311 | 344 | * Queue an event in session to be recorded later on next page load. |
| 345 | + * | |
| 346 | + * @deprecated 13.3 | |
| 312 | 347 | * |
| 313 | 348 | * @param string $event_name The event name. |
| 314 | 349 | * @param array $event_props The event properties. |
| 315 | 350 | */ |