/** * Save Authentication code on return * @since 1.2.0 */ public function wpa_check_authentication() { if (isset($_GET['code']) && isset($_GET['state'])) { $key_google_token = sanitize_text_field($_GET['code']); WP_Analytify::pt_save_data($key_google_token); wp_redirect(esc_url_raw($_GET['state'] . '&tab=profile')); } }
return false; } if (!function_exists('http_build_query')) { esc_html_e('This plugin requires http_build_query()'); return false; } // Save access code if (isset($_POST['save_code'])) { if (isset($_POST['auth_step']) and $_POST['auth_step'] == 'user_keys') { update_option('ANALYTIFY_CLIENTID', $_POST['analytify_clientid']); update_option('ANALYTIFY_CLIENTSECRET', $_POST['analytify_clientsecret']); update_option('ANALYTIFY_DEV_KEY', $_POST['analytify_apikey']); } if (isset($_POST['auth_step']) and $_POST['auth_step'] == 'user_access_code') { $key_google_token = $_POST['key_google_token']; if ($wp_analytify->pt_save_data($key_google_token)) { $update_message = '<div id="setting-error-settings_updated" class="updated settings-error below-h2"><p><strong>Access code saved.</strong></p></div>'; } } } $url = http_build_query(array('next' => $wp_analytify->pa_setting_url(), 'scope' => ANALYTIFY_SCOPE, 'response_type' => 'code', 'redirect_uri' => ANALYTIFY_REDIRECT, 'client_id' => get_option('ANALYTIFY_CLIENTID'), 'access_type' => 'offline', 'approval_prompt' => 'auto')); // Saving settings for back end Analytics for Posts and Pages. if (isset($_POST['save_settings_admin'])) { update_option('post_analytics_settings_back', $_POST['backend']); update_option('analytify_posts_stats', $_POST['posts']); update_option('post_analytics_access_back', $_POST['access_role_back']); update_option('post_analytics_disable_back', $_POST['disable_back']); update_option('post_analytics_exclude_posts_back', @$_POST['exclude_posts_back']); $update_message = '<div id="setting-error-settings_updated" class="updated settings-error below-h2"><p><strong>Admin changes are saved.</strong></p></div>'; } // endif