From 8dc1988d0ca841fd7cd05b27c8a304850e86ead2 Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Sun, 7 Jan 2018 17:02:50 +0530 Subject: [PATCH 1/4] fix wpcs -m update code to remove wpcs warnings #109 --- templates/post_type_extended.mustache | 38 +++++++++++++++++++-------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/templates/post_type_extended.mustache b/templates/post_type_extended.mustache index d0302fa34..ff17bd342 100644 --- a/templates/post_type_extended.mustache +++ b/templates/post_type_extended.mustache @@ -1,10 +1,18 @@ '', // Unused. Messages start at index 1. - 1 => sprintf( __('{{label_ucfirst}} updated. View {{label}}', '{{textdomain}}'), esc_url( $permalink ) ), - 2 => __('Custom field updated.', '{{textdomain}}'), - 3 => __('Custom field deleted.', '{{textdomain}}'), - 4 => __('{{label_ucfirst}} updated.', '{{textdomain}}'), + /* translators: %s: permalink of {{label}}*/ + 1 => sprintf( __( '{{label_ucfirst}} updated. View {{label}}', '{{textdomain}}' ), esc_url( $permalink ) ), + 2 => __( 'Custom field updated.', '{{textdomain}}' ), + 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, - 6 => sprintf( __('{{label_ucfirst}} published. View {{label}}', '{{textdomain}}'), esc_url( $permalink ) ), - 7 => __('{{label_ucfirst}} saved.', '{{textdomain}}'), - 8 => sprintf( __('{{label_ucfirst}} submitted. Preview {{label}}', '{{textdomain}}'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), - 9 => sprintf( __('{{label_ucfirst}} scheduled for: %1$s. Preview {{label}}', '{{textdomain}}'), - // translators: Publish box date format, see https://secure.php.net/manual/en/function.date.php + 5 => isset( $_GET['revision'] ) ? sprintf( __( '{{label_ucfirst}} restored to revision from %s', '{{textdomain}}' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + /* translators: %s: permalink of {{label}}*/ + 6 => sprintf( __( '{{label_ucfirst}} published. View {{label}}', '{{textdomain}}' ), esc_url( $permalink ) ), + 7 => __( '{{label_ucfirst}} saved.', '{{textdomain}}' ), + /* translators: %s: permalink of {{label}}*/ + 8 => sprintf( __( '{{label_ucfirst}} submitted. Preview {{label}}', '{{textdomain}}' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), + + /* + * translators: %1$s :Publish box date format, see https://secure.php.net/manual/en/function.date.php. + * translators: %2$s: permalink of {{label}} + */ + 9 => sprintf( __( '{{label_ucfirst}} scheduled for: %1$s. Preview {{label}}', '{{textdomain}}' ), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ), - 10 => sprintf( __('{{label_ucfirst}} draft updated. Preview {{label}}', '{{textdomain}}'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), + /* translators: %s: permalink of {{label}}*/ + 10 => sprintf( __( '{{label_ucfirst}} draft updated. Preview {{label}}', '{{textdomain}}' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), ); return $messages; From 913053029bb2c93a5e48831e444ce54365ad974b Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Tue, 9 Jan 2018 01:07:13 +0530 Subject: [PATCH 2/4] update code according to review --- templates/post_type.mustache | 24 +++++++-------- templates/post_type_extended.mustache | 43 +++++++++++++-------------- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/templates/post_type.mustache b/templates/post_type.mustache index 753bdd876..e58c0ff37 100644 --- a/templates/post_type.mustache +++ b/templates/post_type.mustache @@ -1,5 +1,5 @@ register_post_type( '{{slug}}', array( - 'labels' => array( + 'labels' => array( 'name' => __( '{{label_plural_ucfirst}}', '{{textdomain}}' ), 'singular_name' => __( '{{label_ucfirst}}', '{{textdomain}}' ), 'all_items' => __( 'All {{label_plural_ucfirst}}', '{{textdomain}}' ), @@ -26,16 +26,16 @@ '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_icon' => 'dashicons-{{dashicon}}', - 'show_in_rest' => true, - 'rest_base' => '{{slug}}', + '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_icon' => 'dashicons-{{dashicon}}', + '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 ff17bd342..9fea44aaf 100644 --- a/templates/post_type_extended.mustache +++ b/templates/post_type_extended.mustache @@ -1,17 +1,18 @@ '', // Unused. Messages start at index 1. - /* translators: %s: permalink of {{label}}*/ - 1 => sprintf( __( '{{label_ucfirst}} updated. View {{label}}', '{{textdomain}}' ), esc_url( $permalink ) ), - 2 => __( 'Custom field updated.', '{{textdomain}}' ), - 3 => __( 'Custom field deleted.', '{{textdomain}}' ), - 4 => __( '{{label_ucfirst}} updated.', '{{textdomain}}' ), + 0 => '', // Unused. Messages start at index 1. + /* translators: %s: post permalink */ + 1 => sprintf( __( '{{label_ucfirst}} updated. View {{label}}', '{{textdomain}}' ), esc_url( $permalink ) ), + 2 => __( 'Custom field updated.', '{{textdomain}}' ), + 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, - /* translators: %s: permalink of {{label}}*/ - 6 => sprintf( __( '{{label_ucfirst}} published. View {{label}}', '{{textdomain}}' ), esc_url( $permalink ) ), - 7 => __( '{{label_ucfirst}} saved.', '{{textdomain}}' ), - /* translators: %s: permalink of {{label}}*/ - 8 => sprintf( __( '{{label_ucfirst}} submitted. Preview {{label}}', '{{textdomain}}' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), - - /* - * translators: %1$s :Publish box date format, see https://secure.php.net/manual/en/function.date.php. - * translators: %2$s: permalink of {{label}} - */ - 9 => sprintf( __( '{{label_ucfirst}} scheduled for: %1$s. Preview {{label}}', '{{textdomain}}' ), + 5 => isset( $_GET['revision'] ) ? sprintf( __( '{{label_ucfirst}} restored to revision from %s', '{{textdomain}}' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + /* translators: %s: post permalink */ + 6 => sprintf( __( '{{label_ucfirst}} published. View {{label}}', '{{textdomain}}' ), esc_url( $permalink ) ), + 7 => __( '{{label_ucfirst}} saved.', '{{textdomain}}' ), + /* translators: %s: post permalink */ + 8 => sprintf( __( '{{label_ucfirst}} submitted. Preview {{label}}', '{{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: %1$s. Preview {{label}}', '{{textdomain}}' ), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ), - /* translators: %s: permalink of {{label}}*/ + /* translators: %s: post permalink */ 10 => sprintf( __( '{{label_ucfirst}} draft updated. Preview {{label}}', '{{textdomain}}' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), ); From 246a4c23c077fb4e8d479a0f3f0ee11dc90f8247 Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Tue, 9 Jan 2018 01:19:18 +0530 Subject: [PATCH 3/4] update code according to review remove space --- templates/post_type_extended.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/post_type_extended.mustache b/templates/post_type_extended.mustache index 9fea44aaf..8c0a1fd1f 100644 --- a/templates/post_type_extended.mustache +++ b/templates/post_type_extended.mustache @@ -8,7 +8,7 @@ function {{machine_name}}_init() { } add_action( 'init', '{{machine_name}}_init' ); -/** +/** * Sets the post updated messages for the `{{machine_name}}` post type. * * @param array $messages Post updated messages. From 01a79757338e8bbe771cb25655092a9aa8b297c4 Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Tue, 9 Jan 2018 02:11:15 +0530 Subject: [PATCH 4/4] fix tests --- features/scaffold.feature | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/features/scaffold.feature b/features/scaffold.feature index 8d3a1fac4..e308c5ef9 100644 --- a/features/scaffold.feature +++ b/features/scaffold.feature @@ -150,7 +150,7 @@ Feature: WordPress code scaffolding """ And STDOUT should contain: """ - 'menu_icon' => 'dashicons-admin-post', + 'menu_icon' => 'dashicons-admin-post', """ Scenario: CPT slug is too long @@ -176,7 +176,7 @@ Feature: WordPress code scaffolding When I run `wp scaffold post-type zombie --dashicon="art"` Then STDOUT should contain: """ - 'menu_icon' => 'dashicons-art', + 'menu_icon' => 'dashicons-art', """ Scenario: Scaffold a Custom Post Type with dashicon in the case of passing "dashicon-info" @@ -184,7 +184,7 @@ Feature: WordPress code scaffolding When I run `wp scaffold post-type zombie --dashicon="dashicon-info"` Then STDOUT should contain: """ - 'menu_icon' => 'dashicons-info', + 'menu_icon' => 'dashicons-info', """ Scenario: Scaffold a Custom Post Type with dashicon in the case of passing "dashicons-info" @@ -192,7 +192,7 @@ Feature: WordPress code scaffolding When I run `wp scaffold post-type zombie --dashicon="dashicons-info"` Then STDOUT should contain: """ - 'menu_icon' => 'dashicons-info', + 'menu_icon' => 'dashicons-info', """ Scenario: Scaffold a plugin