public function handle_actions() { if (empty($_GET['action']) || empty($_GET['page']) || $_GET['page'] != $this->_hook) { return; } if ('clear-locks' == $_GET['action']) { check_admin_referer('clear-locks'); $redirect_args = array('message' => strtolower($_GET['action'])); global $wpdb; $locks_q = "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_tlc_up__twp%'"; $redirect_args['locks_cleared'] = $wpdb->query($locks_q); wp_safe_redirect(add_query_arg($redirect_args, remove_query_arg(array('action', '_wpnonce')))); exit; } if ('remove' == $_GET['action']) { check_admin_referer('remove-' . $_GET['screen_name']); $redirect_args = array('message' => 'removed', 'removed' => ''); unset($this->_settings['twp-authed-users'][strtolower($_GET['screen_name'])]); if (update_option('twp-authed-users', $this->_settings['twp-authed-users'])) { } $redirect_args['removed'] = $_GET['screen_name']; wp_safe_redirect(add_query_arg($redirect_args, $this->get_options_url())); exit; } if ('authorize' == $_GET['action']) { check_admin_referer('authorize'); $auth_redirect = add_query_arg(array('action' => 'authorized'), $this->get_options_url()); $token = $this->_wp_twitter_oauth->getRequestToken($auth_redirect); if (is_wp_error($token)) { $this->_error = $token; return; } update_option('_twp_request_token_' . $token['nonce'], $token); $screen_name = empty($_GET['screen_name']) ? '' : $_GET['screen_name']; wp_redirect($this->_wp_twitter_oauth->get_authorize_url($screen_name)); exit; } if ('authorized' == $_GET['action']) { $redirect_args = array('message' => strtolower($_GET['action']), 'authorized' => ''); if (empty($_GET['oauth_verifier']) || empty($_GET['nonce'])) { wp_safe_redirect(add_query_arg($redirect_args, $this->get_options_url())); } $this->_wp_twitter_oauth->set_token(get_option('_twp_request_token_' . $_GET['nonce'])); delete_option('_twp_request_token_' . $_GET['nonce']); $token = $this->_wp_twitter_oauth->get_access_token($_GET['oauth_verifier']); if (!is_wp_error($token)) { $this->_settings['twp-authed-users'][strtolower($token['screen_name'])] = $token; update_option('twp-authed-users', $this->_settings['twp-authed-users']); $redirect_args['authorized'] = $token['screen_name']; } wp_safe_redirect(add_query_arg($redirect_args, $this->get_options_url())); exit; } }