@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $site_license = array( |
|
| 67 | + $site_license = array( |
|
| 68 | 68 | 'key' => MonsterInsights()->license->get_site_license_key(), |
| 69 | 69 | 'type' => MonsterInsights()->license->get_site_license_type(), |
| 70 | 70 | 'is_disabled' => MonsterInsights()->license->site_license_disabled(), |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | // Array fields are needed even if empty. |
| 125 | 125 | $array_fields = array( 'view_reports', 'save_settings', 'ignore_users' ); |
| 126 | 126 | foreach ( $array_fields as $array_field ) { |
| 127 | - if ( ! isset( $options[ $array_field ] ) ) { |
|
| 128 | - $options[ $array_field ] = array(); |
|
| 127 | + if ( ! isset( $options[$array_field] ) ) { |
|
| 128 | + $options[$array_field] = array(); |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | if ( isset( $options['custom_code'] ) ) { |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | if ( $empty ) { |
| 263 | - unset( $value[ $key ] ); |
|
| 263 | + unset( $value[$key] ); |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | } |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } else { |
| 311 | 311 | $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug ); |
| 312 | 312 | } |
| 313 | - $parsed_addons[ $addon->slug ] = $addon; |
|
| 313 | + $parsed_addons[$addon->slug] = $addon; |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | 'slug' => 'wp-mail-smtp', |
| 405 | 405 | ); |
| 406 | 406 | // SeedProd. |
| 407 | - $parsed_addons['coming-soon'] = array( |
|
| 407 | + $parsed_addons['coming-soon'] = array( |
|
| 408 | 408 | 'active' => function_exists( 'seed_csp4_activation' ), |
| 409 | 409 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugin-seedprod.png', |
| 410 | 410 | 'title' => 'SeedProd', |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | 'slug' => 'coming-soon', |
| 415 | 415 | ); |
| 416 | 416 | // RafflePress |
| 417 | - $parsed_addons['rafflepress'] = array( |
|
| 417 | + $parsed_addons['rafflepress'] = array( |
|
| 418 | 418 | 'active' => function_exists( 'rafflepress_lite_activation' ), |
| 419 | 419 | 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/pluign-rafflepress.png', |
| 420 | 420 | 'title' => 'RafflePress', |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | $installed = false; |
| 487 | 487 | $plugin_basename = monsterinsights_get_plugin_basename_from_slug( $slug ); |
| 488 | 488 | |
| 489 | - if ( isset( $installed_plugins[ $plugin_basename ] ) ) { |
|
| 489 | + if ( isset( $installed_plugins[$plugin_basename] ) ) { |
|
| 490 | 490 | $installed = true; |
| 491 | 491 | |
| 492 | 492 | if ( is_multisite() && is_network_admin() ) { |
@@ -501,8 +501,8 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | $active_version = false; |
| 503 | 503 | if ( $active ) { |
| 504 | - if ( ! empty( $installed_plugins[ $plugin_basename ]['Version'] ) ) { |
|
| 505 | - $active_version = $installed_plugins[ $plugin_basename ]['Version']; |
|
| 504 | + if ( ! empty( $installed_plugins[$plugin_basename]['Version'] ) ) { |
|
| 505 | + $active_version = $installed_plugins[$plugin_basename]['Version']; |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
@@ -637,8 +637,8 @@ discard block |
||
| 637 | 637 | ); |
| 638 | 638 | |
| 639 | 639 | foreach ( $exclude as $e ) { |
| 640 | - if ( ! empty( $new_settings[ $e ] ) ) { |
|
| 641 | - unset( $new_settings[ $e ] ); |
|
| 640 | + if ( ! empty( $new_settings[$e] ) ) { |
|
| 641 | + unset( $new_settings[$e] ); |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | foreach ( $exclude as $e ) { |
| 652 | - if ( ! empty( $settings[ $e ] ) ) { |
|
| 653 | - $new_settings = $settings[ $e ]; |
|
| 652 | + if ( ! empty( $settings[$e] ) ) { |
|
| 653 | + $new_settings = $settings[$e]; |
|
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | ), |
| 811 | 811 | admin_url( 'admin.php' ) |
| 812 | 812 | ); |
| 813 | - $url = esc_url( $url ); |
|
| 813 | + $url = esc_url( $url ); |
|
| 814 | 814 | |
| 815 | 815 | ob_start(); |
| 816 | 816 | if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) { |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | $homepage = get_option( 'page_on_front' ); |
| 917 | 917 | if ( ! $homepage ) { |
| 918 | 918 | $array[] = array( |
| 919 | - 'id' => - 1, |
|
| 919 | + 'id' => -1, |
|
| 920 | 920 | 'title' => __( 'Homepage', 'google-analytics-for-wordpress' ), |
| 921 | 921 | ); |
| 922 | 922 | } |
@@ -990,7 +990,7 @@ discard block |
||
| 990 | 990 | if ( ! post_type_supports( $post_type->name, 'editor' ) || 'product' === $post_type->name ) { |
| 991 | 991 | continue; |
| 992 | 992 | } |
| 993 | - $post_types_parsed[ $post_type->name ] = $post_type->labels->singular_name; |
|
| 993 | + $post_types_parsed[$post_type->name] = $post_type->labels->singular_name; |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | $post_types_parsed = apply_filters( 'monsterinsights_vue_post_types_editor', $post_types_parsed ); |
@@ -1112,18 +1112,18 @@ discard block |
||
| 1112 | 1112 | $value = sanitize_text_field( wp_unslash( $_POST['value'] ) ); // Value of custom style like 12px or #fff. |
| 1113 | 1113 | $settings = get_option( $settings_key, array() ); |
| 1114 | 1114 | |
| 1115 | - if ( ! isset( $settings[ $type ] ) ) { |
|
| 1116 | - $settings[ $type ] = array(); |
|
| 1115 | + if ( ! isset( $settings[$type] ) ) { |
|
| 1116 | + $settings[$type] = array(); |
|
| 1117 | 1117 | } |
| 1118 | - if ( ! isset( $settings[ $type ][ $theme ] ) ) { |
|
| 1119 | - $settings[ $type ][ $theme ] = array(); |
|
| 1118 | + if ( ! isset( $settings[$type][$theme] ) ) { |
|
| 1119 | + $settings[$type][$theme] = array(); |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | - if ( ! isset( $settings[ $type ][ $theme ][ $object ] ) ) { |
|
| 1123 | - $settings[ $type ][ $theme ][ $object ] = array(); |
|
| 1122 | + if ( ! isset( $settings[$type][$theme][$object] ) ) { |
|
| 1123 | + $settings[$type][$theme][$object] = array(); |
|
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | - $settings[ $type ][ $theme ][ $object ][ $key ] = $value; |
|
| 1126 | + $settings[$type][$theme][$object][$key] = $value; |
|
| 1127 | 1127 | |
| 1128 | 1128 | update_option( $settings_key, $settings ); |
| 1129 | 1129 | |
@@ -322,7 +322,7 @@ |
||
| 322 | 322 | $url = admin_url( 'plugins.php' ); |
| 323 | 323 | |
| 324 | 324 | // Check for MS dashboard |
| 325 | - if( is_network_admin() ) { |
|
| 325 | + if ( is_network_admin() ) { |
|
| 326 | 326 | $url = network_admin_url( 'plugins.php' ); |
| 327 | 327 | } |
| 328 | 328 | |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | if ( array_key_exists( $key, $args ) ) { |
| 69 | - $out[ $key ] = $args[ $key ]; |
|
| 69 | + $out[$key] = $args[$key]; |
|
| 70 | 70 | } else { |
| 71 | - $out[ $key ] = $default; |
|
| 71 | + $out[$key] = $default; |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | if ( $this->is_debug ) { |
| 89 | 89 | foreach ( $body['events'] as $index => $event ) { |
| 90 | - $body['events'][ $index ]['params']['debug_mode'] = true; |
|
| 90 | + $body['events'][$index]['params']['debug_mode'] = true; |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
@@ -206,7 +206,7 @@ |
||
| 206 | 206 | $is_dual_tracking_id_ua = monsterinsights_is_valid_ua( $id ); |
| 207 | 207 | |
| 208 | 208 | $is_valid_dual_tracking_id = ( $is_dual_tracking_id_ua && ( $is_manual_v4 || $is_authed_v4 ) ) || |
| 209 | - ( $is_dual_tracking_id_v4 && ( $is_manual_ua || $is_authed_ua ) ); |
|
| 209 | + ( $is_dual_tracking_id_v4 && ( $is_manual_ua || $is_authed_ua ) ); |
|
| 210 | 210 | |
| 211 | 211 | if ( ! $is_valid_dual_tracking_id ) { |
| 212 | 212 | return false; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | final class MonsterInsights_Auth { |
| 20 | 20 | |
| 21 | - private $profile = array(); |
|
| 21 | + private $profile = array(); |
|
| 22 | 22 | private $network = array(); |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | return $result; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - return $this->get_connected_type() === $type && ! empty( $this->profile[ $type ] ); |
|
| 66 | + return $this->get_connected_type() === $type && ! empty( $this->profile[$type] ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function is_network_authed( $type = false ) { |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | return $result; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - return $this->get_connected_type() === $type && ! empty( $this->network[ $type ] ); |
|
| 76 | + return $this->get_connected_type() === $type && ! empty( $this->network[$type] ); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function get_analytics_profile( $force = false ) { |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function set_analytics_profile( $data = array() ){ |
|
| 99 | + public function set_analytics_profile( $data = array() ) { |
|
| 100 | 100 | update_option( 'monsterinsights_site_profile', $data ); |
| 101 | - $this->profile = $data; |
|
| 101 | + $this->profile = $data; |
|
| 102 | 102 | |
| 103 | 103 | // If this is the first time, save the date when they connected. |
| 104 | 104 | $over_time = get_option( 'monsterinsights_over_time', array() ); |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - public function set_network_analytics_profile( $data = array() ){ |
|
| 119 | + public function set_network_analytics_profile( $data = array() ) { |
|
| 120 | 120 | update_site_option( 'monsterinsights_network_profile', $data ); |
| 121 | - $this->network = $data; |
|
| 121 | + $this->network = $data; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public function delete_analytics_profile( $migrate = true ){ |
|
| 124 | + public function delete_analytics_profile( $migrate = true ) { |
|
| 125 | 125 | if ( $migrate ) { |
| 126 | 126 | $newdata = array(); |
| 127 | 127 | if ( isset( $this->profile['ua'] ) ) { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function delete_network_analytics_profile( $migrate = true ){ |
|
| 141 | + public function delete_network_analytics_profile( $migrate = true ) { |
|
| 142 | 142 | if ( $migrate ) { |
| 143 | 143 | $newdata = array(); |
| 144 | 144 | if ( isset( $this->network['ua'] ) ) { |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | do_action( 'monsterinsights_reports_delete_aggregate_data' ); |
| 176 | 176 | |
| 177 | - $this->profile = $data; |
|
| 177 | + $this->profile = $data; |
|
| 178 | 178 | $this->set_analytics_profile( $data ); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | $key = $is_authed_ua ? 'v4' : 'ua'; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( $key && ! empty( $data[ $key ] ) ) { |
|
| 202 | - unset( $data[ $key ] ); |
|
| 201 | + if ( $key && ! empty( $data[$key] ) ) { |
|
| 202 | + unset( $data[$key] ); |
|
| 203 | 203 | } |
| 204 | 204 | } else { |
| 205 | 205 | $is_dual_tracking_id_v4 = monsterinsights_is_valid_v4_id( $id ); |
@@ -218,13 +218,13 @@ discard block |
||
| 218 | 218 | $key = $is_dual_tracking_id_v4 ? 'v4' : 'ua'; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $data[ $key ] = $id; |
|
| 221 | + $data[$key] = $id; |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | return $data; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - public function set_dual_tracking_id ( $id = '' ) { |
|
| 227 | + public function set_dual_tracking_id( $id = '' ) { |
|
| 228 | 228 | $data = empty( $this->profile ) ? array() : $this->profile; |
| 229 | 229 | |
| 230 | 230 | $is_manual_ua = $this->is_manual( 'ua' ); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $this->set_analytics_profile( $prepared_data ); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - public function set_network_dual_tracking_id ( $id = '' ) { |
|
| 244 | + public function set_network_dual_tracking_id( $id = '' ) { |
|
| 245 | 245 | $data = empty( $this->network ) ? array() : $this->network; |
| 246 | 246 | |
| 247 | 247 | $is_manual_ua = $this->is_network_manual( 'ua' ); |
@@ -271,13 +271,13 @@ discard block |
||
| 271 | 271 | if ( empty( $this->profile ) ) { |
| 272 | 272 | $data['manual_v4'] = $v4; |
| 273 | 273 | } else { |
| 274 | - $data = $this->profile; |
|
| 274 | + $data = $this->profile; |
|
| 275 | 275 | $data['manual_v4'] = $v4; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | do_action( 'monsterinsights_reports_delete_aggregate_data' ); |
| 279 | 279 | |
| 280 | - $this->profile = $data; |
|
| 280 | + $this->profile = $data; |
|
| 281 | 281 | $this->set_analytics_profile( $data ); |
| 282 | 282 | } |
| 283 | 283 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | if ( empty( $this->network ) ) { |
| 318 | 318 | $data['manual_v4'] = $v4; |
| 319 | 319 | } else { |
| 320 | - $data = $this->network; |
|
| 320 | + $data = $this->network; |
|
| 321 | 321 | $data['manual_v4'] = $v4; |
| 322 | 322 | } |
| 323 | 323 | |
@@ -425,51 +425,51 @@ discard block |
||
| 425 | 425 | return ! empty( $this->network['v4'] ) ? monsterinsights_is_valid_v4_id( $this->network['v4'] ) : ''; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - public function get_viewname(){ |
|
| 428 | + public function get_viewname() { |
|
| 429 | 429 | return ! empty( $this->profile['viewname'] ) ? $this->profile['viewname'] : ''; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - public function get_network_viewname(){ |
|
| 432 | + public function get_network_viewname() { |
|
| 433 | 433 | return ! empty( $this->network['viewname'] ) ? $this->network['viewname'] : ''; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - public function get_accountid(){ |
|
| 436 | + public function get_accountid() { |
|
| 437 | 437 | return ! empty( $this->profile['a'] ) ? $this->profile['a'] : ''; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - public function get_network_accountid(){ |
|
| 440 | + public function get_network_accountid() { |
|
| 441 | 441 | return ! empty( $this->network['a'] ) ? $this->network['a'] : ''; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - public function get_propertyid(){ |
|
| 444 | + public function get_propertyid() { |
|
| 445 | 445 | return ! empty( $this->profile['w'] ) ? $this->profile['w'] : ''; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - public function get_network_propertyid(){ |
|
| 448 | + public function get_network_propertyid() { |
|
| 449 | 449 | return ! empty( $this->network['w'] ) ? $this->network['w'] : ''; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - public function get_viewid(){ // also known as profileID |
|
| 452 | + public function get_viewid() { // also known as profileID |
|
| 453 | 453 | return ! empty( $this->profile['p'] ) ? $this->profile['p'] : ''; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - public function get_network_viewid(){ // also known as profileID |
|
| 456 | + public function get_network_viewid() { // also known as profileID |
|
| 457 | 457 | return ! empty( $this->network['p'] ) ? $this->network['p'] : ''; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - public function get_key(){ |
|
| 460 | + public function get_key() { |
|
| 461 | 461 | return ! empty( $this->profile['key'] ) ? $this->profile['key'] : ''; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - public function get_network_key(){ |
|
| 464 | + public function get_network_key() { |
|
| 465 | 465 | return ! empty( $this->network['key'] ) ? $this->network['key'] : ''; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - public function get_token(){ |
|
| 468 | + public function get_token() { |
|
| 469 | 469 | return ! empty( $this->profile['token'] ) ? $this->profile['token'] : ''; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - public function get_network_token(){ |
|
| 472 | + public function get_network_token() { |
|
| 473 | 473 | return ! empty( $this->network['token'] ) ? $this->network['token'] : ''; |
| 474 | 474 | } |
| 475 | 475 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function set_analytics_profile( $data = array() ){ |
|
| 99 | + public function set_analytics_profile( $data = array() ) { |
|
| 100 | 100 | update_option( 'monsterinsights_site_profile', $data ); |
| 101 | 101 | $this->profile = $data; |
| 102 | 102 | |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - public function set_network_analytics_profile( $data = array() ){ |
|
| 119 | + public function set_network_analytics_profile( $data = array() ) { |
|
| 120 | 120 | update_site_option( 'monsterinsights_network_profile', $data ); |
| 121 | 121 | $this->network = $data; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public function delete_analytics_profile( $migrate = true ){ |
|
| 124 | + public function delete_analytics_profile( $migrate = true ) { |
|
| 125 | 125 | if ( $migrate ) { |
| 126 | 126 | $newdata = array(); |
| 127 | 127 | if ( isset( $this->profile['ua'] ) ) { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function delete_network_analytics_profile( $migrate = true ){ |
|
| 141 | + public function delete_network_analytics_profile( $migrate = true ) { |
|
| 142 | 142 | if ( $migrate ) { |
| 143 | 143 | $newdata = array(); |
| 144 | 144 | if ( isset( $this->network['ua'] ) ) { |
@@ -425,51 +425,53 @@ discard block |
||
| 425 | 425 | return ! empty( $this->network['v4'] ) ? monsterinsights_is_valid_v4_id( $this->network['v4'] ) : ''; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - public function get_viewname(){ |
|
| 428 | + public function get_viewname() { |
|
| 429 | 429 | return ! empty( $this->profile['viewname'] ) ? $this->profile['viewname'] : ''; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - public function get_network_viewname(){ |
|
| 432 | + public function get_network_viewname() { |
|
| 433 | 433 | return ! empty( $this->network['viewname'] ) ? $this->network['viewname'] : ''; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - public function get_accountid(){ |
|
| 436 | + public function get_accountid() { |
|
| 437 | 437 | return ! empty( $this->profile['a'] ) ? $this->profile['a'] : ''; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - public function get_network_accountid(){ |
|
| 440 | + public function get_network_accountid() { |
|
| 441 | 441 | return ! empty( $this->network['a'] ) ? $this->network['a'] : ''; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - public function get_propertyid(){ |
|
| 444 | + public function get_propertyid() { |
|
| 445 | 445 | return ! empty( $this->profile['w'] ) ? $this->profile['w'] : ''; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - public function get_network_propertyid(){ |
|
| 448 | + public function get_network_propertyid() { |
|
| 449 | 449 | return ! empty( $this->network['w'] ) ? $this->network['w'] : ''; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - public function get_viewid(){ // also known as profileID |
|
| 452 | + public function get_viewid() { |
|
| 453 | +// also known as profileID |
|
| 453 | 454 | return ! empty( $this->profile['p'] ) ? $this->profile['p'] : ''; |
| 454 | 455 | } |
| 455 | 456 | |
| 456 | - public function get_network_viewid(){ // also known as profileID |
|
| 457 | + public function get_network_viewid() { |
|
| 458 | +// also known as profileID |
|
| 457 | 459 | return ! empty( $this->network['p'] ) ? $this->network['p'] : ''; |
| 458 | 460 | } |
| 459 | 461 | |
| 460 | - public function get_key(){ |
|
| 462 | + public function get_key() { |
|
| 461 | 463 | return ! empty( $this->profile['key'] ) ? $this->profile['key'] : ''; |
| 462 | 464 | } |
| 463 | 465 | |
| 464 | - public function get_network_key(){ |
|
| 466 | + public function get_network_key() { |
|
| 465 | 467 | return ! empty( $this->network['key'] ) ? $this->network['key'] : ''; |
| 466 | 468 | } |
| 467 | 469 | |
| 468 | - public function get_token(){ |
|
| 470 | + public function get_token() { |
|
| 469 | 471 | return ! empty( $this->profile['token'] ) ? $this->profile['token'] : ''; |
| 470 | 472 | } |
| 471 | 473 | |
| 472 | - public function get_network_token(){ |
|
| 474 | + public function get_network_token() { |
|
| 473 | 475 | return ! empty( $this->network['token'] ) ? $this->network['token'] : ''; |
| 474 | 476 | } |
| 475 | 477 | |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | $defaults = array( |
| 24 | 24 | 't' => 'event', // Required: Hit type |
| 25 | - 'ec' => '', // Optional: Event category |
|
| 26 | - 'ea' => '', // Optional: Event Action |
|
| 27 | - 'el' => '', // Optional: Event Label |
|
| 28 | - 'ev' => null, // Optional: Event Value |
|
| 25 | + 'ec' => '', // Optional: Event category |
|
| 26 | + 'ea' => '', // Optional: Event Action |
|
| 27 | + 'el' => '', // Optional: Event Label |
|
| 28 | + 'ev' => null, // Optional: Event Value |
|
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | - $body = array_merge( $defaults , $args ); |
|
| 31 | + $body = array_merge( $defaults, $args ); |
|
| 32 | 32 | |
| 33 | 33 | // We want to get the user's IP address when possible |
| 34 | - $ip = ''; |
|
| 34 | + $ip = ''; |
|
| 35 | 35 | if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) && ! filter_var( $_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP ) === false ) { |
| 36 | 36 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
| 37 | 37 | } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && ! filter_var( $_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP ) === false ) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | 'uip' => $ip, |
| 80 | 80 | |
| 81 | 81 | // Optional: User Agent |
| 82 | - 'ua' => ! empty( $user_agent ) ? $user_agent : $_SERVER['HTTP_USER_AGENT'], |
|
| 82 | + 'ua' => ! empty( $user_agent ) ? $user_agent : $_SERVER['HTTP_USER_AGENT'], |
|
| 83 | 83 | |
| 84 | 84 | // Optional: Time of the event |
| 85 | 85 | 'z' => time(), |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | // Unset empty values to reduce request size |
| 101 | 101 | foreach ( $body as $key => $value ) { |
| 102 | 102 | if ( empty( $value ) ) { |
| 103 | - unset( $body[ $key ] ); |
|
| 103 | + unset( $body[$key] ); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | 'ev' => null, |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | - $args = wp_parse_args( $args, $default_args ); |
|
| 154 | + $args = wp_parse_args( $args, $default_args ); |
|
| 155 | 155 | |
| 156 | 156 | //$args = apply_filters( 'monsterinsights_mp_track_event_call', $args ); |
| 157 | 157 | |
@@ -28,23 +28,23 @@ discard block |
||
| 28 | 28 | public function __construct() { |
| 29 | 29 | |
| 30 | 30 | // Authentication Actions |
| 31 | - add_action( 'wp_ajax_monsterinsights_maybe_authenticate', array( $this, 'maybe_authenticate' ) ); |
|
| 32 | - add_action( 'wp_ajax_monsterinsights_maybe_reauthenticate', array( $this, 'maybe_reauthenticate' ) ); |
|
| 33 | - add_action( 'wp_ajax_monsterinsights_maybe_verify', array( $this, 'maybe_verify' ) ); |
|
| 34 | - add_action( 'wp_ajax_monsterinsights_maybe_delete', array( $this, 'maybe_delete' ) ); |
|
| 31 | + add_action( 'wp_ajax_monsterinsights_maybe_authenticate', array( $this, 'maybe_authenticate' ) ); |
|
| 32 | + add_action( 'wp_ajax_monsterinsights_maybe_reauthenticate', array( $this, 'maybe_reauthenticate' ) ); |
|
| 33 | + add_action( 'wp_ajax_monsterinsights_maybe_verify', array( $this, 'maybe_verify' ) ); |
|
| 34 | + add_action( 'wp_ajax_monsterinsights_maybe_delete', array( $this, 'maybe_delete' ) ); |
|
| 35 | 35 | |
| 36 | - add_action( 'admin_init', array( $this, 'authenticate_listener' ) ); |
|
| 37 | - add_action( 'admin_init', array( $this, 'reauthenticate_listener' ) ); |
|
| 36 | + add_action( 'admin_init', array( $this, 'authenticate_listener' ) ); |
|
| 37 | + add_action( 'admin_init', array( $this, 'reauthenticate_listener' ) ); |
|
| 38 | 38 | |
| 39 | - add_action( 'wp_ajax_nopriv_monsterinsights_is_installed', array( $this, 'is_installed' ) ); |
|
| 40 | - add_action( 'wp_ajax_nopriv_monsterinsights_rauthenticate', array( $this, 'rauthenticate' ) ); |
|
| 39 | + add_action( 'wp_ajax_nopriv_monsterinsights_is_installed', array( $this, 'is_installed' ) ); |
|
| 40 | + add_action( 'wp_ajax_nopriv_monsterinsights_rauthenticate', array( $this, 'rauthenticate' ) ); |
|
| 41 | 41 | |
| 42 | 42 | add_filter( 'monsterinsights_maybe_authenticate_siteurl', array( $this, 'before_redirect' ) ); |
| 43 | 43 | |
| 44 | 44 | add_action( 'wp_ajax_nopriv_monsterinsights_push_mp_token', array( $this, 'handle_relay_mp_token_push' ) ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function get_tt(){ |
|
| 47 | + public function get_tt() { |
|
| 48 | 48 | $tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' ); |
| 49 | 49 | if ( empty( $tt ) ) { |
| 50 | 50 | // if TT is empty, generate a new one, save it and then return it |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | return $tt; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function rotate_tt(){ |
|
| 57 | + public function rotate_tt() { |
|
| 58 | 58 | $tt = $this->generate_tt(); |
| 59 | 59 | is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt ); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function generate_tt(){ |
|
| 62 | + public function generate_tt() { |
|
| 63 | 63 | return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) ); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -77,14 +77,14 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function maybe_authenticate(){ |
|
| 80 | + public function maybe_authenticate() { |
|
| 81 | 81 | |
| 82 | 82 | // Check nonce |
| 83 | 83 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
| 84 | 84 | |
| 85 | 85 | // current user can authenticate |
| 86 | 86 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
| 87 | - wp_send_json_error( array( 'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 87 | + wp_send_json_error( array( 'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) { |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | // we do not have a current auth |
| 103 | 103 | if ( ! $this->is_network_admin() && MonsterInsights()->auth->is_authed() ) { |
| 104 | - wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 104 | + wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 105 | 105 | } else if ( $this->is_network_admin() && MonsterInsights()->auth->is_network_authed() ) { |
| 106 | - wp_send_json_error( array( 'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) ); |
|
| 106 | + wp_send_json_error( array( 'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) ); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $sitei = $this->get_sitei(); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | wp_send_json_success(); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - public function authenticate_listener(){ |
|
| 176 | + public function authenticate_listener() { |
|
| 177 | 177 | // Make sure it's for us |
| 178 | 178 | if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) { |
| 179 | 179 | return; |
@@ -191,12 +191,12 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | // Make sure has required params |
| 193 | 193 | if ( |
| 194 | - empty( $_REQUEST['key'] ) || |
|
| 195 | - empty( $_REQUEST['token'] ) || |
|
| 194 | + empty( $_REQUEST['key'] ) || |
|
| 195 | + empty( $_REQUEST['token'] ) || |
|
| 196 | 196 | empty( $_REQUEST['miview'] ) || |
| 197 | - empty( $_REQUEST['a'] ) || |
|
| 198 | - empty( $_REQUEST['w'] ) || |
|
| 199 | - empty( $_REQUEST['p'] ) || |
|
| 197 | + empty( $_REQUEST['a'] ) || |
|
| 198 | + empty( $_REQUEST['w'] ) || |
|
| 199 | + empty( $_REQUEST['p'] ) || |
|
| 200 | 200 | ( empty( $_REQUEST['ua'] ) && empty( $_REQUEST['v4'] ) ) |
| 201 | 201 | ) { |
| 202 | 202 | return; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $profile['measurement_protocol_secret'] = sanitize_text_field( $_REQUEST['mp'] ); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $profile[ $code_key ] = $code_value; |
|
| 233 | + $profile[$code_key] = $code_value; |
|
| 234 | 234 | |
| 235 | 235 | $worked = $this->verify_auth( $profile ); |
| 236 | 236 | if ( ! $worked || is_wp_error( $worked ) ) { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $where = $this->is_network_admin() ? 'network' : 'site'; |
| 245 | 245 | MonsterInsights()->reporting->delete_aggregate_data( $where ); |
| 246 | 246 | |
| 247 | - $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ; |
|
| 247 | + $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ); |
|
| 248 | 248 | $url = add_query_arg( array( |
| 249 | 249 | 'mi_action' => 'auth', |
| 250 | 250 | 'success' => 'true', |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | exit; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - public function maybe_reauthenticate(){ |
|
| 257 | + public function maybe_reauthenticate() { |
|
| 258 | 258 | |
| 259 | 259 | // Check nonce |
| 260 | 260 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
| 261 | 261 | |
| 262 | 262 | // current user can authenticate |
| 263 | 263 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
| 264 | - wp_send_json_error( array( 'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 264 | + wp_send_json_error( array( 'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) { |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | // we do have a current auth |
| 280 | 280 | if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |
| 281 | - wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 281 | + wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 282 | 282 | } else if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 283 | - wp_send_json_error( array( 'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) ); |
|
| 283 | + wp_send_json_error( array( 'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) ); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | $siteurl = add_query_arg( array( |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | wp_send_json_success( array( 'redirect' => $siteurl ) ); |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - public function reauthenticate_listener(){ |
|
| 309 | + public function reauthenticate_listener() { |
|
| 310 | 310 | // Make sure it's for us |
| 311 | 311 | if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) { |
| 312 | 312 | return; |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | $profile['measurement_protocol_secret'] = sanitize_text_field( $_REQUEST['mp'] ); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - $profile[ $code_key ] = $code_value; |
|
| 372 | + $profile[$code_key] = $code_value; |
|
| 373 | 373 | |
| 374 | 374 | // Save Profile |
| 375 | 375 | $this->is_network_admin() ? MonsterInsights()->auth->set_network_analytics_profile( $profile ) : MonsterInsights()->auth->set_analytics_profile( $profile ); |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $where = $this->is_network_admin() ? 'network' : 'site'; |
| 379 | 379 | MonsterInsights()->reporting->delete_aggregate_data( $where ); |
| 380 | 380 | |
| 381 | - $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ; |
|
| 381 | + $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ); |
|
| 382 | 382 | $url = add_query_arg( array( |
| 383 | 383 | 'mi_action' => 'reauth', |
| 384 | 384 | 'success' => 'true', |
@@ -389,14 +389,14 @@ discard block |
||
| 389 | 389 | exit; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - public function maybe_verify(){ |
|
| 392 | + public function maybe_verify() { |
|
| 393 | 393 | |
| 394 | 394 | // Check nonce |
| 395 | 395 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
| 396 | 396 | |
| 397 | 397 | // current user can verify |
| 398 | 398 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
| 399 | - wp_send_json_error( array( 'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 399 | + wp_send_json_error( array( 'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) { |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | |
| 406 | 406 | // we have an auth to verify |
| 407 | 407 | if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 408 | - wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 408 | + wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 409 | 409 | } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |
| 410 | - wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 410 | + wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | if ( monsterinsights_is_pro_version() ) { |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | $worked = $this->verify_auth(); |
| 421 | - if ( $worked && ! is_wp_error( $worked ) ) { |
|
| 421 | + if ( $worked && ! is_wp_error( $worked ) ) { |
|
| 422 | 422 | wp_send_json_success( array( 'message' => __( "Successfully verified.", 'google-analytics-for-wordpress' ) ) ); |
| 423 | 423 | } else { |
| 424 | 424 | wp_send_json_error( array( 'message' => __( "Could not verify.", 'google-analytics-for-wordpress' ) ) ); |
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - public function verify_auth( $credentials = array() ){ |
|
| 428 | + public function verify_auth( $credentials = array() ) { |
|
| 429 | 429 | $creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) ); |
| 430 | 430 | |
| 431 | 431 | if ( empty( $creds['key'] ) ) { |
@@ -444,14 +444,14 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - public function maybe_delete(){ |
|
| 447 | + public function maybe_delete() { |
|
| 448 | 448 | |
| 449 | 449 | // Check nonce |
| 450 | 450 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
| 451 | 451 | |
| 452 | 452 | // current user can delete |
| 453 | 453 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
| 454 | - wp_send_json_error( array( 'message' => __( "You don't have permission to deauthenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 454 | + wp_send_json_error( array( 'message' => __( "You don't have permission to deauthenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) { |
@@ -460,9 +460,9 @@ discard block |
||
| 460 | 460 | |
| 461 | 461 | // we have an auth to delete |
| 462 | 462 | if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 463 | - wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) ); |
|
| 463 | + wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) ); |
|
| 464 | 464 | } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |
| 465 | - wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) ); |
|
| 465 | + wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) ); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | if ( monsterinsights_is_pro_version() ) { |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | $force = ! empty( $_REQUEST['forcedelete'] ) && $_REQUEST['forcedelete'] === 'true'; |
| 476 | 476 | |
| 477 | 477 | $worked = $this->delete_auth( $force ); |
| 478 | - if ( $worked && ! is_wp_error( $worked ) ) { |
|
| 478 | + if ( $worked && ! is_wp_error( $worked ) ) { |
|
| 479 | 479 | wp_send_json_success( array( 'message' => __( "Successfully deauthenticated.", 'google-analytics-for-wordpress' ) ) ); |
| 480 | 480 | } else { |
| 481 | 481 | if ( $force ) { |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - public function delete_auth( $force = false ){ |
|
| 489 | + public function delete_auth( $force = false ) { |
|
| 490 | 490 | if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 491 | 491 | return false; |
| 492 | 492 | } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |
@@ -502,13 +502,13 @@ discard block |
||
| 502 | 502 | // If we have a new siteurl enabled option and the profile site doesn't match the current site, deactivate anyways |
| 503 | 503 | if ( is_network_admin() ) { |
| 504 | 504 | $siteurl = network_admin_url(); |
| 505 | - if ( ! empty( $creds['neturl' ] ) && $creds['neturl'] !== $siteurl ) { |
|
| 505 | + if ( ! empty( $creds['neturl'] ) && $creds['neturl'] !== $siteurl ) { |
|
| 506 | 506 | MonsterInsights()->auth->delete_network_analytics_profile( true ); |
| 507 | 507 | return true; |
| 508 | 508 | } |
| 509 | 509 | } else { |
| 510 | 510 | $siteurl = site_url(); |
| 511 | - if ( ! empty( $creds['siteurl' ] ) && $creds['siteurl'] !== $siteurl ) { |
|
| 511 | + if ( ! empty( $creds['siteurl'] ) && $creds['siteurl'] !== $siteurl ) { |
|
| 512 | 512 | MonsterInsights()->auth->delete_analytics_profile( true ); |
| 513 | 513 | return true; |
| 514 | 514 | } |
@@ -585,15 +585,15 @@ discard block |
||
| 585 | 585 | // return $sitei; |
| 586 | 586 | // } |
| 587 | 587 | |
| 588 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 588 | + $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 589 | 589 | $secure_auth_key = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : ''; |
| 590 | - $logged_in_key = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY : ''; |
|
| 590 | + $logged_in_key = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY : ''; |
|
| 591 | 591 | |
| 592 | 592 | $sitei = $auth_key . $secure_auth_key . $logged_in_key; |
| 593 | - $sitei = preg_replace('/[^a-zA-Z0-9]/', '', $sitei ); |
|
| 593 | + $sitei = preg_replace( '/[^a-zA-Z0-9]/', '', $sitei ); |
|
| 594 | 594 | $sitei = sanitize_text_field( $sitei ); |
| 595 | 595 | $sitei = trim( $sitei ); |
| 596 | - $sitei = ( strlen($sitei) > 30 ) ? substr($sitei, 0, 30 ) : $sitei; |
|
| 596 | + $sitei = ( strlen( $sitei ) > 30 ) ? substr( $sitei, 0, 30 ) : $sitei; |
|
| 597 | 597 | return $sitei; |
| 598 | 598 | } |
| 599 | 599 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | add_action( 'wp_ajax_nopriv_monsterinsights_push_mp_token', array( $this, 'handle_relay_mp_token_push' ) ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function get_tt(){ |
|
| 47 | + public function get_tt() { |
|
| 48 | 48 | $tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' ); |
| 49 | 49 | if ( empty( $tt ) ) { |
| 50 | 50 | // if TT is empty, generate a new one, save it and then return it |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | return $tt; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function rotate_tt(){ |
|
| 57 | + public function rotate_tt() { |
|
| 58 | 58 | $tt = $this->generate_tt(); |
| 59 | 59 | is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt ); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function generate_tt(){ |
|
| 62 | + public function generate_tt() { |
|
| 63 | 63 | return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) ); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function maybe_authenticate(){ |
|
| 80 | + public function maybe_authenticate() { |
|
| 81 | 81 | |
| 82 | 82 | // Check nonce |
| 83 | 83 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | wp_send_json_success(); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - public function authenticate_listener(){ |
|
| 176 | + public function authenticate_listener() { |
|
| 177 | 177 | // Make sure it's for us |
| 178 | 178 | if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) { |
| 179 | 179 | return; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | exit; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - public function maybe_reauthenticate(){ |
|
| 257 | + public function maybe_reauthenticate() { |
|
| 258 | 258 | |
| 259 | 259 | // Check nonce |
| 260 | 260 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | wp_send_json_success( array( 'redirect' => $siteurl ) ); |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - public function reauthenticate_listener(){ |
|
| 309 | + public function reauthenticate_listener() { |
|
| 310 | 310 | // Make sure it's for us |
| 311 | 311 | if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) { |
| 312 | 312 | return; |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | exit; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - public function maybe_verify(){ |
|
| 392 | + public function maybe_verify() { |
|
| 393 | 393 | |
| 394 | 394 | // Check nonce |
| 395 | 395 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - public function verify_auth( $credentials = array() ){ |
|
| 428 | + public function verify_auth( $credentials = array() ) { |
|
| 429 | 429 | $creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) ); |
| 430 | 430 | |
| 431 | 431 | if ( empty( $creds['key'] ) ) { |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - public function maybe_delete(){ |
|
| 447 | + public function maybe_delete() { |
|
| 448 | 448 | |
| 449 | 449 | // Check nonce |
| 450 | 450 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - public function delete_auth( $force = false ){ |
|
| 489 | + public function delete_auth( $force = false ) { |
|
| 490 | 490 | if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 491 | 491 | return false; |
| 492 | 492 | } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |