本文整理汇总了PHP中Jetpack::deactivate_module方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::deactivate_module方法的具体用法?PHP Jetpack::deactivate_module怎么用?PHP Jetpack::deactivate_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::deactivate_module方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_sync_deactivate_module_event
function test_sync_deactivate_module_event()
{
Jetpack_Options::update_option('active_modules', array('stuff'));
Jetpack::deactivate_module('stuff');
$this->client->do_sync();
$events = $this->server_event_storage->get_all_events('jetpack_deactivate_module');
$event = $events[0];
$this->assertEquals('jetpack_deactivate_module', $event->action);
$this->assertEquals('stuff', $event->args[0]);
$this->assertEquals(1, count($events));
}
示例2: deactivate_module
/**
* If it's a valid Jetpack module, deactivate it.
*
* @since 4.3.0
*
* @param string|WP_REST_Request $data {
* Array of parameters received by request.
*
* @type string $slug Module slug.
* }
*
* @return bool|WP_Error True if module was activated. Otherwise, a WP_Error instance with the corresponding error.
*/
public function deactivate_module($data)
{
$module_slug = isset($data['slug']) ? $data['slug'] : $data;
if (!Jetpack::is_module($module_slug)) {
return new WP_Error('not_found', esc_html__('The requested Jetpack module was not found.', 'jetpack'), array('status' => 404));
}
if (!Jetpack::is_module_active($module_slug)) {
return new WP_Error('already_inactive', esc_html__('The requested Jetpack module was already inactive.', 'jetpack'), array('status' => 409));
}
if (Jetpack::deactivate_module($module_slug)) {
return rest_ensure_response(array('code' => 'success', 'message' => esc_html__('The requested Jetpack module was deactivated.', 'jetpack')));
}
return new WP_Error('deactivation_failed', esc_html__('The requested Jetpack module could not be deactivated.', 'jetpack'), array('status' => 400));
}
示例3: jetpack_configuration_load
public function jetpack_configuration_load()
{
if (Jetpack::is_user_connected() && !self::is_active()) {
Jetpack::deactivate_module($this->module);
Jetpack::state('message', 'module_deactivated');
wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
die;
}
if (!empty($_POST['action']) && $_POST['action'] == 'monitor-save') {
check_admin_referer('monitor-settings');
$this->update_option_receive_jetpack_monitor_notification(isset($_POST['receive_jetpack_monitor_notification']));
Jetpack::state('message', 'module_configured');
wp_safe_redirect(Jetpack::module_configuration_url($this->module));
}
}
示例4: deactivate_module
protected function deactivate_module()
{
foreach ($this->modules as $module) {
if (!Jetpack::is_module_active($module)) {
$error = $this->log[$module][] = __('The Jetpack Module is already deactivated.', 'jetpack');
continue;
}
$result = Jetpack::deactivate_module($module);
if (false === $result || Jetpack::is_module_active($module)) {
$error = $this->log[$module][] = __('There was an error while deactivating the module.', 'jetpack');
}
}
if (!$this->bulk && isset($error)) {
return new WP_Error('deactivation_error', $error, 400);
}
return true;
}
示例5: jetpack_site_icon_available_in_core
public static function jetpack_site_icon_available_in_core()
{
global $wp_version;
$core_icon_available = function_exists('has_site_icon') && version_compare($wp_version, '4.3-beta') >= 0;
if (!$core_icon_available) {
return false;
}
// No need for Jetpack's site icon anymore if core's is already set
if (has_site_icon()) {
if (Jetpack::is_module_active('site-icon')) {
Jetpack::log('deactivate', 'site-icon');
Jetpack::deactivate_module('site-icon');
}
return true;
}
// Transfer Jetpack's site icon to use core.
$site_icon_id = Jetpack::get_option('site_icon_id');
if ($site_icon_id) {
// Update core's site icon
update_option('site_icon', $site_icon_id);
// Delete Jetpack's icon option. We still want the blavatar and attached data though.
delete_option('site_icon_id');
}
// No need for Jetpack's site icon anymore
if (Jetpack::is_module_active('site-icon')) {
Jetpack::log('deactivate', 'site-icon');
Jetpack::deactivate_module('site-icon');
}
return true;
}
示例6: 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');
//.........这里部分代码省略.........
示例7: update_settings
/**
* Updates site settings for authorized users
*
* @return (array)
*/
public function update_settings()
{
// $this->input() retrieves posted arguments whitelisted and casted to the $request_format
// specs that get passed in when this class is instantiated
/**
* Filters the settings to be updated on the site.
*
* @since 3.6.0
*
* @param array $input Associative array of site settings to be updated.
*/
$input = apply_filters('rest_api_update_site_settings', $this->input());
$jetpack_relatedposts_options = array();
$sharing_options = array();
$updated = array();
foreach ($input as $key => $value) {
if (!is_array($value)) {
$value = trim($value);
}
$value = wp_unslash($value);
switch ($key) {
case 'default_ping_status':
case 'default_comment_status':
// settings are stored as closed|open
$coerce_value = $value ? 'open' : 'closed';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'jetpack_protect_whitelist':
if (function_exists('jetpack_protect_save_whitelist')) {
$result = jetpack_protect_save_whitelist($value);
if (is_wp_error($result)) {
return $result;
}
$updated[$key] = jetpack_protect_format_whitelist();
}
break;
case 'jetpack_sync_non_public_post_stati':
Jetpack_Options::update_option('sync_non_public_post_stati', $value);
break;
case 'jetpack_relatedposts_enabled':
case 'jetpack_relatedposts_show_thumbnails':
case 'jetpack_relatedposts_show_headline':
if (!$this->jetpack_relatedposts_supported()) {
break;
}
if ('jetpack_relatedposts_enabled' === $key && method_exists('Jetpack', 'is_module_active') && $this->jetpack_relatedposts_supported()) {
$before_action = Jetpack::is_module_active('related-posts');
if ($value) {
Jetpack::activate_module('related-posts', false, false);
} else {
Jetpack::deactivate_module('related-posts');
}
$after_action = Jetpack::is_module_active('related-posts');
if ($after_action == $before_action) {
break;
}
}
$just_the_key = substr($key, 21);
$jetpack_relatedposts_options[$just_the_key] = $value;
break;
case 'social_notifications_like':
case 'social_notifications_reblog':
case 'social_notifications_subscribe':
// settings are stored as on|off
$coerce_value = $value ? 'on' : 'off';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'wga':
if (!isset($value['code']) || !preg_match('/^$|^UA-[\\d-]+$/i', $value['code'])) {
return new WP_Error('invalid_code', 'Invalid UA ID');
}
$wga = get_option('wga', array());
$wga['code'] = $value['code'];
// maintain compatibility with wp-google-analytics
if (update_option('wga', $wga)) {
$updated[$key] = $value;
}
$enabled_or_disabled = $wga['code'] ? 'enabled' : 'disabled';
do_action('jetpack_bump_stats_extras', 'google-analytics', $enabled_or_disabled);
$business_plugins = WPCOM_Business_Plugins::instance();
$business_plugins->activate_plugin('wp-google-analytics');
break;
case 'jetpack_comment_likes_enabled':
// settings are stored as 1|0
$coerce_value = (int) $value;
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
// Sharing options
// Sharing options
//.........这里部分代码省略.........
开发者ID:annbransom,项目名称:techishowl_prod_backup,代码行数:101,代码来源:class.wpcom-json-api-site-settings-endpoint.php
示例8: deactivate_jetpack_modules
static function deactivate_jetpack_modules()
{
check_ajax_referer(self::AJAX_NONCE, 'nonce');
// shamelessly copied from class.jetpack.php
$modules = $_REQUEST['modules'];
$modules = array_map('sanitize_key', $modules);
// $modules_filtered = Jetpack::init()->filter_default_modules( $modules );
foreach ($modules as $module_slug) {
Jetpack::log('deactivate', $module_slug);
Jetpack::deactivate_module($module_slug);
Jetpack::state('message', 'module_deactivated');
}
wp_send_json_success($modules);
}
示例9: admin_page_load
//.........这里部分代码省略.........
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')) {
$error = 'cheatin';
break;
}
$modules = stripslashes($_GET['module']);
check_admin_referer("jetpack_deactivate-{$modules}");
foreach (explode(',', $modules) as $module) {
Jetpack::log('deactivate', $module);
Jetpack::deactivate_module($module);
Jetpack::state('message', 'module_deactivated');
}
Jetpack::state('module', $modules);
wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
exit;
case 'unlink':
$redirect = isset($_GET['redirect']) ? $_GET['redirect'] : '';
check_admin_referer('jetpack-unlink');
Jetpack::log('unlink');
$this->unlink_user();
Jetpack::state('message', 'unlinked');
if ('sub-unlink' == $redirect) {
wp_safe_redirect(admin_url());
} else {
wp_safe_redirect(Jetpack::admin_url(array('page' => $redirect)));
}
exit;
default:
/**
* Fires when a Jetpack admin page is loaded with an unrecognized parameter.
*
* @since 2.6.0
*
* @param string sanitize_key( $_GET['action'] ) Unrecognized URL parameter.
示例10: update_settings
/**
* Updates site settings for authorized users
*
* @return (array)
*/
public function update_settings()
{
// $this->input() retrieves posted arguments whitelisted and casted to the $request_format
// specs that get passed in when this class is instantiated
$input = $this->input();
$jetpack_relatedposts_options = array();
$sharing_options = array();
$updated = array();
foreach ($input as $key => $value) {
if (!is_array($value)) {
$value = trim($value);
}
$value = wp_unslash($value);
switch ($key) {
case 'default_ping_status':
case 'default_comment_status':
// settings are stored as closed|open
$coerce_value = $value ? 'open' : 'closed';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'jetpack_sync_non_public_post_stati':
Jetpack_Options::update_option('sync_non_public_post_stati', $value);
break;
case 'jetpack_relatedposts_enabled':
case 'jetpack_relatedposts_show_thumbnails':
case 'jetpack_relatedposts_show_headline':
if (!$this->jetpack_relatedposts_supported()) {
break;
}
if ('jetpack_relatedposts_enabled' === $key && method_exists('Jetpack', 'is_module_active') && $this->jetpack_relatedposts_supported()) {
$before_action = Jetpack::is_module_active('related-posts');
if ($value) {
Jetpack::activate_module('related-posts', false, false);
} else {
Jetpack::deactivate_module('related-posts');
}
$after_action = Jetpack::is_module_active('related-posts');
if ($after_action == $before_action) {
break;
}
}
$just_the_key = substr($key, 21);
$jetpack_relatedposts_options[$just_the_key] = $value;
break;
case 'social_notifications_like':
case 'social_notifications_reblog':
case 'social_notifications_subscribe':
// settings are stored as on|off
$coerce_value = $value ? 'on' : 'off';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'wga':
if (!isset($value['code']) || !preg_match('/^UA-[\\d-]+$/', $value['code'])) {
return new WP_Error('invalid_code', 'Invalid UA ID');
}
$wga = get_option('wga', array());
$wga['code'] = $value['code'];
// maintain compatibility with wp-google-analytics
if (update_option('wga', $wga)) {
$updated[$key] = $value;
}
break;
case 'jetpack_comment_likes_enabled':
// settings are stored as 1|0
$coerce_value = (int) $value;
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
// Sharing options
// Sharing options
case 'sharing_button_style':
case 'sharing_show':
case 'sharing_open_links':
$sharing_options[preg_replace('/^sharing_/', '', $key)] = $value;
break;
case 'sharing_label':
$sharing_options[$key] = $value;
break;
// no worries, we've already whitelisted and casted arguments above
// no worries, we've already whitelisted and casted arguments above
default:
if (update_option($key, $value)) {
$updated[$key] = $value;
}
}
}
if (count($jetpack_relatedposts_options)) {
// track new jetpack_relatedposts options against old
$old_relatedposts_options = Jetpack_Options::get_option('relatedposts');
if (Jetpack_Options::update_option('relatedposts', $jetpack_relatedposts_options)) {
//.........这里部分代码省略.........
开发者ID:moushegh,项目名称:blog-source-configs,代码行数:101,代码来源:class.wpcom-json-api-site-settings-endpoint.php
示例11: add_filter
add_filter('plugin_row_meta', 'sfw_donate_link', 10, 2);
function sfw_donate_link($links, $file)
{
if ($file == plugin_basename(__FILE__)) {
$links[] = '<a href="' . admin_url('options-general.php?page=sfw_dashboard') . '">' . __('Settings', 'spam-free-wordpress') . '</a>';
$links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SFVH6PCCC6TLG">' . __('Donate', 'spam-free-wordpress') . '</a>';
}
return $links;
}
/*-----------------------------------------------------------------------------------------------------------------------
* Before the comment form can be automatically generated, make sure JetPack Comments module is not active
-------------------------------------------------------------------------------------------------------------------------*/
// Added 1.7.3
if (class_exists('Jetpack')) {
if (in_array('comments', Jetpack::get_active_modules())) {
Jetpack::deactivate_module('comments');
}
}
// automatically generate comment form - fixed in 1.7.8.1
function sfw_comment_form_init()
{
return dirname(__FILE__) . '/comments.php';
}
/*
* Added 1.9
* Loads default comment list and comment form style for themes that do not use
* the comment_form function. Works with themes that do as well.
*/
if ($sfw_options['comment_form'] == 'on') {
add_action('wp_enqueue_scripts', 'sfw_load_styles');
add_filter('comments_template', 'sfw_comment_form_init');
示例12: update_settings
/**
* Updates site settings for authorized users
*
* @return (array)
*/
public function update_settings()
{
// $this->input() retrieves posted arguments whitelisted and casted to the $request_format
// specs that get passed in when this class is instantiated
$input = $this->input();
$jetpack_relatedposts_options = array();
$updated = array();
foreach ($input as $key => $value) {
$value = wp_unslash(trim($value));
switch ($key) {
case 'default_ping_status':
case 'default_comment_status':
// settings are stored as closed|open
$coerce_value = $value ? 'open' : 'closed';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'infinite_scroll':
if (!current_theme_supports('infinite-scroll')) {
continue;
}
if (update_option($key, $value)) {
$updated[$key] = $value;
}
break;
case 'jetpack_relatedposts_enabled':
if (method_exists('Jetpack', 'is_module_active') && $this->jetpack_relatedposts_supported()) {
if ($value) {
Jetpack::activate_module('related-posts', false, false);
} else {
Jetpack::deactivate_module('related-posts');
}
$updated[$key] = $value;
unset($jetpack_relatedposts_options['enabled']);
break;
}
case 'jetpack_relatedposts_show_thumbnails':
case 'jetpack_relatedposts_show_headline':
if (!$this->jetpack_relatedposts_supported()) {
break;
}
$jetpack_relatedposts_options = Jetpack_Options::get_option('relatedposts');
$just_the_key = substr($key, 21);
$jetpack_relatedposts_options[$just_the_key] = $value;
if (Jetpack_Options::update_option('relatedposts', $jetpack_relatedposts_options)) {
$updated[$key] = $value;
}
break;
case 'social_notifications_like':
case 'social_notifications_reblog':
case 'social_notifications_subscribe':
// settings are stored as on|off
$coerce_value = $value ? 'on' : 'off';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
// no worries, we've already whitelisted and casted arguments above
// no worries, we've already whitelisted and casted arguments above
default:
if (update_option($key, $value)) {
$updated[$key] = $value;
}
}
}
return array('updated' => $updated);
}
示例13: update_settings
/**
* Updates site settings for authorized users
*
* @return (array)
*/
public function update_settings()
{
// $this->input() retrieves posted arguments whitelisted and casted to the $request_format
// specs that get passed in when this class is instantiated
/**
* Filters the settings to be updated on the site.
*
* @module json-api
*
* @since 3.6.0
*
* @param array $input Associative array of site settings to be updated.
*/
$input = apply_filters('rest_api_update_site_settings', $this->input());
$jetpack_relatedposts_options = array();
$sharing_options = array();
$updated = array();
foreach ($input as $key => $value) {
if (!is_array($value)) {
$value = trim($value);
}
$value = wp_unslash($value);
switch ($key) {
case 'default_ping_status':
case 'default_comment_status':
// settings are stored as closed|open
$coerce_value = $value ? 'open' : 'closed';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'jetpack_protect_whitelist':
if (function_exists('jetpack_protect_save_whitelist')) {
$result = jetpack_protect_save_whitelist($value);
if (is_wp_error($result)) {
return $result;
}
$updated[$key] = jetpack_protect_format_whitelist();
}
break;
case 'jetpack_sync_non_public_post_stati':
Jetpack_Options::update_option('sync_non_public_post_stati', $value);
break;
case 'jetpack_relatedposts_enabled':
case 'jetpack_relatedposts_show_thumbnails':
case 'jetpack_relatedposts_show_headline':
if (!$this->jetpack_relatedposts_supported()) {
break;
}
if ('jetpack_relatedposts_enabled' === $key && method_exists('Jetpack', 'is_module_active') && $this->jetpack_relatedposts_supported()) {
$before_action = Jetpack::is_module_active('related-posts');
if ($value) {
Jetpack::activate_module('related-posts', false, false);
} else {
Jetpack::deactivate_module('related-posts');
}
$after_action = Jetpack::is_module_active('related-posts');
if ($after_action == $before_action) {
break;
}
}
$just_the_key = substr($key, 21);
$jetpack_relatedposts_options[$just_the_key] = $value;
break;
case 'social_notifications_like':
case 'social_notifications_reblog':
case 'social_notifications_subscribe':
// settings are stored as on|off
$coerce_value = $value ? 'on' : 'off';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'wga':
if (!isset($value['code']) || !preg_match('/^$|^UA-[\\d-]+$/i', $value['code'])) {
return new WP_Error('invalid_code', 'Invalid UA ID');
}
$wga = get_option('wga', array());
$wga['code'] = $value['code'];
// maintain compatibility with wp-google-analytics
if (update_option('wga', $wga)) {
$updated[$key] = $value;
}
$enabled_or_disabled = $wga['code'] ? 'enabled' : 'disabled';
/** This action is documented in modules/widgets/social-media-icons.php */
do_action('jetpack_bump_stats_extras', 'google-analytics', $enabled_or_disabled);
$business_plugins = WPCOM_Business_Plugins::instance();
$business_plugins->activate_plugin('wp-google-analytics');
break;
case 'jetpack_testimonial':
case 'jetpack_portfolio':
case 'jetpack_comment_likes_enabled':
// settings are stored as 1|0
$coerce_value = (int) $value;
if (update_option($key, $coerce_value)) {
//.........这里部分代码省略.........
示例14:
<?php
/**
* Jetpack Compatibility File
* See: http://jetpack.me/
*
* @package acid
*/
//-----------------------------------*/
// Disable Jetpack Photon
//-----------------------------------*/
if (class_exists('Jetpack') && method_exists('Jetpack', 'deactivate_module') && Jetpack::is_module_active('photon')) {
Jetpack::deactivate_module('photon');
}
示例15: module
/**
* Manage Jetpack Modules
*
* ## OPTIONS
*
* list: View all available modules, and their status.
*
* activate <module_slug>: Activate a module.
*
* deactivate <module_slug>: Deactivate a module.
*
* toggle <module_slug>: Toggle a module on or off.
*
* ## EXAMPLES
*
* wp jetpack module list
* wp jetpack module activate stats
* wp jetpack module deactivate stats
* wp jetpack module toggle stats
*
* @synopsis [list|activate|deactivate|toggle [<module_name>]]
*/
public function module($args, $assoc_args)
{
$action = isset($args[0]) ? $args[0] : 'list';
if (!in_array($action, array('list', 'activate', 'deactivate', 'toggle'))) {
WP_CLI::error(sprintf(__('%s is not a valid command.', 'jetpack'), $action));
}
if (in_array($action, array('activate', 'deactivate', 'toggle'))) {
if (isset($args[1])) {
$module_slug = $args[1];
if (!Jetpack::is_module($module_slug)) {
WP_CLI::error(sprintf(__('%s is not a valid module.', 'jetpack'), $module_slug));
}
if ('toggle' == $action) {
$action = Jetpack::is_module_active($module_slug) ? 'deactivate' : 'activate';
}
} else {
WP_CLI::line(__('Please specify a valid module.', 'jetpack'));
$action = 'list';
}
}
switch ($action) {
case 'list':
WP_CLI::line(__('Available Modules:', 'jetpack'));
$modules = Jetpack::get_available_modules();
sort($modules);
foreach ($modules as $module_slug) {
$active = Jetpack::is_module_active($module_slug) ? __('Active', 'jetpack') : __('Inactive', 'jetpack');
WP_CLI::line("\t" . str_pad($module_slug, 24) . $active);
}
break;
case 'activate':
$module = Jetpack::get_module($module_slug);
Jetpack::log('activate', $module_slug);
Jetpack::activate_module($module_slug, false);
WP_CLI::success(sprintf(__('%s has been activated.', 'jetpack'), $module['name']));
break;
case 'deactivate':
$module = Jetpack::get_module($module_slug);
Jetpack::log('deactivate', $module_slug);
Jetpack::deactivate_module($module_slug);
WP_CLI::success(sprintf(__('%s has been deactivated.', 'jetpack'), $module['name']));
break;
case 'toggle':
// Will never happen, should have been handled above and changed to activate or deactivate.
break;
}
}