Posts, Post Types: Introduce "Filter by date" and "Filter by category" as post type and taxonomy labels, respectively.

This provides a more consistent location for these strings and allows for reusing them in other places without hardcoding them in the markup.

Props nicolalaserra, audrasjb, johnjamesjacoby, SergeyBiryukov.
Fixes #42421.
Built from https://develop.svn.wordpress.org/trunk@50120


git-svn-id: http://core.svn.wordpress.org/trunk@49799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-02-01 14:13:00 +00:00
parent 8bd85a870b
commit 81462ca73e
6 changed files with 12 additions and 4 deletions

View File

@ -114,7 +114,7 @@ class WP_Links_List_Table extends WP_List_Table {
'orderby' => 'name', 'orderby' => 'name',
); );
echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>'; echo '<label class="screen-reader-text" for="cat_id">' . get_taxonomy( 'link_category' )->labels->filter_by_item . '</label>';
wp_dropdown_categories( $dropdown_options ); wp_dropdown_categories( $dropdown_options );

View File

@ -633,7 +633,7 @@ class WP_List_Table {
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
?> ?>
<label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label> <label for="filter-by-date" class="screen-reader-text"><?php echo get_post_type_object( $post_type )->labels->filter_by_date; ?></label>
<select name="m" id="filter-by-date"> <select name="m" id="filter-by-date">
<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
<?php <?php

View File

@ -456,7 +456,8 @@ class WP_Posts_List_Table extends WP_List_Table {
'selected' => $cat, 'selected' => $cat,
); );
echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>'; echo '<label class="screen-reader-text" for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>';
wp_dropdown_categories( $dropdown_options ); wp_dropdown_categories( $dropdown_options );
} }
} }

View File

@ -1689,6 +1689,7 @@ function _post_type_meta_capabilities( $capabilities = null ) {
* - `menu_name` - Label for the menu name. Default is the same as `name`. * - `menu_name` - Label for the menu name. Default is the same as `name`.
* - `filter_items_list` - Label for the table views hidden heading. Default is 'Filter posts list' / * - `filter_items_list` - Label for the table views hidden heading. Default is 'Filter posts list' /
* 'Filter pages list'. * 'Filter pages list'.
* - `filter_by_date` - Label for the date filter in list tables. Default is 'Filter by date'.
* - `items_list_navigation` - Label for the table pagination hidden heading. Default is 'Posts list navigation' / * - `items_list_navigation` - Label for the table pagination hidden heading. Default is 'Posts list navigation' /
* 'Pages list navigation'. * 'Pages list navigation'.
* - `items_list` - Label for the table hidden heading. Default is 'Posts list' / 'Pages list'. * - `items_list` - Label for the table hidden heading. Default is 'Posts list' / 'Pages list'.
@ -1715,6 +1716,7 @@ function _post_type_meta_capabilities( $capabilities = null ) {
* @since 4.7.0 Added the `view_items` and `attributes` labels. * @since 4.7.0 Added the `view_items` and `attributes` labels.
* @since 5.0.0 Added the `item_published`, `item_published_privately`, `item_reverted_to_draft`, * @since 5.0.0 Added the `item_published`, `item_published_privately`, `item_reverted_to_draft`,
* `item_scheduled`, and `item_updated` labels. * `item_scheduled`, and `item_updated` labels.
* @since 5.7.0 Added the `filter_by_date` label.
* *
* @access private * @access private
* *
@ -1745,6 +1747,7 @@ function get_post_type_labels( $post_type_object ) {
'remove_featured_image' => array( _x( 'Remove featured image', 'post' ), _x( 'Remove featured image', 'page' ) ), 'remove_featured_image' => array( _x( 'Remove featured image', 'post' ), _x( 'Remove featured image', 'page' ) ),
'use_featured_image' => array( _x( 'Use as featured image', 'post' ), _x( 'Use as featured image', 'page' ) ), 'use_featured_image' => array( _x( 'Use as featured image', 'post' ), _x( 'Use as featured image', 'page' ) ),
'filter_items_list' => array( __( 'Filter posts list' ), __( 'Filter pages list' ) ), 'filter_items_list' => array( __( 'Filter posts list' ), __( 'Filter pages list' ) ),
'filter_by_date' => array( __( 'Filter by date' ), __( 'Filter by date' ) ),
'items_list_navigation' => array( __( 'Posts list navigation' ), __( 'Pages list navigation' ) ), 'items_list_navigation' => array( __( 'Posts list navigation' ), __( 'Pages list navigation' ) ),
'items_list' => array( __( 'Posts list' ), __( 'Pages list' ) ), 'items_list' => array( __( 'Posts list' ), __( 'Pages list' ) ),
'item_published' => array( __( 'Post published.' ), __( 'Page published.' ) ), 'item_published' => array( __( 'Post published.' ), __( 'Page published.' ) ),

View File

@ -537,6 +537,7 @@ function unregister_taxonomy( $taxonomy ) {
* @since 4.3.0 Added the `no_terms` label. * @since 4.3.0 Added the `no_terms` label.
* @since 4.4.0 Added the `items_list_navigation` and `items_list` labels. * @since 4.4.0 Added the `items_list_navigation` and `items_list` labels.
* @since 4.9.0 Added the `most_used` and `back_to_items` labels. * @since 4.9.0 Added the `most_used` and `back_to_items` labels.
* @since 5.7.0 Added the `filter_by_item` label.
* *
* @param WP_Taxonomy $tax Taxonomy object. * @param WP_Taxonomy $tax Taxonomy object.
* @return object { * @return object {
@ -569,6 +570,8 @@ function unregister_taxonomy( $taxonomy ) {
* the meta box and taxonomy list table. * the meta box and taxonomy list table.
* @type string $no_terms Default 'No tags'/'No categories', used in the posts and media * @type string $no_terms Default 'No tags'/'No categories', used in the posts and media
* list tables. * list tables.
* @type string $filter_by_item This label is only used for hierarchical taxonomies. Default
* 'Filter by category', used in the posts list table.
* @type string $items_list_navigation Label for the table pagination hidden heading. * @type string $items_list_navigation Label for the table pagination hidden heading.
* @type string $items_list Label for the table hidden heading. * @type string $items_list Label for the table hidden heading.
* @type string $most_used Title for the Most Used tab. Default 'Most Used'. * @type string $most_used Title for the Most Used tab. Default 'Most Used'.
@ -604,6 +607,7 @@ function get_taxonomy_labels( $tax ) {
'choose_from_most_used' => array( __( 'Choose from the most used tags' ), null ), 'choose_from_most_used' => array( __( 'Choose from the most used tags' ), null ),
'not_found' => array( __( 'No tags found.' ), __( 'No categories found.' ) ), 'not_found' => array( __( 'No tags found.' ), __( 'No categories found.' ) ),
'no_terms' => array( __( 'No tags' ), __( 'No categories' ) ), 'no_terms' => array( __( 'No tags' ), __( 'No categories' ) ),
'filter_by_item' => array( null, __( 'Filter by category' ) ),
'items_list_navigation' => array( __( 'Tags list navigation' ), __( 'Categories list navigation' ) ), 'items_list_navigation' => array( __( 'Tags list navigation' ), __( 'Categories list navigation' ) ),
'items_list' => array( __( 'Tags list' ), __( 'Categories list' ) ), 'items_list' => array( __( 'Tags list' ), __( 'Categories list' ) ),
/* translators: Tab heading when selecting from the most used terms. */ /* translators: Tab heading when selecting from the most used terms. */

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.7-alpha-50119'; $wp_version = '5.7-alpha-50120';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.