gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
%s
', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '
%2$s', menu_page_url( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '
%2$s', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
gapi_controller->token_request(); ?>
' . __( 'Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', 'google-analytics-dashboard-for-wp' ) . ' Library conflicts between WordPress plugins
';
if ( null === $gadwp->gapi_controller ) {
$gadwp->gapi_controller = new GADWP_GAPI_Controller();
}
echo '';
if ( isset( $_POST['gadwp_access_code'] ) ) {
if ( 1 == ! stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) && $_POST['gadwp_access_code'] != get_option( 'gadwp_redeemed_code' ) ) {
try {
$gadwp_access_code = $_POST['gadwp_access_code'];
update_option( 'gadwp_redeemed_code', $gadwp_access_code );
$gadwp->gapi_controller->client->authenticate( $_POST['gadwp_access_code'] );
$gadwp->config->options['token'] = $gadwp->gapi_controller->client->getAccessToken();
$gadwp->config->options['automatic_updates_minorversion'] = 1;
$gadwp->config->set_plugin_options( true );
$options = self::update_options( 'network' );
$message = "
" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "
";
if ( is_multisite() ) { // Cleanup errors on the entire network
foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
switch_to_blog( $blog['blog_id'] );
GADWP_Tools::delete_cache( 'last_error' );
GADWP_Tools::delete_cache( 'gapi_errors' );
restore_current_blog();
}
} else {
GADWP_Tools::delete_cache( 'last_error' );
GADWP_Tools::delete_cache( 'gapi_errors' );
}
if ( $gadwp->config->options['token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
$profiles = $gadwp->gapi_controller->refresh_profiles();
if ( is_array ( $profiles ) && ! empty( $profiles ) ) {
$gadwp->config->options['ga_profiles_list'] = $profiles;
if ( isset( $gadwp->config->options['tableid_jail'] ) && ! $gadwp->config->options['tableid_jail'] ) {
$profile = GADWP_Tools::guess_default_domain( $profiles );
$gadwp->config->options['tableid_jail'] = $profile;
}
$gadwp->config->set_plugin_options( true );
$options = self::update_options( 'network' );
}
}
} catch ( Deconf_IO_Exception $e ) {
$timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
GADWP_Tools::set_error( $e, $timeout );
} catch ( Deconf_Service_Exception $e ) {
$timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
GADWP_Tools::set_error( $e, $timeout );
} catch ( Exception $e ) {
$timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
GADWP_Tools::set_error( $e, $timeout );
$gadwp->gapi_controller->reset_token();
}
} else {
if ( 1 == stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) ) {
$message = "
" . __( "The access code is not your Tracking ID (UA-XXXXX-X) nor your email address!", 'google-analytics-dashboard-for-wp' ) . ".
";
} else {
$message = "
" . __( "You can only use the access code once, please generate a new access code using the red link", 'google-analytics-dashboard-for-wp' ) . "!
";
}
}
}
if ( isset( $_POST['Refresh'] ) ) {
if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
$gadwp->config->options['ga_profiles_list'] = array();
$message = "
" . __( "Properties refreshed.", 'google-analytics-dashboard-for-wp' ) . "
";
$options = self::update_options( 'network' );
if ( $gadwp->config->options['token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
if ( ! empty( $gadwp->config->options['ga_profiles_list'] ) ) {
$profiles = $gadwp->config->options['ga_profiles_list'];
} else {
$profiles = $gadwp->gapi_controller->refresh_profiles();
}
if ( $profiles ) {
$gadwp->config->options['ga_profiles_list'] = $profiles;
if ( isset( $gadwp->config->options['tableid_jail'] ) && ! $gadwp->config->options['tableid_jail'] ) {
$profile = GADWP_Tools::guess_default_domain( $profiles );
$gadwp->config->options['tableid_jail'] = $profile;
}
$gadwp->config->set_plugin_options( true );
$options = self::update_options( 'network' );
}
}
} else {
$message = "
" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "
";
}
}
if ( isset( $_POST['Clear'] ) ) {
if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
GADWP_Tools::clear_cache();
$message = "
" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "
";
} else {
$message = "
" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "
";
}
}
if ( isset( $_POST['Reset'] ) ) {
if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
$gadwp->gapi_controller->reset_token();
GADWP_Tools::clear_cache();
$message = "
" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "
";
$options = self::update_options( 'Reset' );
} else {
$message = "
" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "
";
}
}
if ( isset( $_POST['options']['gadwp_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Refresh'] ) ) {
$message = "
" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "
";
if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
$message = "
" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "
";
}
}
if ( isset( $_POST['Hide'] ) ) {
if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
$message = "
" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "
";
$lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_profiles_list'], $gadwp->config->options['tableid_jail'] );
$gadwp->config->options['ga_profiles_list'] = array( $lock_profile );
$options = self::update_options( 'network' );
} else {
$message = "
" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "
";
}
}
?>
gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
%s
', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '
%2$s', menu_page_url( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '
%2$s', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
gapi_controller->token_request();?>