From e96961f861a2b9e3c73d76f0c3ec60c2acfd947d Mon Sep 17 00:00:00 2001 From: audrasjb Date: Tue, 27 Jun 2023 08:11:23 +0000 Subject: [PATCH] Twenty Nineteen: Add fragment ID to paginated links. This changeset adds the `#content` fragment identifier to paginated links so the screen scrolls down to the content section when clicking on pagination links located on paginated pages. Props laurelfulford, mukesh27, joyously, poena, alvitazwar052, oglekler, audrasjb. Fixes #45920. Built from https://develop.svn.wordpress.org/trunk@56057 git-svn-id: http://core.svn.wordpress.org/trunk@55569 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../twentynineteen/inc/template-functions.php | 17 +++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/wp-content/themes/twentynineteen/inc/template-functions.php b/wp-content/themes/twentynineteen/inc/template-functions.php index de2fa088bb..536fbd3ee4 100644 --- a/wp-content/themes/twentynineteen/inc/template-functions.php +++ b/wp-content/themes/twentynineteen/inc/template-functions.php @@ -223,3 +223,20 @@ function twentynineteen_add_mobile_parent_nav_menu_items( $sorted_menu_items, $a return $amended_menu_items; } add_filter( 'wp_nav_menu_objects', 'twentynineteen_add_mobile_parent_nav_menu_items', 10, 2 ); + +/** + * Adds a fragment identifier (to the content) to paginated links. + * + * @since Twenty Nineteen 2.6 + * + * @param string $link The page number HTML output. + * @param int $i Page number for paginated posts' page links. + * @return string Formatted output in HTML. + */ +function twentynineteen_link_pages_link( $link, $i ) { + if ( $i > 1 && preg_match( '/href="([^"]*)"/', $link, $matches ) ) { + $link = str_replace( $matches[1], $matches[1] . '#content', $link ); + } + return $link; +} +add_filter( 'wp_link_pages_link', 'twentynineteen_link_pages_link', 10, 2 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 5fd58917bd..be89e05ef5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-56056'; +$wp_version = '6.3-alpha-56057'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.