OSDN Git Service

Using WP_CLI::warning
authorjmslbam <jmslbam@gmail.com>
Sun, 3 Mar 2013 16:20:12 +0000 (17:20 +0100)
committerjmslbam <jmslbam@gmail.com>
Sun, 3 Mar 2013 16:20:12 +0000 (17:20 +0100)
php/commands/media.php

index 67ac71d..0380849 100644 (file)
@@ -59,14 +59,14 @@ class Media_Command extends WP_CLI_Command {
         $image = get_post( $id );
         
         if ( !$image || 'attachment' != $image->post_type || 'image/' != substr( $image->post_mime_type, 0, 6 ) ) {
-            WP_CLI::warning( "FAILED: {$image->post_title} - invalid image ID" );
+            WP_CLI::warning( "{$image->post_title} - invalid image ID" );
             return;
         }
         
         $fullsizepath = get_attached_file( $image->ID );
         
         if ( false === $fullsizepath || !file_exists( $fullsizepath ) ) {
-            WP_CLI::warning( "FAILED: {$image->post_title} -  Can't find it $fullsizepath" );
+            WP_CLI::warning( "{$image->post_title} -  Can't find it $fullsizepath" );
             return;
         }
         
@@ -118,12 +118,12 @@ class Media_Command extends WP_CLI_Command {
         $metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );
         
         if ( is_wp_error( $metadata ) ) {
-            WP_CLI::line( $metadata->get_error_message() );
+            WP_CLI::warning( $metadata->get_error_message() );
             return;
         }
         
         if ( empty( $metadata ) ) {
-            WP_CLI::line( 'Unknown failure reason.' );
+            WP_CLI::warning( 'Unknown failure reason.' );
             return;
         }
         wp_update_attachment_metadata( $image->ID, $metadata );