From 8dc60dd2133850c1dd3873019cab89533779523f Mon Sep 17 00:00:00 2001 From: audrasjb Date: Tue, 7 Feb 2023 14:05:20 +0000 Subject: [PATCH] Privacy: Add `rel="privacy-policy"` to the Privacy Policy link. This changeset adds a `rel="privacy-policy"` attribute to user-facing links to the Privacy Policy of the website, when a privacy policy page is set and available. While this `rel` value is still a RFC of the Link Types HTML specification, this changeset helps to make Privacy Policy link more discoverable for user agents and HTML parsers. Props dshanske, audrasjb, bhavz-10, bookwyrm, faisal03, JeffPaul, peterwilsoncc, paapst, davidbaumwald, costdev, robinwpdeveloper, kawserz. Fixes #56345. Built from https://develop.svn.wordpress.org/trunk@55261 git-svn-id: http://core.svn.wordpress.org/trunk@54794 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-walker-nav-menu.php | 12 +++++++++++- wp-includes/link-template.php | 2 +- wp-includes/version.php | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-walker-nav-menu.php b/wp-includes/class-walker-nav-menu.php index 47b3368141..e683a3d5c8 100644 --- a/wp-includes/class-walker-nav-menu.php +++ b/wp-includes/class-walker-nav-menu.php @@ -182,7 +182,17 @@ class Walker_Nav_Menu extends Walker { } else { $atts['rel'] = $menu_item->xfn; } - $atts['href'] = ! empty( $menu_item->url ) ? $menu_item->url : ''; + + if ( ! empty( $menu_item->url ) ) { + if ( get_privacy_policy_url() === $menu_item->url ) { + $atts['rel'] = empty( $atts['rel'] ) ? 'privacy-policy' : $atts['rel'] . ' privacy-policy'; + } + + $atts['href'] = $menu_item->url; + } else { + $atts['href'] = ''; + } + $atts['aria-current'] = $menu_item->current ? 'page' : ''; /** diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 893d1e5932..ec7e6dad80 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -4664,7 +4664,7 @@ function get_the_privacy_policy_link( $before = '', $after = '' ) { if ( $privacy_policy_url && $page_title ) { $link = sprintf( - '%s', + '%s', esc_url( $privacy_policy_url ), esc_html( $page_title ) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index fba04efebd..0a5ce9c40d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55260'; +$wp_version = '6.2-alpha-55261'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.