本文整理汇总了PHP中Sharing_Service::set_global_options方法的典型用法代码示例。如果您正苦于以下问题:PHP Sharing_Service::set_global_options方法的具体用法?PHP Sharing_Service::set_global_options怎么用?PHP Sharing_Service::set_global_options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sharing_Service
的用法示例。
在下文中一共展示了Sharing_Service::set_global_options方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_requests
public function process_requests()
{
if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'sharing-options')) {
$sharer = new Sharing_Service();
$sharer->set_global_options($_POST);
do_action('sharing_admin_update');
wp_safe_redirect(admin_url('options-general.php?page=sharing&update=saved'));
die;
}
}
示例2: update_settings
//.........这里部分代码省略.........
// 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
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;
// Keyring token option
// Keyring token option
case 'eventbrite_api_token':
// These options can only be updated for sites hosted on WordPress.com
if (defined('IS_WPCOM') && IS_WPCOM) {
if (empty($value) || WPCOM_JSON_API::is_falsy($value)) {
if (delete_option($key)) {
$updated[$key] = null;
}
} else {
if (update_option($key, $value)) {
$updated[$key] = (int) $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)) {
foreach ($jetpack_relatedposts_options as $key => $value) {
if ($value !== $old_relatedposts_options[$key]) {
$updated['jetpack_relatedposts_' . $key] = $value;
}
}
}
}
if (!empty($sharing_options) && class_exists('Sharing_Service')) {
$ss = new Sharing_Service();
// Merge current values with updated, since Sharing_Service expects
// all values to be included when updating
$current_sharing_options = $ss->get_global_options();
foreach ($current_sharing_options as $key => $val) {
if (!isset($sharing_options[$key])) {
$sharing_options[$key] = $val;
}
}
$updated_social_options = $ss->set_global_options($sharing_options);
if (isset($input['sharing_button_style'])) {
$updated['sharing_button_style'] = (string) $updated_social_options['button_style'];
}
if (isset($input['sharing_label'])) {
// Sharing_Service won't report label as updated if set to default
$updated['sharing_label'] = (string) $sharing_options['sharing_label'];
}
if (isset($input['sharing_show'])) {
$updated['sharing_show'] = (array) $updated_social_options['show'];
}
if (isset($input['sharing_open_links'])) {
$updated['sharing_open_links'] = (string) $updated_social_options['open_links'];
}
}
return array('updated' => $updated);
}
开发者ID:annbransom,项目名称:techishowl_prod_backup,代码行数:101,代码来源:class.wpcom-json-api-site-settings-endpoint.php
示例3: update_data
//.........这里部分代码省略.........
case 'show_headline':
case 'show_thumbnails':
$grouped_options = $grouped_options_current = (array) Jetpack_Options::get_option('relatedposts');
$grouped_options[$option] = $value;
// If option value was the same, consider it done.
$updated = $grouped_options_current != $grouped_options ? Jetpack_Options::update_option('relatedposts', $grouped_options) : true;
break;
case 'google':
case 'bing':
case 'pinterest':
case 'yandex':
$grouped_options = $grouped_options_current = (array) get_option('verification_services_codes');
$grouped_options[$option] = $value;
// If option value was the same, consider it done.
$updated = $grouped_options_current != $grouped_options ? update_option('verification_services_codes', $grouped_options) : true;
break;
case 'sharing_services':
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
// If option value was the same, consider it done.
$updated = $value != $sharer->get_blog_services() ? $sharer->set_blog_services($value['visible'], $value['hidden']) : true;
break;
case 'button_style':
case 'sharing_label':
case 'show':
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
$grouped_options = $sharer->get_global_options();
$grouped_options[$option] = $value;
$updated = $sharer->set_global_options($grouped_options);
break;
case 'custom':
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
$updated = $sharer->new_service(stripslashes($value['sharing_name']), stripslashes($value['sharing_url']), stripslashes($value['sharing_icon']));
// Return new custom service
$response[$option] = $updated;
break;
case 'sharing_delete_service':
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
$updated = $sharer->delete_service($value);
break;
case 'jetpack-twitter-cards-site-tag':
$value = trim(ltrim(strip_tags($value), '@'));
$updated = get_option($option) !== $value ? update_option($option, $value) : true;
break;
case 'onpublish':
case 'onupdate':
case 'Bias Language':
case 'Cliches':
case 'Complex Expression':
case 'Diacritical Marks':
case 'Double Negative':
case 'Hidden Verbs':
case 'Jargon Language':
case 'Passive voice':
case 'Phrases to Avoid':
示例4: update_module
//.........这里部分代码省略.........
break;
case 'jetpack_protect_global_whitelist':
$updated = jetpack_protect_save_whitelist(explode(PHP_EOL, str_replace(' ', '', $value)));
if (is_wp_error($updated)) {
$error = $updated->get_error_message();
}
break;
case 'show_headline':
case 'show_thumbnails':
$grouped_options = $grouped_options_current = Jetpack_Options::get_option('relatedposts');
$grouped_options[$option] = $value;
// If option value was the same, consider it done.
$updated = $grouped_options_current != $grouped_options ? Jetpack_Options::update_option('relatedposts', $grouped_options) : true;
break;
case 'google':
case 'bing':
case 'pinterest':
$grouped_options = $grouped_options_current = get_option('verification_services_codes');
$grouped_options[$option] = $value;
// If option value was the same, consider it done.
$updated = $grouped_options_current != $grouped_options ? update_option('verification_services_codes', $grouped_options) : true;
break;
case 'sharing_services':
$sharer = new Sharing_Service();
// If option value was the same, consider it done.
$updated = $value != $sharer->get_blog_services() ? $sharer->set_blog_services($value['visible'], $value['hidden']) : true;
break;
case 'button_style':
case 'sharing_label':
case 'show':
$sharer = new Sharing_Service();
$grouped_options = $sharer->get_global_options();
$grouped_options[$option] = $value;
$updated = $sharer->set_global_options($grouped_options);
break;
case 'custom':
$sharer = new Sharing_Service();
$updated = $sharer->new_service(stripslashes($value['sharing_name']), stripslashes($value['sharing_url']), stripslashes($value['sharing_icon']));
// Return new custom service
$response[$option] = $updated;
break;
case 'sharing_delete_service':
$sharer = new Sharing_Service();
$updated = $sharer->delete_service($value);
break;
case 'jetpack-twitter-cards-site-tag':
$value = trim(ltrim(strip_tags($value), '@'));
$updated = get_option($option) !== $value ? update_option($option, $value) : true;
break;
case 'onpublish':
case 'onupdate':
case 'Bias Language':
case 'Cliches':
case 'Complex Expression':
case 'Diacritical Marks':
case 'Double Negative':
case 'Hidden Verbs':
case 'Jargon Language':
case 'Passive voice':
case 'Phrases to Avoid':
case 'Redundant Expression':
case 'guess_lang':
if (in_array($option, array('onpublish', 'onupdate'))) {
$atd_option = 'AtD_check_when';
} elseif ('guess_lang' == $option) {
$atd_option = 'AtD_guess_lang';
示例5: update_settings
//.........这里部分代码省略.........
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)) {
foreach ($jetpack_relatedposts_options as $key => $value) {
if ($value !== $old_relatedposts_options[$key]) {
$updated['jetpack_relatedposts_' . $key] = $value;
}
}
}
}
if (!empty($sharing_options) && class_exists('Sharing_Service')) {
$ss = new Sharing_Service();
// Merge current values with updated, since Sharing_Service expects
// all values to be included when updating
$current_sharing_options = $ss->get_global_options();
foreach ($current_sharing_options as $key => $val) {
if (!isset($sharing_options[$key])) {
$sharing_options[$key] = $val;
}
}
$updated_social_options = $ss->set_global_options($sharing_options);
if (isset($input['sharing_button_style'])) {
$updated['sharing_button_style'] = (string) $updated_social_options['button_style'];
}
if (isset($input['sharing_label'])) {
// Sharing_Service won't report label as updated if set to default
$updated['sharing_label'] = (string) $sharing_options['sharing_label'];
}
if (isset($input['sharing_show'])) {
$updated['sharing_show'] = (array) $updated_social_options['show'];
}
if (isset($input['sharing_open_links'])) {
$updated['sharing_open_links'] = (string) $updated_social_options['open_links'];
}
}
return array('updated' => $updated);
}
开发者ID:moushegh,项目名称:blog-source-configs,代码行数:101,代码来源:class.wpcom-json-api-site-settings-endpoint.php
示例6: update_settings
//.........这里部分代码省略.........
// These options can only be updated for sites hosted on WordPress.com
if (defined('IS_WPCOM') && IS_WPCOM) {
if (empty($value) || WPCOM_JSON_API::is_falsy($value)) {
if (delete_option($key)) {
$updated[$key] = null;
}
} else {
if (update_option($key, $value)) {
$updated[$key] = (int) $value;
}
}
}
break;
case 'holidaysnow':
if (empty($value) || WPCOM_JSON_API::is_falsy($value)) {
if (function_exists('jetpack_holiday_snow_option_name') && delete_option(jetpack_holiday_snow_option_name())) {
$updated[$key] = false;
}
} else {
if (function_exists('jetpack_holiday_snow_option_name') && update_option(jetpack_holiday_snow_option_name(), 'letitsnow')) {
$updated[$key] = true;
}
}
break;
case 'timezone_string':
// Map UTC+- timezones to gmt_offsets and set timezone_string to empty
// https://github.com/WordPress/WordPress/blob/4.4.2/wp-admin/options.php#L175
if (!empty($value) && preg_match('/^UTC[+-]/', $value)) {
$gmt_offset = preg_replace('/UTC\\+?/', '', $value);
if (update_option('gmt_offset', $gmt_offset)) {
$updated['gmt_offset'] = $gmt_offset;
}
$value = '';
}
// Always set timezone_string either with the given value or with an
// empty string
if (update_option($key, $value)) {
$updated[$key] = $value;
}
break;
default:
//allow future versions of this endpoint to support additional settings keys
if (has_filter('site_settings_endpoint_update_' . $key)) {
/**
* Filter current site setting value to be updated.
*
* @module json-api
*
* @since 3.9.3
*
* @param mixed $response_item A single site setting value.
*/
$value = apply_filters('site_settings_endpoint_update_' . $key, $value);
$updated[$key] = $value;
continue;
}
// no worries, we've already whitelisted and casted arguments above
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)) {
foreach ($jetpack_relatedposts_options as $key => $value) {
if ($value !== $old_relatedposts_options[$key]) {
$updated['jetpack_relatedposts_' . $key] = $value;
}
}
}
}
if (!empty($sharing_options) && class_exists('Sharing_Service')) {
$ss = new Sharing_Service();
// Merge current values with updated, since Sharing_Service expects
// all values to be included when updating
$current_sharing_options = $ss->get_global_options();
foreach ($current_sharing_options as $key => $val) {
if (!isset($sharing_options[$key])) {
$sharing_options[$key] = $val;
}
}
$updated_social_options = $ss->set_global_options($sharing_options);
if (isset($input['sharing_button_style'])) {
$updated['sharing_button_style'] = (string) $updated_social_options['button_style'];
}
if (isset($input['sharing_label'])) {
// Sharing_Service won't report label as updated if set to default
$updated['sharing_label'] = (string) $sharing_options['sharing_label'];
}
if (isset($input['sharing_show'])) {
$updated['sharing_show'] = (array) $updated_social_options['show'];
}
if (isset($input['sharing_open_links'])) {
$updated['sharing_open_links'] = (string) $updated_social_options['open_links'];
}
}
return array('updated' => $updated);
}