Make WordPress Core

Changeset 58377


Ignore:
Timestamp:
06/10/2024 11:20:52 PM (5 weeks ago)
Author:
peterwilsoncc
Message:

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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r58248 r58377  
    20842084 * @since 6.4.0 Changed default values for the `add_new` label to include the type of content.
    20852085 *              This matches `add_new_item` and provides more context for better accessibility.
     2086 * @since 6.6.0 Added the `template_name` label.
    20862087 *
    20872088 * @access private
     
    20962097
    20972098    $labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );
     2099
     2100    if ( ! isset( $post_type_object->labels->template_name ) && isset( $post_type_object->labels->singular_name ) ) {
     2101            /* translators: %s: Post type name. */
     2102            $labels->template_name = sprintf( __( 'Single item: %s' ), $post_type_object->labels->singular_name );
     2103    }
    20982104
    20992105    $post_type = $post_type_object->name;
  • trunk/src/wp-includes/taxonomy.php

    r58105 r58377  
    646646 * @since 5.9.0 Added the `name_field_description`, `slug_field_description`,
    647647 *              `parent_field_description`, and `desc_field_description` labels.
     648 * @since 6.6.0 Added the `template_name` label.
    648649 *
    649650 * @param WP_Taxonomy $tax Taxonomy object.
     
    680681 *     @type string $add_new_item               Default 'Add New Tag'/'Add New Category'.
    681682 *     @type string $new_item_name              Default 'New Tag Name'/'New Category Name'.
     683 *     @type string $template_name              Default 'Tag Archives'/'Category Archives'.
    682684 *     @type string $separate_items_with_commas This label is only used for non-hierarchical taxonomies. Default
    683685 *                                              'Separate tags with commas', used in the meta box.
     
    720722    $labels = _get_custom_object_labels( $tax, $nohier_vs_hier_defaults );
    721723
     724    if ( ! isset( $tax->labels->template_name ) && isset( $labels->singular_name ) ) {
     725        /* translators: %s: Taxonomy name. */
     726        $labels->template_name = sprintf( _x( '%s Archives', 'taxonomy template name' ), $labels->singular_name );
     727    }
     728
    722729    $taxonomy = $tax->name;
    723730
Note: See TracChangeset for help on using the changeset viewer.