Skip to content

Commit

Permalink
Merge branch 'WordPress:trunk' into 61648-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kebbet authored Oct 6, 2024
2 parents 185df91 + 208889b commit ea946d9
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 57 deletions.
8 changes: 6 additions & 2 deletions src/wp-admin/includes/class-core-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* It allows for WordPress to upgrade itself in combination with
* the wp-admin/includes/update-core.php file.
*
* Note: Newly introduced functions and methods cannot be used here.
* All functions must be present in the previous version being upgraded from
* as this file is used there too.
*
* @since 2.8.0
* @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader.php.
*
Expand Down Expand Up @@ -391,13 +395,13 @@ public static function should_update_to_version( $offered_ver ) {
*
* @since 3.7.0
*
* @global string $wp_version The WordPress version string.
* @global string $wp_local_package Locale code of the package.
*
* @return bool True if the checksums match, otherwise false.
*/
public function check_files() {
global $wp_local_package;
$wp_version = wp_get_wp_version();
global $wp_version, $wp_local_package;

$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );

Expand Down
14 changes: 9 additions & 5 deletions src/wp-admin/includes/update-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
/**
* WordPress core upgrade functionality.
*
* Note: Newly introduced functions and methods cannot be used here.
* All functions must be present in the previous version being upgraded from
* as this file is used there too.
*
* @package WordPress
* @subpackage Administration
* @since 2.7.0
Expand Down Expand Up @@ -1539,12 +1543,12 @@ function update_core( $from, $to ) {
*
* @global array $_old_requests_files Requests files to be preloaded.
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
* @global string $wp_version The WordPress version string.
*
* @param string $to Path to old WordPress installation.
*/
function _preload_old_requests_classes_and_interfaces( $to ) {
global $_old_requests_files, $wp_filesystem;
$wp_version = wp_get_wp_version();
global $_old_requests_files, $wp_filesystem, $wp_version;

/*
* Requests was introduced in WordPress 4.6.
Expand Down Expand Up @@ -1587,14 +1591,14 @@ function _preload_old_requests_classes_and_interfaces( $to ) {
*
* @since 3.3.0
*
* @global string $pagenow The filename of the current screen.
* @global string $wp_version The WordPress version string.
* @global string $pagenow The filename of the current screen.
* @global string $action
*
* @param string $new_version
*/
function _redirect_to_about_wordpress( $new_version ) {
global $pagenow, $action;
$wp_version = wp_get_wp_version();
global $wp_version, $pagenow, $action;

if ( version_compare( $wp_version, '3.4-RC1', '>=' ) ) {
return;
Expand Down
46 changes: 30 additions & 16 deletions src/wp-includes/class-walker-nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function end_lvl( &$output, $depth = 0, $args = null ) {
* @since 4.4.0 The {@see 'nav_menu_item_args'} filter was added.
* @since 5.9.0 Renamed `$item` to `$data_object` and `$id` to `$current_object_id`
* to match parent class for PHP 8 named parameter support.
* @since 6.7.0 Removed redundant title attributes.
*
* @see Walker::start_el()
*
Expand Down Expand Up @@ -212,8 +213,25 @@ public function start_el( &$output, $data_object, $depth = 0, $args = null, $cur

$output .= $indent . '<li' . $li_attributes . '>';

/** This filter is documented in wp-includes/post-template.php */
$title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );

// Save filtered value before filtering again.
$the_title_filtered = $title;

/**
* Filters a menu item's title.
*
* @since 4.4.0
*
* @param string $title The menu item's title.
* @param WP_Post $menu_item The current menu item object.
* @param stdClass $args An object of wp_nav_menu() arguments.
* @param int $depth Depth of menu item. Used for padding.
*/
$title = apply_filters( 'nav_menu_item_title', $title, $menu_item, $args, $depth );

$atts = array();
$atts['title'] = ! empty( $menu_item->attr_title ) ? $menu_item->attr_title : '';
$atts['target'] = ! empty( $menu_item->target ) ? $menu_item->target : '';
$atts['rel'] = ! empty( $menu_item->xfn ) ? $menu_item->xfn : '';

Expand All @@ -229,6 +247,17 @@ public function start_el( &$output, $data_object, $depth = 0, $args = null, $cur

$atts['aria-current'] = $menu_item->current ? 'page' : '';

// Add title attribute only if it does not match the link text (before or after filtering).
if ( ! empty( $menu_item->attr_title )
&& trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $menu_item->title ) )
&& trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $the_title_filtered ) )
&& trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $title ) )
) {
$atts['title'] = $menu_item->attr_title;
} else {
$atts['title'] = '';
}

/**
* Filters the HTML attributes applied to a menu item's anchor element.
*
Expand All @@ -251,21 +280,6 @@ public function start_el( &$output, $data_object, $depth = 0, $args = null, $cur
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
$attributes = $this->build_atts( $atts );

/** This filter is documented in wp-includes/post-template.php */
$title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );

/**
* Filters a menu item's title.
*
* @since 4.4.0
*
* @param string $title The menu item's title.
* @param WP_Post $menu_item The current menu item object.
* @param stdClass $args An object of wp_nav_menu() arguments.
* @param int $depth Depth of menu item. Used for padding.
*/
$title = apply_filters( 'nav_menu_item_title', $title, $menu_item, $args, $depth );

