/**
  * @param $launchkey_user_hash
  */
 private function prepare_for_launchkey_pair($launchkey_user_hash)
 {
     // Set the pair cookie with the LaunchKey user hash
     $this->wp_facade->setcookie('launchkey_user', $launchkey_user_hash, $this->wp_facade->current_time('timestamp', true) + 300, COOKIEPATH, COOKIE_DOMAIN);
     // Redirect to finish pairing
     if (!$this->wp_facade->current_user_can('manage_options')) {
         //not previously logged in
         $this->wp_facade->wp_redirect($this->wp_facade->wp_login_url() . "?launchkey_pair=1");
     } else {
         //previously authenticated
         $this->wp_facade->wp_redirect($this->wp_facade->admin_url("profile.php?launchkey_admin_pair=1&updated=1"));
     }
 }
 /**
  * Compile the data that will be used by the front end to generate a QR Code for WordPress auto-config.
  * @since 1.4.0
  */
 public function wizard_easy_setup_qr_code()
 {
     if (isset($_POST['nonce'])) {
         if ($this->wp_facade->wp_verify_nonce($_POST['nonce'], static::WIZARD_NONCE_KEY) && $this->wp_facade->current_user_can('manage_options')) {
             $lk_nonce = $this->launchkey_client->auth()->nonce();
             $this->update_option(static::EASY_SETUP_OPTION, array('nonce' => $lk_nonce, 'username' => $this->wp_facade->wp_get_current_user()->user_login));
             $payload = json_encode(array('nonce' => $lk_nonce->getNonce(), 'payload' => array('callback_url' => $this->admin->get_callback_url(), 'rocket_name' => $this->wp_facade->get_bloginfo('name'))));
             $qr_data = base64_encode($payload);
             $response['nonce'] = $this->wp_facade->wp_create_nonce(static::WIZARD_NONCE_KEY);
             $response['qr_code'] = $qr_data;
         } else {
             $response['errors'] = $this->wp_facade->__("An error occurred submitting the page.  Please refresh the page and submit again.");
         }
         $this->wp_facade->wp_send_json($response);
     }
 }
 public function wizard_submit_ajax()
 {
     if (isset($_POST['nonce'])) {
         if ($this->wp_facade->wp_verify_nonce($_POST['nonce'], static::WIZARD_NONCE_KEY) && $this->wp_facade->current_user_can('manage_options')) {
             list($options, $errors) = $this->admin->check_option($_POST);
             if ($errors) {
                 $response["errors"] = $errors;
             } elseif ($this->is_multi_site) {
                 $this->wp_facade->update_site_option(LaunchKey_WP_Admin::OPTION_KEY, $options);
             } else {
                 $this->wp_facade->update_option(LaunchKey_WP_Admin::OPTION_KEY, $options);
             }
             $response['nonce'] = $this->wp_facade->wp_create_nonce(static::WIZARD_NONCE_KEY);
         } else {
             $response["errors"] = $this->wp_facade->__("An error occurred submitting the page.  Please refresh the page and submit again.");
         }
         $this->wp_facade->wp_send_json($response);
     }
 }