Changeset 49563
- Timestamp:
- 11/12/2020 04:14:44 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r49200 r49563 78 78 $redirect = $original; 79 79 $redirect_url = false; 80 $redirect_obj = false; 80 81 81 82 // Notice fixing. … … 103 104 if ( is_feed() && $post_id ) { 104 105 $redirect_url = get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) ); 106 $redirect_obj = get_post( $post_id ); 105 107 106 108 if ( $redirect_url ) { … … 127 129 128 130 $redirect_url = get_permalink( $post_id ); 131 $redirect_obj = get_post( $post_id ); 129 132 130 133 if ( $redirect_url ) { … … 151 154 if ( $post_type_obj->public && 'auto-draft' !== $redirect_post->post_status ) { 152 155 $redirect_url = get_permalink( $redirect_post ); 156 $redirect_obj = get_post( $redirect_post ); 153 157 154 158 $redirect['query'] = _remove_qs_args_if_not_in_url( … … 198 202 if ( $post_id ) { 199 203 $redirect_url = get_permalink( $post_id ); 204 $redirect_obj = get_post( $post_id ); 200 205 201 206 $redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' ); … … 224 229 if ( ! empty( $_GET['attachment_id'] ) ) { 225 230 $redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) ); 231 $redirect_obj = get_post( get_query_var( 'attachment_id' ) ); 226 232 227 233 if ( $redirect_url ) { … … 230 236 } else { 231 237 $redirect_url = get_attachment_link(); 238 $redirect_obj = get_post(); 232 239 } 233 240 } elseif ( is_single() && ! empty( $_GET['p'] ) && ! $redirect_url ) { 234 241 $redirect_url = get_permalink( get_query_var( 'p' ) ); 242 $redirect_obj = get_post( get_query_var( 'p' ) ); 235 243 236 244 if ( $redirect_url ) { … … 239 247 } elseif ( is_single() && ! empty( $_GET['name'] ) && ! $redirect_url ) { 240 248 $redirect_url = get_permalink( $wp_query->get_queried_object_id() ); 249 $redirect_obj = get_post( $wp_query->get_queried_object_id() ); 241 250 242 251 if ( $redirect_url ) { … … 245 254 } elseif ( is_page() && ! empty( $_GET['page_id'] ) && ! $redirect_url ) { 246 255 $redirect_url = get_permalink( get_query_var( 'page_id' ) ); 256 $redirect_obj = get_post( get_query_var( 'page_id' ) ); 247 257 248 258 if ( $redirect_url ) { … … 257 267 ) { 258 268 $redirect_url = get_permalink( get_option( 'page_for_posts' ) ); 269 $redirect_obj = get_post( get_option( 'page_for_posts' ) ); 259 270 260 271 if ( $redirect_url ) { … … 311 322 ) { 312 323 $redirect_url = get_author_posts_url( $author->ID, $author->user_nicename ); 324 $redirect_obj = $author; 313 325 314 326 if ( $redirect_url ) { … … 386 398 ) { 387 399 $redirect_url = get_permalink( $wp_query->get_queried_object_id() ); 400 $redirect_obj = get_post( $wp_query->get_queried_object_id() ); 388 401 } 389 402 } … … 396 409 if ( ! $redirect_url ) { 397 410 $redirect_url = get_permalink( get_queried_object_id() ); 411 $redirect_obj = get_post( get_queried_object_id() ); 398 412 } 399 413 … … 741 755 } 742 756 757 if ( 758 $redirect_obj && 759 is_a( $redirect_obj, 'WP_Post' ) 760 ) { 761 $post_status_obj = get_post_status_object( get_post_status( $redirect_obj ) ); 762 if ( 763 // Unviewable post types are never redirected. 764 ! is_post_type_viewable( $redirect_obj->post_type ) || 765 // Internal or protected posts never redirect. 766 $post_status_obj->internal || 767 $post_status_obj->protected || 768 ( 769 // Don't redirect a non-public post... 770 ! $post_status_obj->public && 771 ( 772 // ...unless it's private and the logged in user has access. 773 $post_status_obj->private && 774 ! current_user_can( 'read_post', $redirect_obj->ID ) 775 ) 776 ) 777 ) { 778 $redirect_obj = false; 779 $redirect_url = false; 780 } 781 } 782 743 783 /** 744 784 * Filters the canonical redirect URL. -
trunk/src/wp-includes/link-template.php
r49222 r49563 419 419 if ( $parent && ! in_array( $parent->post_type, get_post_types(), true ) ) { 420 420 $parent = false; 421 } 422 423 if ( $parent ) { 424 $parent_status_obj = get_post_status_object( get_post_status( $post->post_parent ) ); 425 if ( 426 ! is_post_type_viewable( get_post_type( $post->post_parent ) ) || 427 $parent_status_obj->internal || 428 $parent_status_obj->protected 429 ) { 430 $parent = false; 431 } 421 432 } 422 433
Note: See TracChangeset
for help on using the changeset viewer.