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


PHP WP_CLI::line方法代码示例

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


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

示例1: import_from_csv

 /**
  * Bulk import redirects from a CSV file matching the following structure:
  *
  * redirect_from_path,(redirect_to_post_id|redirect_to_path|redirect_to_url)
  *
  * @subcommand import-from-csv
  * @synopsis --csv=<path-to-csv>
  */
 function import_from_csv($args, $assoc_args)
 {
     define('WP_IMPORTING', true);
     if (empty($assoc_args['csv']) || !file_exists($assoc_args['csv'])) {
         WP_CLI::error("Invalid 'csv' file");
     }
     global $wpdb;
     if (($handle = fopen($assoc_args['csv'], "r")) !== FALSE) {
         while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
             $row++;
             $redirect_from = $data[0];
             $redirect_to = $data[1];
             WP_CLI::line("Adding (CSV) redirect for {$redirect_from} to {$redirect_to}");
             WP_CLI::line("-- at {$row}");
             WPCOM_Legacy_Redirector::insert_legacy_redirect($redirect_from, $redirect_to);
             if (0 == $row % 100) {
                 if (function_exists('stop_the_insanity')) {
                     stop_the_insanity();
                 }
                 sleep(1);
             }
         }
         fclose($handle);
     }
 }
开发者ID:humanmade,项目名称:vip-mu-plugins-public,代码行数:33,代码来源:wp-cli.php

示例2: add

 /**
  * ## OPTIONS
  *
  * [--name=<name>]
  * : Consumer name
  *
  * [--description=<description>]
  * : Consumer description
  */
 public function add($_, $args)
 {
     $consumer = WP_REST_OAuth1_Client::create($args);
     WP_CLI::line(sprintf('ID: %d', $consumer->ID));
     WP_CLI::line(sprintf('Key: %s', $consumer->key));
     WP_CLI::line(sprintf('Secret: %s', $consumer->secret));
 }
开发者ID:danielbachhuber,项目名称:OAuth1,代码行数:16,代码来源:class-wp-rest-oauth1-cli.php

示例3: get_queue

 /**
  * Retrieve the current event queue
  *
  * @subcommand get-queue
  */
 public function get_queue($args, $assoc_args)
 {
     // Build and make request
     $queue_request = new \WP_REST_Request('POST', '/' . \Automattic\WP\Cron_Control\REST_API::API_NAMESPACE . '/' . \Automattic\WP\Cron_Control\REST_API::ENDPOINT_LIST);
     $queue_request->add_header('Content-Type', 'application/json');
     $queue_request->set_body(wp_json_encode(array('secret' => \WP_CRON_CONTROL_SECRET)));
     $queue_request = rest_do_request($queue_request);
     // Oh well
     if ($queue_request->is_error()) {
         \WP_CLI::error($queue_request->as_error()->get_error_message());
     }
     // Get the decoded JSON object returned by the API
     $queue_response = $queue_request->get_data();
     // No events, nothing more to do
     if (empty($queue_response['events'])) {
         \WP_CLI::warning(__('No events in the current queue', 'automattic-cron-control'));
         return;
     }
     // Prepare items for display
     $events_for_display = $this->format_events($queue_response['events']);
     $total_events_to_display = count($events_for_display);
     \WP_CLI::line(sprintf(_n('Displaying one event', 'Displaying %s events', $total_events_to_display, 'automattic-cron-control'), number_format_i18n($total_events_to_display)));
     // And reformat
     $format = 'table';
     if (isset($assoc_args['format'])) {
         if ('ids' === $assoc_args['format']) {
             \WP_CLI::error(__('Invalid output format requested', 'automattic-cron-control'));
         } else {
             $format = $assoc_args['format'];
         }
     }
     \WP_CLI\Utils\format_items($format, $events_for_display, array('timestamp', 'action', 'instance', 'scheduled_for', 'internal_event', 'schedule_name', 'event_args'));
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:38,代码来源:class-rest-api.php

示例4: general_help

    private function general_help()
    {
        WP_CLI::line('Available commands:');
        foreach (WP_CLI::load_all_commands() as $command => $class) {
            if ('help' == $command) {
                continue;
            }
            $out = "    wp {$command}";
            $methods = WP_CLI_Command::get_subcommands($class);
            if (!empty($methods)) {
                $out .= ' [' . implode('|', $methods) . ']';
            }
            WP_CLI::line($out);
        }
        WP_CLI::line(<<<EOB

See 'wp help <command>' for more information on a specific command.

Global parameters:
    --user=<id|login>   set the current user
    --url=<url>         set the current URL
    --path=<path>       set the current path to the WP install
    --require=<path>    load a certain file before running the command
    --quiet             suppress informational messages
    --version           print wp-cli version
EOB
);
    }
开发者ID:roelven,项目名称:wp-cli,代码行数:28,代码来源:help.php

示例5: completions

 /**
  * Generate tab completion strings.
  */
 function completions()
 {
     foreach (WP_CLI::get_root_command()->get_subcommands() as $name => $command) {
         $subcommands = $command->get_subcommands();
         WP_CLI::line($name . ' ' . implode(' ', array_keys($subcommands)));
     }
 }
开发者ID:nb,项目名称:wp-cli,代码行数:10,代码来源:cli.php

示例6: sync

 public function sync($args, $assoc_args)
 {
     $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser());
     WP_CLI::line('Syncing ' . MainWP_DB::num_rows($websites) . ' sites');
     $warnings = 0;
     $errors = 0;
     while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
         WP_CLI::line('  -> ' . $website->name . ' (' . $website->url . ')');
         try {
             if (MainWP_Sync::syncSite($website)) {
                 WP_CLI::success('  Sync succeeded');
             } else {
                 WP_CLI::warning('  Sync failed');
                 $warnings++;
             }
         } catch (Exception $e) {
             WP_CLI::error('  Sync failed');
             $errors++;
         }
     }
     @MainWP_DB::free_result($websites);
     if ($errors > 0) {
         WP_CLI::error('Sync completed with errors');
     } else {
         if ($warnings > 0) {
             WP_CLI::warning('Sync completed with warnings');
         } else {
             WP_CLI::success('Sync completed');
         }
     }
 }
