Make WordPress Core

Changeset 59161


Ignore:
Timestamp:
10/03/2024 10:44:30 PM (2 months ago)
Author:
joedolson
Message:

Administration: Switch core post type labels to add_new_item.

In [56515], the default value of Add New was changed to "Add New Post / Add New Page". This caused problems with post types where add_new was not declared.

Change core usage to reference the add_new_item value and revert the default value of add_new back to "Add New / Add New". This retains the accessibility advantages without creating counter intuitive usage of the add_new key.

With this change, post types registered with no add_new key will be unimpacted in core, and post types registered with no add_new_item key will use the default "Add New Post", which is not a change from the current state.

Props smerriman, afercia, rcreators, joedolson, eclev91, johnbillion.
Fixes #60045.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-advanced.php

    r58419 r59161  
    435435<?php
    436436if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) ) {
    437     echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
     437    echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new_item ) . '</a>';
    438438}
    439439?>
  • trunk/src/wp-admin/edit.php

    r58419 r59161  
    420420<?php
    421421if ( current_user_can( $post_type_object->cap->create_posts ) ) {
    422     echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
     422    echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new_item ) . '</a>';
    423423}
    424424
  • trunk/src/wp-admin/menu.php

    r58278 r59161  
    170170    $menu[ $ptype_menu_position ] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, $ptype_file, '', $menu_class, $ptype_menu_id, $menu_icon );
    171171    $submenu[ $ptype_file ][5]    = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, $ptype_file );
    172     $submenu[ $ptype_file ][10]   = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, $post_new_file );
     172    $submenu[ $ptype_file ][10]   = array( $ptype_obj->labels->add_new_item, $ptype_obj->cap->create_posts, $post_new_file );
    173173
    174174    $i = 15;
  • trunk/src/wp-includes/class-wp-post-type.php

    r58211 r59161  
    974974            'name'                     => array( _x( 'Posts', 'post type general name' ), _x( 'Pages', 'post type general name' ) ),
    975975            'singular_name'            => array( _x( 'Post', 'post type singular name' ), _x( 'Page', 'post type singular name' ) ),
    976             'add_new'                  => array( __( 'Add New Post' ), __( 'Add New Page' ) ),
     976            'add_new'                  => array( __( 'Add New' ), __( 'Add New' ) ),
    977977            'add_new_item'             => array( __( 'Add New Post' ), __( 'Add New Page' ) ),
    978978            'edit_item'                => array( __( 'Edit Post' ), __( 'Edit Page' ) ),
  • trunk/src/wp-includes/post.php

    r59050 r59161  
    20232023 *          by `$post_type_object->label`. Default is 'Posts' / 'Pages'.
    20242024 * - `singular_name` - Name for one object of this post type. Default is 'Post' / 'Page'.
    2025  * - `add_new` - Label for adding a new item. Default is 'Add New Post' / 'Add New Page'.
     2025 * - `add_new` - Label for adding a new item. Default is 'Add New' / 'Add New'.
    20262026 * - `add_new_item` - Label for adding a new singular item. Default is 'Add New Post' / 'Add New Page'.
    20272027 * - `edit_item` - Label for editing a singular item. Default is 'Edit Post' / 'Edit Page'.
     
    20852085 *              This matches `add_new_item` and provides more context for better accessibility.
    20862086 * @since 6.6.0 Added the `template_name` label.
     2087 * @since 6.7.0 Restored pre-6.4.0 defaults for the `add_new` label and updated documentation.
     2088 *              Updated core usage to reference `add_new_item`.
    20872089 *
    20882090 * @access private
Note: See TracChangeset for help on using the changeset viewer.