WordPress.org

Make WordPress Core

Changeset 25574


Ignore:
Timestamp:
09/23/2013 05:21:49 PM (7 years ago)
Author:
nacin
Message:

Set up author data for the author template immediately, rather than waiting for the first the_post() call.

This removes the need to call the_post() and rewind_posts() in an author template to print information about the author.

props obenland.
fixes #14408.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp.php

    r23573 r25574  
    442442     *
    443443     * @global string $query_string Query string for the loop.
     444     * @global array $posts The found posts.
     445     * @global WP_Post|null $post The current post, if available.
     446     * @global string $request The SQL statement for the request.
    444447     * @global int $more Only set, if single page or post.
    445448     * @global int $single If single page or post. Only set, if single page or post.
     449     * @global WP_User $authordata Only set, if author archive.
    446450     *
    447451     * @since 2.0.0
     
    449453    function register_globals() {
    450454        global $wp_query;
     455
    451456        // Extract updated query vars back into global namespace.
    452         foreach ( (array) $wp_query->query_vars as $key => $value) {
    453             $GLOBALS[$key] = $value;
     457        foreach ( (array) $wp_query->query_vars as $key => $value ) {
     458            $GLOBALS[ $key ] = $value;
    454459        }
    455460
    456461        $GLOBALS['query_string'] = $this->query_string;
    457462        $GLOBALS['posts'] = & $wp_query->posts;
    458         $GLOBALS['post'] = (isset($wp_query->post)) ? $wp_query->post : null;
     463        $GLOBALS['post'] = isset( $wp_query->post ) ? $wp_query->post : null;
    459464        $GLOBALS['request'] = $wp_query->request;
    460465
    461         if ( is_single() || is_page() ) {
    462             $GLOBALS['more'] = 1;
     466        if ( $wp_query->is_single() || $wp_query->is_page() ) {
     467            $GLOBALS['more']   = 1;
    463468            $GLOBALS['single'] = 1;
    464469        }
     470
     471        if ( $wp_query->is_author() && $wp_query->post )
     472            $GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
    465473    }
    466474
Note: See TracChangeset for help on using the changeset viewer.