/** * Transition for when the user inputs the app info and logs in with it's personal account. */ private static function transition_set_up_app($app_id, $app_secret, $user_access_token) { if (!$app_id) { throw new InvalidArgumentException('Missing App ID when authenticating the plugin'); } if (!$app_secret) { throw new InvalidArgumentException('Missing App Secret when authenticating the plugin'); } if (!$user_access_token) { throw new InvalidArgumentException('Missing Access Token when authenticating the plugin'); } Instant_Articles_Option_FB_App::update_option(array('app_id' => $app_id, 'app_secret' => $app_secret, 'user_access_token' => $user_access_token)); return update_option('instant-articles-current-state', self::STATE_PAGE_SELECTION); }
/** * Saves the App ID and App Secret. * * That does not trigger a state transition, as the state transition will * only happen when the user logs in and we grab the access token. */ public static function save_app() { if (!current_user_can('manage_options')) { wp_die(esc_html('You do not have sufficient permissions to access this page.')); } $current_state = Instant_Articles_Wizard_State::get_current_state(); if ($current_state !== Instant_Articles_Wizard_State::STATE_APP_SETUP) { die; } $app_id = sanitize_text_field($_POST['app_id']); $app_secret = sanitize_text_field($_POST['app_secret']); Instant_Articles_Option_FB_App::update_option(array('app_id' => $app_id, 'app_secret' => $app_secret)); self::render(true); die; }