Make WordPress Core


Ignore:
Timestamp:
06/10/2024 11:20:52 PM (11 months 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.

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.