diff --git a/features/scaffold-taxonomy.feature b/features/scaffold-taxonomy.feature
index 73a986e4..f6b367a8 100644
--- a/features/scaffold-taxonomy.feature
+++ b/features/scaffold-taxonomy.feature
@@ -19,7 +19,7 @@ Feature: Scaffold a custom taxonomy
"""
And STDOUT should contain:
"""
- $messages['fungus'] = [
+ $messages['fungus'] = array(
"""
And STDOUT should contain:
"""
diff --git a/features/scaffold.feature b/features/scaffold.feature
index 23aee121..b92b7b48 100644
--- a/features/scaffold.feature
+++ b/features/scaffold.feature
@@ -116,7 +116,7 @@ Feature: WordPress code scaffolding
"""
And STDOUT should contain:
"""
- [ 'prefix-zombie', 'wraith' ]
+ array( 'prefix-zombie', 'wraith' )
"""
And STDOUT should contain:
"""
diff --git a/src/Scaffold_Command.php b/src/Scaffold_Command.php
index 99734daa..f841a586 100644
--- a/src/Scaffold_Command.php
+++ b/src/Scaffold_Command.php
@@ -178,7 +178,23 @@ private function scaffold( $slug, $assoc_args, $defaults, $subdir, $templates )
if ( ! $control_args['raw'] ) {
$vars['machine_name'] = $machine_name;
- $vars['output'] = $raw_output;
+ $vars['output'] = rtrim( $raw_output );
+
+ $target_slug = '';
+
+ if ( false !== $control_args['theme'] ) {
+ $target_slug = $control_args['theme'];
+ } elseif ( false !== $control_args['plugin'] ) {
+ $target_slug = $control_args['plugin'];
+ }
+
+ $target_name = ( $target_slug ) ? $this->generate_machine_name( $target_slug ) : '';
+
+ if ( empty( $target_name ) ) {
+ $target_name = $machine_name;
+ }
+
+ $vars['prefix'] = $target_name;
$final_output = self::mustache_render( $extended_template, $vars );
} else {
diff --git a/templates/post_type.mustache b/templates/post_type.mustache
index 8f731a4a..7115162a 100644
--- a/templates/post_type.mustache
+++ b/templates/post_type.mustache
@@ -1,7 +1,7 @@
register_post_type(
'{{slug}}',
- [
- 'labels' => [
+ array(
+ 'labels' => array(
'name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
'singular_name' => __( '{{label_ucfirst}}', '{{textdomain}}' ),
'all_items' => __( 'All {{label_plural_ucfirst}}', '{{textdomain}}' ),
@@ -27,12 +27,12 @@
'not_found_in_trash' => __( 'No {{label_plural}} found in trash', '{{textdomain}}' ),
'parent_item_colon' => __( 'Parent {{label_ucfirst}}:', '{{textdomain}}' ),
'menu_name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
- ],
+ ),
'public' => true,
'hierarchical' => false,
'show_ui' => true,
'show_in_nav_menus' => true,
- 'supports' => [ 'title', 'editor' ],
+ 'supports' => array( 'title', 'editor' ),
'has_archive' => true,
'rewrite' => true,
'query_var' => true,
@@ -41,5 +41,5 @@
'show_in_rest' => true,
'rest_base' => '{{slug}}',
'rest_controller_class' => 'WP_REST_Posts_Controller',
- ]
+ )
);
diff --git a/templates/post_type_extended.mustache b/templates/post_type_extended.mustache
index adb4d9dc..288fa1c9 100644
--- a/templates/post_type_extended.mustache
+++ b/templates/post_type_extended.mustache
@@ -1,13 +1,18 @@
'', // Unused. Messages start at index 1.
/* translators: %s: post permalink */
1 => sprintf( __( '{{label_ucfirst}} updated. View {{label}}', '{{textdomain}}' ), esc_url( $permalink ) ),
@@ -38,12 +43,12 @@ function {{machine_name}}_updated_messages( $messages ) {
9 => sprintf( __( '{{label_ucfirst}} scheduled for: %1$s. Preview {{label}}', '{{textdomain}}' ), date_i18n( __( 'M j, Y @ G:i', '{{textdomain}}' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ),
/* translators: %s: post permalink */
10 => sprintf( __( '{{label_ucfirst}} draft updated. Preview {{label}}', '{{textdomain}}' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
- ];
+ );
return $messages;
}
-add_filter( 'post_updated_messages', '{{machine_name}}_updated_messages' );
+add_filter( 'post_updated_messages', '{{prefix}}_updated_messages' );
/**
* Sets the bulk post updated messages for the `{{machine_name}}` post type.
@@ -53,10 +58,10 @@ add_filter( 'post_updated_messages', '{{machine_name}}_updated_messages' );
* @param int[] $bulk_counts Array of item counts for each message, used to build internationalized strings.
* @return array Bulk messages for the `{{machine_name}}` post type.
*/
-function {{machine_name}}_bulk_updated_messages( $bulk_messages, $bulk_counts ) {
+function {{prefix}}_bulk_updated_messages( $bulk_messages, $bulk_counts ) {
global $post;
- $bulk_messages['{{slug}}'] = [
+ $bulk_messages['{{slug}}'] = array(
/* translators: %s: Number of {{label_plural}}. */
'updated' => _n( '%s {{label}} updated.', '%s {{label_plural}} updated.', $bulk_counts['updated'], '{{textdomain}}' ),
'locked' => ( 1 === $bulk_counts['locked'] ) ? __( '1 {{label}} not updated, somebody is editing it.', '{{textdomain}}' ) :
@@ -68,9 +73,9 @@ function {{machine_name}}_bulk_updated_messages( $bulk_messages, $bulk_counts )
'trashed' => _n( '%s {{label}} moved to the Trash.', '%s {{label_plural}} moved to the Trash.', $bulk_counts['trashed'], '{{textdomain}}' ),
/* translators: %s: Number of {{label_plural}}. */
'untrashed' => _n( '%s {{label}} restored from the Trash.', '%s {{label_plural}} restored from the Trash.', $bulk_counts['untrashed'], '{{textdomain}}' ),
- ];
+ );
return $bulk_messages;
}
-add_filter( 'bulk_post_updated_messages', '{{machine_name}}_bulk_updated_messages', 10, 2 );
+add_filter( 'bulk_post_updated_messages', '{{prefix}}_bulk_updated_messages', 10, 2 );
diff --git a/templates/taxonomy.mustache b/templates/taxonomy.mustache
index 3d9aca11..6f5ea895 100644
--- a/templates/taxonomy.mustache
+++ b/templates/taxonomy.mustache
@@ -1,42 +1,46 @@
- register_taxonomy( '{{slug}}', [ {{post_types}} ], [
- 'hierarchical' => false,
- 'public' => true,
- 'show_in_nav_menus' => true,
- 'show_ui' => true,
- 'show_admin_column' => false,
- 'query_var' => true,
- 'rewrite' => true,
- 'capabilities' => [
- 'manage_terms' => 'edit_posts',
- 'edit_terms' => 'edit_posts',
- 'delete_terms' => 'edit_posts',
- 'assign_terms' => 'edit_posts',
- ],
- 'labels' => [
- 'name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
- 'singular_name' => _x( '{{label_ucfirst}}', 'taxonomy general name', '{{textdomain}}' ),
- 'search_items' => __( 'Search {{label_plural_ucfirst}}', '{{textdomain}}' ),
- 'popular_items' => __( 'Popular {{label_plural_ucfirst}}', '{{textdomain}}' ),
- 'all_items' => __( 'All {{label_plural_ucfirst}}', '{{textdomain}}' ),
- 'parent_item' => __( 'Parent {{label_ucfirst}}', '{{textdomain}}' ),
- 'parent_item_colon' => __( 'Parent {{label_ucfirst}}:', '{{textdomain}}' ),
- 'edit_item' => __( 'Edit {{label_ucfirst}}', '{{textdomain}}' ),
- 'update_item' => __( 'Update {{label_ucfirst}}', '{{textdomain}}' ),
- 'view_item' => __( 'View {{label_ucfirst}}', '{{textdomain}}' ),
- 'add_new_item' => __( 'Add New {{label_ucfirst}}', '{{textdomain}}' ),
- 'new_item_name' => __( 'New {{label_ucfirst}}', '{{textdomain}}' ),
- 'separate_items_with_commas' => __( 'Separate {{label_plural}} with commas', '{{textdomain}}' ),
- 'add_or_remove_items' => __( 'Add or remove {{label_plural}}', '{{textdomain}}' ),
- 'choose_from_most_used' => __( 'Choose from the most used {{label_plural}}', '{{textdomain}}' ),
- 'not_found' => __( 'No {{label_plural}} found.', '{{textdomain}}' ),
- 'no_terms' => __( 'No {{label_plural}}', '{{textdomain}}' ),
- 'menu_name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
- 'items_list_navigation' => __( '{{label_plural_ucfirst}} list navigation', '{{textdomain}}' ),
- 'items_list' => __( '{{label_plural_ucfirst}} list', '{{textdomain}}' ),
- 'most_used' => _x( 'Most Used', '{{slug}}', '{{textdomain}}' ),
- 'back_to_items' => __( '← Back to {{label_plural_ucfirst}}', '{{textdomain}}' ),
- ],
- 'show_in_rest' => true,
- 'rest_base' => '{{slug}}',
- 'rest_controller_class' => 'WP_REST_Terms_Controller',
- ] );
+ register_taxonomy(
+ '{{slug}}',
+ array( {{post_types}} ),
+ array(
+ 'hierarchical' => false,
+ 'public' => true,
+ 'show_in_nav_menus' => true,
+ 'show_ui' => true,
+ 'show_admin_column' => false,
+ 'query_var' => true,
+ 'rewrite' => true,
+ 'capabilities' => array(
+ 'manage_terms' => 'edit_posts',
+ 'edit_terms' => 'edit_posts',
+ 'delete_terms' => 'edit_posts',
+ 'assign_terms' => 'edit_posts',
+ ),
+ 'labels' => array(
+ 'name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
+ 'singular_name' => _x( '{{label_ucfirst}}', 'taxonomy general name', '{{textdomain}}' ),
+ 'search_items' => __( 'Search {{label_plural_ucfirst}}', '{{textdomain}}' ),
+ 'popular_items' => __( 'Popular {{label_plural_ucfirst}}', '{{textdomain}}' ),
+ 'all_items' => __( 'All {{label_plural_ucfirst}}', '{{textdomain}}' ),
+ 'parent_item' => __( 'Parent {{label_ucfirst}}', '{{textdomain}}' ),
+ 'parent_item_colon' => __( 'Parent {{label_ucfirst}}:', '{{textdomain}}' ),
+ 'edit_item' => __( 'Edit {{label_ucfirst}}', '{{textdomain}}' ),
+ 'update_item' => __( 'Update {{label_ucfirst}}', '{{textdomain}}' ),
+ 'view_item' => __( 'View {{label_ucfirst}}', '{{textdomain}}' ),
+ 'add_new_item' => __( 'Add New {{label_ucfirst}}', '{{textdomain}}' ),
+ 'new_item_name' => __( 'New {{label_ucfirst}}', '{{textdomain}}' ),
+ 'separate_items_with_commas' => __( 'Separate {{label_plural}} with commas', '{{textdomain}}' ),
+ 'add_or_remove_items' => __( 'Add or remove {{label_plural}}', '{{textdomain}}' ),
+ 'choose_from_most_used' => __( 'Choose from the most used {{label_plural}}', '{{textdomain}}' ),
+ 'not_found' => __( 'No {{label_plural}} found.', '{{textdomain}}' ),
+ 'no_terms' => __( 'No {{label_plural}}', '{{textdomain}}' ),
+ 'menu_name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
+ 'items_list_navigation' => __( '{{label_plural_ucfirst}} list navigation', '{{textdomain}}' ),
+ 'items_list' => __( '{{label_plural_ucfirst}} list', '{{textdomain}}' ),
+ 'most_used' => _x( 'Most Used', '{{slug}}', '{{textdomain}}' ),
+ 'back_to_items' => __( '← Back to {{label_plural_ucfirst}}', '{{textdomain}}' ),
+ ),
+ 'show_in_rest' => true,
+ 'rest_base' => '{{slug}}',
+ 'rest_controller_class' => 'WP_REST_Terms_Controller',
+ )
+ );
diff --git a/templates/taxonomy_extended.mustache b/templates/taxonomy_extended.mustache
index 9a87cf11..fc71a659 100644
--- a/templates/taxonomy_extended.mustache
+++ b/templates/taxonomy_extended.mustache
@@ -1,14 +1,19 @@
'', // Unused. Messages start at index 1.
1 => __( '{{label_ucfirst}} added.', '{{textdomain}}' ),
2 => __( '{{label_ucfirst}} deleted.', '{{textdomain}}' ),
@@ -26,9 +31,9 @@ function {{machine_name}}_updated_messages( $messages ) {
4 => __( '{{label_ucfirst}} not added.', '{{textdomain}}' ),
5 => __( '{{label_ucfirst}} not updated.', '{{textdomain}}' ),
6 => __( '{{label_plural_ucfirst}} deleted.', '{{textdomain}}' ),
- ];
+ );
return $messages;
}
-add_filter( 'term_updated_messages', '{{machine_name}}_updated_messages' );
+add_filter( 'term_updated_messages', '{{prefix}}_updated_messages' );