OSDN Git Service

Instead of using bash unzip, using WP_CLI native theme install, with optional activate
authorBrandon Lavigne <B@Brandons-Mac-Pro-4.local>
Tue, 5 Feb 2013 03:40:41 +0000 (19:40 -0800)
committerBrandon Lavigne <B@Brandons-Mac-Pro-4.local>
Tue, 5 Feb 2013 03:40:41 +0000 (19:40 -0800)
php/commands/scaffold.php

index 8a64ab0..5e5f466 100644 (file)
@@ -141,6 +141,9 @@ class Scaffold_Command extends WP_CLI_Command {
 
                $theme_slug = $args[0];
                $theme_path = WP_CONTENT_DIR . "/themes";
+               $zip_path  = $theme_path.'/underscores.zip';
+               $activate = ( isset( $assoc_args['activate'] ) ) ? 1 : 0;
+
                $data = wp_parse_args( $assoc_args, array(
                        'theme_name' => ucfirst( $theme_slug ),
                        'author' => "Me",
@@ -154,18 +157,15 @@ class Scaffold_Command extends WP_CLI_Command {
                $prepare .= ' -d underscoresme_description="'.$theme_description.'"';
                $prepare .= ' -d underscoresme_generate_submit="Generate"';
                $prepare .= ' -d underscoresme_generate="1"';
-               $prepare .= ' http://underscores.me > '.$theme_path.'/underscores.zip';
-               $prepare .= ' && unzip -d '.$theme_path.' '.$theme_path.'/underscores.zip && rm '.$theme_path.'/underscores.zip';
-               
-               shell_exec($prepare); // Don't know the WordPress way of doing this.
-               
-               WP_CLI::success( "Created Theme: ".$data['theme_name'] );
+               $prepare .= ' http://underscores.me > '.$zip_path;
                
+               shell_exec($prepare);
+
+               WP_CLI::run_command( array( 'theme', 'install', $zip_path ), array( 'activate' => $activate ) );
 
-               if ( isset( $assoc_args['activate'] ) )
-                       WP_CLI::run_command( array( 'theme', 'activate', $theme_slug ) );
        }
 
+
        private function get_output_path( $assoc_args, $subdir ) {
                extract( $assoc_args, EXTR_SKIP );