WordPress.org

Make WordPress Core

Ticket #9015: 9015.get_loop.diff

File 9015.get_loop.diff, 10.4 KB (added by dd32, 8 years ago)
  • wp-content/themes/twentyten/archive.php

     
    1717
    1818<?php rewind_posts(); ?>
    1919
    20 <?php include 'loop.php'; ?>
     20<?php get_loop('excerpt'); ?>
    2121
    2222                        </div><!-- #content -->
    2323                </div><!-- #container -->
  • wp-content/themes/twentyten/author.php

     
    2121
    2222<?php rewind_posts(); ?>
    2323
    24 <?php include 'loop.php'; ?>
     24<?php get_loop('excerpt'); ?>
    2525
    2626                        </div><!-- #content -->
    2727                </div><!-- #container -->
  • wp-content/themes/twentyten/category.php

     
    1010
    1111<?php rewind_posts(); ?>
    1212
    13 <?php include 'loop.php'; ?>
     13<?php get_loop('excerpt'); ?>
    1414
    1515                        </div><!-- #content -->
    1616                </div><!-- #container -->
  • wp-content/themes/twentyten/index.php

     
    44                        <div id="content">
    55
    66    <?php if ( have_posts() ) :
    7                 include 'loop.php';
     7                get_loop();
    88    else : ?>
    99                <h2><?php _e( 'Not Found', 'twentyten' ); ?></h2>
    1010                <div class="entry-content">
  • wp-content/themes/twentyten/loop.php

     
    1414                        <span class="meta-prep meta-prep-author"><?php _e( 'Posted on ', 'twentyten' ); ?></span>
    1515                        <a href="<?php the_permalink(); ?>" title="<?php the_time(); ?>" rel="bookmark"><span class="entry-date"><?php echo get_the_date(); ?></span></a>
    1616                        <span class="meta-sep"> <?php _e( 'by ', 'twentyten' ); ?> </span>
    17                         <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( $authordata->ID ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
     17                        <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( get_the_author_meta('ID') ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
    1818                </div><!-- .entry-meta -->
    1919
    2020                <div class="entry-content">
     
    4646
    4747<?php } elseif ( in_category( 'asides' ) ) { ?>
    4848        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     49<?php if ( is_named_loop('excerpt') ) : ?>
     50                <div class="entry-summary">
     51                        <?php the_excerpt( __( 'Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
     52                </div><!-- .entry-summary -->
     53<?php else : ?>
    4954                <div class="entry-content">
    5055                        <?php the_content( __( 'Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    5156                </div><!-- .entry-content -->
     57<?php endif; ?>
    5258
    5359                <div class="entry-utility">
    5460                        <span class="meta-prep meta-prep-author"><?php _e( 'Posted on ', 'twentyten' ); ?></span>
    5561                        <a href="<?php the_permalink(); ?>" title="<?php the_time(); ?>" rel="bookmark"><span class="entry-date"><?php echo get_the_date(); ?></span></a>
    5662                        <span class="meta-sep"> <?php _e( ' by ', 'twentyten' ); ?> </span>
    57                         <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( $authordata->ID ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
     63                        <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( get_the_author_meta('ID') ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
    5864                        <span class="meta-sep"><?php __( ' | ', 'twentyten' ); ?></span>
    5965                        <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    6066                        <?php edit_post_link( __( 'Edit', 'twentyten' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t\n" ); ?>
     
    7177                        <a href="<?php
    7278the_permalink(); ?>" title="<?php the_time(); ?>" rel="bookmark"><span class="entry-date"><?php echo get_the_date(); ?></span></a>
    7379                        <span class="meta-sep"><?php _e( ' by ', 'twentyten' ); ?></span>
    74                         <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( $authordata->ID ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
     80                        <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( get_the_author_meta('ID') ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
    7581                </div><!-- .entry-meta -->
    7682
    77 <?php if ( is_archive() || is_search() ) : //Only display Excerpts for archives & search ?>
     83<?php if ( is_named_loop('excerpt') ) : ?>
    7884                <div class="entry-summary">
    79                         <?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
     85                        <?php the_excerpt( __( 'Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    8086                </div><!-- .entry-summary -->
    8187<?php else : ?>
    8288                <div class="entry-content">
  • wp-content/themes/twentyten/search.php

     
    55
    66<?php if ( have_posts() ) : ?>
    77                                <h1 class="page-title"><?php _e( 'Search Results for: ', 'twentyten' ); ?><span><?php the_search_query(); ?></span></h1>
    8         <?php include 'loop.php'; ?>
     8        <?php get_loop('excerpt'); ?>
    99<?php else : ?>
    1010                                <div id="post-0" class="post no-results not-found">
    1111                                        <h2 class="entry-title"><?php _e( 'Nothing Found', 'twentyten' ); ?></h2>
  • wp-content/themes/twentyten/single.php

     
    1515
    1616                                        <div class="entry-meta">
    1717                                                <span class="meta-prep meta-prep-author"><?php _e( 'Posted by ', 'twentyten' ); ?></span>
    18                                                 <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
     18                                                <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( get_the_author_meta('ID') ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
    1919                                                <span class="meta-sep"><?php _e( ' on ', 'twentyten' ); ?> </span>
    2020                                                <a href="<?php the_permalink(); ?>" title="<?php the_time(); ?>" rel="bookmark"><span class="entry-date"><?php echo get_the_date(); ?></span></a>
    2121                                                <?php edit_post_link( __( 'Edit', 'twentyten' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t" ); ?>
     
    3535                                                        <h2><?php _e( 'About ', 'twentyten' ); ?><?php the_author(); ?></h2>
    3636                                                        <?php the_author_meta('description'); ?>
    3737                                                        <div id="author-link">
    38                                                                 <a href="<?php echo get_author_posts_url( $authordata->ID ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php _e( 'View all posts by ', 'twentyten' ); ?><?php the_author(); ?> &rarr;</a>
     38                                                                <a href="<?php echo get_author_posts_url( get_the_author_meta('ID') ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php _e( 'View all posts by ', 'twentyten' ); ?><?php the_author(); ?> &rarr;</a>
    3939                                                        </div><!-- #author-link -->
    4040                                                </div><!-- #author-description  -->
    4141                                        </div><!-- .entry-author-info -->
  • wp-content/themes/twentyten/tag.php

     
    99
    1010<?php rewind_posts(); ?>
    1111
    12 <?php include 'loop.php'; ?>
     12<?php get_loop('excerpt'); ?>
    1313
    1414                        </div><!-- #content -->
    1515                </div><!-- #container -->
  • wp-includes/general-template.php

     
    9494}
    9595
    9696/**
     97 * Load loop template.
     98 *
     99 * Includes the loop template for a theme or if a name is specified then a
     100 * specialised loop will be included.
     101 *
     102 * For the parameter, if the file is called "loop-special.php" then specify
     103 * "special".
     104 *
     105 * @uses locate_template()
     106 * @global $_template_loop
     107 * @since 3.0
     108 * @uses do_action() Calls 'get_loop' action.
     109 *
     110 * @param string $name (optional) The name of the specialised loop.
     111 */
     112function get_loop( $name = null ) {
     113        global $_template_loop;
     114        $_template_loop = $name;
     115        do_action( 'get_loop', $name );
     116
     117        $templates = array();
     118        if ( isset($name) )
     119                $templates[] = "loop-{$name}.php";
     120
     121        $templates[] = "loop.php";
     122
     123        $templates = apply_filters('get_loop_templates', $templates, $name);
     124
     125        return locate_template($templates, true);
     126}
     127
     128/**
     129 * Check to see if Current Loop is a named loop
     130 *
     131 * For the parameter, if the file is called "loop-special.php" then specify
     132 * "special".
     133 *
     134 * @global $_template_loop
     135 * @since 3.0
     136 *
     137 * @param string $name (optional) The name of the specialised loop.
     138 * @return bool If its that named loop or not.
     139 */
     140function is_named_loop($name = null) {
     141        global $_template_loop;
     142        return ($_template_loop == $name);
     143}
     144
     145/**
    97146 * Display search form.
    98147 *
    99148 * Will first attempt to locate the searchform.php file in either the child or