Ticket #20902: 20902.patch
File 20902.patch, 4.7 KB (added by , 7 years ago) |
---|
-
src/wp-includes/canonical.php
172 172 } elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) { 173 173 if ( $redirect_url = get_permalink(get_query_var('page_id')) ) 174 174 $redirect['query'] = remove_query_arg('page_id', $redirect['query']); 175 } elseif ( is_page() && ! empty( $_GET['pagename'] ) ) { 176 $page = get_page_by_path( $_GET['pagename'] ); 177 if ( $page && $redirect_url = get_permalink( $page->ID ) ) { 178 $redirect['query'] = remove_query_arg( 'pagename', $redirect['query'] ); 179 } 175 180 } elseif ( is_page() && !is_feed() && isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') && ! $redirect_url ) { 176 181 $redirect_url = home_url('/'); 177 182 } elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts') && ! $redirect_url ) { … … 208 213 if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) 209 214 $redirect['query'] = remove_query_arg('author', $redirect['query']); 210 215 } 216 } elseif ( is_author() && ! empty( $_GET['author_name'] ) ) { 217 $author = get_user_by( 'slug', $_GET['author_name'] ); 218 if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) { 219 if ( $redirect_url = get_author_posts_url( $author->ID, $author->user_nicename ) ) { 220 $redirect['query'] = remove_query_arg( 'author_name', $redirect['query'] ); 221 } 222 } 211 223 } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories) 212 224 213 225 $term_count = 0; -
src/wp-includes/post-formats.php
159 159 $slugs = get_post_format_slugs(); 160 160 if ( isset( $slugs[ $qvs['post_format'] ] ) ) 161 161 $qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ]; 162 $tax = get_taxonomy( 'post_format' );163 if ( ! is_admin() )164 $qvs['post_type'] = $tax->object_type;165 162 return $qvs; 166 163 } 167 164 -
tests/phpunit/includes/testcase-canonical.php
50 50 51 51 // Already created by install defaults: 52 52 // self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) ); 53 54 self::$post_ids[] = $factory->post->create( array( 'import_id' => 587, 'post_title' => 'post-format-test-audio', 'post_date' => '2008-06-02 00:00:00' ) ); 53 $post_format_audio_id = $factory->post->create( array( 'import_id' => 587, 'post_title' => 'post-format-test-audio', 'post_date' => '2008-06-02 00:00:00' ) ); 54 set_post_format( $post_format_audio_id, 'audio' ); 55 self::$post_ids[] = $post_format_audio_id; 55 56 self::$post_ids[] = $post_id = $factory->post->create( array( 'post_title' => 'post-format-test-gallery', 'post_date' => '2008-06-10 00:00:00' ) ); 56 57 self::$post_ids[] = $factory->post->create( array( 'import_id' => 611, 'post_type' => 'attachment', 'post_title' => 'canola2', 'post_parent' => $post_id ) ); 57 58 -
tests/phpunit/tests/canonical.php
84 84 array( '/?name=images-te', '/2008/09/03/images-test/', 20374), 85 85 // Page slug should resolve to post slug and remove the ?pagename= parameter 86 86 array( '/?pagename=images-test', '/2008/09/03/images-test/', 20374), 87 array( '/?pagename=sample-page', '/sample-page/'), 87 88 89 array( '/?post_format=audio', '/type/audio/' ), 88 90 array( '/2008/06/02/post-format-test-au/', '/2008/06/02/post-format-test-audio/'), 89 91 array( '/2008/06/post-format-test-au/', '/2008/06/02/post-format-test-audio/'), 90 92 array( '/2008/post-format-test-au/', '/2008/06/02/post-format-test-audio/'), … … 118 120 119 121 // Authors 120 122 array( '/?author=%d', '/author/canonical-author/' ), 123 array( '/?author_name=canonical-author', '/author/canonical-author/' ), 124 array( '/?author_name=foobar', '/?author_name=foobar' ), 121 125 // array( '/?author=%d&year=2008', '/2008/?author=3'), 122 126 // array( '/author/canonical-author/?year=2008', '/2008/?author=3'), //Either or, see previous testcase. 123 127