当前位置: 首页>>代码示例>>PHP>>正文


PHP WPCOM_JSON_API::is_falsy方法代码示例

本文整理汇总了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
开发者ID:kanei,项目名称:vantuch.cz,代码行数:67,代码来源:class.wpcom-json-api-site-settings-endpoint.php


注:本文中的WPCOM_JSON_API::is_falsy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。