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


PHP WP_CLI::warning方法代码示例

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


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

示例1: check

 /**
  * Checks one or more comments against the Akismet API.
  *
  * ## OPTIONS
  * <comment_id>...
  * : The ID(s) of the comment(s) to check.
  *
  * [--noaction]
  * : Don't change the status of the comment. Just report what Akismet thinks it is.
  *
  * ## EXAMPLES
  *
  *     wp akismet check 12345
  *
  * @alias comment-check
  */
 public function check($args, $assoc_args)
 {
     foreach ($args as $comment_id) {
         if (isset($assoc_args['noaction'])) {
             // Check the comment, but don't reclassify it.
             $api_response = Akismet::check_db_comment($comment_id, 'wp-cli');
         } else {
             $api_response = Akismet::recheck_comment($comment_id, 'wp-cli');
         }
         if ('true' === $api_response) {
             WP_CLI::line(sprintf(__("Comment #%d is spam.", 'akismet'), $comment_id));
         } else {
             if ('false' === $api_response) {
                 WP_CLI::line(sprintf(__("Comment #%d is not spam.", 'akismet'), $comment_id));
             } else {
                 if (false === $api_response) {
                     WP_CLI::error(__("Failed to connect to Akismet.", 'akismet'));
                 } else {
                     if (is_wp_error($api_response)) {
                         WP_CLI::warning(sprintf(__("Comment #%d could not be checked.", 'akismet'), $comment_id));
                     }
                 }
             }
         }
     }
 }
开发者ID:coreymargulis,项目名称:karenmargulis,代码行数:42,代码来源:class.akismet-cli.php

示例2: users

 /**
  * Generate users
  *
  * @param array $args
  * @param array $assoc_args
  **/
 public function users($args, $assoc_args)
 {
     global $blog_id;
     $defaults = array('count' => 100, 'role' => get_option('default_role'));
     extract(wp_parse_args($assoc_args, $defaults), EXTR_SKIP);
     if ('none' == $role) {
         $role = false;
     } elseif (is_null(get_role($role))) {
         WP_CLI::warning("invalid role.");
         exit;
     }
     $user_count = count_users();
     $total = $user_count['total_users'];
     $limit = $count + $total;
     $notify = new \cli\progress\Bar('Generating users', $count);
     for ($i = $total; $i < $limit; $i++) {
         $login = sprintf('user_%d_%d', $blog_id, $i);
         $name = "User {$i}";
         $user_id = wp_insert_user(array('user_login' => $login, 'user_pass' => $login, 'nickname' => $name, 'display_name' => $name, 'role' => $role));
         if (false === $role) {
             delete_user_option($user_id, 'capabilities');
             delete_user_option($user_id, 'user_level');
         }
         $notify->tick();
     }
     $notify->finish();
 }
开发者ID:roelven,项目名称:wp-cli,代码行数:33,代码来源:generate.php

示例3: install

 /**
  * Run wp_install. Assumes that wp-config.php is already in place.
  */
 public function install($args, $assoc_args)
 {
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     if (is_blog_installed()) {
         WP_CLI::error('WordPress is already installed.');
     }
     extract(wp_parse_args($assoc_args, array('site_url' => defined('WP_SITEURL') ? WP_SITEURL : '', 'site_title' => '', 'admin_name' => 'admin', 'admin_email' => '', 'admin_password' => '')), EXTR_SKIP);
     $missing = false;
     foreach (array('site_url', 'site_title', 'admin_email', 'admin_password') as $required_arg) {
         if (empty(${$required_arg})) {
             WP_CLI::warning("missing --{$required_arg} parameter");
             $missing = true;
         }
     }
     if ($site_url) {
         WP_CLI::set_url($site_url);
     }
     if ($missing) {
         exit(1);
     }
     $public = true;
     $result = wp_install($site_title, $admin_name, $admin_email, $public, '', $admin_password);
     if (is_wp_error($result)) {
         WP_CLI::error('Installation failed (' . WP_CLI::errorToString($result) . ').');
     } else {
         WP_CLI::success('WordPress installed successfully.');
     }
 }
开发者ID:noahmuller,项目名称:wp-cli,代码行数:31,代码来源:core.php

