Changeset 49622 for trunk/src/wp-includes/canonical.php
- Timestamp:
- 11/17/2020 03:27:07 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r49563 r49622 78 78 $redirect = $original; 79 79 $redirect_url = false; 80 $redirect_obj = false;81 80 82 81 // Notice fixing. … … 104 103 if ( is_feed() && $post_id ) { 105 104 $redirect_url = get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) ); 106 $redirect_obj = get_post( $post_id );107 105 108 106 if ( $redirect_url ) { … … 129 127 130 128 $redirect_url = get_permalink( $post_id ); 131 $redirect_obj = get_post( $post_id );132 129 133 130 if ( $redirect_url ) { … … 154 151 if ( $post_type_obj->public && 'auto-draft' !== $redirect_post->post_status ) { 155 152 $redirect_url = get_permalink( $redirect_post ); 156 $redirect_obj = get_post( $redirect_post );157 153 158 154 $redirect['query'] = _remove_qs_args_if_not_in_url( … … 202 198 if ( $post_id ) { 203 199 $redirect_url = get_permalink( $post_id ); 204 $redirect_obj = get_post( $post_id );205 200 206 201 $redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' ); … … 229 224 if ( ! empty( $_GET['attachment_id'] ) ) { 230 225 $redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) ); 231 $redirect_obj = get_post( get_query_var( 'attachment_id' ) );232 226 233 227 if ( $redirect_url ) { … … 236 230 } else { 237 231 $redirect_url = get_attachment_link(); 238 $redirect_obj = get_post();239 232 } 240 233 } elseif ( is_single() && ! empty( $_GET['p'] ) && ! $redirect_url ) { 241 234 $redirect_url = get_permalink( get_query_var( 'p' ) ); 242 $redirect_obj = get_post( get_query_var( 'p' ) );243 235 244 236 if ( $redirect_url ) { … … 247 239 } elseif ( is_single() && ! empty( $_GET['name'] ) && ! $redirect_url ) { 248 240 $redirect_url = get_permalink( $wp_query->get_queried_object_id() ); 249 $redirect_obj = get_post( $wp_query->get_queried_object_id() );250 241 251 242 if ( $redirect_url ) { … … 254 245 } elseif ( is_page() && ! empty( $_GET['page_id'] ) && ! $redirect_url ) { 255 246 $redirect_url = get_permalink( get_query_var( 'page_id' ) ); 256 $redirect_obj = get_post( get_query_var( 'page_id' ) );257 247 258 248 if ( $redirect_url ) { … … 267 257 ) { 268 258 $redirect_url = get_permalink( get_option( 'page_for_posts' ) ); 269 $redirect_obj = get_post( get_option( 'page_for_posts' ) );270 259 271 260 if ( $redirect_url ) { … … 322 311 ) { 323 312 $redirect_url = get_author_posts_url( $author->ID, $author->user_nicename ); 324 $redirect_obj = $author;325 313 326 314 if ( $redirect_url ) { … … 398 386 ) { 399 387 $redirect_url = get_permalink( $wp_query->get_queried_object_id() ); 400 $redirect_obj = get_post( $wp_query->get_queried_object_id() );401 388 } 402 389 } … … 409 396 if ( ! $redirect_url ) { 410 397 $redirect_url = get_permalink( get_queried_object_id() ); 411 $redirect_obj = get_post( get_queried_object_id() );412 398 } 413 399 … … 755 741 } 756 742 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 783 743 /** 784 744 * Filters the canonical redirect URL.
Note: See TracChangeset
for help on using the changeset viewer.