本文整理匯總了PHP中WPCOM_JSON_API::is_falsy方法的典型用法代碼示例。如果您正苦於以下問題:PHP WPCOM_JSON_API::is_falsy方法的具體用法?PHP WPCOM_JSON_API::is_falsy怎麽用?PHP WPCOM_JSON_API::is_falsy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WPCOM_JSON_API
的用法示例。
在下文中一共展示了WPCOM_JSON_API::is_falsy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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
示例2: update_settings
//.........這裏部分代碼省略.........
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)) {
$updated[$key] = (bool) $value;
}
break;
case 'jetpack_testimonial_posts_per_page':
case 'jetpack_portfolio_posts_per_page':
// settings are stored as numeric
$coerce_value = (int) $value;
if (update_option($key, $coerce_value)) {
$updated[$key] = $coerce_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;
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