From ec4734af56eb7492eeb57018a4c649308d2e5947 Mon Sep 17 00:00:00 2001 From: Timothy Jacobs Date: Tue, 30 Oct 2018 23:06:18 -0400 Subject: [PATCH 1/2] Add complete post type labels for Resuable Blocks Fixes #11272. --- lib/register.php | 49 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/lib/register.php b/lib/register.php index 0401af2f8a7c75..026481d2f18b70 100644 --- a/lib/register.php +++ b/lib/register.php @@ -444,9 +444,27 @@ function gutenberg_register_post_types() { 'wp_block', array( 'labels' => array( - 'name' => __( 'Blocks', 'gutenberg' ), - 'singular_name' => __( 'Block', 'gutenberg' ), - 'search_items' => __( 'Search Blocks', 'gutenberg' ), + 'name' => _x( 'Blocks', 'post type general name', 'gutenberg' ), + 'singular_name' => _x( 'Block', 'post type singular name', 'gutenberg' ), + 'menu_name' => _x( 'Blocks', 'admin menu', 'gutenberg' ), + 'name_admin_bar' => _x( 'Block', 'add new on admin bar', 'gutenberg' ), + 'add_new' => _x( 'Add New', 'Block', 'gutenberg' ), + 'add_new_item' => __( 'Add New Block', 'gutenberg' ), + 'new_item' => __( 'New Block', 'gutenberg' ), + 'edit_item' => __( 'Edit Block', 'gutenberg' ), + 'view_item' => __( 'View Block', 'gutenberg' ), + 'all_items' => __( 'All Blocks', 'gutenberg' ), + 'search_items' => __( 'Search Blocks', 'gutenberg' ), + 'not_found' => __( 'No blocks found.', 'gutenberg' ), + 'not_found_in_trash' => __( 'No blocks found in Trash.', 'gutenberg' ), + 'filter_items_list' => __( 'Filter blocks list', 'gutenberg' ), + 'items_list_navigation' => __( 'Blocks list navigation', 'gutenberg' ), + 'items_list' => __( 'Blocks list', 'gutenberg' ), + 'item_published' => __( 'Block published.', 'gutenberg' ), + 'item_published_privately' => __( 'Block published privately.', 'gutenberg' ), + 'item_reverted_to_draft' => __( 'Block reverted to draft.', 'gutenberg' ), + 'item_scheduled' => __( 'Block scheduled.', 'gutenberg' ), + 'item_updated' => __( 'Block updated.', 'gutenberg' ), ), 'public' => false, 'show_ui' => true, @@ -516,6 +534,31 @@ function gutenberg_register_post_types() { } add_action( 'init', 'gutenberg_register_post_types' ); +/** + * Apply the correct labels for Reusable Blocks in the bulk action updated messages. + * + * @since 4.3.0 + * + * @param array $messages + * @param array $bulk_counts + * + * @return array + */ +function gutenberg_bulk_post_updated_messages( $messages, $bulk_counts ) { + $messages['wp_block'] = array( + 'updated' => _n( '%s block updated.', '%s blocks updated.', $bulk_counts['updated'], 'gutenberg' ), + 'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 block not updated, somebody is editing it.', 'gutenberg' ) : + _n( '%s block not updated, somebody is editing it.', '%s blocks not updated, somebody is editing them.', $bulk_counts['locked'], 'gutenberg' ), + 'deleted' => _n( '%s block permanently deleted.', '%s blocks permanently deleted.', $bulk_counts['deleted'], 'gutenberg' ), + 'trashed' => _n( '%s block moved to the Trash.', '%s blocks moved to the Trash.', $bulk_counts['trashed'], 'gutenberg' ), + 'untrashed' => _n( '%s block restored from the Trash.', '%s blocks restored from the Trash.', $bulk_counts['untrashed'], 'gutenberg' ), + ); + + return $messages; +} + +add_filter( 'bulk_post_updated_messages', 'gutenberg_bulk_post_updated_messages', 10, 2 ); + /** * Injects a hidden input in the edit form to propagate the information that classic editor is selected. * From 36010d8205b46dfeb3f8ad45d322f5b255524fd7 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 31 Oct 2018 04:15:58 -0700 Subject: [PATCH 2/2] Clean up PHPCS issues --- lib/register.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/register.php b/lib/register.php index 026481d2f18b70..b86df4fd7a37f0 100644 --- a/lib/register.php +++ b/lib/register.php @@ -539,18 +539,22 @@ function gutenberg_register_post_types() { * * @since 4.3.0 * - * @param array $messages - * @param array $bulk_counts + * @param array $messages Arrays of messages, each keyed by the corresponding post type. + * @param array $bulk_counts Array of item counts for each message, used to build internationalized strings. * * @return array */ function gutenberg_bulk_post_updated_messages( $messages, $bulk_counts ) { $messages['wp_block'] = array( + // translators: Number of blocks updated. 'updated' => _n( '%s block updated.', '%s blocks updated.', $bulk_counts['updated'], 'gutenberg' ), - 'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 block not updated, somebody is editing it.', 'gutenberg' ) : - _n( '%s block not updated, somebody is editing it.', '%s blocks not updated, somebody is editing them.', $bulk_counts['locked'], 'gutenberg' ), + // translators: Blocks not updated because they're locked. + 'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 block not updated, somebody is editing it.', 'gutenberg' ) : _n( '%s block not updated, somebody is editing it.', '%s blocks not updated, somebody is editing them.', $bulk_counts['locked'], 'gutenberg' ), + // translators: Number of blocks deleted. 'deleted' => _n( '%s block permanently deleted.', '%s blocks permanently deleted.', $bulk_counts['deleted'], 'gutenberg' ), + // translators: Number of blocks trashed. 'trashed' => _n( '%s block moved to the Trash.', '%s blocks moved to the Trash.', $bulk_counts['trashed'], 'gutenberg' ), + // translators: Number of blocks untrashed. 'untrashed' => _n( '%s block restored from the Trash.', '%s blocks restored from the Trash.', $bulk_counts['untrashed'], 'gutenberg' ), );