本文整理汇总了PHP中Jetpack::maybe_set_version_option方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::maybe_set_version_option方法的具体用法?PHP Jetpack::maybe_set_version_option怎么用?PHP Jetpack::maybe_set_version_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::maybe_set_version_option方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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, 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')) {
//.........这里部分代码省略.........
示例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);
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}");
//.........这里部分代码省略.........
示例3: 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');
//.........这里部分代码省略.........