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


PHP WP_CLI::print_value方法代码示例

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


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

示例1: verify_api_keys

 /**
  * Verifies the API keys entered will work for writing and deleting from S3.
  *
  * @subcommand verify
  */
 public function verify_api_keys()
 {
     S3_Uploads::get_instance();
     // Boot
     $upload_dir = wp_upload_dir();
     // The upload file location on the local filesystem
     $s3_path = $upload_dir['basedir'] . '/' . mt_rand() . '.jpg';
     // Attempt to copy the file to S3
     WP_CLI::print_value('Attempting to upload file ' . $s3_path);
     // Copy canola from the test dir, upto S3
     $copy = copy(dirname(dirname(__FILE__)) . '/tests/data/canola.jpg', $s3_path);
     // Check that copy worked
     if (!$copy) {
         WP_CLI::error('Failed to copy / write to S3 - check your policy?');
         return;
     }
     WP_CLI::print_value('File uploaded to S3 successfully');
     // Delete off S3
     WP_CLI::print_value('Attempting to delete file ' . $s3_path);
     $delete = unlink($s3_path);
     // Check that delete worked
     if (!$delete) {
         WP_CLI::error('Failed to delete ' . $s3_path);
         return;
     }
     WP_CLI::print_value('File deleted from S3 successfully');
     WP_CLI::success('Looks like your configuration is correct.');
 }
开发者ID:automationforamerica,项目名称:S3-Uploads,代码行数:33,代码来源:class-s3-uploads-wp-cli-command.php

示例2: perform_option_action

 /**
  * Perform an option action on a remote site
  */
 private function perform_option_action($action, $args, $assoc_args)
 {
     $site_id = $assoc_args['site-id'];
     unset($assoc_args['site-id']);
     list($option_name) = $args;
     $this->set_account();
     $method = strtoupper($action);
     if ('update' == $action) {
         $method = 'POST';
         $api_args = array('option_value' => WP_CLI::read_value($args[1], $assoc_args));
     } else {
         $api_args = array();
     }
     $args = array('endpoint' => 'site/' . (int) $site_id . '/option/' . $option_name, 'method' => $method, 'body' => $api_args);
     $response = $this->api_request($args);
     if (is_wp_error($response)) {
         WP_CLI::error($response->get_error_message());
     }
     switch ($action) {
         case 'get':
             if (empty($response)) {
                 die(1);
             }
             WP_CLI::print_value($response, $assoc_args);
             break;
         case 'update':
             WP_CLI::success("Updated '{$option_name}' option.");
             break;
         case 'delete':
             WP_CLI::success("Deleted '{$option_name}' option.");
             break;
     }
 }
开发者ID:gokuale,项目名称:wp-remote-cli,代码行数:36,代码来源:class-wp-remote-option-command.php

示例3: verify_api_keys

 /**
  * Verifies the API keys entered will work for writing and deleting from S3.
  *
  * @subcommand verify
  */
 public function verify_api_keys()
 {
     // Verify first that we have the necessary access keys to connect to S3.
     if (!$this->verify_s3_access_constants()) {
         return;
     }
     // Get S3 Upload instance.
     $instance = S3_Uploads::get_instance();
     // Create a path in the base directory, with a random file name to avoid potentially overwriting existing data.
     $upload_dir = wp_upload_dir();
     $s3_path = $upload_dir['basedir'] . '/' . mt_rand() . '.jpg';
     // Attempt to copy the local Canola test file to the generated path on S3.
     WP_CLI::print_value('Attempting to upload file ' . $s3_path);
     $copy = copy(dirname(dirname(__FILE__)) . '/tests/data/canola.jpg', $s3_path);
     // Check that the copy worked.
     if (!$copy) {
         WP_CLI::error('Failed to copy / write to S3 - check your policy?');
         return;
     }
     WP_CLI::print_value('File uploaded to S3 successfully.');
     // Delete the file off S3.
     WP_CLI::print_value('Attempting to delete file. ' . $s3_path);
     $delete = unlink($s3_path);
     // Check that the delete worked.
     if (!$delete) {
         WP_CLI::error('Failed to delete ' . $s3_path);
         return;
     }
     WP_CLI::print_value('File deleted from S3 successfully.');
     WP_CLI::success('Looks like your configuration is correct.');
 }
开发者ID:iamlos,项目名称:S3-Uploads,代码行数:36,代码来源:class-s3-uploads-wp-cli-command.php

