OSDN Git Service

Added confirmation check before regenerating all images
authorjmslbam <jmslbam@gmail.com>
Mon, 25 Feb 2013 22:42:51 +0000 (23:42 +0100)
committerjmslbam <jmslbam@gmail.com>
Mon, 25 Feb 2013 22:42:51 +0000 (23:42 +0100)
php/commands/media.php

index 5b11fb5..28cb8b4 100644 (file)
@@ -16,18 +16,20 @@ class Media_Command extends WP_CLI_Command {
     /**
      * Regenerate thumbnail(s)
      *
-     * @synopsis    [--id=<id>]
+     * @synopsis    [--id=<id>] [--yes]
      * props @benmay & @Viper007Bond
      */
     function regenerate( $args, $assoc_args = array() ) {
         global $wpdb;
 
         $vars = wp_parse_args( $assoc_args, array(
-            'id' => false,
+            'id' => false
         ) );
 
         extract($vars, EXTR_SKIP);
 
+        WP_CLI::confirm('Do you realy want to regenerate all images?', $assoc_args);
+
         $where_clause = ( $id ) ? "AND ID = $id" : '';
 
         if ( !$images = $wpdb->get_results( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' $where_clause AND post_mime_type LIKE 'image/%' ORDER BY ID DESC" ) ) {