Skip to content

Commit

Permalink
Fix PHPCS issues for post-types
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Kau committed Oct 2, 2020
1 parent ab12eda commit 18a15cc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 46 deletions.
2 changes: 1 addition & 1 deletion features/scaffold.feature
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Feature: WordPress code scaffolding
When I run `wp scaffold post-type zombie`
Then STDOUT should contain:
"""
register_post_type( 'zombie'
'rest_base' => 'zombie'
"""
And STDOUT should contain:
"""
Expand Down
87 changes: 45 additions & 42 deletions templates/post_type.mustache
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
register_post_type( '{{slug}}', array(
'labels' => array(
'name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
'singular_name' => __( '{{label_ucfirst}}', '{{textdomain}}' ),
'all_items' => __( 'All {{label_plural_ucfirst}}', '{{textdomain}}' ),
'archives' => __( '{{label_ucfirst}} Archives', '{{textdomain}}' ),
'attributes' => __( '{{label_ucfirst}} Attributes', '{{textdomain}}' ),
'insert_into_item' => __( 'Insert into {{label}}', '{{textdomain}}' ),
'uploaded_to_this_item' => __( 'Uploaded to this {{label}}', '{{textdomain}}' ),
'featured_image' => _x( 'Featured Image', '{{slug}}', '{{textdomain}}' ),
'set_featured_image' => _x( 'Set featured image', '{{slug}}', '{{textdomain}}' ),
'remove_featured_image' => _x( 'Remove featured image', '{{slug}}', '{{textdomain}}' ),
'use_featured_image' => _x( 'Use as featured image', '{{slug}}', '{{textdomain}}' ),
'filter_items_list' => __( 'Filter {{label_plural}} list', '{{textdomain}}' ),
'items_list_navigation' => __( '{{label_plural_ucfirst}} list navigation', '{{textdomain}}' ),
'items_list' => __( '{{label_plural_ucfirst}} list', '{{textdomain}}' ),
'new_item' => __( 'New {{label_ucfirst}}', '{{textdomain}}' ),
'add_new' => __( 'Add New', '{{textdomain}}' ),
'add_new_item' => __( 'Add New {{label_ucfirst}}', '{{textdomain}}' ),
'edit_item' => __( 'Edit {{label_ucfirst}}', '{{textdomain}}' ),
'view_item' => __( 'View {{label_ucfirst}}', '{{textdomain}}' ),
'view_items' => __( 'View {{label_plural_ucfirst}}', '{{textdomain}}' ),
'search_items' => __( 'Search {{label_plural}}', '{{textdomain}}' ),
'not_found' => __( 'No {{label_plural}} found', '{{textdomain}}' ),
'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' => array( 'title', 'editor' ),
'has_archive' => true,
'rewrite' => true,
'query_var' => true,
'menu_position' => null,
'menu_icon' => 'dashicons-{{dashicon}}',
'show_in_rest' => true,
'rest_base' => '{{slug}}',
'rest_controller_class' => 'WP_REST_Posts_Controller',
) );
register_post_type(
'{{slug}}',
array(
'labels' => array(
'name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ),
'singular_name' => __( '{{label_ucfirst}}', '{{textdomain}}' ),
'all_items' => __( 'All {{label_plural_ucfirst}}', '{{textdomain}}' ),
'archives' => __( '{{label_ucfirst}} Archives', '{{textdomain}}' ),
'attributes' => __( '{{label_ucfirst}} Attributes', '{{textdomain}}' ),
'insert_into_item' => __( 'Insert into {{label}}', '{{textdomain}}' ),
'uploaded_to_this_item' => __( 'Uploaded to this {{label}}', '{{textdomain}}' ),
'featured_image' => _x( 'Featured Image', '{{slug}}', '{{textdomain}}' ),
'set_featured_image' => _x( 'Set featured image', '{{slug}}', '{{textdomain}}' ),
'remove_featured_image' => _x( 'Remove featured image', '{{slug}}', '{{textdomain}}' ),
'use_featured_image' => _x( 'Use as featured image', '{{slug}}', '{{textdomain}}' ),
'filter_items_list' => __( 'Filter {{label_plural}} list', '{{textdomain}}' ),
'items_list_navigation' => __( '{{label_plural_ucfirst}} list navigation', '{{textdomain}}' ),
'items_list' => __( '{{label_plural_ucfirst}} list', '{{textdomain}}' ),
'new_item' => __( 'New {{label_ucfirst}}', '{{textdomain}}' ),
'add_new' => __( 'Add New', '{{textdomain}}' ),
'add_new_item' => __( 'Add New {{label_ucfirst}}', '{{textdomain}}' ),
'edit_item' => __( 'Edit {{label_ucfirst}}', '{{textdomain}}' ),
'view_item' => __( 'View {{label_ucfirst}}', '{{textdomain}}' ),
'view_items' => __( 'View {{label_plural_ucfirst}}', '{{textdomain}}' ),
'search_items' => __( 'Search {{label_plural}}', '{{textdomain}}' ),
'not_found' => __( 'No {{label_plural}} found', '{{textdomain}}' ),
'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' => array( 'title', 'editor' ),
'has_archive' => true,
'rewrite' => true,
'query_var' => true,
'menu_position' => null,
'menu_icon' => 'dashicons-{{dashicon}}',
'show_in_rest' => true,
'rest_base' => '{{slug}}',
'rest_controller_class' => 'WP_REST_Posts_Controller',
)
);
5 changes: 2 additions & 3 deletions templates/post_type_extended.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ function {{machine_name}}_updated_messages( $messages ) {
3 => __( 'Custom field deleted.', '{{textdomain}}' ),
4 => __( '{{label_ucfirst}} updated.', '{{textdomain}}' ),
/* translators: %s: date and time of the revision */
5 => isset( $_GET['revision'] ) ? sprintf( __( '{{label_ucfirst}} restored to revision from %s', '{{textdomain}}' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
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
/* translators: %s: post permalink */
6 => sprintf( __( '{{label_ucfirst}} published. <a href="%s">View {{label}}</a>', '{{textdomain}}' ), esc_url( $permalink ) ),
7 => __( '{{label_ucfirst}} saved.', '{{textdomain}}' ),
/* translators: %s: post permalink */
8 => sprintf( __( '{{label_ucfirst}} submitted. <a target="_blank" href="%s">Preview {{label}}</a>', '{{textdomain}}' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
/* translators: 1: Publish box date format, see https://secure.php.net/date 2: Post permalink */
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 ) ),
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 ) ),
/* translators: %s: post permalink */
10 => sprintf( __( '{{label_ucfirst}} draft updated. <a target="_blank" href="%s">Preview {{label}}</a>', '{{textdomain}}' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
);
Expand Down

0 comments on commit 18a15cc

Please sign in to comment.