示例4: emit

 /**
  * Emit the message in specified format
  *
  * @params $format string optional - options are "raw","json"
  */
 public static function emit($format = 'raw')
 {
     $messenger = self::instance();
     switch ($format) {
         case 'pantheon':
         case 'json':
             $formatted = array();
             foreach ($messenger->messages as $message) {
                 $formatted[$message['name']] = $message;
             }
             \WP_CLI::print_value($formatted, array('format' => 'json'));
             break;
         case 'raw':
         case 'default':
             foreach ($messenger->messages as $message) {
                 // colorize
                 if ($message['score'] == 2) {
                     $color = "%G";
                 } elseif ($message['score'] == 0) {
                     $color = "%C";
                 } else {
                     $color = "%R";
                 }
                 // @todo might be a better way to do this
                 echo \cli\Colors::colorize(sprintf(str_repeat('-', 80) . PHP_EOL . "%s: (%s) \n%s\nResult:%s %s\nRecommendation: %s\n\n" . PHP_EOL, strtoupper($message['label']), $message['description'], str_repeat('-', 80), $color, $message['result'] . '%n', $message['action']));
             }
             break;
     }
 }
开发者ID:ThemeSurgeon,项目名称:wp_launch_check,代码行数:34,代码来源:messenger.php

示例5: debug

 /**
  * Debug object cache hit / miss ratio for any page URL.
  *
  * ## OPTIONS
  *
  * [--url=<url>]
  * : Execute a request against a specified URL. Defaults to home_url( '/' ).
  *
  * [--format=<format>]
  * : Render the results in a particular format.
  *
  * @when before_wp_load
  */
 public function debug($_, $assoc_args)
 {
     global $wp_object_cache;
     $this->load_wordpress_with_template();
     $data = array('cache_hits' => $wp_object_cache->cache_hits, 'cache_misses' => $wp_object_cache->cache_misses, 'redis_calls' => $wp_object_cache->redis_calls);
     WP_CLI::print_value($data, $assoc_args);
 }
开发者ID:pantheon-systems,项目名称:wp-redis,代码行数:20,代码来源:cli.php

示例6: get

 /**
  * Get an option.
  *
  * @synopsis <key> [--format=<format>]
  */
 public function get($args, $assoc_args)
 {
     list($key) = $args;
     $value = get_option($key);
     if (false === $value) {
         die(1);
     }
     WP_CLI::print_value($value, $assoc_args);
 }
开发者ID:adeagboola,项目名称:wordpress-to-jekyll-exporter,代码行数:14,代码来源:option.php

示例7: get

 /**
  * Get meta field value.
  *
  * @synopsis <id> <key> [--format=<format>]
  */
 public function get($args, $assoc_args)
 {
     list($object_id, $meta_key) = $args;
     $value = \get_metadata($this->meta_type, $object_id, $meta_key, true);
     if ('' === $value) {
         die(1);
     }
     \WP_CLI::print_value($value, $assoc_args);
 }
开发者ID:nb,项目名称:wp-cli,代码行数:14,代码来源:CommandWithMeta.php

示例8: get

 /**
  * Get a transient value.
  *
  * @synopsis <key> [--json]
  */
 public function get($args, $assoc_args)
 {
     list($key) = $args;
     $value = get_transient($key);
     if (false === $value) {
         WP_CLI::warning('Transient with key "' . $key . '" is not set.');
         exit;
     }
     WP_CLI::print_value($value, $assoc_args);
 }
开发者ID:nb,项目名称:wp-cli,代码行数:15,代码来源:transient.php

示例9: get

 /**
  * Get meta field value
  *
  * @param array $args
  * @param array $assoc_args
  **/
 public function get($args, $assoc_args)
 {
     $object_id = WP_CLI::get_numeric_arg($args, 0, "{$this->meta_type} ID");
     $meta_key = self::get_arg_or_error($args, 1, "meta_key");
     $value = get_metadata($this->meta_type, $object_id, $meta_key, true);
     if ('' === $value) {
         die(1);
     }
     WP_CLI::print_value($value, $assoc_args);
 }
开发者ID:roelven,项目名称:wp-cli,代码行数:16,代码来源:class-wp-cli-command-with-meta.php