开发者ID:jexmex,项目名称:mainwp,代码行数:31,代码来源:class-mainwp-wp-cli-command.php

示例7: test

 public function test($args = array(), $assoc_args = array())
 {
     WP_CLI::line('Processing ... ');
     WP_CLI::line(print_r($args, true));
     WP_CLI::line(print_r($assoc_args, true));
     WP_CLI::success('Success!');
 }
开发者ID:joshcanhelp,项目名称:wp-starter,代码行数:7,代码来源:wp-cli.php

示例8: __invoke

 /**
  * Reset the post_date field on your posts.
  * A sadly necessary step after you change your timezone in WordPress
  * 
  * @synopsis --post_type=<post-type>
  */
 public function __invoke($args, $assoc_args)
 {
     global $wpdb;
     $query_args = array('post_type' => $assoc_args['post_type'], 'posts_per_page' => -1, 'post_status' => 'publish');
     $query = new WP_Query($query_args);
     if (empty($query->posts)) {
         WP_CLI::error("No posts found");
     }
     WP_CLI::line(sprintf("Updating post_date on %d posts.", count($query->posts)));
     foreach ($query->posts as $key => $post) {
         if (empty($post->post_date_gmt) || "0000-00-00 00:00:00" == $post->post_date_gmt) {
             WP_CLI::line(sprintf("Error: Post %d is missing a publish date.", $post->ID));
             continue;
         }
         $original = $post->post_date;
         $new = get_date_from_gmt($post->post_date_gmt);
         if ($new == $original) {
             WP_CLI::line(sprintf("No Change: Post %d has the correct post_date of %s", $post->ID, $original));
             continue;
         }
         $wpdb->update($wpdb->posts, array('post_date' => $new), array('ID' => $post->ID));
         clean_post_cache($post->ID);
         WP_CLI::line(sprintf("Updated: Post %d changed from %s to %s", $post->ID, $original, $new));
         if ($key && $key % 10 == 0) {
             sleep(1);
         }
     }
     WP_CLI::success("Posts were updated with the correct post_date.");
 }
开发者ID:danielbachhuber,项目名称:wp-cli-reset-post-date-command,代码行数:35,代码来源:wp-cli-reset-post-date-command.php

示例9: create

 /**
  * Create a user.
  *
  * @synopsis <user-login> <user-email> [--role=<role>] [--porcelain]
  */
 public function create($args, $assoc_args)
 {
     global $blog_id;
     list($user_login, $user_email) = $args;
     $defaults = array('role' => get_option('default_role'), 'user_pass' => wp_generate_password(), 'user_registered' => strftime("%F %T", time()), 'display_name' => false);
     extract(wp_parse_args($assoc_args, $defaults), EXTR_SKIP);
     if ('none' == $role) {
         $role = false;
     } elseif (is_null(get_role($role))) {
         WP_CLI::error("Invalid role.");
     }
     $user_id = wp_insert_user(array('user_email' => $user_email, 'user_login' => $user_login, 'user_pass' => $user_pass, 'user_registered' => $user_registered, 'display_name' => $display_name, 'role' => $role));
     if (is_wp_error($user_id)) {
         WP_CLI::error($user_id);
     } else {
         if (false === $role) {
             delete_user_option($user_id, 'capabilities');
             delete_user_option($user_id, 'user_level');
         }
     }
     if (isset($assoc_args['porcelain'])) {
         WP_CLI::line($user_id);
     } else {
         WP_CLI::success("Created user {$user_id}.");
     }
 }
