本文整理汇总了PHP中Jetpack::try_registration方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::try_registration方法的具体用法?PHP Jetpack::try_registration怎么用?PHP Jetpack::try_registration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::try_registration方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_page_load
/**
* Handles the page load events for the Jetpack admin page
*/
function admin_page_load()
{
$error = false;
// Make sure we have the right body class to hook stylings for subpages off of.
add_filter('admin_body_class', array(__CLASS__, 'add_jetpack_pagestyles'));
if (!empty($_GET['jetpack_restate'])) {
// Should only be used in intermediate redirects to preserve state across redirects
Jetpack::restate();
}
if (isset($_GET['connect_url_redirect'])) {
// User clicked in the iframe to link their accounts
if (!Jetpack::is_user_connected()) {
$connect_url = $this->build_connect_url(true);
if (isset($_GET['notes_iframe'])) {
$connect_url .= '¬es_iframe';
}
wp_redirect($connect_url);
exit;
} else {
Jetpack::state('message', 'already_authorized');
wp_safe_redirect(Jetpack::admin_url());
exit;
}
}
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'authorize':
if (Jetpack::is_active() && Jetpack::is_user_connected()) {
Jetpack::state('message', 'already_authorized');
wp_safe_redirect(Jetpack::admin_url());
exit;
}
Jetpack::log('authorize');
$client_server = new Jetpack_Client_Server();
$client_server->authorize();
exit;
case 'register':
check_admin_referer('jetpack-register');
Jetpack::log('register');
Jetpack::maybe_set_version_option();
$registered = Jetpack::try_registration();
if (is_wp_error($registered)) {
$error = $registered->get_error_code();
Jetpack::state('error_description', $registered->get_error_message());
break;
}
wp_redirect($this->build_connect_url(true));
exit;
case 'activate':
if (!current_user_can('jetpack_activate_modules')) {
$error = 'cheatin';
break;
}
$module = stripslashes($_GET['module']);
check_admin_referer("jetpack_activate-{$module}");
Jetpack::log('activate', $module);
Jetpack::activate_module($module);
// The following two lines will rarely happen, as Jetpack::activate_module normally exits at the end.
wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
exit;
case 'activate_default_modules':
check_admin_referer('activate_default_modules');
Jetpack::log('activate_default_modules');
Jetpack::restate();
$min_version = isset($_GET['min_version']) ? $_GET['min_version'] : false;
$max_version = isset($_GET['max_version']) ? $_GET['max_version'] : false;
$other_modules = isset($_GET['other_modules']) && is_array($_GET['other_modules']) ? $_GET['other_modules'] : array();
Jetpack::activate_default_modules($min_version, $max_version, $other_modules);
wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
exit;
case 'disconnect':
if (!current_user_can('jetpack_disconnect')) {
$error = 'cheatin';
break;
}
check_admin_referer('jetpack-disconnect');
Jetpack::log('disconnect');
Jetpack::disconnect();
wp_safe_redirect(Jetpack::admin_url());
exit;
case 'reconnect':
if (!current_user_can('jetpack_reconnect')) {
$error = 'cheatin';
break;
}
check_admin_referer('jetpack-reconnect');
Jetpack::log('reconnect');
$this->disconnect();
wp_redirect($this->build_connect_url(true));
exit;
case 'deactivate':
if (!current_user_can('jetpack_deactivate_modules')) {
$error = 'cheatin';
break;
}
$modules = stripslashes($_GET['module']);
check_admin_referer("jetpack_deactivate-{$modules}");
//.........这里部分代码省略.........
示例2: admin_page_load
/**
* Handles the page load events for the Jetpack admin page
*/
function admin_page_load()
{
$error = false;
// Make sure we have the right body class to hook stylings for subpages off of.
add_filter('admin_body_class', array(__CLASS__, 'add_jetpack_pagestyles'));
if (!empty($_GET['jetpack_restate'])) {
// Should only be used in intermediate redirects to preserve state across redirects
Jetpack::restate();
}
if (isset($_GET['connect_url_redirect'])) {
// User clicked in the iframe to link their accounts
if (!Jetpack::is_user_connected()) {
$connect_url = $this->build_connect_url(true, false, 'iframe');
if (isset($_GET['notes_iframe'])) {
$connect_url .= '¬es_iframe';
}
wp_redirect($connect_url);
exit;
} else {
Jetpack::state('message', 'already_authorized');
wp_safe_redirect(Jetpack::admin_url());
exit;
}
}
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'authorize':
if (Jetpack::is_active() && Jetpack::is_user_connected()) {
Jetpack::state('message', 'already_authorized');
wp_safe_redirect(Jetpack::admin_url());
exit;
}
Jetpack::log('authorize');
$client_server = new Jetpack_Client_Server();
$client_server->client_authorize();
exit;
case 'register':
if (!current_user_can('jetpack_connect')) {
$error = 'cheatin';
break;
}
check_admin_referer('jetpack-register');
Jetpack::log('register');
Jetpack::maybe_set_version_option();
$registered = Jetpack::try_registration();
if (is_wp_error($registered)) {
$error = $registered->get_error_code();
Jetpack::state('error_description', $registered->get_error_message());
break;
}
$from = isset($_GET['from']) ? $_GET['from'] : false;
wp_redirect($this->build_connect_url(true, false, $from));
exit;
case 'activate':
if (!current_user_can('jetpack_activate_modules')) {
$error = 'cheatin';
break;
}
$module = stripslashes($_GET['module']);
check_admin_referer("jetpack_activate-{$module}");
Jetpack::log('activate', $module);
Jetpack::activate_module($module);
// The following two lines will rarely happen, as Jetpack::activate_module normally exits at the end.
wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
exit;
case 'activate_default_modules':
check_admin_referer('activate_default_modules');
Jetpack::log('activate_default_modules');
Jetpack::restate();
$min_version = isset($_GET['min_version']) ? $_GET['min_version'] : false;
$max_version = isset($_GET['max_version']) ? $_GET['max_version'] : false;
$other_modules = isset($_GET['other_modules']) && is_array($_GET['other_modules']) ? $_GET['other_modules'] : array();
Jetpack::activate_default_modules($min_version, $max_version, $other_modules);
wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
exit;
case 'disconnect':
if (!current_user_can('jetpack_disconnect')) {
$error = 'cheatin';
break;
}
check_admin_referer('jetpack-disconnect');
Jetpack::log('disconnect');
Jetpack::disconnect();
wp_safe_redirect(Jetpack::admin_url('disconnected=true'));
exit;
case 'reconnect':
if (!current_user_can('jetpack_reconnect')) {
$error = 'cheatin';
break;
}
check_admin_referer('jetpack-reconnect');
Jetpack::log('reconnect');
$this->disconnect();
wp_redirect($this->build_connect_url(true, false, 'reconnect'));
exit;
case 'deactivate':
if (!current_user_can('jetpack_deactivate_modules')) {
//.........这里部分代码省略.........
示例3: configure_jetpack
static function configure_jetpack()
{
check_ajax_referer(self::AJAX_NONCE, 'nonce');
$return_to_step = $_REQUEST['return_to_step'];
if (!is_plugin_active('jetpack')) {
activate_plugin('jetpack');
}
if (!class_exists('Jetpack')) {
wp_send_json_error('There was a problem activating Jetpack');
die;
}
if (!Jetpack::is_active()) {
if (!Jetpack_Options::get_option('blog_token') || !Jetpack_Options::get_option('id')) {
$result = Jetpack::try_registration();
if (is_wp_error($result)) {
$error = $result->get_error_code();
$message = $result->get_error_message();
wp_send_json_error($message . ' (code: ' . $error . ')');
die;
}
}
$jp_landing_page = new Jetpack_Landing_Page();
$jp_landing_page->add_actions();
// redirect to activate link
$connect_url = Jetpack::init()->build_connect_url(true, admin_url('index.php#welcome/steps/' . $return_to_step));
if (JETPACK_STEP_AUTO_REDIRECT) {
$connect_url = add_query_arg('src', JETPACK_STEP_AUTO_REDIRECT_SRC, $connect_url);
}
wp_send_json_success(array('next' => $connect_url));
} else {
wp_send_json_success('already_active');
}
}
示例4: admin_page_load
function admin_page_load()
{
$error = false;
if (!empty($_GET['jetpack_restate'])) {
// Should only be used in intermediate redirects to preserve state across redirects
Jetpack::restate();
}
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'authorize':
if (Jetpack::is_active()) {
Jetpack::state('message', 'already_authorized');
wp_safe_redirect(Jetpack::admin_url());
exit;
}
$client_server =& new Jetpack_Client_Server();
$client_server->authorize();
exit;
case 'register':
check_admin_referer('jetpack-register');
$registered = Jetpack::try_registration();
if (is_wp_error($registered)) {
$error = $registered->get_error_code();
Jetpack::state('error_description', $registered->get_error_message());
break;
}
wp_redirect($this->build_connect_url(true));
exit;
case 'activate':
$module = stripslashes($_GET['module']);
check_admin_referer("jetpack_activate-{$module}");
Jetpack::activate_module($module);
wp_safe_redirect(Jetpack::admin_url());
exit;
case 'activate_default_modules':
check_admin_referer('activate_default_modules');
Jetpack::restate();
$min_version = isset($_GET['min_version']) ? $_GET['min_version'] : false;
$max_version = isset($_GET['max_version']) ? $_GET['max_version'] : false;
$other_modules = isset($_GET['other_modules']) && is_array($_GET['other_modules']) ? $_GET['other_modules'] : array();
Jetpack::activate_default_modules($min_version, $max_version, $other_modules);
wp_safe_redirect(Jetpack::admin_url());
exit;
case 'disconnect':
check_admin_referer('jetpack-disconnect');
$this->disconnect();
wp_safe_redirect(Jetpack::admin_url());
exit;
case 'deactivate':
$module = stripslashes($_GET['module']);
check_admin_referer("jetpack_deactivate-{$module}");
Jetpack::deactivate_module($module);
Jetpack::state('message', 'module_deactivated');
Jetpack::state('module', $module);
wp_safe_redirect(Jetpack::admin_url());
exit;
}
}
if (!($error = $error ? $error : Jetpack::state('error'))) {
Jetpack::activate_new_modules();
}
switch ($error) {
case 'access_denied':
$this->error = __('You need to authorize the Jetpack connection between your site and WordPress.com to enable the awesome features.', 'jetpack');
break;
case 'wrong_state':
$this->error = __("Don’t cross the streams! You need to stay logged in to your WordPress blog while you authorize Jetpack.", 'jetpack');
break;
case 'invalid_client':
// @todo re-register instead of deactivate/reactivate
$this->error = __('Return to sender. Whoops! It looks like you got the wrong Jetpack in the mail; deactivate then reactivate the Jetpack plugin to get a new one.', 'jetpack');
break;
case 'invalid_grant':
$this->error = __("Wrong size. Hm… it seems your Jetpack doesn’t quite fit. Have you lost weight? Click “Connect to WordPress.com” again to get your Jetpack adjusted.", 'jetpack');
break;
case 'site_inaccessible':
case 'site_requires_authorization':
$this->error = sprintf(__('Your website needs to be publicly accessible to use Jetpack: %s', 'jetpack'), "<code>{$error}</code>");
break;
case 'module_activation_failed':
$module = Jetpack::state('module');
if (!empty($module) && ($mod = Jetpack::get_module($module))) {
if ('sharedaddy' == $module && version_compare(PHP_VERSION, '5', '<')) {
$this->error = sprintf(__('The %1$s module requires <strong>PHP version %2$s</strong> or higher.', 'jetpack'), '<strong>' . $mod['name'] . '</strong>', '5');
} else {
$this->error = sprintf(__('%s could not be activated because it triggered a <strong>fatal error</strong>. Perhaps there is a conflict with another plugin you have installed?', 'jetpack'), $mod['name']);
if (isset($this->plugins_to_deactivate[$module])) {
$this->error .= ' ' . sprintf(__('Do you still have the %s plugin installed?', 'jetpack'), $this->plugins_to_deactivate[$module][1]);
}
}
} else {
$this->error = __('Module could not be activated because it triggered a <strong>fatal error</strong>. Perhaps there is a conflict with another plugin you have installed?', 'jetpack');
}
if ($php_errors = Jetpack::state('php_errors')) {
$this->error .= "<br />\n";
$this->error .= $php_errors;
}
break;
case 'not_public':
$this->error = __("<strong>Your Jetpack has a glitch.</strong> Connecting this site with WordPress.com is not possible. This usually means your site is not publicly accessible (localhost).", 'jetpack');
//.........这里部分代码省略.........
示例5: admin_page_load
/**
* Handles the page load events for the Jetpack admin page
*/
function admin_page_load()
{
$error = false;
// Make sure we have the right body class to hook stylings for subpages off of.
add_filter('admin_body_class', array(__CLASS__, 'add_jetpack_pagestyles'));
if (!empty($_GET['jetpack_restate'])) {
// Should only be used in intermediate redirects to preserve state across redirects
Jetpack::restate();
}
if (isset($_GET['connect_url_redirect'])) {
// User clicked in the iframe to link their accounts
if (!Jetpack::is_user_connected()) {
$connect_url = $this->build_connect_url(true, false, 'iframe');
if (isset($_GET['notes_iframe'])) {
$connect_url .= '¬es_iframe';
}
wp_redirect($connect_url);
exit;
} else {
if (!isset($_GET['calypso_env'])) {
Jetpack::state('message', 'already_authorized');
wp_safe_redirect(Jetpack::admin_url());
} else {
$connect_url = $this->build_connect_url(true, false, 'iframe');
$connect_url .= '&already_authorized=true';
wp_redirect($connect_url);
}
}
}
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'authorize':
if (Jetpack::is_active() && Jetpack::is_user_connected()) {
Jetpack::state('message', 'already_authorized');
wp_safe_redirect(Jetpack::admin_url());
exit;
}
Jetpack::log('authorize');
$client_server = new Jetpack_Client_Server();
$client_server->client_authorize();
exit;
case 'register':
if (!current_user_can('jetpack_connect')) {
$error = 'cheatin';
break;
}
check_admin_referer('jetpack-register');
Jetpack::log('register');
Jetpack::maybe_set_version_option();
$registered = Jetpack::try_registration();
if (is_wp_error($registered)) {
$error = $registered->get_error_code();
Jetpack::state('error', $error);
Jetpack::state('error', $registered->get_error_message());
break;
}
$from = isset($_GET['from']) ? $_GET['from'] : false;
wp_redirect($this->build_connect_url(true, false, $from));
exit;
case 'activate':
if (!current_user_can('jetpack_activate_modules')) {
$error = 'cheatin';
break;
}
$module = stripslashes($_GET['module']);
check_admin_referer("jetpack_activate-{$module}");
Jetpack::log('activate', $module);
Jetpack::activate_module($module);
// The following two lines will rarely happen, as Jetpack::activate_module normally exits at the end.
wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
exit;
case 'activate_default_modules':
check_admin_referer('activate_default_modules');
Jetpack::log('activate_default_modules');
Jetpack::restate();
$min_version = isset($_GET['min_version']) ? $_GET['min_version'] : false;
$max_version = isset($_GET['max_version']) ? $_GET['max_version'] : false;
$other_modules = isset($_GET['other_modules']) && is_array($_GET['other_modules']) ? $_GET['other_modules'] : array();
Jetpack::activate_default_modules($min_version, $max_version, $other_modules);
wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
exit;
case 'disconnect':
if (!current_user_can('jetpack_disconnect')) {
$error = 'cheatin';
break;
}
check_admin_referer('jetpack-disconnect');
Jetpack::log('disconnect');
Jetpack::disconnect();
wp_safe_redirect(Jetpack::admin_url('disconnected=true'));
exit;
case 'reconnect':
if (!current_user_can('jetpack_reconnect')) {
$error = 'cheatin';
break;
}
check_admin_referer('jetpack-reconnect');
//.........这里部分代码省略.........