Make WordPress Core

Changeset 24537


Ignore:
Timestamp:
07/01/2013 05:27:41 PM (11 years ago)
Author:
lancewillett
Message:

Twenty Thirteen: cleanup for functions.php file, props obenland. See #24653.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentythirteen/functions.php

    r24516 r24537  
    3535 * Adds support for a custom header image.
    3636 */
    37 require( get_template_directory() . '/inc/custom-header.php' );
     37require get_template_directory() . '/inc/custom-header.php';
    3838
    3939/**
     
    4141 */
    4242if ( version_compare( $GLOBALS['wp_version'], '3.6-alpha', '<' ) )
    43     require( get_template_directory() . '/inc/back-compat.php' );
     43    require get_template_directory() . '/inc/back-compat.php';
    4444
    4545/**
     
    275275        'name'          => __( 'Main Widget Area', 'twentythirteen' ),
    276276        'id'            => 'sidebar-1',
    277         'description'   => __( 'Appears in the footer section of the site', 'twentythirteen' ),
     277        'description'   => __( 'Appears in the footer section of the site.', 'twentythirteen' ),
    278278        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    279279        'after_widget'  => '</aside>',
     
    306306
    307307    // Don't print empty markup if there's only one page.
    308     if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) )
     308    if ( $wp_query->max_num_pages < 2 )
    309309        return;
    310310    ?>
     
    340340    // Don't print empty markup if there's nowhere to navigate.
    341341    $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
    342     $next = get_adjacent_post( false, '', false );
     342    $next     = get_adjacent_post( false, '', false );
    343343
    344344    if ( ! $next && ! $previous )
     
    445445     * link to that image file.
    446446     */
    447     $attachments = array_values( get_children( array(
     447    $attachment_ids = get_posts( array(
    448448        'post_parent'    => $post->post_parent,
     449        'fields'         => 'ids',
     450        'numberposts'    => -1,
    449451        'post_status'    => 'inherit',
    450452        'post_type'      => 'attachment',
     
    452454        'order'          => 'ASC',
    453455        'orderby'        => 'menu_order ID'
    454     ) ) );
     456    ) );
    455457
    456458    // If there is more than 1 attachment in a gallery...
    457     if ( count( $attachments ) > 1 ) {
    458         foreach ( $attachments as $k => $attachment ) {
    459             if ( $attachment->ID == $post->ID )
     459    if ( count( $attachment_ids ) > 1 ) {
     460        foreach ( $attachment_ids as $attachment_id ) {
     461            if ( $attachment_id == $post->ID ) {
     462                $next_id = current( $attachment_ids );
    460463                break;
     464            }
    461465        }
    462         $k++;
    463466
    464467        // get the URL of the next image attachment...
    465         if ( isset( $attachments[ $k ] ) )
    466             $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
     468        if ( $next_id )
     469            $next_attachment_url = get_attachment_link( $next_id );
    467470
    468471        // or get the URL of the first image attachment.
    469472        else
    470             $next_attachment_url = get_attachment_link( $attachments[0]->ID );
     473            $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) );
    471474    }
    472475
Note: See TracChangeset for help on using the changeset viewer.