diff --git wp-includes/canonical.php wp-includes/canonical.php
index 423dcc6..cc84ac3 100644
|
|
function redirect_canonical( $requested_url = null, $do_redirect = true ) { |
148 | 148 | } elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) { |
149 | 149 | if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) ) |
150 | 150 | $redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']); |
151 | | } elseif ( is_year() && !empty($_GET['year']) ) { |
| 151 | } elseif ( is_matched_query_var( 'year' ) && is_year() && ! empty( $_GET['year'] ) ) { |
152 | 152 | if ( $redirect_url = get_year_link(get_query_var('year')) ) |
153 | 153 | $redirect['query'] = remove_query_arg('year', $redirect['query']); |
154 | | } elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) { |
| 154 | } elseif ( is_matched_query_var( 'author' ) && is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) { |
155 | 155 | $author = get_userdata(get_query_var('author')); |
156 | 156 | 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 ) ) ) { |
157 | 157 | if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) |
diff --git wp-includes/class-wp.php wp-includes/class-wp.php
index dc77688..505acd3 100644
|
|
class WP { |
106 | 106 | function set_query_var($key, $value) { |
107 | 107 | $this->query_vars[$key] = $value; |
108 | 108 | } |
109 | | |
| 109 | /** |
| 110 | * Determine if the query var matches a proper property in WP's $matched_query |
| 111 | * |
| 112 | * @since 3.7.0 |
| 113 | * |
| 114 | * @param string $key Name of the query var to check |
| 115 | * @return bool Whether the query var is in the matched rewrite (pretty permalinks) or |
| 116 | * query string |
| 117 | */ |
| 118 | function is_matched_query_var( $key ) { |
| 119 | $queries = wp_parse_args( $this->matched_query ); |
| 120 | return ( empty( $this->matched_query ) && ! empty( $_GET[$key] ) ) || array_key_exists( $key, $queries ); |
| 121 | } |
110 | 122 | /** |
111 | 123 | * Parse request to find correct WordPress query. |
112 | 124 | * |
diff --git wp-includes/functions.php wp-includes/functions.php
index 869da31..aca03ac 100644
|
|
function wp( $query_vars = '' ) { |
783 | 783 | } |
784 | 784 | |
785 | 785 | /** |
| 786 | * Determine if the query var matches a proper property in WP's $matched_query |
| 787 | * |
| 788 | * @since 3.7.0 |
| 789 | * |
| 790 | * @global WP $wp The main WP instance |
| 791 | * @param string $key Name of the query var to check |
| 792 | * @return bool Whether the query var is in the matched rewrite (pretty permalinks) or |
| 793 | * query string |
| 794 | */ |
| 795 | function is_matched_query_var( $key ) { |
| 796 | global $wp; |
| 797 | return $wp->is_matched_query_var( $key ); |
| 798 | } |
| 799 | |
| 800 | /** |
786 | 801 | * Retrieve the description for the HTTP status. |
787 | 802 | * |
788 | 803 | * @since 2.3.0 |