示例4: export

 /**
  * Export the translation set
  *
  * ## OPTIONS
  *
  * <project>
  * : Project path
  *
  * <locale>
  * : Locale to export
  *
  * [--set=<set>]
  * : Translation set slug; default is "default"
  *
  * [--format=<format>]
  * : Format for output (one of "po", "mo", "android", "resx", "strings"; default is "po")
  *
  * [--search=<search>]
  * : Search term
  *
  * [--status=<status>]
  * : Translation string status; default is "current"
  *
  * [--priority=<priorities>]
  * : Original priorities, comma separated. Possible values are "hidden,low,normal,high"
  */
 public function export($args, $assoc_args)
 {
     $set_slug = isset($assoc_args['set']) ? $assoc_args['set'] : 'default';
     $translation_set = $this->get_translation_set($args[0], $args[1], $set_slug);
     if (is_wp_error($translation_set)) {
         WP_CLI::error($translation_set->get_error_message());
     }
     $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'));
     }
     $filters = array();
     if (isset($assoc_args['search'])) {
         $filters['term'] = $assoc_args['search'];
     }
     $filters['status'] = isset($assoc_args['status']) ? $assoc_args['status'] : 'current';
     if (isset($assoc_args['priority'])) {
         $filters['priority'] = array();
         $priorities = explode(',', $assoc_args['priority']);
         $valid_priorities = GP::$original->get_static('priorities');
         foreach ($priorities as $priority) {
             $key = array_search($priority, $valid_priorities);
             if (false === $key) {
                 WP_CLI::warning(sprintf('Invalid priority %s', $priority));
             } else {
                 $filters['priority'][] = $key;
             }
         }
     }
     $entries = GP::$translation->for_export($this->project, $translation_set, $filters);
     WP_CLI::line($format->print_exported_file($this->project, $this->locale, $translation_set, $entries));
 }
开发者ID:ramiy,项目名称:GlotPress-WP,代码行数:59,代码来源:translation-set.php

示例5: 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