开发者ID:navitronic,项目名称:wp-cli-1,代码行数:31,代码来源:user.php

示例10: recheck_queue

 /**
  * Recheck all comments in the Pending queue.
  *
  * ## EXAMPLES
  *
  *     wp akismet recheck_queue
  *
  * @alias recheck-queue
  */
 public function recheck_queue()
 {
     $batch_size = 100;
     $start = 0;
     $total_counts = array();
     do {
         $result_counts = Akismet_Admin::recheck_queue_portion($start, $batch_size);
         if ($result_counts['processed'] > 0) {
             foreach ($result_counts as $key => $count) {
                 if (!isset($total_counts[$key])) {
                     $total_counts[$key] = $count;
                 } else {
                     $total_counts[$key] += $count;
                 }
             }
             $start += $batch_size;
             $start -= $result_counts['spam'];
             // These comments will have been removed from the queue.
         }
     } while ($result_counts['processed'] > 0);
     WP_CLI::line(sprintf(_n("Processed %d comment.", "Processed %d comments.", $total_counts['processed'], 'akismet'), number_format($total_counts['processed'])));
     WP_CLI::line(sprintf(_n("%d comment moved to Spam.", "%d comments moved to Spam.", $total_counts['spam'], 'akismet'), number_format($total_counts['spam'])));
     if ($total_counts['error']) {
         WP_CLI::line(sprintf(_n("%d comment could not be checked.", "%d comments could not be checked.", $total_counts['error'], 'akismet'), number_format($total_counts['error'])));
     }
 }
开发者ID:coreymargulis,项目名称:karenmargulis,代码行数:35,代码来源:class.akismet-cli.php

示例11: __invoke

 /**
  * Import originals for a project from a file
  *
  * ## OPTIONS
  *
  * <project>
  * : Project name
  *
  * <file>
  * : File to import from
  *
  * [--format=<format>]
  * : Accepted values: po, mo, android, resx, strings. Default: po
  */
 public function __invoke($args, $assoc_args)
 {
     // Double-check for compatibility
     if ($args[0] === '-p' || $args[1] === '-f') {
         WP_CLI::error(__('-p and -f are no longer required and should be removed.', 'glotpress'));
     }
     $project = GP::$project->by_path($args[0]);
     if (!$project) {
         WP_CLI::error(__('Project not found!', 'glotpress'));
     }
     $format = isset($assoc_args['format']) ? $assoc_args['format'] : 'po';
     $format = gp_array_get(GP::$formats, $format, null);
     if (!$format) {
         WP_CLI::error(__('No such format.', 'glotpress'));
     }
     $translations = $format->read_originals_from_file($args[1], $project);
     if (!$translations) {
         WP_CLI::error(__("Couldn't load translations from file!", 'glotpress'));
     }
     list($originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted, $originals_error) = GP::$original->import_for_project($project, $translations);
     $notice = sprintf(__('%1$s new strings added, %2$s updated, %3$s fuzzied, and %4$s obsoleted.', 'glotpress'), $originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted);
     if ($originals_error) {
         $notice = ' ' . sprintf(_n('%s new string was not imported due to an error.', '%s new strings were not imported due to an error.', $originals_error, 'glotpress'), $originals_error);
     }
     WP_CLI::line($notice);
 }
开发者ID:ramiy,项目名称:GlotPress-WP,代码行数:40,代码来源:import-originals.php

