@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if ( ! is_array( $item ) ) { |
162 | 162 | echo ' _gaq.push([' . $item . "]);\n"; |
163 | 163 | } else if ( isset( $item['value'] ) ) { |
164 | - echo ' '.$item['value'] . "\n"; |
|
164 | + echo ' ' . $item['value'] . "\n"; |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | var ga = document.createElement('script'); |
172 | 172 | ga.type = 'text/javascript'; |
173 | 173 | ga.async = true; |
174 | - ga.src = <?php echo $src;?> |
|
174 | + ga.src = <?php echo $src; ?> |
|
175 | 175 | var s = document.getElementsByTagName('script')[0]; |
176 | 176 | s.parentNode.insertBefore(ga, s); |
177 | 177 | })(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @access public |
53 | 53 | */ |
54 | 54 | public function __construct() { |
55 | - $this->base = MonsterInsights(); |
|
55 | + $this->base = MonsterInsights(); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return array Array of the options to use. |
69 | 69 | */ |
70 | 70 | public function frontend_tracking_options( ) { |
71 | - return array(); |
|
71 | + return array(); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @return string Javascript to output. |
85 | 85 | */ |
86 | 86 | public function frontend_output( ) { |
87 | - $output = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->'; |
|
88 | - $output .= '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->'; |
|
89 | - $output .= '<!-- / Google Analytics by MonsterInsights -->'; |
|
90 | - return $output; |
|
87 | + $output = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->'; |
|
88 | + $output .= '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->'; |
|
89 | + $output .= '<!-- / Google Analytics by MonsterInsights -->'; |
|
90 | + return $output; |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -84,9 +84,9 @@ |
||
84 | 84 | * @return string Javascript to output. |
85 | 85 | */ |
86 | 86 | public function frontend_output( ) { |
87 | - $output = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->'; |
|
88 | - $output .= '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->'; |
|
89 | - $output .= '<!-- / Google Analytics by MonsterInsights -->'; |
|
87 | + $output = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION . ' - https://www.monsterinsights.com/ -->'; |
|
88 | + $output .= '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->'; |
|
89 | + $output .= '<!-- / Google Analytics by MonsterInsights -->'; |
|
90 | 90 | return $output; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @access public |
53 | 53 | */ |
54 | 54 | public function __construct() { |
55 | - $this->base = MonsterInsights(); |
|
55 | + $this->base = MonsterInsights(); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return array Array of the options to use. |
69 | 69 | */ |
70 | 70 | public function frontend_tracking_options( ) { |
71 | - return array(); |
|
71 | + return array(); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * @return string Javascript to output. |
85 | 85 | */ |
86 | 86 | public function frontend_output( ) { |
87 | - $output = PHP_EOL . '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->' . PHP_EOL; |
|
87 | + $output = PHP_EOL . '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->' . PHP_EOL; |
|
88 | 88 | |
89 | - if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
90 | - $output .= '<!-- ' . sprintf( esc_html__( '@Webmaster, normally you will find the Google Analytics tracking code here, but you are in the disabled user groups. To change this, navigate to Insights %1$s Settings %1$s Ignore Users', 'google-analytics-for-wordpress' ), '->' ) . ' -->' . PHP_EOL; |
|
91 | - } else { |
|
92 | - $output .= '<!-- ' . esc_html__( 'Normally you will find the Google Analytics tracking code here, but the webmaster disabled your user group.', 'google-analytics-for-wordpress' ) . ' -->' . PHP_EOL; |
|
93 | - } |
|
94 | - $output .= '<!-- / Google Analytics by MonsterInsights -->' . PHP_EOL . PHP_EOL; |
|
95 | - return $output; |
|
89 | + if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
|
90 | + $output .= '<!-- ' . sprintf( esc_html__( '@Webmaster, normally you will find the Google Analytics tracking code here, but you are in the disabled user groups. To change this, navigate to Insights %1$s Settings %1$s Ignore Users', 'google-analytics-for-wordpress' ), '->' ) . ' -->' . PHP_EOL; |
|
91 | + } else { |
|
92 | + $output .= '<!-- ' . esc_html__( 'Normally you will find the Google Analytics tracking code here, but the webmaster disabled your user group.', 'google-analytics-for-wordpress' ) . ' -->' . PHP_EOL; |
|
93 | + } |
|
94 | + $output .= '<!-- / Google Analytics by MonsterInsights -->' . PHP_EOL . PHP_EOL; |
|
95 | + return $output; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | \ No newline at end of file |
@@ -84,14 +84,14 @@ |
||
84 | 84 | * @return string Javascript to output. |
85 | 85 | */ |
86 | 86 | public function frontend_output( ) { |
87 | - $output = PHP_EOL . '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->' . PHP_EOL; |
|
87 | + $output = PHP_EOL . '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION . ' - https://www.monsterinsights.com/ -->' . PHP_EOL; |
|
88 | 88 | |
89 | 89 | if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
90 | - $output .= '<!-- ' . sprintf( esc_html__( '@Webmaster, normally you will find the Google Analytics tracking code here, but you are in the disabled user groups. To change this, navigate to Insights %1$s Settings %1$s Ignore Users', 'google-analytics-for-wordpress' ), '->' ) . ' -->' . PHP_EOL; |
|
90 | + $output .= '<!-- ' . sprintf( esc_html__( '@Webmaster, normally you will find the Google Analytics tracking code here, but you are in the disabled user groups. To change this, navigate to Insights %1$s Settings %1$s Ignore Users', 'google-analytics-for-wordpress' ), '->' ) . ' -->' . PHP_EOL; |
|
91 | 91 | } else { |
92 | - $output .= '<!-- ' . esc_html__( 'Normally you will find the Google Analytics tracking code here, but the webmaster disabled your user group.', 'google-analytics-for-wordpress' ) . ' -->' . PHP_EOL; |
|
92 | + $output .= '<!-- ' . esc_html__( 'Normally you will find the Google Analytics tracking code here, but the webmaster disabled your user group.', 'google-analytics-for-wordpress' ) . ' -->' . PHP_EOL; |
|
93 | 93 | } |
94 | - $output .= '<!-- / Google Analytics by MonsterInsights -->' . PHP_EOL . PHP_EOL; |
|
94 | + $output .= '<!-- / Google Analytics by MonsterInsights -->' . PHP_EOL . PHP_EOL; |
|
95 | 95 | return $output; |
96 | 96 | } |
97 | 97 | } |
98 | 98 | \ No newline at end of file |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | if ( $create && ! empty( $create ) && is_array( $create ) ) { |
101 | 101 | $create = json_encode( $create ); |
102 | - $create = str_replace( '"', "'", $create ); |
|
103 | - $options['create'] = "'create', '" . esc_js( $ua_code ). "', '" . esc_js( $domain ) . "', " . $create; |
|
102 | + $create = str_replace( '"', "'", $create ); |
|
103 | + $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "', " . $create; |
|
104 | 104 | } else { |
105 | 105 | $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "'"; |
106 | 106 | } |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function frontend_output( ) { |
178 | 178 | $options = $this->frontend_tracking_options(); |
179 | - $is_debug_mode = monsterinsights_is_debug_mode(); |
|
180 | - $src = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js' ); |
|
179 | + $is_debug_mode = monsterinsights_is_debug_mode(); |
|
180 | + $src = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js' ); |
|
181 | 181 | if ( current_user_can( 'manage_options' ) && $is_debug_mode ) { |
182 | - $src = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics_debug.js' ); |
|
182 | + $src = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics_debug.js' ); |
|
183 | 183 | } |
184 | 184 | $compat = monsterinsights_get_option( 'gatracker_compatibility_mode', false ); |
185 | 185 | $compat = $compat ? 'window.ga = __gaTracker;' : ''; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param array $matches Matches found for the hyperlink. |
137 | 137 | */ |
138 | 138 | public function __construct( $base, $category, $matches ) { |
139 | - $this->base = $base; |
|
139 | + $this->base = $base; |
|
140 | 140 | $this->category = $category; |
141 | 141 | $this->original_url = $matches[5]; |
142 | 142 | $this->domain = $this->get_domain(); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $type = 'email'; |
193 | 193 | } else if ( in_array( $this->extension, $download_extensions ) ) { |
194 | 194 | $type = 'download'; |
195 | - } else if ( in_array( $this->protocol, array( 'http', 'https') ) && $full_url !== rtrim( home_url(), '\/' ) ) { |
|
195 | + } else if ( in_array( $this->protocol, array( 'http', 'https' ) ) && $full_url !== rtrim( home_url(), '\/' ) ) { |
|
196 | 196 | $type = 'outbound'; |
197 | 197 | } else { |
198 | 198 | $type = $this->parse_internal_link_type(); |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | $internal_label = esc_js( $internal_label ); |
91 | 91 | |
92 | 92 | // Get inbound as outbound to track |
93 | - $inbound_paths = monsterinsights_get_option( 'track_internal_as_outbound','' ); |
|
93 | + $inbound_paths = monsterinsights_get_option( 'track_internal_as_outbound', '' ); |
|
94 | 94 | $inbound_paths = explode( ',', $inbound_paths ); |
95 | 95 | if ( ! is_array( $inbound_paths ) ) { |
96 | 96 | $inbound_paths = array( $inbound_paths ); |
97 | 97 | } |
98 | 98 | $i = 0; |
99 | - foreach ( $inbound_paths as $path ){ |
|
100 | - $inbound_paths[ $i ] = esc_js( trim( $path ) ); |
|
99 | + foreach ( $inbound_paths as $path ) { |
|
100 | + $inbound_paths[$i] = esc_js( trim( $path ) ); |
|
101 | 101 | $i++; |
102 | 102 | } |
103 | 103 | |
@@ -110,14 +110,14 @@ discard block |
||
110 | 110 | $download_extensions = array( $download_extensions ); |
111 | 111 | } |
112 | 112 | $i = 0; |
113 | - foreach( $download_extensions as $extension ){ |
|
114 | - $download_extensions[ $i ] = esc_js( trim( $extension ) ); |
|
113 | + foreach ( $download_extensions as $extension ) { |
|
114 | + $download_extensions[$i] = esc_js( trim( $extension ) ); |
|
115 | 115 | $i++; |
116 | 116 | } |
117 | 117 | |
118 | 118 | $download_extensions = implode( ",", $download_extensions ); |
119 | 119 | |
120 | - $is_debug_mode = monsterinsights_is_debug_mode(); |
|
120 | + $is_debug_mode = monsterinsights_is_debug_mode(); |
|
121 | 121 | if ( current_user_can( 'manage_options' ) && $is_debug_mode ) { |
122 | 122 | $is_debug_mode = 'true'; |
123 | 123 | } else { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $inbound_paths = array( $inbound_paths ); |
97 | 97 | } |
98 | 98 | $i = 0; |
99 | - foreach ( $inbound_paths as $path ){ |
|
99 | + foreach ( $inbound_paths as $path ) { |
|
100 | 100 | $inbound_paths[ $i ] = esc_js( trim( $path ) ); |
101 | 101 | $i++; |
102 | 102 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $download_extensions = array( $download_extensions ); |
111 | 111 | } |
112 | 112 | $i = 0; |
113 | - foreach( $download_extensions as $extension ){ |
|
113 | + foreach( $download_extensions as $extension ) { |
|
114 | 114 | $download_extensions[ $i ] = esc_js( trim( $extension ) ); |
115 | 115 | $i++; |
116 | 116 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | . '>' // matches the characters > literally |
108 | 108 | . '(.*)' // 7. matches any character (except newline) (Between 0 and * times) |
109 | 109 | . '<\/a>' // matches the characters </a> literally |
110 | - . '/isU'; // case insensitive, single line, ungreedy |
|
110 | + . '/isU'; // case insensitive, single line, ungreedy |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | return $link_attribute; |
257 | 257 | } else if ( preg_match( '/onclick=[\'\"](.*?)[\'\"]/i', $link_attribute, $matches ) > 0 && is_string( $onclick ) ) { // if not closed, see #33 |
258 | 258 | $onclick_with_double = str_replace( "'", '"', $onclick ); |
259 | - if ( strlen( trim ( $matches[1] ) ) > 0 ) { |
|
259 | + if ( strlen( trim( $matches[1] ) ) > 0 ) { |
|
260 | 260 | $js_snippet_single = 'onclick=\'' . $matches[1] . '; ' . $onclick_with_double . '\''; |
261 | 261 | $js_snippet_double = 'onclick="' . $matches[1] . '; ' . $onclick . '"'; |
262 | 262 | } else { |
@@ -371,14 +371,14 @@ discard block |
||
371 | 371 | $full_url = $this->make_full_url( $link_target ); |
372 | 372 | switch ( $link_target->type ) { |
373 | 373 | case 'download': |
374 | - if ( $this->tracking === 'ga' ){ |
|
375 | - if ( monsterinsights_get_option('track_download_as', '' ) === 'pageview' ) { |
|
374 | + if ( $this->tracking === 'ga' ) { |
|
375 | + if ( monsterinsights_get_option( 'track_download_as', '' ) === 'pageview' ) { |
|
376 | 376 | $onclick = $object_name . "(['_trackPageview','download/" . esc_js( $full_url ) . "']);"; |
377 | 377 | } else { |
378 | 378 | $onclick = $object_name . "(['_trackEvent','download','" . esc_js( $full_url ) . "']);"; |
379 | 379 | } |
380 | 380 | } else { |
381 | - if ( monsterinsights_get_option('track_download_as', '' ) === 'pageview' ) { |
|
381 | + if ( monsterinsights_get_option( 'track_download_as', '' ) === 'pageview' ) { |
|
382 | 382 | $onclick = $object_name . "('send', 'pageview', '" . esc_js( $full_url ) . "');"; |
383 | 383 | } else { |
384 | 384 | $onclick = $object_name . "('send', 'event', 'download', '" . esc_js( $full_url ) . "');"; |
@@ -386,23 +386,23 @@ discard block |
||
386 | 386 | } |
387 | 387 | break; |
388 | 388 | case 'email': |
389 | - if ( $this->tracking === 'ga' ){ |
|
389 | + if ( $this->tracking === 'ga' ) { |
|
390 | 390 | $onclick = $object_name . "(['_trackEvent','mailto','" . esc_js( $link_target->original_url ) . "']);"; |
391 | 391 | } else { |
392 | 392 | $onclick = $object_name . "('send', 'event', 'mailto', '" . esc_js( $link_target->original_url ) . "');"; |
393 | 393 | } |
394 | 394 | break; |
395 | 395 | case 'internal-as-outbound': |
396 | - if ( $this->tracking === 'ga' ){ |
|
396 | + if ( $this->tracking === 'ga' ) { |
|
397 | 397 | $category = $this->sanitize_internal_label(); |
398 | 398 | $onclick = $object_name . "(['_trackEvent', '" . esc_js( $link_target->category ) . '-' . esc_js( $category ) . "', '" . esc_js( $full_url ) . "', '" . esc_js( strip_tags( $link_target->link_text ) ) . "']);"; |
399 | 399 | } else { |
400 | 400 | $category = $this->sanitize_internal_label(); |
401 | - $onclick = $object_name . "('send', '" . esc_js( monsterinsights_get_option('track_download_as', '' ) ) . "', '" . esc_js( $link_target->category ) . '-' . esc_js( $category ) . "', '" . esc_js( $full_url ) . "', '" . esc_js( strip_tags( $link_target->link_text ) ) . "');"; |
|
401 | + $onclick = $object_name . "('send', '" . esc_js( monsterinsights_get_option( 'track_download_as', '' ) ) . "', '" . esc_js( $link_target->category ) . '-' . esc_js( $category ) . "', '" . esc_js( $full_url ) . "', '" . esc_js( strip_tags( $link_target->link_text ) ) . "');"; |
|
402 | 402 | } |
403 | 403 | break; |
404 | 404 | case 'outbound': |
405 | - if ( $this->tracking === 'ga' ){ |
|
405 | + if ( $this->tracking === 'ga' ) { |
|
406 | 406 | $onclick = $object_name . "(['_trackEvent', '" . esc_js( $link_target->category ) . "', '" . esc_js( $full_url ) . "', '" . esc_js( strip_tags( $link_target->link_text ) ) . "']);"; |
407 | 407 | } else { |
408 | 408 | $onclick = $object_name . "('send', 'event', '" . esc_js( $link_target->category ) . "', '" . esc_js( $full_url ) . "', '" . esc_js( strip_tags( $link_target->link_text ) ) . "');"; |
@@ -254,7 +254,8 @@ discard block |
||
254 | 254 | $link_attribute = str_replace( "onclick='" . $matches[1] . "'", $js_snippet_single, $link_attribute ); |
255 | 255 | |
256 | 256 | return $link_attribute; |
257 | - } else if ( preg_match( '/onclick=[\'\"](.*?)[\'\"]/i', $link_attribute, $matches ) > 0 && is_string( $onclick ) ) { // if not closed, see #33 |
|
257 | + } else if ( preg_match( '/onclick=[\'\"](.*?)[\'\"]/i', $link_attribute, $matches ) > 0 && is_string( $onclick ) ) { |
|
258 | +// if not closed, see #33 |
|
258 | 259 | $onclick_with_double = str_replace( "'", '"', $onclick ); |
259 | 260 | if ( strlen( trim ( $matches[1] ) ) > 0 ) { |
260 | 261 | $js_snippet_single = 'onclick=\'' . $matches[1] . '; ' . $onclick_with_double . '\''; |
@@ -371,7 +372,7 @@ discard block |
||
371 | 372 | $full_url = $this->make_full_url( $link_target ); |
372 | 373 | switch ( $link_target->type ) { |
373 | 374 | case 'download': |
374 | - if ( $this->tracking === 'ga' ){ |
|
375 | + if ( $this->tracking === 'ga' ) { |
|
375 | 376 | if ( monsterinsights_get_option('track_download_as', '' ) === 'pageview' ) { |
376 | 377 | $onclick = $object_name . "(['_trackPageview','download/" . esc_js( $full_url ) . "']);"; |
377 | 378 | } else { |
@@ -386,14 +387,14 @@ discard block |
||
386 | 387 | } |
387 | 388 | break; |
388 | 389 | case 'email': |
389 | - if ( $this->tracking === 'ga' ){ |
|
390 | + if ( $this->tracking === 'ga' ) { |
|
390 | 391 | $onclick = $object_name . "(['_trackEvent','mailto','" . esc_js( $link_target->original_url ) . "']);"; |
391 | 392 | } else { |
392 | 393 | $onclick = $object_name . "('send', 'event', 'mailto', '" . esc_js( $link_target->original_url ) . "');"; |
393 | 394 | } |
394 | 395 | break; |
395 | 396 | case 'internal-as-outbound': |
396 | - if ( $this->tracking === 'ga' ){ |
|
397 | + if ( $this->tracking === 'ga' ) { |
|
397 | 398 | $category = $this->sanitize_internal_label(); |
398 | 399 | $onclick = $object_name . "(['_trackEvent', '" . esc_js( $link_target->category ) . '-' . esc_js( $category ) . "', '" . esc_js( $full_url ) . "', '" . esc_js( strip_tags( $link_target->link_text ) ) . "']);"; |
399 | 400 | } else { |
@@ -402,7 +403,7 @@ discard block |
||
402 | 403 | } |
403 | 404 | break; |
404 | 405 | case 'outbound': |
405 | - if ( $this->tracking === 'ga' ){ |
|
406 | + if ( $this->tracking === 'ga' ) { |
|
406 | 407 | $onclick = $object_name . "(['_trackEvent', '" . esc_js( $link_target->category ) . "', '" . esc_js( $full_url ) . "', '" . esc_js( strip_tags( $link_target->link_text ) ) . "']);"; |
407 | 408 | } else { |
408 | 409 | $onclick = $object_name . "('send', 'event', '" . esc_js( $link_target->category ) . "', '" . esc_js( $full_url ) . "', '" . esc_js( strip_tags( $link_target->link_text ) ) . "');"; |
@@ -34,48 +34,48 @@ discard block |
||
34 | 34 | $mode = ''; |
35 | 35 | |
36 | 36 | if ( is_preview() ) { |
37 | - $mode = 'preview'; |
|
37 | + $mode = 'preview'; |
|
38 | 38 | } else if ( ! monsterinsights_track_user() ) { |
39 | - $mode = 'disabled'; |
|
39 | + $mode = 'disabled'; |
|
40 | 40 | } else if ( $tracking_mode === 'analytics' ) { |
41 | - $mode = 'analytics'; |
|
41 | + $mode = 'analytics'; |
|
42 | 42 | } else if ( $tracking_mode === 'ga' ) { |
43 | - $mode = 'ga'; |
|
43 | + $mode = 'ga'; |
|
44 | 44 | } else { |
45 | - //$mode = apply_filters( 'monsterinsights_custom_tracking_name', 'name-of-method' ); |
|
45 | + //$mode = apply_filters( 'monsterinsights_custom_tracking_name', 'name-of-method' ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | do_action( 'monsterinsights_tracking_before_' . $mode ); |
49 | 49 | do_action( 'monsterinsights_tracking_before', $mode ); |
50 | 50 | |
51 | 51 | switch ( $mode ) { |
52 | - case 'preview': |
|
53 | - require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-preview.php'; |
|
54 | - $tracking = new MonsterInsights_Tracking_Preview(); |
|
55 | - echo $tracking->frontend_output(); |
|
56 | - break; |
|
57 | - |
|
58 | - case 'disabled': |
|
59 | - require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-disabled.php'; |
|
60 | - $tracking = new MonsterInsights_Tracking_Disabled(); |
|
61 | - echo $tracking->frontend_output(); |
|
62 | - break; |
|
63 | - |
|
64 | - case 'analytics': |
|
65 | - require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php'; |
|
66 | - $tracking = new MonsterInsights_Tracking_Analytics(); |
|
67 | - echo $tracking->frontend_output(); |
|
68 | - break; |
|
69 | - |
|
70 | - case 'ga': |
|
71 | - require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-ga.php'; |
|
72 | - $tracking = new MonsterInsights_Tracking_GA(); |
|
73 | - echo $tracking->frontend_output(); |
|
74 | - break; |
|
75 | - |
|
76 | - default: |
|
77 | - //do_action( 'monsterinsights_custom_tracking' ); |
|
78 | - break; |
|
52 | + case 'preview': |
|
53 | + require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-preview.php'; |
|
54 | + $tracking = new MonsterInsights_Tracking_Preview(); |
|
55 | + echo $tracking->frontend_output(); |
|
56 | + break; |
|
57 | + |
|
58 | + case 'disabled': |
|
59 | + require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-disabled.php'; |
|
60 | + $tracking = new MonsterInsights_Tracking_Disabled(); |
|
61 | + echo $tracking->frontend_output(); |
|
62 | + break; |
|
63 | + |
|
64 | + case 'analytics': |
|
65 | + require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php'; |
|
66 | + $tracking = new MonsterInsights_Tracking_Analytics(); |
|
67 | + echo $tracking->frontend_output(); |
|
68 | + break; |
|
69 | + |
|
70 | + case 'ga': |
|
71 | + require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-ga.php'; |
|
72 | + $tracking = new MonsterInsights_Tracking_GA(); |
|
73 | + echo $tracking->frontend_output(); |
|
74 | + break; |
|
75 | + |
|
76 | + default: |
|
77 | + //do_action( 'monsterinsights_custom_tracking' ); |
|
78 | + break; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | do_action( 'monsterinsights_tracking_after_' . $mode ); |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | $track_user = monsterinsights_track_user(); |
103 | 103 | |
104 | 104 | if ( $track_user && $events_mode === 'php' && ( $tracking_mode === 'ga' || $tracking_mode === 'analytics' ) ) { |
105 | - require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-events-php.php'; |
|
106 | - new MonsterInsights_Events_PHP(); |
|
105 | + require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-events-php.php'; |
|
106 | + new MonsterInsights_Events_PHP(); |
|
107 | 107 | } else if ( $track_user && $events_mode === 'js' && $tracking_mode === 'analytics' ) { |
108 | - require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-events-js.php'; |
|
109 | - new MonsterInsights_Events_JS(); |
|
108 | + require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-events-js.php'; |
|
109 | + new MonsterInsights_Events_JS(); |
|
110 | 110 | } else { |
111 | - // User is in the disabled group or events mode is off |
|
111 | + // User is in the disabled group or events mode is off |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | add_action( 'template_redirect', 'monsterinsights_events_tracking', 9 ); |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | global $post; |
128 | 128 | |
129 | 129 | if ( monsterinsights_get_option( 'tag_links_in_rss', false ) ){ |
130 | - if ( is_feed() ) { |
|
131 | - if ( monsterinsights_get_option( 'allow_anchor', false ) ) { |
|
132 | - $delimiter = '#'; |
|
133 | - } else { |
|
134 | - $delimiter = '?'; |
|
135 | - if ( strpos( $guid, $delimiter ) > 0 ) { |
|
136 | - $delimiter = '&'; |
|
137 | - } |
|
138 | - } |
|
139 | - return $guid . $delimiter . 'utm_source=rss&utm_medium=rss&utm_campaign=' . urlencode( $post->post_name ); |
|
140 | - } |
|
130 | + if ( is_feed() ) { |
|
131 | + if ( monsterinsights_get_option( 'allow_anchor', false ) ) { |
|
132 | + $delimiter = '#'; |
|
133 | + } else { |
|
134 | + $delimiter = '?'; |
|
135 | + if ( strpos( $guid, $delimiter ) > 0 ) { |
|
136 | + $delimiter = '&'; |
|
137 | + } |
|
138 | + } |
|
139 | + return $guid . $delimiter . 'utm_source=rss&utm_medium=rss&utm_campaign=' . urlencode( $post->post_name ); |
|
140 | + } |
|
141 | 141 | } |
142 | 142 | return $guid; |
143 | 143 | } |
@@ -126,7 +126,7 @@ |
||
126 | 126 | function monsterinsights_rss_link_tagger( $guid ) { |
127 | 127 | global $post; |
128 | 128 | |
129 | - if ( monsterinsights_get_option( 'tag_links_in_rss', false ) ){ |
|
129 | + if ( monsterinsights_get_option( 'tag_links_in_rss', false ) ) { |
|
130 | 130 | if ( is_feed() ) { |
131 | 131 | if ( monsterinsights_get_option( 'allow_anchor', false ) ) { |
132 | 132 | $delimiter = '#'; |
@@ -126,7 +126,7 @@ |
||
126 | 126 | function monsterinsights_rss_link_tagger( $guid ) { |
127 | 127 | global $post; |
128 | 128 | |
129 | - if ( monsterinsights_get_option( 'tag_links_in_rss', false ) ){ |
|
129 | + if ( monsterinsights_get_option( 'tag_links_in_rss', false ) ) { |
|
130 | 130 | if ( is_feed() ) { |
131 | 131 | if ( monsterinsights_get_option( 'allow_anchor', false ) ) { |
132 | 132 | $delimiter = '#'; |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | // Fallback to make sure every default option has a value |
309 | 309 | $defaults = $this->get_yoast_default_values(); |
310 | 310 | if ( is_array( $defaults ) ) { |
311 | - foreach ( $defaults[ 'ga_general' ] as $key => $value ) { |
|
312 | - if ( ! isset( $options[ $key ] ) ) { |
|
313 | - $options[ $key ] = $value; |
|
311 | + foreach ( $defaults['ga_general'] as $key => $value ) { |
|
312 | + if ( ! isset( $options[$key] ) ) { |
|
313 | + $options[$key] = $value; |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | } |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | // Set to the current version now that we've done all needed upgrades |
319 | 319 | $options['version'] = '5.5.3'; // Last Yoast codebase version |
320 | 320 | $saved_options = get_option( 'yst_ga' ); |
321 | - $saved_options[ 'ga_general' ] = $options; |
|
321 | + $saved_options['ga_general'] = $options; |
|
322 | 322 | update_option( 'yst_ga', $saved_options ); |
323 | 323 | |
324 | 324 | |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | $network = false; |
329 | 329 | // Try network active Premium |
330 | 330 | $is_key = get_site_option( 'google-analytics-by-yoast-premium_license', array() ); |
331 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){ |
|
332 | - $key = $is_key['key']; |
|
331 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ) { |
|
332 | + $key = $is_key['key']; |
|
333 | 333 | $found = true; |
334 | 334 | $network = true; |
335 | 335 | } |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | // Try single site Premium |
338 | 338 | if ( ! $found ) { |
339 | 339 | $is_key = get_option( 'google-analytics-by-yoast-premium_license', array() ); |
340 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){ |
|
341 | - $key = $is_key['key']; |
|
340 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ) { |
|
341 | + $key = $is_key['key']; |
|
342 | 342 | $found = true; |
343 | 343 | } |
344 | 344 | } |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | // Try network active Premium |
347 | 347 | if ( ! $found ) { |
348 | 348 | $is_key = get_site_option( 'monsterinsights-pro_license', array() ); |
349 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){ |
|
350 | - $key = $is_key['key']; |
|
349 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ) { |
|
350 | + $key = $is_key['key']; |
|
351 | 351 | $found = true; |
352 | 352 | $network = true; |
353 | 353 | } |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | // Try single site Premium |
357 | 357 | if ( ! $found ) { |
358 | 358 | $is_key = get_option( 'monsterinsights-pro_license', array() ); |
359 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){ |
|
360 | - $key = $is_key['key']; |
|
359 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ) { |
|
360 | + $key = $is_key['key']; |
|
361 | 361 | $found = true; |
362 | 362 | } |
363 | 363 | } |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | // Try network active ecommmerce |
366 | 366 | if ( ! $found ) { |
367 | 367 | $is_key = get_site_option( 'ecommerce-addon_license', array() ); |
368 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){ |
|
369 | - $key = $is_key['key']; |
|
368 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ) { |
|
369 | + $key = $is_key['key']; |
|
370 | 370 | $found = true; |
371 | 371 | $network = true; |
372 | 372 | } |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | // Try single site ecommerce |
375 | 375 | if ( ! $found ) { |
376 | 376 | $is_key = get_option( 'ecommerce-addon_license', array() ); |
377 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){ |
|
378 | - $key = $is_key['key']; |
|
377 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ) { |
|
378 | + $key = $is_key['key']; |
|
379 | 379 | $found = true; |
380 | 380 | } |
381 | 381 | } |
@@ -490,10 +490,10 @@ discard block |
||
490 | 490 | } |
491 | 491 | } |
492 | 492 | } |
493 | - $options['cron_last_run'] = strtotime("-25 hours"); |
|
493 | + $options['cron_last_run'] = strtotime( "-25 hours" ); |
|
494 | 494 | } else { |
495 | 495 | // if UA in manual code field, remove analytics profile fields if set |
496 | - if ( ! empty( $options['manual_ua_code_field' ] ) ) { |
|
496 | + if ( ! empty( $options['manual_ua_code_field'] ) ) { |
|
497 | 497 | if ( isset( $options['analytics_profile_code'] ) ) { |
498 | 498 | unset( $options['analytics_profile_code'] ); |
499 | 499 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | delete_option( 'yoast-ga-access_token' ); |
505 | 505 | delete_option( 'yoast-ga-refresh_token' ); |
506 | 506 | delete_option( 'yst_ga_api' ); |
507 | - } else if ( ! empty( $options['analytics_profile_code' ] ) ) { |
|
507 | + } else if ( ! empty( $options['analytics_profile_code'] ) ) { |
|
508 | 508 | // if UA in profile fields, remove others and use that |
509 | 509 | $options['manual_ua_code'] = $options['analytics_profile_code']; |
510 | 510 | if ( isset( $options['analytics_profile_code'] ) ) { |
@@ -516,13 +516,13 @@ discard block |
||
516 | 516 | delete_option( 'yoast-ga-access_token' ); |
517 | 517 | delete_option( 'yoast-ga-refresh_token' ); |
518 | 518 | delete_option( 'yst_ga_api' ); |
519 | - } else { |
|
519 | + } else { |
|
520 | 520 | // if UA in profile profiles, remove others and use that |
521 | - if ( ! empty( $options['analytics_profile' ] ) && ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) { |
|
521 | + if ( ! empty( $options['analytics_profile'] ) && ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) { |
|
522 | 522 | foreach ( $profiles as $account ) { |
523 | 523 | foreach ( $account['items'] as $profile ) { |
524 | 524 | foreach ( $profile['items'] as $subprofile ) { |
525 | - if ( isset( $subprofile['id'] ) && $subprofile['id'] == $options['analytics_profile' ] ) { |
|
525 | + if ( isset( $subprofile['id'] ) && $subprofile['id'] == $options['analytics_profile'] ) { |
|
526 | 526 | $options['manual_ua_code'] = $subprofile['ua_code']; |
527 | 527 | break 3; |
528 | 528 | } |
@@ -642,8 +642,8 @@ discard block |
||
642 | 642 | */ |
643 | 643 | public function v602_upgrades() { |
644 | 644 | $options = get_option( 'yst_ga', array() ); |
645 | - if ( ( empty( $this->new_settings[ 'manual_ua_code'] ) || $this->new_settings[ 'manual_ua_code'] === '1' ) && |
|
646 | - empty( $this->new_settings[ 'analytics_profile_code'] ) && |
|
645 | + if ( ( empty( $this->new_settings['manual_ua_code'] ) || $this->new_settings['manual_ua_code'] === '1' ) && |
|
646 | + empty( $this->new_settings['analytics_profile_code'] ) && |
|
647 | 647 | ! empty( $options ) && |
648 | 648 | is_array( $options ) && |
649 | 649 | ! empty( $options['ga_general']['manual_ua_code_field'] ) |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | */ |
692 | 692 | public function v620_upgrades() { |
693 | 693 | // Turns off debug mode if its on. |
694 | - if ( empty( $this->new_settings['debug_mode' ] ) ) { |
|
695 | - $this->new_settings['debug_mode' ] = 0; |
|
694 | + if ( empty( $this->new_settings['debug_mode'] ) ) { |
|
695 | + $this->new_settings['debug_mode'] = 0; |
|
696 | 696 | } |
697 | 697 | } |
698 | 698 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -72,7 +72,8 @@ discard block |
||
72 | 72 | // This is the version used for MI upgrade routines. |
73 | 73 | update_option( 'monsterinsights_db_version', '6.2.0' ); |
74 | 74 | |
75 | - } else if ( ! $version && $yoast ) { // if new install and has used Yoast previously |
|
75 | + } else if ( ! $version && $yoast ) { |
|
76 | +// if new install and has used Yoast previously |
|
76 | 77 | |
77 | 78 | $this->upgrade_from_yoast(); |
78 | 79 | // This is the version used for MI upgrade routines. |
@@ -83,7 +84,8 @@ discard block |
||
83 | 84 | $cachec = true; |
84 | 85 | } |
85 | 86 | |
86 | - } else { // if existing install |
|
87 | + } else { |
|
88 | +// if existing install |
|
87 | 89 | if ( version_compare( $version, '6.0.2', '<' ) ) { |
88 | 90 | $this->v602_upgrades(); |
89 | 91 | } |
@@ -328,7 +330,7 @@ discard block |
||
328 | 330 | $network = false; |
329 | 331 | // Try network active Premium |
330 | 332 | $is_key = get_site_option( 'google-analytics-by-yoast-premium_license', array() ); |
331 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){ |
|
333 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ) { |
|
332 | 334 | $key = $is_key['key']; |
333 | 335 | $found = true; |
334 | 336 | $network = true; |
@@ -337,7 +339,7 @@ discard block |
||
337 | 339 | // Try single site Premium |
338 | 340 | if ( ! $found ) { |
339 | 341 | $is_key = get_option( 'google-analytics-by-yoast-premium_license', array() ); |
340 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){ |
|
342 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ) { |
|
341 | 343 | $key = $is_key['key']; |
342 | 344 | $found = true; |
343 | 345 | } |
@@ -346,7 +348,7 @@ discard block |
||
346 | 348 | // Try network active Premium |
347 | 349 | if ( ! $found ) { |
348 | 350 | $is_key = get_site_option( 'monsterinsights-pro_license', array() ); |
349 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){ |
|
351 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ) { |
|
350 | 352 | $key = $is_key['key']; |
351 | 353 | $found = true; |
352 | 354 | $network = true; |
@@ -356,7 +358,7 @@ discard block |
||
356 | 358 | // Try single site Premium |
357 | 359 | if ( ! $found ) { |
358 | 360 | $is_key = get_option( 'monsterinsights-pro_license', array() ); |
359 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){ |
|
361 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ) { |
|
360 | 362 | $key = $is_key['key']; |
361 | 363 | $found = true; |
362 | 364 | } |
@@ -365,7 +367,7 @@ discard block |
||
365 | 367 | // Try network active ecommmerce |
366 | 368 | if ( ! $found ) { |
367 | 369 | $is_key = get_site_option( 'ecommerce-addon_license', array() ); |
368 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ){ |
|
370 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) && is_multisite() ) { |
|
369 | 371 | $key = $is_key['key']; |
370 | 372 | $found = true; |
371 | 373 | $network = true; |
@@ -374,7 +376,7 @@ discard block |
||
374 | 376 | // Try single site ecommerce |
375 | 377 | if ( ! $found ) { |
376 | 378 | $is_key = get_option( 'ecommerce-addon_license', array() ); |
377 | - if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ){ |
|
379 | + if ( $is_key && ! empty( $is_key ) && is_array( $is_key ) && ! empty( $is_key['key'] ) ) { |
|
378 | 380 | $key = $is_key['key']; |
379 | 381 | $found = true; |
380 | 382 | } |
@@ -516,7 +518,7 @@ discard block |
||
516 | 518 | delete_option( 'yoast-ga-access_token' ); |
517 | 519 | delete_option( 'yoast-ga-refresh_token' ); |
518 | 520 | delete_option( 'yst_ga_api' ); |
519 | - } else { |
|
521 | + } else { |
|
520 | 522 | // if UA in profile profiles, remove others and use that |
521 | 523 | if ( ! empty( $options['analytics_profile' ] ) && ! empty( $profiles['ga_api_response_accounts'] ) && is_array( $profiles['ga_api_response_accounts'] ) ) { |
522 | 524 | foreach ( $profiles as $account ) { |