@@ -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 | |
@@ -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() ) { |