示例12: status

 /**
  * get status of settings
  *
  * ## EXAMPLES
  *
  *     wp multi-device status
  *
  */
 public function status($args, $assoc_args)
 {
     $options = get_option($this->options);
     $rows = array();
     $slug_table = array('None' => '');
     $themes = wp_get_themes();
     foreach ($themes as $theme_slug => $header) {
         $slug_table[$header->get('Name')] = $theme_slug;
     }
     $rows[] = array('Device' => 'smartphone (Smart Phone)', 'Theme' => $options['theme_smartphone'], 'Slug' => $slug_table[$options['theme_smartphone']], 'UserAgent' => $options['userAgent_smart']);
     $rows[] = array('Device' => 'tablet (Tablet PC)', 'Theme' => $options['theme_tablet'], 'Slug' => $slug_table[$options['theme_tablet']], 'UserAgent' => $options['userAgent_tablet']);
     $rows[] = array('Device' => 'mobile (Mobile Phone)', 'Theme' => $options['theme_mobile'], 'Slug' => $slug_table[$options['theme_mobile']], 'UserAgent' => $options['userAgent_mobile']);
     $rows[] = array('Device' => 'game (Game Platforms)', 'Theme' => $options['theme_game'], 'Slug' => $slug_table[$options['theme_game']], 'UserAgent' => $options['userAgent_game']);
     foreach ($options as $custom_switcher_option => $custom_switcher_theme) {
         if (!preg_match('/^custom_switcher_theme_/', $custom_switcher_option)) {
             continue;
         }
         $custom_switcher_name = preg_replace('/^custom_switcher_theme_/', '', $custom_switcher_option);
         $rows[] = array('Device' => $custom_switcher_name, 'Theme' => $options['custom_switcher_theme_' . $custom_switcher_name], 'Slug' => $slug_table[$options['custom_switcher_theme_' . $custom_switcher_name]], 'UserAgent' => $options['custom_switcher_userAgent_' . $custom_switcher_name]);
     }
     $default_theme = wp_get_theme()->get('Name');
     $default_theme .= ' | ';
     $default_theme .= get_stylesheet();
     WP_CLI::line('Active Theme: ' . $default_theme);
     WP_CLI\Utils\format_items('table', $rows, array('Device', 'Theme', 'Slug', 'UserAgent'));
     $line = '';
     $line .= 'PC Switcher: ';
     $line .= $options['pc_switcher'] ? 'on' : 'off';
     $line .= "\n";
     $line .= 'default CSS: ';
     $line .= $options['default_css'] ? 'on' : 'off';
     WP_CLI::line($line);
 }
开发者ID:dragonwzj,项目名称:multi-device-switcher,代码行数:41,代码来源:wp-cli.php

示例13: _list

 /**
  * Show a list of users with super-admin capabilities.
  *
  * @subcommand list
  */
 public function _list($_, $assoc_args)
 {
     $super_admins = self::get_admins();
     foreach ($super_admins as $user_login) {
         WP_CLI::line($user_login);
     }
 }
开发者ID:Jaace,项目名称:wp-cli,代码行数:12,代码来源:super-admin.php

示例14: flush

 /**
  * Flush All CloudFront Cache
  *
  * ## OPTIONS
  * <post_id>
  * post_id
  *
  * [--force]
  * Activate Force Clear Mode
  *
  * ## EXAMPLES
  *
  *     wp c3 flush <post_id>       : Flush <post_id>'s CloudFront Cache.
  *     wp c3 flush all             : Flush All CloudFront Cache.
  *     wp c3 flush all --force     : Flush All CloudFront Cache.( Force )
  *
  * @param string $args: WP-CLI Command Name
  * @param string $assoc_args: WP-CLI Command Option
  * @since 2.3.0
  */
 function flush($args, $assoc_args)
 {
     WP_CLI::line('Start to Clear CloudFront Cache...');
     if (empty($args)) {
         WP_CLI::error('Please input parameter:post_id(numeric) or all');
         exit;
     }
     list($type) = $args;
     $c3 = CloudFront_Clear_Cache::get_instance();
     if (array_search('force', $assoc_args)) {
         WP_CLI::line('Force Clear Mode');
         add_filter('c3_invalidation_flag', '__return_false');
     }
     if ('all' == $type) {
         WP_CLI::line('Clear Item = All');
         $result = $c3->c3_invalidation();
     } elseif (is_numeric($type)) {
         WP_CLI::line("Clear Item = (post_id={$type})");
         $result = $c3->c3_invalidation($type);
     } else {
         WP_CLI::error('Please input parameter:post_id(numeric) or all');
         exit;
     }
     if (!is_wp_error($result)) {
         WP_CLI::success("Create Invalidation Request. Please wait few minutes to finished clear CloudFront Cache.");
     }
 }
开发者ID:amimoto-ami,项目名称:c3-cloudfront-clear-cache,代码行数:47,代码来源:cli.php

示例15: list_

 /**
  * List capabilities for a given role.
  *
  * <role>
  * : Key for the role.
  *
  * ## EXAMPLES
  *
  *     # Display alphabetical list of bbPress moderator capabilities
  *     wp cap list 'bbp_moderator' | sort
  *
  * @subcommand list
  */
 public function list_($args)
 {
     $role_obj = self::get_role($args[0]);
     foreach (array_keys($role_obj->capabilities) as $cap) {
         WP_CLI::line($cap);
     }
 }
开发者ID:Jaace,项目名称:wp-cli,代码行数:20,代码来源:cap.php


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