public function settingsView() { self::processingPostRequest(); WPAdm_GA_View::$subtitle = 'settings'; if ($template = self::getErrorTemplate()) { WPAdm_GA_View::$content_file = $template; } else { if (WPAdm_GA_Options::gaTokenIsExpired() && !isset($_GET['token'])) { ob_clean(); $location = self::URL_GA_AUTH . '?redirect=' . urlencode(self::getCurUrl()); header("Location: {$location}"); } WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'settings.php'; } //GA Account $ga_accout_form = new wpadmForm(); $ga_accout_form->setValue('ga-id', WPAdm_GA_Options::getGAId()); $ga_accout_form->setValue('ga-webPropertyId', WPAdm_GA_Options::getGAWebPropertyId()); $ga_accout_form->setValue('ga-url', WPAdm_GA_Options::getGAUrl()); $ga_accout_form->setValue('ga-enableCode', WPAdm_GA_Options::getGAEnableCode()); if ('POST' == strtoupper($_SERVER['REQUEST_METHOD']) && isset($_POST['form_name']) && 'ga-account' == $_POST['form_name']) { if ('disconnect' == filter_input(INPUT_POST, 'ga-disconnect-btn', FILTER_SANITIZE_STRING)) { self::googleAnalyticsDisconnect(); return; } $id = filter_input(INPUT_POST, 'ga-id', FILTER_SANITIZE_NUMBER_INT); $url = filter_input(INPUT_POST, 'ga-url', FILTER_SANITIZE_URL); $webPropertyId = filter_input(INPUT_POST, 'ga-webPropertyId', FILTER_SANITIZE_STRING); $enableCode = (int) filter_input(INPUT_POST, 'ga-enableCode', FILTER_SANITIZE_NUMBER_INT); $enableCode = $enableCode ? 1 : 0; WPAdm_GA_Options::setGAId($id); WPAdm_GA_Options::setGAUrl($url); WPAdm_GA_Options::setGAWebPropertyId($webPropertyId); WPAdm_GA_Options::setGAEnableCode($enableCode); $ga_accout_form->setValue('ga-id', $id); $ga_accout_form->setValue('ga-webPropertyId', $webPropertyId); $ga_accout_form->setValue('ga-enableCode', $enableCode); //redirect to stat ob_clean(); if (isset($_GET['modal'])) { echo '<script> top.frames.location.reload(false);</script>'; } else { $location = admin_url() . 'options-general.php?page=wpadm-ga-menu-visit'; header("Location: {$location}"); } exit; } // $wpadm_account_form = new wpadmAuthForm(); // if('POST' == strtoupper($_SERVER['REQUEST_METHOD']) // && isset($_POST['form_name']) // && 'wpadm-account' == $_POST['form_name'] // ) { // $form_data = array( // 'wpadm_username' => $_POST['wpadm_username'], // 'wpadm_password' => $_POST['wpadm_password'], // 'wpadm_password_confirm' => $_POST['wpadm_password_confirm'], // 'wpadm_imnewuser_checkbox' => (isset($_POST['wpadm_imnewuser_checkbox'])&& $_POST['wpadm_imnewuser_checkbox'] == 1) ? 1 :0 // ); // $wpadm_account_form->setData($form_data); // // if ($wpadm_account_form->isValid()) { // // WPAdm_GA_Api::register(); // echo 'doit'; // exit; // } // } // if('POST' == strtoupper($_SERVER['REQUEST_METHOD']) // && isset($_POST['form_name']) // && 'ga-account-logout' == $_POST['form_name'] // ) { // // $url = get_option('siteurl'); // $p_url = parse_url($url); // $postdata = array( // 'host' => $p_url['host'], // ); // // $response = wp_remote_post(self::URL_GA_SERVER . 'logout', array( // 'method' => 'POST', // 'timeout' => 45, // 'body' => self::getParamsForRequest($postdata) // )); // // if ( is_wp_error( $response ) ) { // //todo: отработать исключение // $error_message = $response->get_error_message(); // echo "Something went wrong: $error_message"; // } else { // // } // // echo '<!-- start dump --><pre><small>' . __FILE__ . "</small>\n"; // print_r($response['body']); // echo '</pre><!-- end dump -->'; // exit; // // // } require WPADM_GA__VIEW_LAYOUT; }