當前位置: 首頁>>代碼示例>>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方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: migrate_attachments_to_s3

 /**
  * @subcommand migrate-attachments
  * @synopsis [--delete-local]
  */
 public function migrate_attachments_to_s3($args, $args_assoc)
 {
     $attachments = new WP_Query(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'all'));
     WP_CLI::line(sprintf('Attempting to move %d attachments to S3', $attachments->found_posts));
     foreach ($attachments->posts as $attachment) {
         $this->migrate_attachment_to_s3(array($attachment->ID), $args_assoc);
     }
     WP_CLI::success('Moved all attachment to S3. If you wish to update references in your database run: ');
     WP_CLI::line('');
     $old_upload_dir = S3_Uploads::get_instance()->get_original_upload_dir();
     $upload_dir = wp_upload_dir();
     WP_CLI::Line(sprintf('wp search-replace "%s" "%s"', $old_upload_dir['baseurl'], $upload_dir['baseurl']));
 }
開發者ID:automationforamerica,項目名稱:S3-Uploads,代碼行數:17,代碼來源:class-s3-uploads-wp-cli-command.php

示例2: purge

 /**
  * Migrates records from the legacy custom tables into custom post type
  *
  * ## OPTIONS
  *
  * [<days_old>]
  * Delete entries older than this many days, defaults to whatever you
  * have configured in the plugin settings
  *
  * --dry-run
  * Shows number of entries that would be deleted but does not
  * delete them
  * 
  * ## EXAMPLES
  *
  *     wp rest-api-log purge
  *
  *     wp rest-api-log purge 90
  *
  * @synopsis [<days_old>] [--dry-run]
  */
 function purge($positional_args, $assoc_args = array())
 {
     $days_old = absint(!empty($positional_args[0]) ? $positional_args[0] : 0);
     $dry_run = !empty($assoc_args['dry-run']);
     WP_CLI::Line("Purging old REST API log entries...");
     $log = new WP_REST_API_Log();
     $number_deleted = $log->purge_old_records($days_old, $dry_run);
     WP_CLI::Success(sprintf("%d entries purged", $number_deleted));
 }
開發者ID:petenelson,項目名稱:wp-rest-api-log,代碼行數:30,代碼來源:class-wp-rest-api-log-wp-cli-log.php


注:本文中的WP_CLI::Line方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。