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


PHP WP_CLI::out方法代码示例

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


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

示例1: _list

 /**
  * Get a list of posts.
  *
  * @subcommand list
  * @synopsis [--<field>=<value>] [--ids]
  */
 public function _list($_, $assoc_args)
 {
     $query_args = array('posts_per_page' => -1);
     foreach ($assoc_args as $key => $value) {
         if (true === $value) {
             continue;
         }
         $query_args[$key] = $value;
     }
     if (isset($assoc_args['ids'])) {
         $query_args['fields'] = 'ids';
     }
     $query = new WP_Query($query_args);
     if (isset($assoc_args['ids'])) {
         WP_CLI::out(implode(' ', $query->posts));
     } else {
         $fields = array('ID', 'post_title', 'post_name', 'post_date');
         $table = new \cli\Table();
         $table->setHeaders($fields);
         foreach ($query->posts as $post) {
             $line = array();
             foreach ($fields as $field) {
                 $line[] = $post->{$field};
             }
             $table->addRow($line);
         }
         $table->display();
     }
 }
开发者ID:nunomorgadinho,项目名称:wp-cli,代码行数:35,代码来源:post.php

示例2: _list

 /**
  * List users.
  *
  * @subcommand list
  * @synopsis [--role=<role>] [--ids]
  */
 public function _list($args, $assoc_args)
 {
     global $blog_id;
     $params = array('blog_id' => $blog_id, 'fields' => isset($assoc_args['ids']) ? 'ids' : 'all_with_meta');
     if (array_key_exists('role', $assoc_args)) {
         $params['role'] = $assoc_args['role'];
     }
     $users = get_users($params);
     if (isset($assoc_args['ids'])) {
         WP_CLI::out(implode(' ', $users));
         return;
     }
     $fields = array('ID', 'user_login', 'display_name', 'user_email', 'user_registered');
     $table = new \cli\Table();
     $table->setHeaders(array_merge($fields, array('roles')));
     foreach ($users as $user) {
         $line = array();
         foreach ($fields as $field) {
             $line[] = $user->{$field};
         }
         $line[] = implode(',', $user->roles);
         $table->addRow($line);
     }
     $table->display();
     WP_CLI::line('Total: ' . count($users) . ' users');
 }
开发者ID:netcon-source,项目名称:wp-cli,代码行数:32,代码来源:user.php

示例3: single_command_help

 private function single_command_help($name, $command)
 {
     WP_CLI::out('    wp ' . $name);
     $methods = WP_CLI_Command::get_subcommands($command);
     if (!empty($methods)) {
         WP_CLI::out(' [' . implode('|', $methods) . ']');
     }
     WP_CLI::line(' ...');
 }
开发者ID:netconstructor,项目名称:wp-cli,代码行数:9,代码来源:help.php

示例4: confirm

 private static function confirm($question, $assoc_args)
 {
     if (!isset($assoc_args['yes'])) {
         WP_CLI::out($question . " [y/n] ");
         $answer = trim(fgets(STDIN));
         if ('y' != $answer) {
             exit;
         }
     }
 }
开发者ID:nunomorgadinho,项目名称:wp-cli,代码行数:10,代码来源:db.php

示例5: reset

 /**
  * Removes all tables from the database.
  */
 function reset($args, $assoc_args)
 {
     if (!isset($assoc_args['yes'])) {
         WP_CLI::out("Are you sure you want to reset the database? [y/n] ");
         $answer = trim(fgets(STDIN));
         if ('y' != $answer) {
             return;
         }
     }
     WP_CLI::launch(self::create_cmd('mysql --host=%s --user=%s --password=%s --execute=%s', DB_HOST, DB_USER, DB_PASSWORD, 'DROP DATABASE IF EXISTS ' . DB_NAME));
     WP_CLI::launch(self::create_cmd('mysql --host=%s --user=%s --password=%s --execute=%s', DB_HOST, DB_USER, DB_PASSWORD, 'CREATE DATABASE ' . DB_NAME));
     WP_CLI::success("Database reset.");
 }
开发者ID:roelven,项目名称:wp-cli,代码行数:16,代码来源:db.php

示例6: o

 /**
  * Print string
  *
  * @param string $string
  */
 protected static function o($string)
 {
     \WP_CLI::out($string);
 }
开发者ID:hametuha,项目名称:wpametu,代码行数:9,代码来源:Command.php

示例7: fetch_counts

 /**
  * Pull sharedcount for all posts
  *
  * ## OPTIONS
  *
  * [--parallelize=<n_of_m>]
  * : Process only every N of M attachments, formatted as N/M. Useful for doing large batches quickly, optimizing the CPU. Wrap in a shell script to iterate 0 < N < M and reap the benefits.
  *
  */
 function fetch_counts($args, $assoc_args = array())
 {
     // Clean the output buffer. Not sure why this exists.
     ob_end_clean();
     // Either every single post...
     $every_n = 0;
     $of_m = 1;
     // Or a set of them to parallelize pages
     if (!empty($assoc_args['parallelize']) && preg_match('#^(\\d+)/(\\d+)$#', $assoc_args['parallelize'], $matches)) {
         $every_n = (int) $matches[1];
         $of_m = (int) $matches[2];
     }
     $query_args = array('meta_query' => array('relation' => 'OR', array('key' => 'sharedcount_updated', 'type' => 'DATETIME', 'value' => gmdate('Y-m-d H:i:s', time() - 3600), 'compare' => '<'), array('key' => 'sharedcount_updated', 'compare' => 'NOT EXISTS')), 'posts_per_page' => 50, 'paged' => $every_n);
     do {
         $query = new WP_Query(apply_filters('sharedcount_update_query', $query_args));
         foreach ($query->posts as $post) {
             $current = (int) get_post_meta($post->ID, 'sharedcount_count', true);
             WP_CLI::out("Getting sharecount for {$post->ID} `{$post->post_title}` (current: {$current}) ... ");
             $counts = SharedCount::get_counts(get_permalink($post));
             if (!empty($counts)) {
                 $count = (int) $counts['total'];
                 WP_CLI::out($count . '... ');
                 if ($current < $count) {
                     WP_CLI::out(' Updating');
                     update_post_meta($post->ID, 'sharedcount_count', $count);
                 }
             }
             WP_CLI::line();
             update_post_meta($post->ID, 'sharedcount_updated', current_time('mysql', true));
         }
         $query_args['paged'] += $of_m;
     } while ($query->max_num_pages > $query_args['paged']);
 }
开发者ID:oomphinc,项目名称:sharedcount,代码行数:42,代码来源:sharedcount.php

示例8: prompt

 /**
  * Prompt for some input from the user
  */
 private function prompt($message)
 {
     WP_CLI::out(trim($message) . " ");
     return trim(fgets(STDIN));
 }
开发者ID:gokuale,项目名称:wp-remote-cli,代码行数:8,代码来源:class-wp-remote-command.php


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