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


PHP Jetpack_Options::get_option_names方法代码示例

本文整理汇总了PHP中Jetpack_Options::get_option_names方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack_Options::get_option_names方法的具体用法?PHP Jetpack_Options::get_option_names怎么用?PHP Jetpack_Options::get_option_names使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jetpack_Options的用法示例。


在下文中一共展示了Jetpack_Options::get_option_names方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: options

 /**
  * Manage Jetpack Options
  *
  * ## OPTIONS
  *
  * list   : List all jetpack options and their values
  * delete : Delete an option
  *          - can only delete options that are white listed.
  * update : update an option
  *          - can only update option strings
  * get    : get the value of an option
  *
  * ## EXAMPLES
  *
  * wp jetpack options list
  * wp jetpack options get    <option_name>
  * wp jetpack options delete <option_name>
  * wp jetpack options update <option_name> [<option_value>]
  *
  * @synopsis <list|get|delete|update> [<option_name>] [<option_value>]
  */
 public function options($args, $assoc_args)
 {
     $action = isset($args[0]) ? $args[0] : 'list';
     $safe_to_modify = Jetpack::get_jetpack_options_for_reset();
     // Jumpstart is special
     array_push($safe_to_modify, 'jumpstart');
     // Is the option flagged as unsafe?
     $flagged = !in_array($args[1], $safe_to_modify);
     if (!in_array($action, array('list', 'get', 'delete', 'update'))) {
         WP_CLI::error(sprintf(__('%s is not a valid command.', 'jetpack'), $action));
     }
     if (isset($args[0])) {
         if ('get' == $args[0] && isset($args[1])) {
             $action = 'get';
         } else {
             if ('delete' == $args[0] && isset($args[1])) {
                 $action = 'delete';
             } else {
                 if ('update' == $args[0] && isset($args[1])) {
                     $action = 'update';
                 } else {
                     $action = 'list';
                 }
             }
         }
     }
     // Bail if the option isn't found
     $option = isset($args[1]) ? Jetpack_Options::get_option($args[1]) : false;
     if (isset($args[1]) && !$option && 'update' !== $args[0]) {
         WP_CLI::error(__('Option not found or is empty.  Use "list" to list option names', 'jetpack'));
     }
     // Let's print_r the option if it's an array
     // Used in the 'get' and 'list' actions
     $option = is_array($option) ? print_r($option) : $option;
     switch ($action) {
         case 'get':
             WP_CLI::success("\t" . $option);
             break;
         case 'delete':
             jetpack_cli_are_you_sure($flagged);
             Jetpack_Options::delete_option($args[1]);
             WP_CLI::success(sprintf(__('Deleted option: %s', 'jetpack'), $args[1]));
             break;
         case 'update':
             jetpack_cli_are_you_sure($flagged);
             // Updating arrays would get pretty tricky...
             $value = Jetpack_Options::get_option($args[1]);
             if ($value && is_array($value)) {
                 WP_CLI::error(__('Sorry, no updating arrays at this time', 'jetpack'));
             }
             Jetpack_Options::update_option($args[1], $args[2]);
             WP_CLI::success(sprintf(_x('Updated option: %s to "%s"', 'Updating an option from "this" to "that".', 'jetpack'), $args[1], $args[2]));
             break;
         case 'list':
             $options_compact = Jetpack_Options::get_option_names();
             $options_non_compact = Jetpack_Options::get_option_names('non_compact');
             $options_private = Jetpack_Options::get_option_names('private');
             $options = array_merge($options_compact, $options_non_compact, $options_private);
             // Table headers
             WP_CLI::line("\t" . str_pad(__('Option', 'jetpack'), 30) . __('Value', 'jetpack'));
             // List out the options and their values
             // Tell them if the value is empty or not
             // Tell them if it's an array
             foreach ($options as $option) {
                 $value = Jetpack_Options::get_option($option);
                 if (!$value) {
                     WP_CLI::line("\t" . str_pad($option, 30) . 'Empty');
                     continue;
                 }
                 if (!is_array($value)) {
                     WP_CLI::line("\t" . str_pad($option, 30) . $value);
                 } else {
                     if (is_array($value)) {
                         WP_CLI::line("\t" . str_pad($option, 30) . 'Array - Use "get <option>" to read option array.');
                     }
                 }
             }
             $option_text = '{' . _x('option', 'a variable command that a user can write, provided in the printed instructions', 'jetpack') . '}';
             $value_text = '{' . _x('value', 'the value that they want to update the option to', 'jetpack') . '}';
//.........这里部分代码省略.........
开发者ID:kanei,项目名称:vantuch.cz,代码行数:101,代码来源:class.jetpack-cli.php

示例2: get_option_names

 public static function get_option_names($type = 'compact')
 {
     return Jetpack_Options::get_option_names($type);
 }
开发者ID:lokenxo,项目名称:familygenerator,代码行数:4,代码来源:class.jetpack.php

示例3: get_jetpack_options_for_reset

 public static function get_jetpack_options_for_reset()
 {
     $jetpack_options = Jetpack_Options::get_option_names();
     $jetpack_options_non_compat = Jetpack_Options::get_option_names('non_compact');
     $jetpack_options_private = Jetpack_Options::get_option_names('private');
     $all_jp_options = array_merge($jetpack_options, $jetpack_options_non_compat, $jetpack_options_private);
     // A manual build of the wp options
     $wp_options = array('sharing-options', 'disabled_likes', 'disabled_reblogs', 'jetpack_comments_likes_enabled', 'wp_mobile_excerpt', 'wp_mobile_featured_images', 'wp_mobile_app_promos', 'stats_options', 'stats_dashboard_widget', 'safecss_preview_rev', 'safecss_rev', 'safecss_revision_migrated', 'nova_menu_order', 'jetpack_portfolio', 'jetpack_portfolio_posts_per_page', 'jetpack_testimonial', 'jetpack_testimonial_posts_per_page', 'wp_mobile_custom_css', 'sharedaddy_disable_resources', 'sharing-options', 'sharing-services', 'site_icon_temp_data', 'featured-content', 'site_logo');
     // Flag some Jetpack options as unsafe
     $unsafe_options = array('id', 'master_user', 'version', 'jumpstart', 'activated', 'register', 'blog_token', 'user_token', 'user_tokens');
     // Remove the unsafe Jetpack options
     foreach ($unsafe_options as $unsafe_option) {
         if (false !== ($key = array_search($unsafe_option, $all_jp_options))) {
             unset($all_jp_options[$key]);
         }
     }
     $options = array('jp_options' => $all_jp_options, 'wp_options' => $wp_options);
     return $options;
 }
开发者ID:jordankoschei,项目名称:jordankoschei-dot-com,代码行数:19,代码来源:class.jetpack.php


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