Changeset 59674
- Timestamp:
- 01/21/2025 09:24:59 PM (2 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-walker-nav-menu.php
r59179 r59674 41 41 42 42 /** 43 * The URL to the privacy policy page. 44 * 45 * @since 6.8.0 46 * @var string 47 */ 48 private $privacy_policy_url; 49 50 /** 51 * Constructor. 52 * 53 * @since 6.8.0 54 */ 55 public function __construct() { 56 $this->privacy_policy_url = get_privacy_policy_url(); 57 } 58 59 /** 43 60 * Starts the list before the elements are added. 44 61 * … … 237 254 238 255 if ( ! empty( $menu_item->url ) ) { 239 if ( get_privacy_policy_url()=== $menu_item->url ) {256 if ( $this->privacy_policy_url === $menu_item->url ) { 240 257 $atts['rel'] = empty( $atts['rel'] ) ? 'privacy-policy' : $atts['rel'] . ' privacy-policy'; 241 258 } -
trunk/tests/phpunit/tests/menu/walker-nav-menu.php
r59120 r59674 19 19 20 20 /** 21 * The ID of the privacy policy page. 22 * 23 * @var int 24 */ 25 private $privacy_policy_id; 26 27 /** 21 28 * Setup. 22 29 */ … … 28 35 /** Walker_Nav_Menu class */ 29 36 require_once ABSPATH . 'wp-includes/class-walker-nav-menu.php'; 37 38 $post_id = self::factory()->post->create( 39 array( 40 'post_type' => 'page', 41 'post_title' => 'Test Privacy Policy', 42 'post_status' => 'publish', 43 ) 44 ); 45 46 // Set the privacy policy page. 47 update_option( 'wp_page_for_privacy_policy', $post_id ); 48 $this->privacy_policy_id = (int) get_option( 'wp_page_for_privacy_policy' ); 49 30 50 $this->walker = new Walker_Nav_Menu(); 31 51 … … 40 60 41 61 $_wp_nav_menu_max_depth = $this->orig_wp_nav_menu_max_depth; 62 delete_option( 'wp_page_for_privacy_policy' ); 42 63 parent::tear_down(); 43 64 } … … 137 158 */ 138 159 public function test_walker_nav_menu_start_el_should_add_rel_privacy_policy_to_privacy_policy_url( $expected, $xfn = '', $target = '' ) { 139 $post_id = self::factory()->post->create(140 array(141 'post_type' => 'page',142 'post_title' => 'Test Privacy Policy',143 'post_status' => 'publish',144 )145 );146 147 // Set the privacy policy page.148 update_option( 'wp_page_for_privacy_policy', $post_id );149 $privacy_policy_id = (int) get_option( 'wp_page_for_privacy_policy' );150 160 151 161 $output = ''; 152 162 153 163 $item = array( 154 'ID' => $ privacy_policy_id,155 'object_id' => $ privacy_policy_id,164 'ID' => $this->privacy_policy_id, 165 'object_id' => $this->privacy_policy_id, 156 166 'title' => 'Privacy Policy', 157 167 'target' => $target, … … 252 262 */ 253 263 public function test_walker_nav_menu_start_el_should_not_add_rel_privacy_policy_when_no_url_is_passed() { 254 $post_id = self::factory()->post->create(255 array(256 'post_type' => 'page',257 'post_title' => 'Test Privacy Policy',258 'post_status' => 'publish',259 )260 );261 262 // Set the privacy policy page.263 update_option( 'wp_page_for_privacy_policy', $post_id );264 $privacy_policy_id = (int) get_option( 'wp_page_for_privacy_policy' );265 264 266 265 $output = ''; 267 266 268 267 $item = array( 269 'ID' => $ privacy_policy_id,270 'object_id' => $ privacy_policy_id,268 'ID' => $this->privacy_policy_id, 269 'object_id' => $this->privacy_policy_id, 271 270 'title' => 'Privacy Policy', 272 271 'target' => '', … … 297 296 */ 298 297 public function test_walker_nav_menu_start_el_should_add_rel_privacy_policy_when_id_does_not_match_but_url_does() { 299 $post_id = self::factory()->post->create(300 array(301 'post_type' => 'page',302 'post_title' => 'Test Privacy Policy',303 'post_status' => 'publish',304 )305 );306 307 // Set the privacy policy page.308 update_option( 'wp_page_for_privacy_policy', $post_id );309 $privacy_policy_id = (int) get_option( 'wp_page_for_privacy_policy' );310 298 311 299 $output = ''; 312 300 313 301 // Ensure the ID does not match the privacy policy. 314 $not_privacy_policy_id = $ privacy_policy_id - 1;302 $not_privacy_policy_id = $this->privacy_policy_id - 1; 315 303 316 304 $item = array(
Note: See TracChangeset
for help on using the changeset viewer.