Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce 'template_name' label to custom post types and custom taxonomies #6344

Closed
1 change: 1 addition & 0 deletions src/wp-includes/class-wp-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@ public static function get_default_labels() {
_x( 'A link to a post.', 'navigation link block description' ),
_x( 'A link to a page.', 'navigation link block description' ),
),
'template_name' => array( __( 'Single item: Post' ), __( 'Single item: Page' ) ),
);

return self::$default_labels;
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/class-wp-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ public static function get_default_labels() {
_x( 'A link to a tag.', 'navigation link block description' ),
_x( 'A link to a category.', 'navigation link block description' ),
),
'template_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
Aljullu marked this conversation as resolved.
Show resolved Hide resolved
);

return self::$default_labels;
Expand Down
6 changes: 6 additions & 0 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,7 @@ function _post_type_meta_capabilities( $capabilities = null ) {
* @since 6.3.0 Added the `item_trashed` label.
* @since 6.4.0 Changed default values for the `add_new` label to include the type of content.
* This matches `add_new_item` and provides more context for better accessibility.
* @since 6.6.0 Added the `template_name` label.
*
* @access private
*
Expand Down Expand Up @@ -2167,6 +2168,11 @@ function _get_custom_object_labels( $data_object, $nohier_vs_hier_defaults ) {
$data_object->labels['archives'] = $data_object->labels['all_items'];
}

if ( ! isset( $data_object->labels['template_name'] ) && isset( $data_object->labels['singular_name'] ) ) {
/* translators: %s: Post type name. */
$data_object->labels['template_name'] = sprintf( __( 'Single item: %s' ), $data_object->labels['singular_name'] );
}

$defaults = array();
foreach ( $nohier_vs_hier_defaults as $key => $value ) {
$defaults[ $key ] = $data_object->hierarchical ? $value[1] : $value[0];
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ function unregister_taxonomy( $taxonomy ) {
* @since 5.8.0 Added the `item_link` and `item_link_description` labels.
* @since 5.9.0 Added the `name_field_description`, `slug_field_description`,
* `parent_field_description`, and `desc_field_description` labels.
* @since 6.6.0 Added the `template_name` label.
Aljullu marked this conversation as resolved.
Show resolved Hide resolved
*
* @param WP_Taxonomy $tax Taxonomy object.
* @return object {
Expand Down
Loading