示例6: blank_media_fix

 /**
  * Fixes issues with slow saving in wp-admin due to no audio/video media files
  *
  * Core Ticket: https://core.trac.wordpress.org/ticket/31071
  *
  * eg.: `wp vip-go-one-time-fixers blank-media-fix --allow-root --url=beta.thesun.co.uk`
  *
  * @subcommand blank-media-fix
  */
 public function blank_media_fix($args, $assoc_args)
 {
     if (!function_exists('wpcom_vip_download_image')) {
         WP_CLI::error('This script requires the wpcom_vip_download_image() function, https://vip.wordpress.com/functions/wpcom_vip_download_image/');
     }
     $audio_file_url = 'https://cldup.com/xmre07YagX.mp3';
     // 1sec.mp3
     $video_file_url = 'https://cldup.com/KHsK5yZkvv.avi';
     // 1sec.avi
     $args = array('post_type' => 'attachment', 'post_status' => 'inherit', 'meta_query' => array(array('key' => '_vip_blank_media_fix', 'value' => 'video')));
     $video_query = new WP_Query($args);
     if (!$video_query->post_count) {
         WP_CLI::log('Video fix not found, applying...');
         $video_file_id = $this->wpcom_vip_download_image($video_file_url, 0, 'VIP: Fix for slow post saving');
         if (!is_wp_error($video_file_id)) {
             $args = array('ID' => $video_file_id, 'post_date' => '2000-01-01', 'post_date_gmt' => '2000-01-01', 'post_modified' => '2000-01-01', 'post_modified_gmt' => '2000-01-01');
             $updated_video_file_id = wp_update_post($args, true);
             if (!is_wp_error($updated_video_file_id)) {
                 WP_CLI::success('Video fix applied');
                 $video_meta = update_post_meta($updated_video_file_id, '_vip_blank_media_fix', 'video');
                 if (false === $video_meta) {
                     WP_CLI::warning('Could not update video _vip_blank_media_fix meta');
                 }
             } else {
                 // Video date was not updated
                 WP_CLI::error($updated_video_file_id->get_error_message());
             }
         } else {
             // Sideload failed
             WP_CLI::error($video_file_id->get_error_message());
         }
     } else {
         WP_CLI::warning('Blank video fix already exists for this site');
     }
     $args = array('post_type' => 'attachment', 'post_status' => 'inherit', 'meta_query' => array(array('key' => '_vip_blank_media_fix', 'value' => 'audio')));
     $audio_query = new WP_Query($args);
     if (!$audio_query->post_count) {
         WP_CLI::log('Audio fix not found, applying...');
         $audio_file_id = $this->wpcom_vip_download_image($audio_file_url, 0, 'VIP: Fix for slow post saving');
         if (!is_wp_error($audio_file_id)) {
             $args = array('ID' => $audio_file_id, 'post_date' => '2000-01-01', 'post_date_gmt' => '2000-01-01', 'post_modified' => '2000-01-01', 'post_modified_gmt' => '2000-01-01');
             $updated_audio_file_id = wp_update_post($args, true);
             if (!is_wp_error($updated_audio_file_id)) {
                 WP_CLI::success('Audio fix applied');
                 $audio_meta = update_post_meta($updated_audio_file_id, '_vip_blank_media_fix', 'audio');
                 if (false === $audio_meta) {
                     WP_CLI::warning('Could not update audio _vip_blank_media_fix meta');
                 }
             } else {
                 // Audio date was not updated
                 WP_CLI::error($updated_audio_file_id->get_error_message());
             }
         } else {
             // Sideload failed
             WP_CLI::error($video_file_id->get_error_message());
         }
     } else {
         WP_CLI::warning('Blank video fix already exists for this site');
     }
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:69,代码来源:vip-fixers.php

示例7: 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

示例8: log

 private function log($msg, $error = false)
 {
     if ($error) {
         WP_CLI::error($msg);
     }
     WP_CLI::warning($msg);
 }
开发者ID:JayWood,项目名称:eve-profit,代码行数:7,代码来源:import.php

示例9: add

 /**
  * Grant super-admin privileges to one or more users.
  *
  * <user>...
  * : One or more user IDs, user emails, or user logins.
  */
 public function add($args, $_)
 {
     $users = $this->fetcher->get_many($args);
     $user_logins = wp_list_pluck($users, 'user_login');
     $super_admins = self::get_admins();
     $num_super_admins = count($super_admins);
     foreach ($user_logins as $user_login) {
         $user = get_user_by('login', $user_login);
         if (!$user) {
             WP_CLI::warning("Couldn't find {$user_login} user.");
             continue;
         }
         if (in_array($user->user_login, $super_admins)) {
             WP_CLI::warning("User {$user_login} already has super-admin capabilities.");
             continue;
         }
         $super_admins[] = $user->user_login;
     }
     if ($num_super_admins === count($super_admins)) {
         WP_CLI::log('No changes.');
     } else {
         if (update_site_option('site_admins', $super_admins)) {
             WP_CLI::success('Granted super-admin capabilities.');
         } else {
             WP_CLI::error('Site options update failed!');
         }
     }
 }
开发者ID:Jaace,项目名称:wp-cli,代码行数:34,代码来源:super-admin.php

示例10: error

 function error($error)
 {
     if (!$error) {
         return;
     }
     // TODO: show all errors, not just the first one
     WP_CLI::warning(WP_CLI::errorToString($error));
 }
开发者ID:bytewang,项目名称:wp-cli,代码行数:8,代码来源:class-cli-upgrader-skin.php

示例11: wp_redirect_handler

function wp_redirect_handler($url)
{
    \WP_CLI::warning('Some code is trying to do a URL redirect. Backtrace:');
    ob_start();
    debug_print_backtrace();
    fwrite(STDERR, ob_get_clean());
    return $url;
}
开发者ID:wp-cli,项目名称:wp-cli,代码行数:8,代码来源:utils-wp.php

示例12: flush_internal_caches

 /**
  * Flush the cache
  *
  * @subcommand flush
  */
 public function flush_internal_caches($args, $assoc_args)
 {
     $flushed = \Automattic\WP\Cron_Control\_flush_internal_caches();
     if ($flushed) {
         \WP_CLI::success(__('Internal caches cleared', 'automattic-cron-control'));
     } else {
         \WP_CLI::warning(__('No caches to clear', 'automattic-cron-control'));
     }
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:14,代码来源:class-cache.php

示例13: migrate

 /**
  * Run a migration.
  *
  * ## OPTIONS
  *
  * <profile>
  * : ID of the profile to use for the migration.
  *
  * ## EXAMPLES
  *
  * 	wp wpmdb migrate 1
  *
  * @synopsis <profile>
  *
  * @since 1.0
  */
 public function migrate($args, $assoc_args)
 {
     $profile = $args[0];
     $result = wpmdb_migrate($profile);
     if (true === $result) {
         WP_CLI::success(__('Migration successful.', 'wp-migrate-db-pro-cli'));
         return;
     }
     WP_CLI::warning($result->get_error_message());
     return;
 }
开发者ID:GaryJones,项目名称:m2xdemo,代码行数:27,代码来源:command.php

示例14: error

 function error($error)
 {
     if (!$error) {
         return;
     }
     if (is_string($error) && isset($this->upgrader->strings[$error])) {
         $error = $this->upgrader->strings[$error];
     }
     // TODO: show all errors, not just the first one
     \WP_CLI::warning($error);
 }
开发者ID:ryanshoover,项目名称:wp-cli,代码行数:11,代码来源:UpgraderSkin.php

示例15: success_or_failure

 protected function success_or_failure($r)
 {
     list($type, $msg) = $r;
     if ('success' == $type) {
         \WP_CLI::success($msg);
         $status = 0;
     } else {
         \WP_CLI::warning($msg);
         $status = 1;
     }
     return $status;
 }
开发者ID:nb,项目名称:wp-cli,代码行数:12,代码来源:CommandWithDBObject.php


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