$item_output = $args->before;
$item_output .= '<a' . $attributes . '>';
$item_output .= $args->link_before . $title . $args->link_after;
Expand Down
79 changes: 45 additions & 34 deletions src/wp-includes/comment-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1733,19 +1733,23 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c
* @param array $args {
* Optional. Override default arguments.
*
* @type string $add_below The first part of the selector used to identify the comment to respond below.
* The resulting value is passed as the first parameter to addComment.moveForm(),
* concatenated as $add_below-$comment->comment_ID. Default 'comment'.
* @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
* to addComment.moveForm(), and appended to the link URL as a hash value.
* Default 'respond'.
* @type string $reply_text The text of the Reply link. Default 'Reply'.
* @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
* @type int $max_depth The max depth of the comment tree. Default 0.
* @type int $depth The depth of the new comment. Must be greater than 0 and less than the value
* of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
* @type string $before The text or HTML to add before the reply link. Default empty.
* @type string $after The text or HTML to add after the reply link. Default empty.
* @type string $add_below The first part of the selector used to identify the comment to respond below.
* The resulting value is passed as the first parameter to addComment.moveForm(),
* concatenated as $add_below-$comment->comment_ID. Default 'comment'.
* @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
* to addComment.moveForm(), and appended to the link URL as a hash value.
* Default 'respond'.
* @type string $reply_text The visible text of the Reply link. Default 'Reply'.
* @type string $reply_to_text The accessible name of the Reply link, using `%s` as a placeholder
* for the comment author's name. Default 'Reply to %s'.
* Should start with the visible `reply_text` value.
* @type bool $show_reply_to_text Whether to use `reply_to_text` as visible link text. Default false.
* @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
* @type int $max_depth The max depth of the comment tree. Default 0.
* @type int $depth The depth of the new comment. Must be greater than 0 and less than the value
* of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
* @type string $before The text or HTML to add before the reply link. Default empty.
* @type string $after The text or HTML to add after the reply link. Default empty.
* }
* @param int|WP_Comment $comment Optional. Comment being replied to. Default current comment.
* @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on.
Expand All @@ -1754,16 +1758,17 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c
*/
function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
$defaults = array(
'add_below' => 'comment',
'respond_id' => 'respond',
'reply_text' => __( 'Reply' ),
'add_below' => 'comment',
'respond_id' => 'respond',
'reply_text' => __( 'Reply' ),
/* translators: Comment reply button text. %s: Comment author name. */
'reply_to_text' => __( 'Reply to %s' ),
'login_text' => __( 'Log in to Reply' ),
'max_depth' => 0,
'depth' => 0,
'before' => '',
'after' => '',
'reply_to_text' => __( 'Reply to %s' ),
'login_text' => __( 'Log in to Reply' ),
'max_depth' => 0,
'depth' => 0,
'before' => '',
'after' => '',
'show_reply_to_text' => false,
);

$args = wp_parse_args( $args, $defaults );
Expand Down Expand Up @@ -1829,8 +1834,14 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null

$data_attribute_string = trim( $data_attribute_string );

$reply_text = $args['show_reply_to_text']
? sprintf( $args['reply_to_text'], get_comment_author( $comment ) )
: $args['reply_text'];

$aria_label = $args['show_reply_to_text'] ? '' : sprintf( $args['reply_to_text'], get_comment_author( $comment ) );

$link = sprintf(
"<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>",
'<a rel="nofollow" class="comment-reply-link" href="%s" %s%s>%s</a>',
esc_url(
add_query_arg(
array(
Expand All @@ -1842,8 +1853,8 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null
)
) . '#' . $args['respond_id'],
$data_attribute_string,
esc_attr( sprintf( $args['reply_to_text'], get_comment_author( $comment ) ) ),
$args['reply_text']
$aria_label ? ' aria-label="' . esc_attr( $aria_label ) . '"' : '',
$reply_text
);
}

Expand Down Expand Up @@ -2089,15 +2100,15 @@ function comment_id_fields( $post = null ) {
*
* @global WP_Comment $comment Global comment object.
*
* @param string|false $no_reply_text Optional. Text to display when not replying to a comment.
* Default false.
* @param string|false $reply_text Optional. Text to display when replying to a comment.
* Default false. Accepts "%s" for the author of the comment
* being replied to.
* @param bool $link_to_parent Optional. Boolean to control making the author's name a link
* to their comment. Default true.
* @param int|WP_Post|null $post Optional. The post that the comment form is being displayed for.
* Defaults to the current global post.
* @param string|false $no_reply_text Optional. Text to display when not replying to a comment.
* Default false.
* @param string|false $reply_text Optional. Text to display when replying to a comment.
* Default false. Accepts "%s" for the author of the comment
* being replied to.
* @param bool $link_to_parent Optional. Boolean to control making the author's name a link
* to their comment. Default true.
* @param int|WP_Post|null $post Optional. The post that the comment form is being displayed for.
* Defaults to the current global post.
*/
function comment_form_title( $no_reply_text = false, $reply_text = false, $link_to_parent = true, $post = null ) {
global $comment;
Expand Down

0 comments on commit ea946d9

Please sign in to comment.