Skip to content

Commit 9895c22

Browse files
authored
Merge pull request #276 from 2ndkauboy/fix/post-type-phpcs-fixes
Fix PHPCS issues for post-types
2 parents fca04f5 + 18a15cc commit 9895c22

File tree

3 files changed

+48
-46
lines changed

3 files changed

+48
-46
lines changed

features/scaffold.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Feature: WordPress code scaffolding
9393
When I run `wp scaffold post-type zombie`
9494
Then STDOUT should contain:
9595
"""
96-
register_post_type( 'zombie'
96+
'rest_base' => 'zombie'
9797
"""
9898
And STDOUT should contain:
9999
"""

templates/post_type.mustache

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
1-
register_post_type( '{{slug}}', array(
2-
'labels' => array(
3-
'name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
4-
'singular_name' => __( '{{label_ucfirst}}', '{{textdomain}}' ),
5-
'all_items' => __( 'All {{label_plural_ucfirst}}', '{{textdomain}}' ),
6-
'archives' => __( '{{label_ucfirst}} Archives', '{{textdomain}}' ),
7-
'attributes' => __( '{{label_ucfirst}} Attributes', '{{textdomain}}' ),
8-
'insert_into_item' => __( 'Insert into {{label}}', '{{textdomain}}' ),
9-
'uploaded_to_this_item' => __( 'Uploaded to this {{label}}', '{{textdomain}}' ),
10-
'featured_image' => _x( 'Featured Image', '{{slug}}', '{{textdomain}}' ),
11-
'set_featured_image' => _x( 'Set featured image', '{{slug}}', '{{textdomain}}' ),
12-
'remove_featured_image' => _x( 'Remove featured image', '{{slug}}', '{{textdomain}}' ),
13-
'use_featured_image' => _x( 'Use as featured image', '{{slug}}', '{{textdomain}}' ),
14-
'filter_items_list' => __( 'Filter {{label_plural}} list', '{{textdomain}}' ),
15-
'items_list_navigation' => __( '{{label_plural_ucfirst}} list navigation', '{{textdomain}}' ),
16-
'items_list' => __( '{{label_plural_ucfirst}} list', '{{textdomain}}' ),
17-
'new_item' => __( 'New {{label_ucfirst}}', '{{textdomain}}' ),
18-
'add_new' => __( 'Add New', '{{textdomain}}' ),
19-
'add_new_item' => __( 'Add New {{label_ucfirst}}', '{{textdomain}}' ),
20-
'edit_item' => __( 'Edit {{label_ucfirst}}', '{{textdomain}}' ),
21-
'view_item' => __( 'View {{label_ucfirst}}', '{{textdomain}}' ),
22-
'view_items' => __( 'View {{label_plural_ucfirst}}', '{{textdomain}}' ),
23-
'search_items' => __( 'Search {{label_plural}}', '{{textdomain}}' ),
24-
'not_found' => __( 'No {{label_plural}} found', '{{textdomain}}' ),
25-
'not_found_in_trash' => __( 'No {{label_plural}} found in trash', '{{textdomain}}' ),
26-
'parent_item_colon' => __( 'Parent {{label_ucfirst}}:', '{{textdomain}}' ),
27-
'menu_name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
28-
),
29-
'public' => true,
30-
'hierarchical' => false,
31-
'show_ui' => true,
32-
'show_in_nav_menus' => true,
33-
'supports' => array( 'title', 'editor' ),
34-
'has_archive' => true,
35-
'rewrite' => true,
36-
'query_var' => true,
37-
'menu_position' => null,
38-
'menu_icon' => 'dashicons-{{dashicon}}',
39-
'show_in_rest' => true,
40-
'rest_base' => '{{slug}}',
41-
'rest_controller_class' => 'WP_REST_Posts_Controller',
42-
) );
1+
register_post_type(
2+
'{{slug}}',
3+
array(
4+
'labels' => array(
5+
'name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
6+
'singular_name' => __( '{{label_ucfirst}}', '{{textdomain}}' ),
7+
'all_items' => __( 'All {{label_plural_ucfirst}}', '{{textdomain}}' ),
8+
'archives' => __( '{{label_ucfirst}} Archives', '{{textdomain}}' ),
9+
'attributes' => __( '{{label_ucfirst}} Attributes', '{{textdomain}}' ),
10+
'insert_into_item' => __( 'Insert into {{label}}', '{{textdomain}}' ),
11+
'uploaded_to_this_item' => __( 'Uploaded to this {{label}}', '{{textdomain}}' ),
12+
'featured_image' => _x( 'Featured Image', '{{slug}}', '{{textdomain}}' ),
13+
'set_featured_image' => _x( 'Set featured image', '{{slug}}', '{{textdomain}}' ),
14+
'remove_featured_image' => _x( 'Remove featured image', '{{slug}}', '{{textdomain}}' ),
15+
'use_featured_image' => _x( 'Use as featured image', '{{slug}}', '{{textdomain}}' ),
16+
'filter_items_list' => __( 'Filter {{label_plural}} list', '{{textdomain}}' ),
17+
'items_list_navigation' => __( '{{label_plural_ucfirst}} list navigation', '{{textdomain}}' ),
18+
'items_list' => __( '{{label_plural_ucfirst}} list', '{{textdomain}}' ),
19+
'new_item' => __( 'New {{label_ucfirst}}', '{{textdomain}}' ),
20+
'add_new' => __( 'Add New', '{{textdomain}}' ),
21+
'add_new_item' => __( 'Add New {{label_ucfirst}}', '{{textdomain}}' ),
22+
'edit_item' => __( 'Edit {{label_ucfirst}}', '{{textdomain}}' ),
23+
'view_item' => __( 'View {{label_ucfirst}}', '{{textdomain}}' ),
24+
'view_items' => __( 'View {{label_plural_ucfirst}}', '{{textdomain}}' ),
25+
'search_items' => __( 'Search {{label_plural}}', '{{textdomain}}' ),
26+
'not_found' => __( 'No {{label_plural}} found', '{{textdomain}}' ),
27+
'not_found_in_trash' => __( 'No {{label_plural}} found in trash', '{{textdomain}}' ),
28+
'parent_item_colon' => __( 'Parent {{label_ucfirst}}:', '{{textdomain}}' ),
29+
'menu_name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
30+
),
31+
'public' => true,
32+
'hierarchical' => false,
33+
'show_ui' => true,
34+
'show_in_nav_menus' => true,
35+
'supports' => array( 'title', 'editor' ),
36+
'has_archive' => true,
37+
'rewrite' => true,
38+
'query_var' => true,
39+
'menu_position' => null,
40+
'menu_icon' => 'dashicons-{{dashicon}}',
41+
'show_in_rest' => true,
42+
'rest_base' => '{{slug}}',
43+
'rest_controller_class' => 'WP_REST_Posts_Controller',
44+
)
45+
);

templates/post_type_extended.mustache

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ function {{machine_name}}_updated_messages( $messages ) {
2727
3 => __( 'Custom field deleted.', '{{textdomain}}' ),
2828
4 => __( '{{label_ucfirst}} updated.', '{{textdomain}}' ),
2929
/* translators: %s: date and time of the revision */
30-
5 => isset( $_GET['revision'] ) ? sprintf( __( '{{label_ucfirst}} restored to revision from %s', '{{textdomain}}' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
30+
5 => isset( $_GET['revision'] ) ? sprintf( __( '{{label_ucfirst}} restored to revision from %s', '{{textdomain}}' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, // phpcs:ignore WordPress.Security.NonceVerification.Recommended
3131
/* translators: %s: post permalink */
3232
6 => sprintf( __( '{{label_ucfirst}} published. <a href="%s">View {{label}}</a>', '{{textdomain}}' ), esc_url( $permalink ) ),
3333
7 => __( '{{label_ucfirst}} saved.', '{{textdomain}}' ),
3434
/* translators: %s: post permalink */
3535
8 => sprintf( __( '{{label_ucfirst}} submitted. <a target="_blank" href="%s">Preview {{label}}</a>', '{{textdomain}}' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
3636
/* translators: 1: Publish box date format, see https://secure.php.net/date 2: Post permalink */
37-
9 => sprintf( __( '{{label_ucfirst}} scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview {{label}}</a>', '{{textdomain}}' ),
38-
date_i18n( __( 'M j, Y @ G:i', '{{textdomain}}' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ),
37+
9 => sprintf( __( '{{label_ucfirst}} scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview {{label}}</a>', '{{textdomain}}' ), date_i18n( __( 'M j, Y @ G:i', '{{textdomain}}' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ),
3938
/* translators: %s: post permalink */
4039
10 => sprintf( __( '{{label_ucfirst}} draft updated. <a target="_blank" href="%s">Preview {{label}}</a>', '{{textdomain}}' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
4140
);

0 commit comments

Comments
 (0)