From 27bdc71f332e503b4c51ef7315ec58a338960ecd Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Mon, 10 Jun 2024 23:22:12 +0000 Subject: [PATCH] Editor: Add labels for template name display in site editor. Add the label `template_name` to post types and taxonomies for use by the site editor to display on the templates/add new template screens to allow extenders to customize the display. For post types the template name applies to templates for a singular pages with the default value "Single item: [singular name]". For taxonomies the template name applies to templates for term archives with the default value "[singular name] Archives". Props aljullu, audrasjb, ntsekouras, ellatrix, oglekler, rajinsharwar. Fixes #60881. Built from https://develop.svn.wordpress.org/trunk@58377 git-svn-id: http://core.svn.wordpress.org/trunk@57826 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 6 ++++++ wp-includes/taxonomy.php | 7 +++++++ wp-includes/version.php | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index b0967dbad8..2f7cba613f 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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 * @@ -2096,6 +2097,11 @@ function get_post_type_labels( $post_type_object ) { $labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults ); + if ( ! isset( $post_type_object->labels->template_name ) && isset( $post_type_object->labels->singular_name ) ) { + /* translators: %s: Post type name. */ + $labels->template_name = sprintf( __( 'Single item: %s' ), $post_type_object->labels->singular_name ); + } + $post_type = $post_type_object->name; $default_labels = clone $labels; diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 5f5f9bf089..693ab1b84d 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -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. * * @param WP_Taxonomy $tax Taxonomy object. * @return object { @@ -679,6 +680,7 @@ function unregister_taxonomy( $taxonomy ) { * @type string $update_item Default 'Update Tag'/'Update Category'. * @type string $add_new_item Default 'Add New Tag'/'Add New Category'. * @type string $new_item_name Default 'New Tag Name'/'New Category Name'. + * @type string $template_name Default 'Tag Archives'/'Category Archives'. * @type string $separate_items_with_commas This label is only used for non-hierarchical taxonomies. Default * 'Separate tags with commas', used in the meta box. * @type string $add_or_remove_items This label is only used for non-hierarchical taxonomies. Default @@ -719,6 +721,11 @@ function get_taxonomy_labels( $tax ) { $labels = _get_custom_object_labels( $tax, $nohier_vs_hier_defaults ); + if ( ! isset( $tax->labels->template_name ) && isset( $labels->singular_name ) ) { + /* translators: %s: Taxonomy name. */ + $labels->template_name = sprintf( _x( '%s Archives', 'taxonomy template name' ), $labels->singular_name ); + } + $taxonomy = $tax->name; $default_labels = clone $labels; diff --git a/wp-includes/version.php b/wp-includes/version.php index 54d363bbd1..2029ccdd26 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-beta1-58376'; +$wp_version = '6.6-beta1-58377'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.