WordPress.org

Make WordPress Core

Ticket #17661: 17661.diff

File 17661.diff, 2.8 KB (added by wonderboymusic, 8 years ago)
  • wp-includes/canonical.php

    diff --git wp-includes/canonical.php wp-includes/canonical.php
    index 423dcc6..cc84ac3 100644
    function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    148148                } elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) {
    149149                        if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
    150150                                $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'] ) ) {
    152152                        if ( $redirect_url = get_year_link(get_query_var('year')) )
    153153                                $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'] ) ) {
    155155                        $author = get_userdata(get_query_var('author'));
    156156                        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 ) ) ) {
    157157                                if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) )
  • wp-includes/class-wp.php

    diff --git wp-includes/class-wp.php wp-includes/class-wp.php
    index dc77688..505acd3 100644
    class WP { 
    106106        function set_query_var($key, $value) {
    107107                $this->query_vars[$key] = $value;
    108108        }
    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        }
    110122        /**
    111123         * Parse request to find correct WordPress query.
    112124         *
  • wp-includes/functions.php

    diff --git wp-includes/functions.php wp-includes/functions.php
    index 869da31..aca03ac 100644
    function wp( $query_vars = '' ) { 
    783783}
    784784
    785785/**
     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 */
     795function is_matched_query_var( $key ) {
     796        global $wp;
     797        return $wp->is_matched_query_var( $key );
     798}
     799
     800/**
    786801 * Retrieve the description for the HTTP status.
    787802 *
    788803 * @since 2.3.0