示例10: get

 /**
  * Get a transient value.
  *
  * ## OPTIONS
  *
  * <key>
  * : Key for the transient.
  *
  * [--format=<format>]
  * : Render output in a particular format.
  * ---
  * default: table
  * options:
  *   - table
  *   - csv
  *   - json
  *   - yaml
  * ---
  *
  * [--network]
  * : Get the value of the network transient, instead of the single site.
  *
  * ## EXAMPLES
  *
  *     $ wp transient get sample_key
  *     test data
  *
  *     $ wp transient get random_key
  *     Warning: Transient with key "random_key" is not set.
  */
 public function get($args, $assoc_args)
 {
     list($key) = $args;
     $func = \WP_CLI\Utils\get_flag_value($assoc_args, 'network') ? 'get_site_transient' : 'get_transient';
     $value = $func($key);
     if (false === $value) {
         WP_CLI::warning('Transient with key "' . $key . '" is not set.');
         exit;
     }
     WP_CLI::print_value($value, $assoc_args);
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:41,代码来源:transient.php

示例11: add_posts

 public function add_posts($args, $assoc_args)
 {
     $i = 0;
     $wp_cat_id = null;
     if (empty($this->mt_data)) {
         $this->init($args[0], $args[1]);
     }
     foreach ($this->mt_data->entry as $mt_entry) {
         $mt_entry = (array) $mt_entry;
         $mt_entry_atts = $mt_entry['@attributes'];
         if (!empty($mt_entry_atts['title']) && $i < $this->import_limit) {
             $date_stamp = strtotime($mt_entry_atts['authored_on']);
             $postdate = date("Y-m-d H:i:s", $date_stamp);
             $args = array('post_title' => $mt_entry_atts['title'], 'post_author' => $this->author_id, 'post_date' => $postdate, 'post_status' => 'publish', 'post_type' => 'property', 'post_excerpt' => !empty($mt_entry['excerpt']) ? $mt_entry['excerpt'] : '', 'post_content' => !empty($mt_entry['text']) ? $mt_entry['text'] : '');
             $mt_entry_cats = $this->get_mt_categories($mt_entry_atts['id']);
             if (!empty($mt_entry_cats) && in_array(5, $mt_entry_cats)) {
                 $args['post_type'] = 'post';
                 WP_CLI::print_value($mt_entry);
                 WP_CLI::print_value($args);
             }
             // $post_id = $this->create_post( $args );
             // $this->add_post_to_category( $post_id, $mt_entry_cats );
             // if ( ! in_array( 5, $mt_entry_cats ) ) {
             // 	$post_meta = array(
             // 		'name' => ! empty( $mt_entry_atts['field.property-name'] ) ? $mt_entry_atts['field.property-name'] : '',
             // 		'architect' => ! empty( $mt_entry_atts['field.property-architect'] ) ? $mt_entry_atts['field.property-architect'] : '',
             // 		'address' => ! empty( $mt_entry['field.property-address'] ) ? $mt_entry['field.property-address'] : '',
             // 		'price' => ! empty( $mt_entry_atts['field.property-price'] ) ? $mt_entry_atts['field.property-price'] : '',
             // 		'status' => ! empty( $mt_entry_atts['field.property-status'] ) ? $mt_entry_atts['field.property-status'] : '',
             // 		'listing-number' => ! empty( $mt_entry_atts['field.property-listing-number'] ) ? $mt_entry_atts['field.property-listing-number'] : '',
             // 		'listing-provided-by' => ! empty( $mt_entry_atts['field.property-listing-provided-by'] ) ? $mt_entry_atts['field.property-listing-provided-by'] : '',
             // 		'type' => ! empty( $mt_entry_atts['field.property-type'] ) ? $mt_entry_atts['field.property-type'] : '',
             // 		'bedrooms' => ! empty( $mt_entry_atts['field.property-bedrooms'] ) ? $mt_entry_atts['field.property-bedrooms'] : '',
             // 		'bathrooms' => ! empty( $mt_entry_atts['field.property-bathrooms'] ) ? $mt_entry_atts['field.property-bathrooms'] : '',
             // 		'square-footage' => ! empty( $mt_entry_atts['field.property-square-footage'] ) ? $mt_entry_atts['field.property-square-footage'] : '',
             // 		'lot-size' => ! empty( $mt_entry_atts['field.property-lot-size'] ) ? $mt_entry_atts['field.property-lot-size'] : '',
             // 		'year-built' => ! empty( $mt_entry_atts['field.property-year-built'] ) ? $mt_entry_atts['field.property-year-built'] : '',
             // 		'parking' => ! empty( $mt_entry_atts['field.property-parking'] ) ? $mt_entry_atts['field.property-parking'] : '',
             // 		'fireplaces' => ! empty( $mt_entry_atts['field.property-fireplaces'] ) ? $mt_entry_atts['field.property-fireplaces'] : '',
             // 		'amenities' => ! empty( $mt_entry['field.property-amenities'] ) ? $mt_entry['field.property-amenities'] : '',
             // 		'appliances' => ! empty( $mt_entry['field.property-appliances'] ) ? $mt_entry['field.property-appliances'] : '',
             // 		'features' => ! empty( $mt_entry['field.property-featured'] ) ? $mt_entry['field.property-features'] : ''
             // 	);
             // 	$this->set_post_meta( $post_id, $post_meta );
             // 	$this->add_images( $post_id, $mt_entry_atts['id'] );
             // } else {
             // 	WP_CLI::line( 'blog post' );
             // }
         }
         $i++;
     }
 }
开发者ID:amaschas,项目名称:architecturalhomesny,代码行数:52,代码来源:import.php

示例12: get

 /**
  * Get an option
  *
  * @param array $args
  **/
 public function get($args, $assoc_args)
 {
     if (empty($args)) {
         WP_CLI::line("usage: wp option get <option-name>");
         exit;
     }
     list($key) = $args;
     $value = get_option($key);
     if (false === $value) {
         die(1);
     }
     WP_CLI::print_value($value, $assoc_args);
 }
开发者ID:roelven,项目名称:wp-cli,代码行数:18,代码来源:option.php

示例13: incr

 /**
  * Increment a value in the object cache.
  *
  * @synopsis <key> [<offset>] [<group>]
  */
 public function incr($args, $assoc_args)
 {
     $key = $args[0];
     $offset = isset($args[1]) ? $args[1] : 1;
     $group = isset($args[2]) ? $args[2] : '';
     $value = wp_cache_incr($key, $offset, $group);
     if (false === $value) {
         WP_CLI::error('The value was not incremented.');
     }
     WP_CLI::print_value($value, $assoc_args);
 }
开发者ID:adeagboola,项目名称:wordpress-to-jekyll-exporter,代码行数:16,代码来源:cache.php

示例14: show_multiple_fields

 /**
  * Show multiple fields of an object.
  *
  * @param object|array Data to display
  * @param string Format to display the data in
  */
 private function show_multiple_fields($data, $format)
 {
     $true_fields = array();
     foreach ($this->args['fields'] as $field) {
         $true_fields[] = $this->find_item_key($data, $field);
     }
     foreach ($data as $key => $value) {
         if (!in_array($key, $true_fields)) {
             if (is_array($data)) {
                 unset($data[$key]);
             } else {
                 if (is_object($data)) {
                     unset($data->{$key});
                 }
             }
         }
     }
     switch ($format) {
         case 'table':
         case 'csv':
             $rows = $this->assoc_array_to_rows($data);
             $fields = array('Field', 'Value');
             if ('table' == $format) {
                 self::show_table($rows, $fields);
             } else {
                 if ('csv' == $format) {
                     \WP_CLI\Utils\write_csv(STDOUT, $rows, $fields);
                 }
             }
             break;
         case 'yaml':
         case 'json':
             \WP_CLI::print_value($data, array('format' => $format));
             break;
         default:
             \WP_CLI::error("Invalid format: " . $format);
             break;
     }
 }
开发者ID:ryanshoover,项目名称:wp-cli,代码行数:45,代码来源:Formatter.php

示例15: write_log

 /**
  * Print to WP_CLI if in CLI environment or
  * write to debug.log if WP_DEBUG is enabled
  * @source http://www.stumiller.me/sending-output-to-the-wordpress-debug-log/
  *
  * @param mixed $msg
  * @param string $write
  */
 public static function write_log($msg, $write = 'line')
 {
     if (defined('WP_CLI') && WP_CLI) {
         if (is_array($msg) || is_object($msg)) {
             WP_CLI::print_value($msg);
         } else {
             WP_CLI::$write($msg);
         }
     } elseif (true === WP_DEBUG) {
         if (is_array($msg) || is_object($msg)) {
             error_log(print_r($msg, true));
         } else {
             error_log($msg);
         }
     }
 }
开发者ID:AramZS,项目名称:wordpress-github-sync,代码行数:24,代码来源:wp-github-sync.php


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