@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function __construct() { |
| 63 | 63 | // Allow dashboard widget to be hidden on multisite installs |
| 64 | - $show_widget = is_multisite() ? apply_filters( 'monsterinsights_show_dashboard_widget', true ) : true; |
|
| 64 | + $show_widget = is_multisite() ? apply_filters( 'monsterinsights_show_dashboard_widget', true ) : true; |
|
| 65 | 65 | if ( ! $show_widget ) { |
| 66 | 66 | return false; |
| 67 | 67 | } |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | // Attept to place the widget at the top. |
| 95 | 95 | $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core']; |
| 96 | - $widget_instance = array( self::WIDGET_KEY => $normal_dashboard[ self::WIDGET_KEY ] ); |
|
| 97 | - unset( $normal_dashboard[ self::WIDGET_KEY ] ); |
|
| 96 | + $widget_instance = array( self::WIDGET_KEY => $normal_dashboard[self::WIDGET_KEY] ); |
|
| 97 | + unset( $normal_dashboard[self::WIDGET_KEY] ); |
|
| 98 | 98 | $sorted_dashboard = array_merge( $widget_instance, $normal_dashboard ); |
| 99 | 99 | $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard; |
| 100 | 100 | } |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | $b = (array) $b; |
| 250 | 250 | $result = $b; |
| 251 | 251 | foreach ( $a as $k => &$v ) { |
| 252 | - if ( is_array( $v ) && isset( $result[ $k ] ) ) { |
|
| 253 | - $result[ $k ] = self::wp_parse_args_recursive( $v, $result[ $k ] ); |
|
| 252 | + if ( is_array( $v ) && isset( $result[$k] ) ) { |
|
| 253 | + $result[$k] = self::wp_parse_args_recursive( $v, $result[$k] ); |
|
| 254 | 254 | } else { |
| 255 | - $result[ $k ] = $v; |
|
| 255 | + $result[$k] = $v; |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | ); |
| 116 | 116 | |
| 117 | 117 | foreach ( $this->conditional_options as $key => $default ) { |
| 118 | - if ( ! empty( $instance[ $key ] ) ) { |
|
| 119 | - $atts[ $key ] = $instance[ $key ]; |
|
| 118 | + if ( ! empty( $instance[$key] ) ) { |
|
| 119 | + $atts[$key] = $instance[$key]; |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $theme = $themes->get_theme(); |
| 150 | 150 | |
| 151 | 151 | foreach ( $this->conditional_options as $key => $obj ) { |
| 152 | - $new_instance = $this->maybe_remove_option( ! empty( $theme['styles'][ $obj[0] ][ $obj[1] ] ), $key, $new_instance ); |
|
| 152 | + $new_instance = $this->maybe_remove_option( ! empty( $theme['styles'][$obj[0]][$obj[1]] ), $key, $new_instance ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | return $new_instance; |
@@ -172,12 +172,12 @@ discard block |
||
| 172 | 172 | 'meta_comments', |
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | - if ( $is_used && ! isset( $instance[ $key ] ) && in_array( $key, $checkboxes ) ) { |
|
| 176 | - $instance[ $key ] = 'off'; |
|
| 177 | - } elseif ( ! $is_used && isset( $instance[ $key ] ) ) { |
|
| 178 | - unset( $instance[ $key ] ); |
|
| 179 | - } elseif ( $is_used && isset( $instance[ $key ] ) ) { |
|
| 180 | - $instance[ $key ] = wp_strip_all_tags( $instance[ $key ] ); |
|
| 175 | + if ( $is_used && ! isset( $instance[$key] ) && in_array( $key, $checkboxes ) ) { |
|
| 176 | + $instance[$key] = 'off'; |
|
| 177 | + } elseif ( ! $is_used && isset( $instance[$key] ) ) { |
|
| 178 | + unset( $instance[$key] ); |
|
| 179 | + } elseif ( $is_used && isset( $instance[$key] ) ) { |
|
| 180 | + $instance[$key] = wp_strip_all_tags( $instance[$key] ); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return $instance; |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | <input type="text" |
| 325 | 325 | id="<?php echo esc_attr( $this->get_field_id( $name ) ); ?>" |
| 326 | 326 | name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>" |
| 327 | - value="<?php echo esc_attr( $instance[ $name ] ); ?>" |
|
| 327 | + value="<?php echo esc_attr( $instance[$name] ); ?>" |
|
| 328 | 328 | class="widefat monsterinsights-color-field"/> |
| 329 | 329 | </p> |
| 330 | 330 | <?php |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | <input type="text" |
| 347 | 347 | id="<?php echo esc_attr( $this->get_field_id( $name ) ); ?>" |
| 348 | 348 | name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>" |
| 349 | - value="<?php echo esc_attr( $instance[ $name ] ); ?>" class="widefat"/> |
|
| 349 | + value="<?php echo esc_attr( $instance[$name] ); ?>" class="widefat"/> |
|
| 350 | 350 | </p> |
| 351 | 351 | <?php |
| 352 | 352 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | <select id="<?php echo esc_attr( $this->get_field_id( $name ) ); ?>" |
| 369 | 369 | name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>" class="widefat"> |
| 370 | 370 | <?php foreach ( $range as $font_size ) { ?> |
| 371 | - <option value="<?php echo absint( $font_size ); ?>" <?php selected( $instance[ $name ], $font_size ); ?>><?php printf( esc_html_x( '%dpx', 'google-analytics-for-wordpress' ), $font_size ); ?></option> |
|
| 371 | + <option value="<?php echo absint( $font_size ); ?>" <?php selected( $instance[$name], $font_size ); ?>><?php printf( esc_html_x( '%dpx', 'google-analytics-for-wordpress' ), $font_size ); ?></option> |
|
| 372 | 372 | <?php } ?> |
| 373 | 373 | </select> |
| 374 | 374 | </p> |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | public function prepare_defaults_from_theme( $theme ) { |
| 384 | 384 | foreach ( $this->conditional_options as $key => $obj ) { |
| 385 | - if ( ! empty( $theme['styles'][ $obj[0] ][ $obj[1] ] ) ) { |
|
| 386 | - $this->defaults[ $key ] = $theme['styles'][ $obj[0] ][ $obj[1] ]; |
|
| 385 | + if ( ! empty( $theme['styles'][$obj[0]][$obj[1]] ) ) { |
|
| 386 | + $this->defaults[$key] = $theme['styles'][$obj[0]][$obj[1]]; |
|
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $time = time(); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $this->last_run[ $notification_id ] = $time; |
|
| 94 | + $this->last_run[$notification_id] = $time; |
|
| 95 | 95 | $this->changed = true; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @var MonsterInsights_Notification_Event $notification |
| 126 | 126 | */ |
| 127 | - if ( empty( $last_runs[ $notification->notification_id ] ) ) { |
|
| 127 | + if ( empty( $last_runs[$notification->notification_id] ) ) { |
|
| 128 | 128 | // If the notification never ran, save current time to show it after the interval. |
| 129 | 129 | $this->update_last_run( $notification->notification_id ); |
| 130 | 130 | } else { |
| 131 | 131 | // Has run before so let's check if enough days passed since the last run. |
| 132 | - $time_since = $last_runs[ $notification->notification_id ] + $notification->notification_interval * DAY_IN_SECONDS; |
|
| 132 | + $time_since = $last_runs[$notification->notification_id] + $notification->notification_interval * DAY_IN_SECONDS; |
|
| 133 | 133 | $time_now = time(); |
| 134 | 134 | if ( $time_since < $time_now ) { |
| 135 | 135 | // Interval passed since it ran so let's add this one. |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | public function register_notification( $notification ) { |
| 165 | 165 | |
| 166 | 166 | $notification_id = isset( $notification->notification_id ) ? $notification->notification_id : false; |
| 167 | - if ( ! empty( $notification_id ) && ! isset( self::$notifications[ $notification_id ] ) ) { |
|
| 168 | - self::$notifications[ $notification_id ] = $notification; |
|
| 167 | + if ( ! empty( $notification_id ) && ! isset( self::$notifications[$notification_id] ) ) { |
|
| 168 | + self::$notifications[$notification_id] = $notification; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | } |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | $translations = wp_get_available_translations(); |
| 80 | 80 | |
| 81 | 81 | if ( is_array( $translations ) && ! empty( $translations ) ) { |
| 82 | - $site_iso = isset( $translations[ $site_language ]['iso'] ) ? $translations[ $site_language ]['iso'] : array(); // keep empty array, because site language has no iso setup for en_US language |
|
| 82 | + $site_iso = isset( $translations[$site_language]['iso'] ) ? $translations[$site_language]['iso'] : array(); // keep empty array, because site language has no iso setup for en_US language |
|
| 83 | 83 | |
| 84 | 84 | if ( is_array( $site_iso ) && ! in_array( $country['iso'], $site_iso ) ) { |
| 85 | 85 | $data['country'] = $country['name']; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | ( ! empty( $notification['end'] ) && time() > strtotime( $notification['end'] ) ) || |
| 233 | 233 | ( ! empty( $notification['type'] ) && ! in_array( $license_type, $notification['type'] ) ) |
| 234 | 234 | ) { |
| 235 | - unset( $notifications[ $key ] ); |
|
| 235 | + unset( $notifications[$key] ); |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | foreach ( $notifications as $key => $notification ) { |
| 291 | 291 | if ( ! empty( $notification['content'] ) ) { |
| 292 | - $notifications[ $key ]['content'] = wpautop( $notification['content'] ); |
|
| 293 | - $notifications[ $key ]['content'] = apply_filters( 'monsterinsights_notification_content_display', $notifications[ $key ]['content'] ); |
|
| 292 | + $notifications[$key]['content'] = wpautop( $notification['content'] ); |
|
| 293 | + $notifications[$key]['content'] = apply_filters( 'monsterinsights_notification_content_display', $notifications[$key]['content'] ); |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // Translators: Readable time to display |
| 318 | 318 | $modified_start_time = sprintf( __( '%1$s ago', 'google-analytics-for-wordpress' ), human_time_diff( strtotime( $notification['start'] ), current_time( 'timestamp' ) ) ); |
| 319 | - $notifications[ $key ]['start'] = $modified_start_time; |
|
| 319 | + $notifications[$key]['start'] = $modified_start_time; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | return $notifications; |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | if ( is_array( $option['feed'] ) && ! empty( $option['feed'] ) ) { |
| 447 | 447 | foreach ( $option['feed'] as $key => $notification ) { |
| 448 | 448 | array_unshift( $option['dismissed'], $notification ); |
| 449 | - unset( $option['feed'][ $key ] ); |
|
| 449 | + unset( $option['feed'][$key] ); |
|
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | if ( is_array( $option['events'] ) && ! empty( $option['events'] ) ) { |
| 453 | 453 | foreach ( $option['events'] as $key => $notification ) { |
| 454 | 454 | array_unshift( $option['dismissed'], $notification ); |
| 455 | - unset( $option['events'][ $key ] ); |
|
| 455 | + unset( $option['events'][$key] ); |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | } |
@@ -460,13 +460,13 @@ discard block |
||
| 460 | 460 | $type = is_numeric( $id ) ? 'feed' : 'events'; |
| 461 | 461 | |
| 462 | 462 | // Remove notification and add in dismissed array. |
| 463 | - if ( is_array( $option[ $type ] ) && ! empty( $option[ $type ] ) ) { |
|
| 464 | - foreach ( $option[ $type ] as $key => $notification ) { |
|
| 463 | + if ( is_array( $option[$type] ) && ! empty( $option[$type] ) ) { |
|
| 464 | + foreach ( $option[$type] as $key => $notification ) { |
|
| 465 | 465 | if ( $notification['id'] == $id ) { // phpcs:ignore WordPress.PHP.StrictComparisons |
| 466 | 466 | // Add notification to dismissed array. |
| 467 | 467 | array_unshift( $option['dismissed'], $notification ); |
| 468 | 468 | // Remove notification from feed or events. |
| 469 | - unset( $option[ $type ][ $key ] ); |
|
| 469 | + unset( $option[$type][$key] ); |
|
| 470 | 470 | break; |
| 471 | 471 | } |
| 472 | 472 | } |
@@ -141,7 +141,8 @@ discard block |
||
| 141 | 141 | * @since {VERSION} |
| 142 | 142 | * |
| 143 | 143 | */ |
| 144 | - public function verify( $notifications ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh |
|
| 144 | + public function verify( $notifications ) { |
|
| 145 | +// phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh |
|
| 145 | 146 | |
| 146 | 147 | $data = array(); |
| 147 | 148 | |
@@ -462,7 +463,8 @@ discard block |
||
| 462 | 463 | // Remove notification and add in dismissed array. |
| 463 | 464 | if ( is_array( $option[ $type ] ) && ! empty( $option[ $type ] ) ) { |
| 464 | 465 | foreach ( $option[ $type ] as $key => $notification ) { |
| 465 | - if ( $notification['id'] == $id ) { // phpcs:ignore WordPress.PHP.StrictComparisons |
|
| 466 | + if ( $notification['id'] == $id ) { |
|
| 467 | +// phpcs:ignore WordPress.PHP.StrictComparisons |
|
| 466 | 468 | // Add notification to dismissed array. |
| 467 | 469 | array_unshift( $option['dismissed'], $notification ); |
| 468 | 470 | // Remove notification from feed or events. |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | // if new install or Yoast Era instal |
| 64 | 64 | if ( ! $version ) { |
| 65 | 65 | // See if from Yoast |
| 66 | - $yoast = get_option( 'yst_ga', false ); |
|
| 66 | + $yoast = get_option( 'yst_ga', false ); |
|
| 67 | 67 | |
| 68 | 68 | // In case from Yoast, start from scratch |
| 69 | 69 | delete_option( 'yoast-ga-access_token' ); |
@@ -363,25 +363,25 @@ discard block |
||
| 363 | 363 | public function v700_upgrades() { |
| 364 | 364 | // 1. Default all event tracking and tracking to GA + JS respectively |
| 365 | 365 | // 3a Set tracking_mode to use analytics.js |
| 366 | - $this->new_settings['tracking_mode' ] = 'analytics'; |
|
| 366 | + $this->new_settings['tracking_mode'] = 'analytics'; |
|
| 367 | 367 | |
| 368 | 368 | |
| 369 | 369 | // 3b Set events mode to use JS if the events mode is not set explicitly to none |
| 370 | - if ( empty( $this->new_settings['events_mode' ] ) || $this->new_settings['events_mode' ] !== 'none' ) { |
|
| 371 | - $this->new_settings['events_mode' ] = 'js'; |
|
| 370 | + if ( empty( $this->new_settings['events_mode'] ) || $this->new_settings['events_mode'] !== 'none' ) { |
|
| 371 | + $this->new_settings['events_mode'] = 'js'; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | // 2. Migrate manual UA codes |
| 375 | 375 | // 2a Manual UA has the lowest priority |
| 376 | - if ( ! empty( $this->new_settings['manual_ua_code' ] ) ) { |
|
| 376 | + if ( ! empty( $this->new_settings['manual_ua_code'] ) ) { |
|
| 377 | 377 | // Set as manual UA code |
| 378 | - is_network_admin() ? update_site_option( 'monsterinsights_network_profile', array( 'manual' => $this->new_settings['manual_ua_code' ] ) ) : update_option( 'monsterinsights_site_profile', array( 'manual' => $this->new_settings['manual_ua_code' ] ) ); |
|
| 378 | + is_network_admin() ? update_site_option( 'monsterinsights_network_profile', array( 'manual' => $this->new_settings['manual_ua_code'] ) ) : update_option( 'monsterinsights_site_profile', array( 'manual' => $this->new_settings['manual_ua_code'] ) ); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | // 2b Then try the oAuth UA code |
| 382 | - if ( ! empty( $this->new_settings['analytics_profile_code' ] ) ) { |
|
| 382 | + if ( ! empty( $this->new_settings['analytics_profile_code'] ) ) { |
|
| 383 | 383 | // Set as manual UA code |
| 384 | - is_network_admin() ? update_site_option( 'monsterinsights_network_profile', array( 'manual' => $this->new_settings['analytics_profile_code' ] ) ) : update_option( 'monsterinsights_site_profile', array( 'manual' => $this->new_settings['analytics_profile_code' ] ) ); |
|
| 384 | + is_network_admin() ? update_site_option( 'monsterinsights_network_profile', array( 'manual' => $this->new_settings['analytics_profile_code'] ) ) : update_option( 'monsterinsights_site_profile', array( 'manual' => $this->new_settings['analytics_profile_code'] ) ); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // 3. Migrate License keys |
@@ -423,8 +423,8 @@ discard block |
||
| 423 | 423 | 'track_internal_as_label', |
| 424 | 424 | ); |
| 425 | 425 | foreach ( $settings as $setting ) { |
| 426 | - if ( ! empty( $this->new_settings[ $setting ] ) ) { |
|
| 427 | - unset( $this->new_settings[ $setting ] ); |
|
| 426 | + if ( ! empty( $this->new_settings[$setting] ) ) { |
|
| 427 | + unset( $this->new_settings[$setting] ); |
|
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | } |
@@ -468,8 +468,8 @@ discard block |
||
| 468 | 468 | ); |
| 469 | 469 | |
| 470 | 470 | foreach ( $settings as $setting ) { |
| 471 | - if ( ! empty( $this->new_settings[ $setting ] ) ) { |
|
| 472 | - unset( $this->new_settings[ $setting ] ); |
|
| 471 | + if ( ! empty( $this->new_settings[$setting] ) ) { |
|
| 472 | + unset( $this->new_settings[$setting] ); |
|
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | |
@@ -508,8 +508,8 @@ discard block |
||
| 508 | 508 | ); |
| 509 | 509 | |
| 510 | 510 | foreach ( $settings as $setting ) { |
| 511 | - if ( ! empty( $this->new_settings[ $setting ] ) ) { |
|
| 512 | - unset( $this->new_settings[ $setting ] ); |
|
| 511 | + if ( ! empty( $this->new_settings[$setting] ) ) { |
|
| 512 | + unset( $this->new_settings[$setting] ); |
|
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | 515 | |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | } |
| 601 | 601 | preg_match( $regex, $cross_domain['domain'], $matches ); |
| 602 | 602 | if ( count( $matches ) > 0 ) { |
| 603 | - unset( $this->new_settings['cross_domains'][ $key ] ); |
|
| 603 | + unset( $this->new_settings['cross_domains'][$key] ); |
|
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | } |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | 'js', |
| 681 | 681 | 'tgz' |
| 682 | 682 | ); |
| 683 | - $extensions_to_add = array( |
|
| 683 | + $extensions_to_add = array( |
|
| 684 | 684 | 'docx', |
| 685 | 685 | 'pptx', |
| 686 | 686 | 'xlsx', |
@@ -782,8 +782,8 @@ discard block |
||
| 782 | 782 | ); |
| 783 | 783 | |
| 784 | 784 | foreach ( $popular_posts_defaults as $key => $value ) { |
| 785 | - if ( empty( $this->new_settings[ $key ] ) ) { |
|
| 786 | - $this->new_settings[ $key ] = $value; |
|
| 785 | + if ( empty( $this->new_settings[$key] ) ) { |
|
| 786 | + $this->new_settings[$key] = $value; |
|
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | 789 | |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | $content = isset( $dismiss_notification['content'] ) ? $dismiss_notification['content'] : ''; |
| 799 | 799 | |
| 800 | 800 | if ( empty( $title ) || empty( $content ) ) { |
| 801 | - unset( $dismissed_notifications[ $key ] ); |
|
| 801 | + unset( $dismissed_notifications[$key] ); |
|
| 802 | 802 | } |
| 803 | 803 | } |
| 804 | 804 | |