Make WordPress Core


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