@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $site_license = array( |
|
| 70 | + $site_license = array( |
|
| 71 | 71 | 'key' => MonsterInsights()->license->get_site_license_key(), |
| 72 | 72 | 'type' => MonsterInsights()->license->get_site_license_type(), |
| 73 | 73 | 'is_disabled' => MonsterInsights()->license->site_license_disabled(), |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | // Array fields are needed even if empty. |
| 135 | 135 | $array_fields = array( 'view_reports', 'save_settings', 'ignore_users' ); |
| 136 | 136 | foreach ( $array_fields as $array_field ) { |
| 137 | - if ( ! isset( $options[ $array_field ] ) ) { |
|
| 138 | - $options[ $array_field ] = array(); |
|
| 137 | + if ( ! isset( $options[$array_field] ) ) { |
|
| 138 | + $options[$array_field] = array(); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | if ( $empty ) { |
| 268 | - unset( $value[ $key ] ); |
|
| 268 | + unset( $value[$key] ); |
|
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | } |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | } else { |
| 316 | 316 | $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug ); |
| 317 | 317 | } |
| 318 | - $parsed_addons[ $addon->slug ] = $addon; |
|
| 318 | + $parsed_addons[$addon->slug] = $addon; |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
@@ -365,11 +365,11 @@ discard block |
||
| 365 | 365 | ); |
| 366 | 366 | // Complianz. |
| 367 | 367 | $parsed_addons['complianz'] = array( |
| 368 | - 'active' => defined( 'cmplz_plugin') || defined( 'cmplz_premium'), |
|
| 368 | + 'active' => defined( 'cmplz_plugin' ) || defined( 'cmplz_premium' ), |
|
| 369 | 369 | ); |
| 370 | 370 | // Cookie Yes |
| 371 | 371 | $parsed_addons['cookie_yes'] = array( |
| 372 | - 'active' => defined( 'CLI_SETTINGS_FIELD'), |
|
| 372 | + 'active' => defined( 'CLI_SETTINGS_FIELD' ), |
|
| 373 | 373 | ); |
| 374 | 374 | // Fb Instant Articles. |
| 375 | 375 | $parsed_addons['instant_articles'] = array( |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | 'slug' => 'wp-mail-smtp', |
| 435 | 435 | ); |
| 436 | 436 | // SeedProd. |
| 437 | - $parsed_addons['coming-soon'] = array( |
|
| 437 | + $parsed_addons['coming-soon'] = array( |
|
| 438 | 438 | 'active' => defined( 'SEEDPROD_VERSION' ), |
| 439 | 439 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugin-seedprod.png', |
| 440 | 440 | 'title' => 'SeedProd', |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | 'settings' => admin_url( 'admin.php?page=seedprod_lite' ), |
| 446 | 446 | ); |
| 447 | 447 | // RafflePress |
| 448 | - $parsed_addons['rafflepress'] = array( |
|
| 448 | + $parsed_addons['rafflepress'] = array( |
|
| 449 | 449 | 'active' => function_exists( 'rafflepress_lite_activation' ), |
| 450 | 450 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/pluign-rafflepress.png', |
| 451 | 451 | 'title' => 'RafflePress', |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | $installed = false; |
| 556 | 556 | $plugin_basename = monsterinsights_get_plugin_basename_from_slug( $slug ); |
| 557 | 557 | |
| 558 | - if ( isset( $installed_plugins[ $plugin_basename ] ) ) { |
|
| 558 | + if ( isset( $installed_plugins[$plugin_basename] ) ) { |
|
| 559 | 559 | $installed = true; |
| 560 | 560 | |
| 561 | 561 | if ( is_multisite() && is_network_admin() ) { |
@@ -570,8 +570,8 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | $active_version = false; |
| 572 | 572 | if ( $active ) { |
| 573 | - if ( ! empty( $installed_plugins[ $plugin_basename ]['Version'] ) ) { |
|
| 574 | - $active_version = $installed_plugins[ $plugin_basename ]['Version']; |
|
| 573 | + if ( ! empty( $installed_plugins[$plugin_basename]['Version'] ) ) { |
|
| 574 | + $active_version = $installed_plugins[$plugin_basename]['Version']; |
|
| 575 | 575 | } |
| 576 | 576 | } |
| 577 | 577 | |
@@ -839,14 +839,14 @@ discard block |
||
| 839 | 839 | ); |
| 840 | 840 | |
| 841 | 841 | foreach ( $exclude as $e ) { |
| 842 | - if ( ! empty( $new_settings[ $e ] ) ) { |
|
| 843 | - unset( $new_settings[ $e ] ); |
|
| 842 | + if ( ! empty( $new_settings[$e] ) ) { |
|
| 843 | + unset( $new_settings[$e] ); |
|
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | foreach ( $exclude as $e ) { |
| 848 | - if ( ! empty( $settings[ $e ] ) ) { |
|
| 849 | - $new_settings = $settings[ $e ]; |
|
| 848 | + if ( ! empty( $settings[$e] ) ) { |
|
| 849 | + $new_settings = $settings[$e]; |
|
| 850 | 850 | } |
| 851 | 851 | } |
| 852 | 852 | |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | ), |
| 1007 | 1007 | admin_url( 'admin.php' ) |
| 1008 | 1008 | ); |
| 1009 | - $url = esc_url( $url ); |
|
| 1009 | + $url = esc_url( $url ); |
|
| 1010 | 1010 | |
| 1011 | 1011 | ob_start(); |
| 1012 | 1012 | if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) { |
@@ -1112,7 +1112,7 @@ discard block |
||
| 1112 | 1112 | $homepage = get_option( 'page_on_front' ); |
| 1113 | 1113 | if ( ! $homepage ) { |
| 1114 | 1114 | $array[] = array( |
| 1115 | - 'id' => - 1, |
|
| 1115 | + 'id' => -1, |
|
| 1116 | 1116 | 'title' => __( 'Homepage', 'google-analytics-for-wordpress' ), |
| 1117 | 1117 | ); |
| 1118 | 1118 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | if ( ! post_type_supports( $post_type->name, 'editor' ) || 'product' === $post_type->name ) { |
| 1187 | 1187 | continue; |
| 1188 | 1188 | } |
| 1189 | - $post_types_parsed[ $post_type->name ] = $post_type->labels->singular_name; |
|
| 1189 | + $post_types_parsed[$post_type->name] = $post_type->labels->singular_name; |
|
| 1190 | 1190 | } |
| 1191 | 1191 | |
| 1192 | 1192 | $post_types_parsed = apply_filters( 'monsterinsights_vue_post_types_editor', $post_types_parsed ); |
@@ -1308,18 +1308,18 @@ discard block |
||
| 1308 | 1308 | $value = sanitize_text_field( wp_unslash( $_POST['value'] ) ); // Value of custom style like 12px or #fff. |
| 1309 | 1309 | $settings = get_option( $settings_key, array() ); |
| 1310 | 1310 | |
| 1311 | - if ( ! isset( $settings[ $type ] ) ) { |
|
| 1312 | - $settings[ $type ] = array(); |
|
| 1311 | + if ( ! isset( $settings[$type] ) ) { |
|
| 1312 | + $settings[$type] = array(); |
|
| 1313 | 1313 | } |
| 1314 | - if ( ! isset( $settings[ $type ][ $theme ] ) ) { |
|
| 1315 | - $settings[ $type ][ $theme ] = array(); |
|
| 1314 | + if ( ! isset( $settings[$type][$theme] ) ) { |
|
| 1315 | + $settings[$type][$theme] = array(); |
|
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | - if ( ! isset( $settings[ $type ][ $theme ][ $object ] ) ) { |
|
| 1319 | - $settings[ $type ][ $theme ][ $object ] = array(); |
|
| 1318 | + if ( ! isset( $settings[$type][$theme][$object] ) ) { |
|
| 1319 | + $settings[$type][$theme][$object] = array(); |
|
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | - $settings[ $type ][ $theme ][ $object ][ $key ] = $value; |
|
| 1322 | + $settings[$type][$theme][$object][$key] = $value; |
|
| 1323 | 1323 | |
| 1324 | 1324 | update_option( $settings_key, $settings ); |
| 1325 | 1325 | |
@@ -36,10 +36,10 @@ |
||
| 36 | 36 | require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-gtag-events.php'; |
| 37 | 37 | new MonsterInsights_Gtag_Events(); |
| 38 | 38 | |
| 39 | - // Let's run form tracking if we find it |
|
| 40 | - if ( function_exists( 'monsterinsights_forms_output_after_script' ) ) { |
|
| 41 | - monsterinsights_forms_output_after_script( array() ); |
|
| 42 | - } |
|
| 39 | + // Let's run form tracking if we find it |
|
| 40 | + if ( function_exists( 'monsterinsights_forms_output_after_script' ) ) { |
|
| 41 | + monsterinsights_forms_output_after_script( array() ); |
|
| 42 | + } |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | add_action( 'seedprod_monsterinsights_output_tracking', 'monsterinsights_seedprod_tracking', 6, 1 ); |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | do_action( 'monsterinsights_tracking_after_gtag' ); |
| 31 | 31 | do_action( 'monsterinsights_tracking_after', 'gtag' ); |
| 32 | 32 | |
| 33 | - $track_user = monsterinsights_track_user(); |
|
| 33 | + $track_user = monsterinsights_track_user(); |
|
| 34 | 34 | |
| 35 | 35 | if ( $track_user ) { |
| 36 | 36 | require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-gtag-events.php'; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function frontend_tracking_options_persistent() |
| 54 | 54 | { |
| 55 | - return apply_filters('monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', []); |
|
| 55 | + return apply_filters('monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', []); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -71,107 +71,107 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function frontend_tracking_options($type = 'ua', $encoded = false) |
| 73 | 73 | { |
| 74 | - global $wp_query; |
|
| 75 | - $options = []; |
|
| 74 | + global $wp_query; |
|
| 75 | + $options = []; |
|
| 76 | 76 | |
| 77 | - $tracking_ids = monsterinsights_get_tracking_ids(); |
|
| 78 | - if (empty($tracking_ids)) { |
|
| 79 | - return $encoded ? wp_json_encode($options) : $options; |
|
| 80 | - } |
|
| 77 | + $tracking_ids = monsterinsights_get_tracking_ids(); |
|
| 78 | + if (empty($tracking_ids)) { |
|
| 79 | + return $encoded ? wp_json_encode($options) : $options; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - $placeholder = ''; |
|
| 82 | + $placeholder = ''; |
|
| 83 | 83 | |
| 84 | - if ($encoded) { |
|
| 85 | - $placeholder = '!@#'; |
|
| 86 | - } |
|
| 84 | + if ($encoded) { |
|
| 85 | + $placeholder = '!@#'; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // $track_user = monsterinsights_track_user(); |
|
| 88 | + // $track_user = monsterinsights_track_user(); |
|
| 89 | 89 | // |
| 90 | - // if ( ! $track_user ) { |
|
| 91 | - // $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( 'auto' ) . "'"; |
|
| 92 | - // $options['forceSSL'] = "'set', 'forceSSL', true"; |
|
| 93 | - // $options['send'] = "'send','pageview'"; |
|
| 90 | + // if ( ! $track_user ) { |
|
| 91 | + // $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( 'auto' ) . "'"; |
|
| 92 | + // $options['forceSSL'] = "'set', 'forceSSL', true"; |
|
| 93 | + // $options['send'] = "'send','pageview'"; |
|
| 94 | 94 | // |
| 95 | - // return $options; |
|
| 96 | - // } |
|
| 97 | - |
|
| 98 | - $cross_domains = monsterinsights_get_option('cross_domains', []); |
|
| 99 | - $allow_anchor = monsterinsights_get_option('allow_anchor', false); |
|
| 100 | - |
|
| 101 | - if ($allow_anchor) { |
|
| 102 | - $options['allow_anchor'] = 'true'; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - if (class_exists('MonsterInsights_AMP')) { |
|
| 106 | - $options['use_amp_client_id'] = 'true'; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $options['forceSSL'] = 'true'; |
|
| 110 | - |
|
| 111 | - // Anonymous data. |
|
| 112 | - if (monsterinsights_get_option('anonymize_ips', false)) { |
|
| 113 | - $options['anonymize_ip'] = 'true'; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_scripts', $options); |
|
| 117 | - |
|
| 118 | - // Add Enhanced link attribution. |
|
| 119 | - if (monsterinsights_get_option('link_attribution', false)) { |
|
| 120 | - $options['link_attribution'] = 'true'; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // Add cross-domain tracking. |
|
| 124 | - if (is_array($cross_domains) && !empty($cross_domains)) { |
|
| 125 | - $linker_domains = []; |
|
| 126 | - foreach ($cross_domains as $cross_domain) { |
|
| 127 | - if (!empty($cross_domain['domain'])) { |
|
| 128 | - $linker_domains[] = $cross_domain['domain']; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - $options['linker'] = [ |
|
| 132 | - 'domains' => $linker_domains, |
|
| 133 | - ]; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - if (monsterinsights_is_debug_mode()) { |
|
| 137 | - $options['debug_mode'] = true; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_pageview', $options, $type); |
|
| 141 | - $options = apply_filters('monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version, $type); |
|
| 142 | - |
|
| 143 | - if (is_404()) { |
|
| 144 | - if (monsterinsights_get_option('hash_tracking', false)) { |
|
| 145 | - $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer{$placeholder}"; |
|
| 146 | - } else { |
|
| 147 | - $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer{$placeholder}"; |
|
| 148 | - } |
|
| 149 | - } elseif ($wp_query->is_search) { |
|
| 150 | - $pushstr = "'/?s="; |
|
| 151 | - if (0 === (int) $wp_query->found_posts) { |
|
| 152 | - $options['page_path'] = $pushstr.'no-results:'.rawurlencode($wp_query->query_vars['s'])."&cat=no-results'"; |
|
| 153 | - } elseif (1 === (int) $wp_query->found_posts) { |
|
| 154 | - $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=1-result'"; |
|
| 155 | - } elseif ($wp_query->found_posts > 1 && $wp_query->found_posts < 6) { |
|
| 156 | - $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=2-5-results'"; |
|
| 157 | - } else { |
|
| 158 | - $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=plus-5-results'"; |
|
| 159 | - } |
|
| 160 | - } elseif (monsterinsights_get_option('hash_tracking', false)) { |
|
| 161 | - $options['page_path'] = "{$placeholder}location.pathname + location.search + location.hash{$placeholder}"; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_end', $options, $type); |
|
| 165 | - |
|
| 166 | - if ($encoded) { |
|
| 167 | - return str_replace( |
|
| 168 | - ['"'.$placeholder, $placeholder.'"'], |
|
| 169 | - '', |
|
| 170 | - wp_json_encode($options) |
|
| 171 | - ); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - return $options; |
|
| 95 | + // return $options; |
|
| 96 | + // } |
|
| 97 | + |
|
| 98 | + $cross_domains = monsterinsights_get_option('cross_domains', []); |
|
| 99 | + $allow_anchor = monsterinsights_get_option('allow_anchor', false); |
|
| 100 | + |
|
| 101 | + if ($allow_anchor) { |
|
| 102 | + $options['allow_anchor'] = 'true'; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + if (class_exists('MonsterInsights_AMP')) { |
|
| 106 | + $options['use_amp_client_id'] = 'true'; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $options['forceSSL'] = 'true'; |
|
| 110 | + |
|
| 111 | + // Anonymous data. |
|
| 112 | + if (monsterinsights_get_option('anonymize_ips', false)) { |
|
| 113 | + $options['anonymize_ip'] = 'true'; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_scripts', $options); |
|
| 117 | + |
|
| 118 | + // Add Enhanced link attribution. |
|
| 119 | + if (monsterinsights_get_option('link_attribution', false)) { |
|
| 120 | + $options['link_attribution'] = 'true'; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // Add cross-domain tracking. |
|
| 124 | + if (is_array($cross_domains) && !empty($cross_domains)) { |
|
| 125 | + $linker_domains = []; |
|
| 126 | + foreach ($cross_domains as $cross_domain) { |
|
| 127 | + if (!empty($cross_domain['domain'])) { |
|
| 128 | + $linker_domains[] = $cross_domain['domain']; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + $options['linker'] = [ |
|
| 132 | + 'domains' => $linker_domains, |
|
| 133 | + ]; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + if (monsterinsights_is_debug_mode()) { |
|
| 137 | + $options['debug_mode'] = true; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_pageview', $options, $type); |
|
| 141 | + $options = apply_filters('monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version, $type); |
|
| 142 | + |
|
| 143 | + if (is_404()) { |
|
| 144 | + if (monsterinsights_get_option('hash_tracking', false)) { |
|
| 145 | + $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer{$placeholder}"; |
|
| 146 | + } else { |
|
| 147 | + $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer{$placeholder}"; |
|
| 148 | + } |
|
| 149 | + } elseif ($wp_query->is_search) { |
|
| 150 | + $pushstr = "'/?s="; |
|
| 151 | + if (0 === (int) $wp_query->found_posts) { |
|
| 152 | + $options['page_path'] = $pushstr.'no-results:'.rawurlencode($wp_query->query_vars['s'])."&cat=no-results'"; |
|
| 153 | + } elseif (1 === (int) $wp_query->found_posts) { |
|
| 154 | + $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=1-result'"; |
|
| 155 | + } elseif ($wp_query->found_posts > 1 && $wp_query->found_posts < 6) { |
|
| 156 | + $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=2-5-results'"; |
|
| 157 | + } else { |
|
| 158 | + $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=plus-5-results'"; |
|
| 159 | + } |
|
| 160 | + } elseif (monsterinsights_get_option('hash_tracking', false)) { |
|
| 161 | + $options['page_path'] = "{$placeholder}location.pathname + location.search + location.hash{$placeholder}"; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_end', $options, $type); |
|
| 165 | + |
|
| 166 | + if ($encoded) { |
|
| 167 | + return str_replace( |
|
| 168 | + ['"'.$placeholder, $placeholder.'"'], |
|
| 169 | + '', |
|
| 170 | + wp_json_encode($options) |
|
| 171 | + ); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + return $options; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -187,36 +187,36 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function frontend_output() |
| 189 | 189 | { |
| 190 | - $options = $this->frontend_tracking_options('ua', true); |
|
| 191 | - $options_v4 = $this->frontend_tracking_options('v4', true); |
|
| 192 | - $persistent = $this->frontend_tracking_options_persistent(); |
|
| 193 | - $connected_type = MonsterInsights()->auth->get_connected_type(); |
|
| 194 | - $v4_id = monsterinsights_get_v4_id_to_output(); |
|
| 195 | - $ua = monsterinsights_get_ua_to_output(); |
|
| 196 | - $main_id = 'ua' === $connected_type ? $ua : $v4_id; |
|
| 197 | - $src = apply_filters('monsterinsights_frontend_output_gtag_src', '//www.googletagmanager.com/gtag/js?id='.$main_id); |
|
| 198 | - $compat_mode = apply_filters('monsterinsights_get_option_gtagtracker_compatibility_mode', true); |
|
| 199 | - $compat = $compat_mode ? 'window.gtag = __gtagTracker;' : ''; |
|
| 200 | - $track_user = monsterinsights_track_user(); |
|
| 201 | - $output = ''; |
|
| 202 | - $reason = ''; |
|
| 203 | - $attr_string = monsterinsights_get_frontend_analytics_script_atts(); |
|
| 204 | - $gtag_async = apply_filters('monsterinsights_frontend_gtag_script_async', true) ? 'async' : ''; |
|
| 205 | - ob_start(); ?> |
|
| 190 | + $options = $this->frontend_tracking_options('ua', true); |
|
| 191 | + $options_v4 = $this->frontend_tracking_options('v4', true); |
|
| 192 | + $persistent = $this->frontend_tracking_options_persistent(); |
|
| 193 | + $connected_type = MonsterInsights()->auth->get_connected_type(); |
|
| 194 | + $v4_id = monsterinsights_get_v4_id_to_output(); |
|
| 195 | + $ua = monsterinsights_get_ua_to_output(); |
|
| 196 | + $main_id = 'ua' === $connected_type ? $ua : $v4_id; |
|
| 197 | + $src = apply_filters('monsterinsights_frontend_output_gtag_src', '//www.googletagmanager.com/gtag/js?id='.$main_id); |
|
| 198 | + $compat_mode = apply_filters('monsterinsights_get_option_gtagtracker_compatibility_mode', true); |
|
| 199 | + $compat = $compat_mode ? 'window.gtag = __gtagTracker;' : ''; |
|
| 200 | + $track_user = monsterinsights_track_user(); |
|
| 201 | + $output = ''; |
|
| 202 | + $reason = ''; |
|
| 203 | + $attr_string = monsterinsights_get_frontend_analytics_script_atts(); |
|
| 204 | + $gtag_async = apply_filters('monsterinsights_frontend_gtag_script_async', true) ? 'async' : ''; |
|
| 205 | + ob_start(); ?> |
|
| 206 | 206 | <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ --> |
| 207 | 207 | <?php if (!$track_user) { |
| 208 | - if (empty($v4_id) && empty($ua)) { |
|
| 209 | - $reason = __('Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress'); |
|
| 210 | - $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL; |
|
| 211 | - } elseif (current_user_can('monsterinsights_save_settings')) { |
|
| 212 | - $reason = __('Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'.PHP_EOL.'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress'); |
|
| 213 | - $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL; |
|
| 214 | - } else { |
|
| 215 | - $reason = __('Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress'); |
|
| 216 | - $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL; |
|
| 217 | - } |
|
| 218 | - echo $output; |
|
| 219 | - } ?> |
|
| 208 | + if (empty($v4_id) && empty($ua)) { |
|
| 209 | + $reason = __('Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress'); |
|
| 210 | + $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL; |
|
| 211 | + } elseif (current_user_can('monsterinsights_save_settings')) { |
|
| 212 | + $reason = __('Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'.PHP_EOL.'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress'); |
|
| 213 | + $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL; |
|
| 214 | + } else { |
|
| 215 | + $reason = __('Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress'); |
|
| 216 | + $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL; |
|
| 217 | + } |
|
| 218 | + echo $output; |
|
| 219 | + } ?> |
|
| 220 | 220 | <?php if (!empty($v4_id) || !empty($ua)) { ?> |
| 221 | 221 | <script src="<?php echo esc_attr($src); ?>" <?php echo $attr_string; ?> <?php echo esc_attr($gtag_async); ?>></script> |
| 222 | 222 | <script<?php echo $attr_string; ?>> |
@@ -315,12 +315,12 @@ discard block |
||
| 315 | 315 | __gtagTracker( 'set', { |
| 316 | 316 | 'developer_id.dZGIzZG' : true, |
| 317 | 317 | <?php |
| 318 | - if (!empty($persistent)) { |
|
| 319 | - foreach ($persistent as $key => $value) { |
|
| 320 | - echo "'".esc_js($key)."' : '".esc_js($value)."',"; |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - ?> |
|
| 318 | + if (!empty($persistent)) { |
|
| 319 | + foreach ($persistent as $key => $value) { |
|
| 320 | + echo "'".esc_js($key)."' : '".esc_js($value)."',"; |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + ?> |
|
| 324 | 324 | } ); |
| 325 | 325 | <?php if (!empty($v4_id)) { ?> |
| 326 | 326 | __gtagTracker( 'config', '<?php echo esc_js($v4_id); ?>', <?php echo $options_v4; ?> ); |
@@ -328,15 +328,15 @@ discard block |
||
| 328 | 328 | <?php if (!empty($ua)) { ?> |
| 329 | 329 | __gtagTracker( 'config', '<?php echo esc_js($ua); ?>', <?php echo $options; ?> ); |
| 330 | 330 | <?php |
| 331 | - } |
|
| 332 | - /* |
|
| 331 | + } |
|
| 332 | + /* |
|
| 333 | 333 | * Extend or enhance the functionality by adding custom code to frontend |
| 334 | 334 | * tracking via this hook. |
| 335 | 335 | * |
| 336 | 336 | * @since 7.15.0 |
| 337 | 337 | */ |
| 338 | - do_action('monsterinsights_frontend_tracking_gtag_after_pageview'); |
|
| 339 | - ?> |
|
| 338 | + do_action('monsterinsights_frontend_tracking_gtag_after_pageview'); |
|
| 339 | + ?> |
|
| 340 | 340 | <?php echo esc_js($compat); ?> |
| 341 | 341 | <?php if (apply_filters('monsterinsights_tracking_gtag_frontend_gatracker_compatibility', true)) { ?> |
| 342 | 342 | (function () { |
@@ -467,14 +467,14 @@ discard block |
||
| 467 | 467 | <?php } ?> |
| 468 | 468 | <!-- / Google Analytics by MonsterInsights --> |
| 469 | 469 | <?php |
| 470 | - $output = ob_get_contents(); |
|
| 471 | - ob_end_clean(); |
|
| 470 | + $output = ob_get_contents(); |
|
| 471 | + ob_end_clean(); |
|
| 472 | 472 | |
| 473 | - return $output; |
|
| 473 | + return $output; |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | public function should_do_optout() |
| 477 | 477 | { |
| 478 | - return !(defined('MI_NO_TRACKING_OPTOUT') && MI_NO_TRACKING_OPTOUT); |
|
| 478 | + return !(defined('MI_NO_TRACKING_OPTOUT') && MI_NO_TRACKING_OPTOUT); |
|
| 479 | 479 | } |
| 480 | 480 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | // Exit if accessed directly |
| 11 | -if (!defined('ABSPATH')) { |
|
| 11 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function frontend_tracking_options_persistent() |
| 54 | 54 | { |
| 55 | - return apply_filters('monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', []); |
|
| 55 | + return apply_filters( 'monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', [] ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @since 7.15.0 |
| 71 | 71 | */ |
| 72 | - public function frontend_tracking_options($type = 'ua', $encoded = false) |
|
| 72 | + public function frontend_tracking_options( $type = 'ua', $encoded = false ) |
|
| 73 | 73 | { |
| 74 | 74 | global $wp_query; |
| 75 | 75 | $options = []; |
| 76 | 76 | |
| 77 | 77 | $tracking_ids = monsterinsights_get_tracking_ids(); |
| 78 | - if (empty($tracking_ids)) { |
|
| 79 | - return $encoded ? wp_json_encode($options) : $options; |
|
| 78 | + if ( empty( $tracking_ids ) ) { |
|
| 79 | + return $encoded ? wp_json_encode( $options ) : $options; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $placeholder = ''; |
| 83 | 83 | |
| 84 | - if ($encoded) { |
|
| 84 | + if ( $encoded ) { |
|
| 85 | 85 | $placeholder = '!@#'; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -95,36 +95,36 @@ discard block |
||
| 95 | 95 | // return $options; |
| 96 | 96 | // } |
| 97 | 97 | |
| 98 | - $cross_domains = monsterinsights_get_option('cross_domains', []); |
|
| 99 | - $allow_anchor = monsterinsights_get_option('allow_anchor', false); |
|
| 98 | + $cross_domains = monsterinsights_get_option( 'cross_domains', [] ); |
|
| 99 | + $allow_anchor = monsterinsights_get_option( 'allow_anchor', false ); |
|
| 100 | 100 | |
| 101 | - if ($allow_anchor) { |
|
| 101 | + if ( $allow_anchor ) { |
|
| 102 | 102 | $options['allow_anchor'] = 'true'; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if (class_exists('MonsterInsights_AMP')) { |
|
| 105 | + if ( class_exists( 'MonsterInsights_AMP' ) ) { |
|
| 106 | 106 | $options['use_amp_client_id'] = 'true'; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $options['forceSSL'] = 'true'; |
| 110 | 110 | |
| 111 | 111 | // Anonymous data. |
| 112 | - if (monsterinsights_get_option('anonymize_ips', false)) { |
|
| 112 | + if ( monsterinsights_get_option( 'anonymize_ips', false ) ) { |
|
| 113 | 113 | $options['anonymize_ip'] = 'true'; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_scripts', $options); |
|
| 116 | + $options = apply_filters( 'monsterinsights_frontend_tracking_options_gtag_before_scripts', $options ); |
|
| 117 | 117 | |
| 118 | 118 | // Add Enhanced link attribution. |
| 119 | - if (monsterinsights_get_option('link_attribution', false)) { |
|
| 119 | + if ( monsterinsights_get_option( 'link_attribution', false ) ) { |
|
| 120 | 120 | $options['link_attribution'] = 'true'; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Add cross-domain tracking. |
| 124 | - if (is_array($cross_domains) && !empty($cross_domains)) { |
|
| 124 | + if ( is_array( $cross_domains ) && ! empty( $cross_domains ) ) { |
|
| 125 | 125 | $linker_domains = []; |
| 126 | - foreach ($cross_domains as $cross_domain) { |
|
| 127 | - if (!empty($cross_domain['domain'])) { |
|
| 126 | + foreach ( $cross_domains as $cross_domain ) { |
|
| 127 | + if ( ! empty( $cross_domain['domain'] ) ) { |
|
| 128 | 128 | $linker_domains[] = $cross_domain['domain']; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -133,41 +133,41 @@ discard block |
||
| 133 | 133 | ]; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if (monsterinsights_is_debug_mode()) { |
|
| 136 | + if ( monsterinsights_is_debug_mode() ) { |
|
| 137 | 137 | $options['debug_mode'] = true; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_before_pageview', $options, $type); |
|
| 141 | - $options = apply_filters('monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version, $type); |
|
| 140 | + $options = apply_filters( 'monsterinsights_frontend_tracking_options_gtag_before_pageview', $options, $type ); |
|
| 141 | + $options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version, $type ); |
|
| 142 | 142 | |
| 143 | - if (is_404()) { |
|
| 144 | - if (monsterinsights_get_option('hash_tracking', false)) { |
|
| 143 | + if ( is_404() ) { |
|
| 144 | + if ( monsterinsights_get_option( 'hash_tracking', false ) ) { |
|
| 145 | 145 | $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer{$placeholder}"; |
| 146 | 146 | } else { |
| 147 | 147 | $options['page_path'] = "{$placeholder}'/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer{$placeholder}"; |
| 148 | 148 | } |
| 149 | - } elseif ($wp_query->is_search) { |
|
| 149 | + } elseif ( $wp_query->is_search ) { |
|
| 150 | 150 | $pushstr = "'/?s="; |
| 151 | - if (0 === (int) $wp_query->found_posts) { |
|
| 152 | - $options['page_path'] = $pushstr.'no-results:'.rawurlencode($wp_query->query_vars['s'])."&cat=no-results'"; |
|
| 153 | - } elseif (1 === (int) $wp_query->found_posts) { |
|
| 154 | - $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=1-result'"; |
|
| 155 | - } elseif ($wp_query->found_posts > 1 && $wp_query->found_posts < 6) { |
|
| 156 | - $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=2-5-results'"; |
|
| 151 | + if ( 0 === (int) $wp_query->found_posts ) { |
|
| 152 | + $options['page_path'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'"; |
|
| 153 | + } elseif ( 1 === (int) $wp_query->found_posts ) { |
|
| 154 | + $options['page_path'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'"; |
|
| 155 | + } elseif ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) { |
|
| 156 | + $options['page_path'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'"; |
|
| 157 | 157 | } else { |
| 158 | - $options['page_path'] = $pushstr.rawurlencode($wp_query->query_vars['s'])."&cat=plus-5-results'"; |
|
| 158 | + $options['page_path'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'"; |
|
| 159 | 159 | } |
| 160 | - } elseif (monsterinsights_get_option('hash_tracking', false)) { |
|
| 160 | + } elseif ( monsterinsights_get_option( 'hash_tracking', false ) ) { |
|
| 161 | 161 | $options['page_path'] = "{$placeholder}location.pathname + location.search + location.hash{$placeholder}"; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $options = apply_filters('monsterinsights_frontend_tracking_options_gtag_end', $options, $type); |
|
| 164 | + $options = apply_filters( 'monsterinsights_frontend_tracking_options_gtag_end', $options, $type ); |
|
| 165 | 165 | |
| 166 | - if ($encoded) { |
|
| 166 | + if ( $encoded ) { |
|
| 167 | 167 | return str_replace( |
| 168 | - ['"'.$placeholder, $placeholder.'"'], |
|
| 168 | + ['"' . $placeholder, $placeholder . '"'], |
|
| 169 | 169 | '', |
| 170 | - wp_json_encode($options) |
|
| 170 | + wp_json_encode( $options ) |
|
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -187,51 +187,51 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function frontend_output() |
| 189 | 189 | { |
| 190 | - $options = $this->frontend_tracking_options('ua', true); |
|
| 191 | - $options_v4 = $this->frontend_tracking_options('v4', true); |
|
| 190 | + $options = $this->frontend_tracking_options( 'ua', true ); |
|
| 191 | + $options_v4 = $this->frontend_tracking_options( 'v4', true ); |
|
| 192 | 192 | $persistent = $this->frontend_tracking_options_persistent(); |
| 193 | 193 | $connected_type = MonsterInsights()->auth->get_connected_type(); |
| 194 | 194 | $v4_id = monsterinsights_get_v4_id_to_output(); |
| 195 | 195 | $ua = monsterinsights_get_ua_to_output(); |
| 196 | 196 | $main_id = 'ua' === $connected_type ? $ua : $v4_id; |
| 197 | - $src = apply_filters('monsterinsights_frontend_output_gtag_src', '//www.googletagmanager.com/gtag/js?id='.$main_id); |
|
| 198 | - $compat_mode = apply_filters('monsterinsights_get_option_gtagtracker_compatibility_mode', true); |
|
| 197 | + $src = apply_filters( 'monsterinsights_frontend_output_gtag_src', '//www.googletagmanager.com/gtag/js?id=' . $main_id ); |
|
| 198 | + $compat_mode = apply_filters( 'monsterinsights_get_option_gtagtracker_compatibility_mode', true ); |
|
| 199 | 199 | $compat = $compat_mode ? 'window.gtag = __gtagTracker;' : ''; |
| 200 | 200 | $track_user = monsterinsights_track_user(); |
| 201 | 201 | $output = ''; |
| 202 | 202 | $reason = ''; |
| 203 | 203 | $attr_string = monsterinsights_get_frontend_analytics_script_atts(); |
| 204 | - $gtag_async = apply_filters('monsterinsights_frontend_gtag_script_async', true) ? 'async' : ''; |
|
| 204 | + $gtag_async = apply_filters( 'monsterinsights_frontend_gtag_script_async', true ) ? 'async' : ''; |
|
| 205 | 205 | ob_start(); ?> |
| 206 | 206 | <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ --> |
| 207 | - <?php if (!$track_user) { |
|
| 208 | - if (empty($v4_id) && empty($ua)) { |
|
| 209 | - $reason = __('Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress'); |
|
| 210 | - $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL; |
|
| 211 | - } elseif (current_user_can('monsterinsights_save_settings')) { |
|
| 212 | - $reason = __('Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'.PHP_EOL.'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress'); |
|
| 213 | - $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL; |
|
| 207 | + <?php if ( ! $track_user ) { |
|
| 208 | + if ( empty( $v4_id ) && empty( $ua ) ) { |
|
| 209 | + $reason = __( 'Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress' ); |
|
| 210 | + $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL; |
|
| 211 | + } elseif ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
| 212 | + $reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.' . PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' ); |
|
| 213 | + $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL; |
|
| 214 | 214 | } else { |
| 215 | - $reason = __('Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress'); |
|
| 216 | - $output .= '<!-- '.esc_html($reason).' -->'.PHP_EOL; |
|
| 215 | + $reason = __( 'Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress' ); |
|
| 216 | + $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL; |
|
| 217 | 217 | } |
| 218 | 218 | echo $output; |
| 219 | 219 | } ?> |
| 220 | - <?php if (!empty($v4_id) || !empty($ua)) { ?> |
|
| 221 | - <script src="<?php echo esc_attr($src); ?>" <?php echo $attr_string; ?> <?php echo esc_attr($gtag_async); ?>></script> |
|
| 220 | + <?php if ( ! empty( $v4_id ) || ! empty( $ua ) ) { ?> |
|
| 221 | + <script src="<?php echo esc_attr( $src ); ?>" <?php echo $attr_string; ?> <?php echo esc_attr( $gtag_async ); ?>></script> |
|
| 222 | 222 | <script<?php echo $attr_string; ?>> |
| 223 | 223 | var mi_version = '<?php echo MONSTERINSIGHTS_VERSION; ?>'; |
| 224 | 224 | var mi_track_user = <?php echo $track_user ? 'true' : 'false'; ?>; |
| 225 | - var mi_no_track_reason = <?php echo $reason ? "'".esc_js($reason)."'" : "''"; ?>; |
|
| 226 | - <?php do_action('monsterinsights_tracking_gtag_frontend_output_after_mi_track_user'); ?> |
|
| 225 | + var mi_no_track_reason = <?php echo $reason ? "'" . esc_js( $reason ) . "'" : "''"; ?>; |
|
| 226 | + <?php do_action( 'monsterinsights_tracking_gtag_frontend_output_after_mi_track_user' ); ?> |
|
| 227 | 227 | |
| 228 | - <?php if ($this->should_do_optout()) { ?> |
|
| 228 | + <?php if ( $this->should_do_optout() ) { ?> |
|
| 229 | 229 | var disableStrs = [ |
| 230 | - <?php if (!empty($v4_id)) { ?> |
|
| 231 | - 'ga-disable-<?php echo esc_js($v4_id); ?>', |
|
| 230 | + <?php if ( ! empty( $v4_id ) ) { ?> |
|
| 231 | + 'ga-disable-<?php echo esc_js( $v4_id ); ?>', |
|
| 232 | 232 | <?php } ?> |
| 233 | - <?php if (!empty($ua)) { ?> |
|
| 234 | - 'ga-disable-<?php echo esc_js($ua); ?>', |
|
| 233 | + <?php if ( ! empty( $ua ) ) { ?> |
|
| 234 | + 'ga-disable-<?php echo esc_js( $ua ); ?>', |
|
| 235 | 235 | <?php } ?> |
| 236 | 236 | ]; |
| 237 | 237 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | if ( type === 'event' ) { |
| 292 | - <?php if ($v4_id) { ?> |
|
| 292 | + <?php if ( $v4_id ) { ?> |
|
| 293 | 293 | parameters.send_to = monsterinsights_frontend.v4_id; |
| 294 | 294 | var hookName = name; |
| 295 | 295 | if ( typeof parameters[ 'event_category' ] !== 'undefined' ) { |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | <?php } ?> |
| 305 | 305 | |
| 306 | - <?php if ($ua) { ?> |
|
| 306 | + <?php if ( $ua ) { ?> |
|
| 307 | 307 | parameters.send_to = monsterinsights_frontend.ua; |
| 308 | 308 | __gtagDataLayer( type, name, parameters ); |
| 309 | 309 | <?php } ?> |
@@ -315,18 +315,18 @@ discard block |
||
| 315 | 315 | __gtagTracker( 'set', { |
| 316 | 316 | 'developer_id.dZGIzZG' : true, |
| 317 | 317 | <?php |
| 318 | - if (!empty($persistent)) { |
|
| 319 | - foreach ($persistent as $key => $value) { |
|
| 320 | - echo "'".esc_js($key)."' : '".esc_js($value)."',"; |
|
| 318 | + if ( ! empty( $persistent ) ) { |
|
| 319 | + foreach ( $persistent as $key => $value ) { |
|
| 320 | + echo "'" . esc_js( $key ) . "' : '" . esc_js( $value ) . "',"; |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | ?> |
| 324 | 324 | } ); |
| 325 | - <?php if (!empty($v4_id)) { ?> |
|
| 326 | - __gtagTracker( 'config', '<?php echo esc_js($v4_id); ?>', <?php echo $options_v4; ?> ); |
|
| 325 | + <?php if ( ! empty( $v4_id ) ) { ?> |
|
| 326 | + __gtagTracker( 'config', '<?php echo esc_js( $v4_id ); ?>', <?php echo $options_v4; ?> ); |
|
| 327 | 327 | <?php } ?> |
| 328 | - <?php if (!empty($ua)) { ?> |
|
| 329 | - __gtagTracker( 'config', '<?php echo esc_js($ua); ?>', <?php echo $options; ?> ); |
|
| 328 | + <?php if ( ! empty( $ua ) ) { ?> |
|
| 329 | + __gtagTracker( 'config', '<?php echo esc_js( $ua ); ?>', <?php echo $options; ?> ); |
|
| 330 | 330 | <?php |
| 331 | 331 | } |
| 332 | 332 | /* |
@@ -335,10 +335,10 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @since 7.15.0 |
| 337 | 337 | */ |
| 338 | - do_action('monsterinsights_frontend_tracking_gtag_after_pageview'); |
|
| 338 | + do_action( 'monsterinsights_frontend_tracking_gtag_after_pageview' ); |
|
| 339 | 339 | ?> |
| 340 | - <?php echo esc_js($compat); ?> |
|
| 341 | - <?php if (apply_filters('monsterinsights_tracking_gtag_frontend_gatracker_compatibility', true)) { ?> |
|
| 340 | + <?php echo esc_js( $compat ); ?> |
|
| 341 | + <?php if ( apply_filters( 'monsterinsights_tracking_gtag_frontend_gatracker_compatibility', true ) ) { ?> |
|
| 342 | 342 | (function () { |
| 343 | 343 | /* https://developers.google.com/analytics/devguides/collection/analyticsjs/ */ |
| 344 | 344 | /* ga and __gaTracker compatibility shim. */ |
@@ -450,8 +450,8 @@ discard block |
||
| 450 | 450 | })(); |
| 451 | 451 | <?php } ?> |
| 452 | 452 | } else { |
| 453 | - <?php if ($this->should_do_optout()) { ?> |
|
| 454 | - console.log( "<?php echo esc_js($reason); ?>" ); |
|
| 453 | + <?php if ( $this->should_do_optout() ) { ?> |
|
| 454 | + console.log( "<?php echo esc_js( $reason ); ?>" ); |
|
| 455 | 455 | ( function () { |
| 456 | 456 | function __gtagTracker() { |
| 457 | 457 | return null; |
@@ -475,6 +475,6 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | public function should_do_optout() |
| 477 | 477 | { |
| 478 | - return !(defined('MI_NO_TRACKING_OPTOUT') && MI_NO_TRACKING_OPTOUT); |
|
| 478 | + return ! ( defined( 'MI_NO_TRACKING_OPTOUT' ) && MI_NO_TRACKING_OPTOUT ); |
|
| 479 | 479 | } |
| 480 | 480 | } |
@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -class MonsterInsights_Tracking_Gtag extends MonsterInsights_Tracking_Abstract |
|
| 16 | -{ |
|
| 15 | +class MonsterInsights_Tracking_Gtag extends MonsterInsights_Tracking_Abstract { |
|
| 17 | 16 | /** |
| 18 | 17 | * Holds the name of the tracking type. |
| 19 | 18 | * |
@@ -37,8 +36,7 @@ discard block |
||
| 37 | 36 | * |
| 38 | 37 | * @since 7.15.0 |
| 39 | 38 | */ |
| 40 | - public function __construct() |
|
| 41 | - { |
|
| 39 | + public function __construct() { |
|
| 42 | 40 | } |
| 43 | 41 | |
| 44 | 42 | /** |
@@ -50,8 +48,7 @@ discard block |
||
| 50 | 48 | * |
| 51 | 49 | * @since 7.15.0 |
| 52 | 50 | */ |
| 53 | - public function frontend_tracking_options_persistent() |
|
| 54 | - { |
|
| 51 | + public function frontend_tracking_options_persistent() { |
|
| 55 | 52 | return apply_filters('monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', []); |
| 56 | 53 | } |
| 57 | 54 | |
@@ -69,8 +66,7 @@ discard block |
||
| 69 | 66 | * |
| 70 | 67 | * @since 7.15.0 |
| 71 | 68 | */ |
| 72 | - public function frontend_tracking_options($type = 'ua', $encoded = false) |
|
| 73 | - { |
|
| 69 | + public function frontend_tracking_options($type = 'ua', $encoded = false) { |
|
| 74 | 70 | global $wp_query; |
| 75 | 71 | $options = []; |
| 76 | 72 | |
@@ -185,8 +181,7 @@ discard block |
||
| 185 | 181 | * |
| 186 | 182 | * @since 7.15.0 |
| 187 | 183 | */ |
| 188 | - public function frontend_output() |
|
| 189 | - { |
|
| 184 | + public function frontend_output() { |
|
| 190 | 185 | $options = $this->frontend_tracking_options('ua', true); |
| 191 | 186 | $options_v4 = $this->frontend_tracking_options('v4', true); |
| 192 | 187 | $persistent = $this->frontend_tracking_options_persistent(); |
@@ -473,8 +468,7 @@ discard block |
||
| 473 | 468 | return $output; |
| 474 | 469 | } |
| 475 | 470 | |
| 476 | - public function should_do_optout() |
|
| 477 | - { |
|
| 471 | + public function should_do_optout() { |
|
| 478 | 472 | return !(defined('MI_NO_TRACKING_OPTOUT') && MI_NO_TRACKING_OPTOUT); |
| 479 | 473 | } |
| 480 | 474 | } |