@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $site_license = array( |
|
| 43 | + $site_license = array( |
|
| 44 | 44 | 'key' => MonsterInsights()->license->get_site_license_key(), |
| 45 | 45 | 'type' => MonsterInsights()->license->get_site_license_type(), |
| 46 | 46 | 'is_disabled' => MonsterInsights()->license->site_license_disabled(), |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | // Array fields are needed even if empty. |
| 101 | 101 | $array_fields = array( 'view_reports', 'save_settings', 'ignore_users' ); |
| 102 | 102 | foreach ( $array_fields as $array_field ) { |
| 103 | - if ( ! isset( $options[ $array_field ] ) ) { |
|
| 104 | - $options[ $array_field ] = array(); |
|
| 103 | + if ( ! isset( $options[$array_field] ) ) { |
|
| 104 | + $options[$array_field] = array(); |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | if ( isset( $options['custom_code'] ) ) { |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | if ( $empty ) { |
| 178 | - unset( $value[ $key ] ); |
|
| 178 | + unset( $value[$key] ); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } else { |
| 226 | 226 | $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug ); |
| 227 | 227 | } |
| 228 | - $parsed_addons[ $addon->slug ] = $addon; |
|
| 228 | + $parsed_addons[$addon->slug] = $addon; |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | $installed = false; |
| 311 | 311 | $plugin_basename = monsterinsights_get_plugin_basename_from_slug( $slug ); |
| 312 | 312 | |
| 313 | - if ( isset( $installed_plugins[ $plugin_basename ] ) ) { |
|
| 313 | + if ( isset( $installed_plugins[$plugin_basename] ) ) { |
|
| 314 | 314 | $installed = true; |
| 315 | 315 | $ms_active = is_plugin_active_for_network( $plugin_basename ); |
| 316 | 316 | $ss_active = is_plugin_active( $plugin_basename ); |
@@ -455,8 +455,8 @@ discard block |
||
| 455 | 455 | ); |
| 456 | 456 | |
| 457 | 457 | foreach ( $exclude as $e ) { |
| 458 | - if ( ! empty( $new_settings[ $e ] ) ) { |
|
| 459 | - unset( $new_settings[ $e ] ); |
|
| 458 | + if ( ! empty( $new_settings[$e] ) ) { |
|
| 459 | + unset( $new_settings[$e] ); |
|
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | |
@@ -467,8 +467,8 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | foreach ( $exclude as $e ) { |
| 470 | - if ( ! empty( $settings[ $e ] ) ) { |
|
| 471 | - $new_settings = $settings[ $e ]; |
|
| 470 | + if ( ! empty( $settings[$e] ) ) { |
|
| 471 | + $new_settings = $settings[$e]; |
|
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | ), |
| 617 | 617 | admin_url( 'admin.php' ) |
| 618 | 618 | ); |
| 619 | - $url = esc_url( $url ); |
|
| 619 | + $url = esc_url( $url ); |
|
| 620 | 620 | |
| 621 | 621 | ob_start(); |
| 622 | 622 | if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) { |
@@ -47,17 +47,17 @@ |
||
| 47 | 47 | if ( ! empty( $data['data']['countries'] ) ) { |
| 48 | 48 | $country_names = monsterinsights_get_country_list( true ); |
| 49 | 49 | foreach ( $data['data']['countries'] as $key => $country ) { |
| 50 | - $data['data']['countries'][ $key ]['name'] = isset( $country_names[ $country['iso'] ] ) ? $country_names[ $country['iso'] ] : $country['iso']; |
|
| 50 | + $data['data']['countries'][$key]['name'] = isset( $country_names[$country['iso']] ) ? $country_names[$country['iso']] : $country['iso']; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Escape urls for the top pages report. |
| 55 | 55 | if ( ! empty( $data['data']['toppages'] ) ) { |
| 56 | 56 | foreach ( $data['data']['toppages'] as $key => $page ) { |
| 57 | - $title = $data['data']['toppages'][ $key ]['title']; |
|
| 58 | - $url = '(not set)' === $title ? '' : esc_url( $data['data']['toppages'][ $key ]['hostname'] ); |
|
| 57 | + $title = $data['data']['toppages'][$key]['title']; |
|
| 58 | + $url = '(not set)' === $title ? '' : esc_url( $data['data']['toppages'][$key]['hostname'] ); |
|
| 59 | 59 | |
| 60 | - $data['data']['toppages'][ $key ]['hostname'] = $url; |
|
| 60 | + $data['data']['toppages'][$key]['hostname'] = $url; |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
@@ -28,21 +28,21 @@ 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 | |
| 45 | - public function get_tt(){ |
|
| 45 | + public function get_tt() { |
|
| 46 | 46 | $tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' ); |
| 47 | 47 | if ( empty( $tt ) ) { |
| 48 | 48 | // if TT is empty, generate a new one, save it and then return it |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | return $tt; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function rotate_tt(){ |
|
| 55 | + public function rotate_tt() { |
|
| 56 | 56 | $tt = $this->generate_tt(); |
| 57 | 57 | is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function generate_tt(){ |
|
| 60 | + public function generate_tt() { |
|
| 61 | 61 | return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) ); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -75,14 +75,14 @@ discard block |
||
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function maybe_authenticate(){ |
|
| 78 | + public function maybe_authenticate() { |
|
| 79 | 79 | |
| 80 | 80 | // Check nonce |
| 81 | 81 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
| 82 | 82 | |
| 83 | 83 | // current user can authenticate |
| 84 | 84 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
| 85 | - wp_send_json_error( array( 'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 85 | + wp_send_json_error( array( 'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) { |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | // Only for Pro users, require a license key to be entered first so we can link to things. |
| 93 | 93 | $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed(); |
| 94 | 94 | if ( monsterinsights_is_pro_version() && ! $valid ) { |
| 95 | - wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) ); |
|
| 95 | + wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // we do not have a current auth |
| 99 | 99 | if ( ! $this->is_network_admin() && MonsterInsights()->auth->is_authed() ) { |
| 100 | - wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 100 | + wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 101 | 101 | } else if ( $this->is_network_admin() && MonsterInsights()->auth->is_network_authed() ) { |
| 102 | - wp_send_json_error( array( 'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) ); |
|
| 102 | + wp_send_json_error( array( 'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $sitei = $this->get_sitei(); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | wp_send_json_success(); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - public function authenticate_listener(){ |
|
| 163 | + public function authenticate_listener() { |
|
| 164 | 164 | // Make sure it's for us |
| 165 | 165 | if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) { |
| 166 | 166 | return; |
@@ -177,12 +177,12 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // Make sure has required params |
| 180 | - if ( empty( $_REQUEST['key'] ) || |
|
| 181 | - empty( $_REQUEST['token'] ) || |
|
| 182 | - empty( $_REQUEST['ua'] ) || |
|
| 183 | - empty( $_REQUEST['miview'] ) || |
|
| 184 | - empty( $_REQUEST['a'] ) || |
|
| 185 | - empty( $_REQUEST['w'] ) || |
|
| 180 | + if ( empty( $_REQUEST['key'] ) || |
|
| 181 | + empty( $_REQUEST['token'] ) || |
|
| 182 | + empty( $_REQUEST['ua'] ) || |
|
| 183 | + empty( $_REQUEST['miview'] ) || |
|
| 184 | + empty( $_REQUEST['a'] ) || |
|
| 185 | + empty( $_REQUEST['w'] ) || |
|
| 186 | 186 | empty( $_REQUEST['p'] ) |
| 187 | 187 | ) { |
| 188 | 188 | return; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $where = $this->is_network_admin() ? 'network' : 'site'; |
| 219 | 219 | MonsterInsights()->reporting->delete_aggregate_data( $where ); |
| 220 | 220 | |
| 221 | - $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ; |
|
| 221 | + $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ); |
|
| 222 | 222 | $url = add_query_arg( array( |
| 223 | 223 | 'mi_action' => 'auth', |
| 224 | 224 | 'success' => 'true', |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | exit; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - public function maybe_reauthenticate(){ |
|
| 231 | + public function maybe_reauthenticate() { |
|
| 232 | 232 | |
| 233 | 233 | // Check nonce |
| 234 | 234 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
| 235 | 235 | |
| 236 | 236 | // current user can authenticate |
| 237 | 237 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
| 238 | - wp_send_json_error( array( 'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 238 | + wp_send_json_error( array( 'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) { |
@@ -245,14 +245,14 @@ discard block |
||
| 245 | 245 | // Only for Pro users, require a license key to be entered first so we can link to things. |
| 246 | 246 | $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed(); |
| 247 | 247 | if ( monsterinsights_is_pro_version() && ! $valid ) { |
| 248 | - wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) ); |
|
| 248 | + wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) ); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // we do have a current auth |
| 252 | 252 | if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |
| 253 | - wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 253 | + wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 254 | 254 | } else if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 255 | - wp_send_json_error( array( 'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) ); |
|
| 255 | + wp_send_json_error( array( 'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) ); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | $siteurl = add_query_arg( array( |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | wp_send_json_success( array( 'redirect' => $siteurl ) ); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - public function reauthenticate_listener(){ |
|
| 281 | + public function reauthenticate_listener() { |
|
| 282 | 282 | // Make sure it's for us |
| 283 | 283 | if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) { |
| 284 | 284 | return; |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | // Make sure has required params |
| 298 | 298 | if ( |
| 299 | - empty( $_REQUEST['ua'] ) || |
|
| 300 | - empty( $_REQUEST['miview'] ) || |
|
| 301 | - empty( $_REQUEST['a'] ) || |
|
| 302 | - empty( $_REQUEST['w'] ) || |
|
| 299 | + empty( $_REQUEST['ua'] ) || |
|
| 300 | + empty( $_REQUEST['miview'] ) || |
|
| 301 | + empty( $_REQUEST['a'] ) || |
|
| 302 | + empty( $_REQUEST['w'] ) || |
|
| 303 | 303 | empty( $_REQUEST['p'] ) |
| 304 | 304 | ) { |
| 305 | 305 | return; |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $where = $this->is_network_admin() ? 'network' : 'site'; |
| 337 | 337 | MonsterInsights()->reporting->delete_aggregate_data( $where ); |
| 338 | 338 | |
| 339 | - $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ; |
|
| 339 | + $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ); |
|
| 340 | 340 | $url = add_query_arg( array( |
| 341 | 341 | 'mi_action' => 'reauth', |
| 342 | 342 | 'success' => 'true', |
@@ -347,14 +347,14 @@ discard block |
||
| 347 | 347 | exit; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - public function maybe_verify(){ |
|
| 350 | + public function maybe_verify() { |
|
| 351 | 351 | |
| 352 | 352 | // Check nonce |
| 353 | 353 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
| 354 | 354 | |
| 355 | 355 | // current user can verify |
| 356 | 356 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
| 357 | - wp_send_json_error( array( 'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 357 | + wp_send_json_error( array( 'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) { |
@@ -363,25 +363,25 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | // we have an auth to verify |
| 365 | 365 | if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 366 | - wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 366 | + wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 367 | 367 | } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |
| 368 | - wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 368 | + wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) ); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed(); |
| 372 | 372 | if ( monsterinsights_is_pro_version() && ! $valid ) { |
| 373 | - wp_send_json_error( array( 'message' => __( "Cannot verify. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) ); |
|
| 373 | + wp_send_json_error( array( 'message' => __( "Cannot verify. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) ); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | $worked = $this->verify_auth(); |
| 377 | - if ( $worked && ! is_wp_error( $worked ) ) { |
|
| 377 | + if ( $worked && ! is_wp_error( $worked ) ) { |
|
| 378 | 378 | wp_send_json_success( array( 'message' => __( "Successfully verified.", 'google-analytics-for-wordpress' ) ) ); |
| 379 | 379 | } else { |
| 380 | 380 | wp_send_json_error( array( 'message' => __( "Could not verify.", 'google-analytics-for-wordpress' ) ) ); |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - public function verify_auth( $credentials = array() ){ |
|
| 384 | + public function verify_auth( $credentials = array() ) { |
|
| 385 | 385 | $creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) ); |
| 386 | 386 | |
| 387 | 387 | if ( empty( $creds['key'] ) ) { |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - public function maybe_delete(){ |
|
| 403 | + public function maybe_delete() { |
|
| 404 | 404 | |
| 405 | 405 | // Check nonce |
| 406 | 406 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
| 407 | 407 | |
| 408 | 408 | // current user can delete |
| 409 | 409 | if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
| 410 | - wp_send_json_error( array( 'message' => __( "You don't have permission to deauthenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 410 | + wp_send_json_error( array( 'message' => __( "You don't have permission to deauthenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) ); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) { |
@@ -416,20 +416,20 @@ discard block |
||
| 416 | 416 | |
| 417 | 417 | // we have an auth to delete |
| 418 | 418 | if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 419 | - wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) ); |
|
| 419 | + wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) ); |
|
| 420 | 420 | } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |
| 421 | - wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) ); |
|
| 421 | + wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) ); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed(); |
| 425 | 425 | if ( monsterinsights_is_pro_version() && ! $valid ) { |
| 426 | - wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) ); |
|
| 426 | + wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) ); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | $force = ! empty( $_REQUEST['forcedelete'] ) && $_REQUEST['forcedelete'] === 'true'; |
| 430 | 430 | |
| 431 | 431 | $worked = $this->delete_auth( $force ); |
| 432 | - if ( $worked && ! is_wp_error( $worked ) ) { |
|
| 432 | + if ( $worked && ! is_wp_error( $worked ) ) { |
|
| 433 | 433 | wp_send_json_success( array( 'message' => __( "Successfully deauthenticated.", 'google-analytics-for-wordpress' ) ) ); |
| 434 | 434 | } else { |
| 435 | 435 | if ( $force ) { |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - public function delete_auth( $force = false ){ |
|
| 443 | + public function delete_auth( $force = false ) { |
|
| 444 | 444 | if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 445 | 445 | return false; |
| 446 | 446 | } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |
@@ -456,13 +456,13 @@ discard block |
||
| 456 | 456 | // If we have a new siteurl enabled option and the profile site doesn't match the current site, deactivate anyways |
| 457 | 457 | if ( is_network_admin() ) { |
| 458 | 458 | $siteurl = network_admin_url(); |
| 459 | - if ( ! empty( $creds['neturl' ] ) && $creds['neturl'] !== $siteurl ) { |
|
| 459 | + if ( ! empty( $creds['neturl'] ) && $creds['neturl'] !== $siteurl ) { |
|
| 460 | 460 | MonsterInsights()->auth->delete_network_analytics_profile( true ); |
| 461 | 461 | return true; |
| 462 | 462 | } |
| 463 | 463 | } else { |
| 464 | 464 | $siteurl = site_url(); |
| 465 | - if ( ! empty( $creds['siteurl' ] ) && $creds['siteurl'] !== $siteurl ) { |
|
| 465 | + if ( ! empty( $creds['siteurl'] ) && $creds['siteurl'] !== $siteurl ) { |
|
| 466 | 466 | MonsterInsights()->auth->delete_analytics_profile( true ); |
| 467 | 467 | return true; |
| 468 | 468 | } |
@@ -539,15 +539,15 @@ discard block |
||
| 539 | 539 | // return $sitei; |
| 540 | 540 | // } |
| 541 | 541 | |
| 542 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 542 | + $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 543 | 543 | $secure_auth_key = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : ''; |
| 544 | - $logged_in_key = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY : ''; |
|
| 544 | + $logged_in_key = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY : ''; |
|
| 545 | 545 | |
| 546 | 546 | $sitei = $auth_key . $secure_auth_key . $logged_in_key; |
| 547 | - $sitei = preg_replace('/[^a-zA-Z0-9]/', '', $sitei ); |
|
| 547 | + $sitei = preg_replace( '/[^a-zA-Z0-9]/', '', $sitei ); |
|
| 548 | 548 | $sitei = sanitize_text_field( $sitei ); |
| 549 | 549 | $sitei = trim( $sitei ); |
| 550 | - $sitei = ( strlen($sitei) > 30 ) ? substr($sitei, 0, 30 ) : $sitei; |
|
| 550 | + $sitei = ( strlen( $sitei ) > 30 ) ? substr( $sitei, 0, 30 ) : $sitei; |
|
| 551 | 551 | return $sitei; |
| 552 | 552 | } |
| 553 | 553 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | add_filter( 'monsterinsights_maybe_authenticate_siteurl', array( $this, 'before_redirect' ) ); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function get_tt(){ |
|
| 45 | + public function get_tt() { |
|
| 46 | 46 | $tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' ); |
| 47 | 47 | if ( empty( $tt ) ) { |
| 48 | 48 | // if TT is empty, generate a new one, save it and then return it |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | return $tt; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function rotate_tt(){ |
|
| 55 | + public function rotate_tt() { |
|
| 56 | 56 | $tt = $this->generate_tt(); |
| 57 | 57 | is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function generate_tt(){ |
|
| 60 | + public function generate_tt() { |
|
| 61 | 61 | return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) ); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function maybe_authenticate(){ |
|
| 78 | + public function maybe_authenticate() { |
|
| 79 | 79 | |
| 80 | 80 | // Check nonce |
| 81 | 81 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | wp_send_json_success(); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - public function authenticate_listener(){ |
|
| 163 | + public function authenticate_listener() { |
|
| 164 | 164 | // Make sure it's for us |
| 165 | 165 | if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) { |
| 166 | 166 | return; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | exit; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - public function maybe_reauthenticate(){ |
|
| 231 | + public function maybe_reauthenticate() { |
|
| 232 | 232 | |
| 233 | 233 | // Check nonce |
| 234 | 234 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | wp_send_json_success( array( 'redirect' => $siteurl ) ); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - public function reauthenticate_listener(){ |
|
| 281 | + public function reauthenticate_listener() { |
|
| 282 | 282 | // Make sure it's for us |
| 283 | 283 | if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) { |
| 284 | 284 | return; |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | exit; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - public function maybe_verify(){ |
|
| 350 | + public function maybe_verify() { |
|
| 351 | 351 | |
| 352 | 352 | // Check nonce |
| 353 | 353 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - public function verify_auth( $credentials = array() ){ |
|
| 384 | + public function verify_auth( $credentials = array() ) { |
|
| 385 | 385 | $creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) ); |
| 386 | 386 | |
| 387 | 387 | if ( empty( $creds['key'] ) ) { |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - public function maybe_delete(){ |
|
| 403 | + public function maybe_delete() { |
|
| 404 | 404 | |
| 405 | 405 | // Check nonce |
| 406 | 406 | check_ajax_referer( 'mi-admin-nonce', 'nonce' ); |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - public function delete_auth( $force = false ){ |
|
| 443 | + public function delete_auth( $force = false ) { |
|
| 444 | 444 | if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) { |
| 445 | 445 | return false; |
| 446 | 446 | } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) { |
@@ -40,7 +40,8 @@ |
||
| 40 | 40 | // Load the Upgrade functions. |
| 41 | 41 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/upgrade.php'; |
| 42 | 42 | |
| 43 | - if ( isset( $_GET['page'] ) && 'monsterinsights-onboarding' === $_GET['page'] ) { // WPCS: CSRF ok, input var ok. |
|
| 43 | + if ( isset( $_GET['page'] ) && 'monsterinsights-onboarding' === $_GET['page'] ) { |
|
| 44 | +// WPCS: CSRF ok, input var ok. |
|
| 44 | 45 | // Only load the Onboarding wizard if the required parameter is present. |
| 45 | 46 | require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/admin/onboarding-wizard.php'; |
| 46 | 47 | } |
@@ -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 | |