Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r41756 r42343  
    4040
    4141// Set the content width based on the theme's design and stylesheet.
    42 if ( ! isset( $content_width ) )
     42if ( ! isset( $content_width ) ) {
    4343    $content_width = 584;
     44}
    4445
    4546/*
     
    4849add_action( 'after_setup_theme', 'twentyeleven_setup' );
    4950
    50 if ( ! function_exists( 'twentyeleven_setup' ) ):
    51 /**
    52  * Set up theme defaults and registers support for various WordPress features.
    53  *
    54  * Note that this function is hooked into the after_setup_theme hook, which runs
    55  * before the init hook. The init hook is too late for some features, such as indicating
    56  * support post thumbnails.
    57  *
    58  * To override twentyeleven_setup() in a child theme, add your own twentyeleven_setup to your child theme's
    59  * functions.php file.
    60  *
    61  * @uses load_theme_textdomain()    For translation/localization support.
    62  * @uses add_editor_style()         To style the visual editor.
    63  * @uses add_theme_support()        To add support for post thumbnails, automatic feed links, custom headers
    64  *                                  and backgrounds, and post formats.
    65  * @uses register_nav_menus()       To add support for navigation menus.
    66  * @uses register_default_headers() To register the default custom header images provided with the theme.
    67  * @uses set_post_thumbnail_size()  To set a custom post thumbnail size.
    68  *
    69  * @since Twenty Eleven 1.0
    70  */
    71 function twentyeleven_setup() {
    72 
    73     /*
    74      * Make Twenty Eleven available for translation.
    75      * Translations can be added to the /languages/ directory.
    76      * If you're building a theme based on Twenty Eleven, use
    77      * a find and replace to change 'twentyeleven' to the name
    78      * of your theme in all the template files.
     51if ( ! function_exists( 'twentyeleven_setup' ) ) :
     52    /**
     53     * Set up theme defaults and registers support for various WordPress features.
     54     *
     55     * Note that this function is hooked into the after_setup_theme hook, which runs
     56     * before the init hook. The init hook is too late for some features, such as indicating
     57     * support post thumbnails.
     58     *
     59     * To override twentyeleven_setup() in a child theme, add your own twentyeleven_setup to your child theme's
     60     * functions.php file.
     61     *
     62     * @uses load_theme_textdomain()    For translation/localization support.
     63     * @uses add_editor_style()         To style the visual editor.
     64     * @uses add_theme_support()        To add support for post thumbnails, automatic feed links, custom headers
     65     *                                  and backgrounds, and post formats.
     66     * @uses register_nav_menus()       To add support for navigation menus.
     67     * @uses register_default_headers() To register the default custom header images provided with the theme.
     68     * @uses set_post_thumbnail_size()  To set a custom post thumbnail size.
     69     *
     70     * @since Twenty Eleven 1.0
    7971     */
    80     load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' );
    81 
    82     // This theme styles the visual editor with editor-style.css to match the theme style.
    83     add_editor_style();
    84 
    85     // Load up our theme options page and related code.
    86     require( get_template_directory() . '/inc/theme-options.php' );
    87 
    88     // Grab Twenty Eleven's Ephemera widget.
    89     require( get_template_directory() . '/inc/widgets.php' );
    90 
    91     // Add default posts and comments RSS feed links to <head>.
    92     add_theme_support( 'automatic-feed-links' );
    93 
    94     // This theme uses wp_nav_menu() in one location.
    95     register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
    96 
    97     // Add support for a variety of post formats
    98     add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
    99 
    100     $theme_options = twentyeleven_get_theme_options();
    101     if ( 'dark' == $theme_options['color_scheme'] )
    102         $default_background_color = '1d1d1d';
    103     else
    104         $default_background_color = 'e2e2e2';
    105 
    106     // Add support for custom backgrounds.
    107     add_theme_support( 'custom-background', array(
     72    function twentyeleven_setup() {
     73
    10874        /*
    109          * Let WordPress know what our default background color is.
    110          * This is dependent on our current color scheme.
     75         * Make Twenty Eleven available for translation.
     76         * Translations can be added to the /languages/ directory.
     77         * If you're building a theme based on Twenty Eleven, use
     78         * a find and replace to change 'twentyeleven' to the name
     79         * of your theme in all the template files.
    11180         */
    112         'default-color' => $default_background_color,
    113     ) );
    114 
    115     // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
    116     add_theme_support( 'post-thumbnails' );
    117 
    118     // Add support for custom headers.
    119     $custom_header_support = array(
    120         // The default header text color.
    121         'default-text-color' => '000',
    122         // The height and width of our custom header.
    123         /**
    124          * Filter the Twenty Eleven default header image width.
    125          *
    126          * @since Twenty Eleven 1.0
    127          *
    128          * @param int The default header image width in pixels. Default 1000.
     81        load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' );
     82
     83        // This theme styles the visual editor with editor-style.css to match the theme style.
     84        add_editor_style();
     85
     86        // Load up our theme options page and related code.
     87        require( get_template_directory() . '/inc/theme-options.php' );
     88
     89        // Grab Twenty Eleven's Ephemera widget.
     90        require( get_template_directory() . '/inc/widgets.php' );
     91
     92        // Add default posts and comments RSS feed links to <head>.
     93        add_theme_support( 'automatic-feed-links' );
     94
     95        // This theme uses wp_nav_menu() in one location.
     96        register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
     97
     98        // Add support for a variety of post formats
     99        add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
     100
     101        $theme_options = twentyeleven_get_theme_options();
     102        if ( 'dark' == $theme_options['color_scheme'] ) {
     103            $default_background_color = '1d1d1d';
     104        } else {
     105            $default_background_color = 'e2e2e2';
     106        }
     107
     108        // Add support for custom backgrounds.
     109        add_theme_support(
     110            'custom-background', array(
     111                /*
     112                * Let WordPress know what our default background color is.
     113                * This is dependent on our current color scheme.
     114                */
     115                'default-color' => $default_background_color,
     116            )
     117        );
     118
     119        // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
     120        add_theme_support( 'post-thumbnails' );
     121
     122        // Add support for custom headers.
     123        $custom_header_support = array(
     124            // The default header text color.
     125            'default-text-color'     => '000',
     126            // The height and width of our custom header.
     127            /**
     128             * Filter the Twenty Eleven default header image width.
     129             *
     130             * @since Twenty Eleven 1.0
     131             *
     132             * @param int The default header image width in pixels. Default 1000.
     133             */
     134            'width'                  => apply_filters( 'twentyeleven_header_image_width', 1000 ),
     135            /**
     136             * Filter the Twenty Eleven default header image height.
     137             *
     138             * @since Twenty Eleven 1.0
     139             *
     140             * @param int The default header image height in pixels. Default 288.
     141             */
     142               'height'              => apply_filters( 'twentyeleven_header_image_height', 288 ),
     143            // Support flexible heights.
     144            'flex-height'            => true,
     145            // Random image rotation by default.
     146            'random-default'         => true,
     147            // Callback for styling the header.
     148            'wp-head-callback'       => 'twentyeleven_header_style',
     149            // Callback for styling the header preview in the admin.
     150            'admin-head-callback'    => 'twentyeleven_admin_header_style',
     151            // Callback used to display the header preview in the admin.
     152            'admin-preview-callback' => 'twentyeleven_admin_header_image',
     153        );
     154
     155        add_theme_support( 'custom-header', $custom_header_support );
     156
     157        if ( ! function_exists( 'get_custom_header' ) ) {
     158            // This is all for compatibility with versions of WordPress prior to 3.4.
     159            define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
     160            define( 'HEADER_IMAGE', '' );
     161            define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
     162            define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
     163            add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
     164            add_custom_background();
     165        }
     166
     167        /*
     168         * We'll be using post thumbnails for custom header images on posts and pages.
     169         * We want them to be the size of the header image that we just defined.
     170         * Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
    129171         */
    130         'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ),
    131         /**
    132          * Filter the Twenty Eleven default header image height.
    133          *
    134          * @since Twenty Eleven 1.0
    135          *
    136          * @param int The default header image height in pixels. Default 288.
     172        set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
     173
     174        /*
     175         * Add Twenty Eleven's custom image sizes.
     176         * Used for large feature (header) images.
    137177         */
    138         'height' => apply_filters( 'twentyeleven_header_image_height', 288 ),
    139         // Support flexible heights.
    140         'flex-height' => true,
    141         // Random image rotation by default.
    142         'random-default' => true,
    143         // Callback for styling the header.
    144         'wp-head-callback' => 'twentyeleven_header_style',
    145         // Callback for styling the header preview in the admin.
    146         'admin-head-callback' => 'twentyeleven_admin_header_style',
    147         // Callback used to display the header preview in the admin.
    148         'admin-preview-callback' => 'twentyeleven_admin_header_image',
    149     );
    150 
    151     add_theme_support( 'custom-header', $custom_header_support );
    152 
    153     if ( ! function_exists( 'get_custom_header' ) ) {
    154         // This is all for compatibility with versions of WordPress prior to 3.4.
    155         define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
    156         define( 'HEADER_IMAGE', '' );
    157         define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
    158         define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
    159         add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
    160         add_custom_background();
    161     }
    162 
    163     /*
    164      * We'll be using post thumbnails for custom header images on posts and pages.
    165      * We want them to be the size of the header image that we just defined.
    166      * Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
     178        add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
     179        // Used for featured posts if a large-feature doesn't exist.
     180        add_image_size( 'small-feature', 500, 300 );
     181
     182        // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
     183        register_default_headers(
     184            array(
     185                'wheel'      => array(
     186                    'url'           => '%s/images/headers/wheel.jpg',
     187                    'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
     188                    /* translators: header image description */
     189                    'description'   => __( 'Wheel', 'twentyeleven' ),
     190                ),
     191                'shore'      => array(
     192                    'url'           => '%s/images/headers/shore.jpg',
     193                    'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',
     194                    /* translators: header image description */
     195                    'description'   => __( 'Shore', 'twentyeleven' ),
     196                ),
     197                'trolley'    => array(
     198                    'url'           => '%s/images/headers/trolley.jpg',
     199                    'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg',
     200                    /* translators: header image description */
     201                    'description'   => __( 'Trolley', 'twentyeleven' ),
     202                ),
     203                'pine-cone'  => array(
     204                    'url'           => '%s/images/headers/pine-cone.jpg',
     205                    'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg',
     206                    /* translators: header image description */
     207                    'description'   => __( 'Pine Cone', 'twentyeleven' ),
     208                ),
     209                'chessboard' => array(
     210                    'url'           => '%s/images/headers/chessboard.jpg',
     211                    'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg',
     212                    /* translators: header image description */
     213                    'description'   => __( 'Chessboard', 'twentyeleven' ),
     214                ),
     215                'lanterns'   => array(
     216                    'url'           => '%s/images/headers/lanterns.jpg',
     217                    'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg',
     218                    /* translators: header image description */
     219                    'description'   => __( 'Lanterns', 'twentyeleven' ),
     220                ),
     221                'willow'     => array(
     222                    'url'           => '%s/images/headers/willow.jpg',
     223                    'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg',
     224                    /* translators: header image description */
     225                    'description'   => __( 'Willow', 'twentyeleven' ),
     226                ),
     227                'hanoi'      => array(
     228                    'url'           => '%s/images/headers/hanoi.jpg',
     229                    'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg',
     230                    /* translators: header image description */
     231                    'description'   => __( 'Hanoi Plant', 'twentyeleven' ),
     232                ),
     233            )
     234        );
     235
     236        // Indicate widget sidebars can use selective refresh in the Customizer.
     237        add_theme_support( 'customize-selective-refresh-widgets' );
     238    }
     239endif; // twentyeleven_setup
     240
     241if ( ! function_exists( 'twentyeleven_header_style' ) ) :
     242    /**
     243     * Styles the header image and text displayed on the blog.
     244     *
     245     * @since Twenty Eleven 1.0
    167246     */
    168     set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
    169 
    170     /*
    171      * Add Twenty Eleven's custom image sizes.
    172      * Used for large feature (header) images.
    173      */
    174     add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
    175     // Used for featured posts if a large-feature doesn't exist.
    176     add_image_size( 'small-feature', 500, 300 );
    177 
    178     // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
    179     register_default_headers( array(
    180         'wheel' => array(
    181             'url' => '%s/images/headers/wheel.jpg',
    182             'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
    183             /* translators: header image description */
    184             'description' => __( 'Wheel', 'twentyeleven' )
    185         ),
    186         'shore' => array(
    187             'url' => '%s/images/headers/shore.jpg',
    188             'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',
    189             /* translators: header image description */
    190             'description' => __( 'Shore', 'twentyeleven' )
    191         ),
    192         'trolley' => array(
    193             'url' => '%s/images/headers/trolley.jpg',
    194             'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg',
    195             /* translators: header image description */
    196             'description' => __( 'Trolley', 'twentyeleven' )
    197         ),
    198         'pine-cone' => array(
    199             'url' => '%s/images/headers/pine-cone.jpg',
    200             'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg',
    201             /* translators: header image description */
    202             'description' => __( 'Pine Cone', 'twentyeleven' )
    203         ),
    204         'chessboard' => array(
    205             'url' => '%s/images/headers/chessboard.jpg',
    206             'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg',
    207             /* translators: header image description */
    208             'description' => __( 'Chessboard', 'twentyeleven' )
    209         ),
    210         'lanterns' => array(
    211             'url' => '%s/images/headers/lanterns.jpg',
    212             'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg',
    213             /* translators: header image description */
    214             'description' => __( 'Lanterns', 'twentyeleven' )
    215         ),
    216         'willow' => array(
    217             'url' => '%s/images/headers/willow.jpg',
    218             'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg',
    219             /* translators: header image description */
    220             'description' => __( 'Willow', 'twentyeleven' )
    221         ),
    222         'hanoi' => array(
    223             'url' => '%s/images/headers/hanoi.jpg',
    224             'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg',
    225             /* translators: header image description */
    226             'description' => __( 'Hanoi Plant', 'twentyeleven' )
    227         )
    228     ) );
    229 
    230     // Indicate widget sidebars can use selective refresh in the Customizer.
    231     add_theme_support( 'customize-selective-refresh-widgets' );
    232 }
    233 endif; // twentyeleven_setup
    234 
    235 if ( ! function_exists( 'twentyeleven_header_style' ) ) :
    236 /**
    237  * Styles the header image and text displayed on the blog.
    238  *
    239  * @since Twenty Eleven 1.0
    240  */
    241 function twentyeleven_header_style() {
    242     $text_color = get_header_textcolor();
    243 
    244     // If no custom options for text are set, let's bail.
    245     if ( $text_color == HEADER_TEXTCOLOR )
    246         return;
    247 
    248     // If we get this far, we have custom styles. Let's do this.
    249     ?>
    250     <style type="text/css" id="twentyeleven-header-css">
    251     <?php
     247    function twentyeleven_header_style() {
     248        $text_color = get_header_textcolor();
     249
     250        // If no custom options for text are set, let's bail.
     251        if ( $text_color == HEADER_TEXTCOLOR ) {
     252            return;
     253        }
     254
     255        // If we get this far, we have custom styles. Let's do this.
     256        ?>
     257        <style type="text/css" id="twentyeleven-header-css">
     258        <?php
    252259        // Has the text been hidden?
    253260        if ( 'blank' == $text_color ) :
     
    270277    </style>
    271278    <?php
    272 }
     279    }
    273280endif; // twentyeleven_header_style
    274281
    275282if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) :
    276 /**
    277  * Styles the header image displayed on the Appearance > Header admin panel.
    278  *
    279  * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
    280  *
    281  * @since Twenty Eleven 1.0
    282  */
    283 function twentyeleven_admin_header_style() {
    284 ?>
     283    /**
     284    * Styles the header image displayed on the Appearance > Header admin panel.
     285    *
     286    * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
     287    *
     288    * @since Twenty Eleven 1.0
     289    */
     290    function twentyeleven_admin_header_style() {
     291    ?>
    285292    <style type="text/css" id="twentyeleven-admin-header-css">
    286293    .appearance_page_custom-header #headimg {
     
    306313    <?php
    307314        // If the user has set a custom color for the text use that
    308         if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
     315    if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
    309316    ?>
    310         #site-title a,
    311         #site-description {
    312             color: #<?php echo get_header_textcolor(); ?>;
    313         }
     317    #site-title a,
     318    #site-description {
     319        color: #<?php echo get_header_textcolor(); ?>;
     320    }
    314321    <?php endif; ?>
    315322    #headimg img {
     
    319326    }
    320327    </style>
    321 <?php
    322 }
     328    <?php
     329    }
    323330endif; // twentyeleven_admin_header_style
    324331
    325332if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) :
    326 /**
    327  * Custom header image markup displayed on the Appearance > Header admin panel.
    328  *
    329  * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
    330  *
    331  * @since Twenty Eleven 1.0
    332  */
    333 function twentyeleven_admin_header_image() { ?>
    334     <div id="headimg">
    335         <?php
    336         $color = get_header_textcolor();
    337         $image = get_header_image();
    338         $style = 'display: none;';
    339         if ( $color && $color != 'blank' ) {
    340             $style = 'color: #' . $color . ';';
    341         }
    342         ?>
    343         <h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( $style ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
     333    /**
     334     * Custom header image markup displayed on the Appearance > Header admin panel.
     335     *
     336     * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
     337     *
     338     * @since Twenty Eleven 1.0
     339     */
     340    function twentyeleven_admin_header_image() {
     341
     342?>
     343        <div id="headimg">
     344            <?php
     345            $color = get_header_textcolor();
     346            $image = get_header_image();
     347            $style = 'display: none;';
     348            if ( $color && $color != 'blank' ) {
     349                $style = 'color: #' . $color . ';';
     350            }
     351            ?>
     352            <h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( $style ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
    344353        <div id="desc" class="displaying-header-text" style="<?php echo esc_attr( $style ); ?>"><?php bloginfo( 'description' ); ?></div>
    345         <?php if ( $image ) : ?>
     354        <?php if ( $image ) : ?>
    346355            <img src="<?php echo esc_url( $image ); ?>" alt="" />
    347356        <?php endif; ?>
    348     </div>
    349 <?php }
     357        </div>
     358    <?php
     359    }
    350360endif; // twentyeleven_admin_header_image
    351361
     
    368378
    369379if ( ! function_exists( 'twentyeleven_continue_reading_link' ) ) :
    370 /**
    371  * Return a "Continue Reading" link for excerpts
    372  *
    373  * @since Twenty Eleven 1.0
    374  *
    375  * @return string The "Continue Reading" HTML link.
    376  */
    377 function twentyeleven_continue_reading_link() {
    378     return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>';
    379 }
     380    /**
     381    * Return a "Continue Reading" link for excerpts
     382    *
     383    * @since Twenty Eleven 1.0
     384    *
     385    * @return string The "Continue Reading" HTML link.
     386    */
     387    function twentyeleven_continue_reading_link() {
     388        return ' <a href="' . esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>';
     389    }
    380390endif; // twentyeleven_continue_reading_link
    381391
     
    429439 */
    430440function twentyeleven_page_menu_args( $args ) {
    431     if ( ! isset( $args['show_home'] ) )
     441    if ( ! isset( $args['show_home'] ) ) {
    432442        $args['show_home'] = true;
     443    }
    433444    return $args;
    434445}
     
    446457    register_widget( 'Twenty_Eleven_Ephemera_Widget' );
    447458
    448     register_sidebar( array(
    449         'name' => __( 'Main Sidebar', 'twentyeleven' ),
    450         'id' => 'sidebar-1',
    451         'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    452         'after_widget' => '</aside>',
    453         'before_title' => '<h3 class="widget-title">',
    454         'after_title' => '</h3>',
    455     ) );
    456 
    457     register_sidebar( array(
    458         'name' => __( 'Showcase Sidebar', 'twentyeleven' ),
    459         'id' => 'sidebar-2',
    460         'description' => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ),
    461         'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    462         'after_widget' => '</aside>',
    463         'before_title' => '<h3 class="widget-title">',
    464         'after_title' => '</h3>',
    465     ) );
    466 
    467     register_sidebar( array(
    468         'name' => __( 'Footer Area One', 'twentyeleven' ),
    469         'id' => 'sidebar-3',
    470         'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
    471         'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    472         'after_widget' => '</aside>',
    473         'before_title' => '<h3 class="widget-title">',
    474         'after_title' => '</h3>',
    475     ) );
    476 
    477     register_sidebar( array(
    478         'name' => __( 'Footer Area Two', 'twentyeleven' ),
    479         'id' => 'sidebar-4',
    480         'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
    481         'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    482         'after_widget' => '</aside>',
    483         'before_title' => '<h3 class="widget-title">',
    484         'after_title' => '</h3>',
    485     ) );
    486 
    487     register_sidebar( array(
    488         'name' => __( 'Footer Area Three', 'twentyeleven' ),
    489         'id' => 'sidebar-5',
    490         'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
    491         'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    492         'after_widget' => '</aside>',
    493         'before_title' => '<h3 class="widget-title">',
    494         'after_title' => '</h3>',
    495     ) );
     459    register_sidebar(
     460        array(
     461            'name'          => __( 'Main Sidebar', 'twentyeleven' ),
     462            'id'            => 'sidebar-1',
     463            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
     464            'after_widget'  => '</aside>',
     465            'before_title'  => '<h3 class="widget-title">',
     466            'after_title'   => '</h3>',
     467        )
     468    );
     469
     470    register_sidebar(
     471        array(
     472            'name'          => __( 'Showcase Sidebar', 'twentyeleven' ),
     473            'id'            => 'sidebar-2',
     474            'description'   => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ),
     475            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
     476            'after_widget'  => '</aside>',
     477            'before_title'  => '<h3 class="widget-title">',
     478            'after_title'   => '</h3>',
     479        )
     480    );
     481
     482    register_sidebar(
     483        array(
     484            'name'          => __( 'Footer Area One', 'twentyeleven' ),
     485            'id'            => 'sidebar-3',
     486            'description'   => __( 'An optional widget area for your site footer', 'twentyeleven' ),
     487            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
     488            'after_widget'  => '</aside>',
     489            'before_title'  => '<h3 class="widget-title">',
     490            'after_title'   => '</h3>',
     491        )
     492    );
     493
     494    register_sidebar(
     495        array(
     496            'name'          => __( 'Footer Area Two', 'twentyeleven' ),
     497            'id'            => 'sidebar-4',
     498            'description'   => __( 'An optional widget area for your site footer', 'twentyeleven' ),
     499            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
     500            'after_widget'  => '</aside>',
     501            'before_title'  => '<h3 class="widget-title">',
     502            'after_title'   => '</h3>',
     503        )
     504    );
     505
     506    register_sidebar(
     507        array(
     508            'name'          => __( 'Footer Area Three', 'twentyeleven' ),
     509            'id'            => 'sidebar-5',
     510            'description'   => __( 'An optional widget area for your site footer', 'twentyeleven' ),
     511            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
     512            'after_widget'  => '</aside>',
     513            'before_title'  => '<h3 class="widget-title">',
     514            'after_title'   => '</h3>',
     515        )
     516    );
    496517}
    497518add_action( 'widgets_init', 'twentyeleven_widgets_init' );
    498519
    499520if ( ! function_exists( 'twentyeleven_content_nav' ) ) :
    500 /**
    501  * Display navigation to next/previous pages when applicable.
    502  *
    503  * @since Twenty Eleven 1.0
    504  *
    505  * @param string $html_id The HTML id attribute.
    506  */
    507 function twentyeleven_content_nav( $html_id ) {
    508     global $wp_query;
    509 
    510     if ( $wp_query->max_num_pages > 1 ) : ?>
    511         <nav id="<?php echo esc_attr( $html_id ); ?>">
    512             <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
    513             <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
    514             <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
    515         </nav><!-- #nav-above -->
    516     <?php endif;
    517 }
     521    /**
     522     * Display navigation to next/previous pages when applicable.
     523     *
     524     * @since Twenty Eleven 1.0
     525     *
     526     * @param string $html_id The HTML id attribute.
     527     */
     528    function twentyeleven_content_nav( $html_id ) {
     529        global $wp_query;
     530
     531        if ( $wp_query->max_num_pages > 1 ) :
     532    ?>
     533            <nav id="<?php echo esc_attr( $html_id ); ?>">
     534                <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
     535                <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
     536                <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
     537            </nav><!-- #nav-above -->
     538        <?php
     539    endif;
     540    }
    518541endif; // twentyeleven_content_nav
    519542
     
    532555    $has_url = function_exists( 'get_url_in_content' ) ? get_url_in_content( $content ) : false;
    533556
    534     if ( ! $has_url )
     557    if ( ! $has_url ) {
    535558        $has_url = twentyeleven_url_grabber();
     559    }
    536560
    537561    /** This filter is documented in wp-includes/link-template.php */
     
    547571 */
    548572function twentyeleven_url_grabber() {
    549     if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
     573    if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) {
    550574        return false;
     575    }
    551576
    552577    return esc_url_raw( $matches[1] );
     
    561586    $count = 0;
    562587
    563     if ( is_active_sidebar( 'sidebar-3' ) )
     588    if ( is_active_sidebar( 'sidebar-3' ) ) {
    564589        $count++;
    565 
    566     if ( is_active_sidebar( 'sidebar-4' ) )
     590    }
     591
     592    if ( is_active_sidebar( 'sidebar-4' ) ) {
    567593        $count++;
    568 
    569     if ( is_active_sidebar( 'sidebar-5' ) )
     594    }
     595
     596    if ( is_active_sidebar( 'sidebar-5' ) ) {
    570597        $count++;
     598    }
    571599
    572600    $class = '';
     
    584612    }
    585613
    586     if ( $class )
     614    if ( $class ) {
    587615        echo 'class="' . esc_attr( $class ) . '"';
     616    }
    588617}
    589618
    590619if ( ! function_exists( 'twentyeleven_comment' ) ) :
    591 /**
    592  * Template for comments and pingbacks.
    593  *
    594  * To override this walker in a child theme without modifying the comments template
    595  * simply create your own twentyeleven_comment(), and that function will be used instead.
    596  *
    597  * Used as a callback by wp_list_comments() for displaying the comments.
    598  *
    599  * @since Twenty Eleven 1.0
    600  *
    601  * @param object $comment The comment object.
    602  * @param array  $args    An array of comment arguments. @see get_comment_reply_link()
    603  * @param int    $depth   The depth of the comment.
    604  */
    605 function twentyeleven_comment( $comment, $args, $depth ) {
    606     $GLOBALS['comment'] = $comment;
    607     switch ( $comment->comment_type ) :
    608         case 'pingback' :
    609         case 'trackback' :
    610     ?>
    611     <li class="post pingback">
     620    /**
     621    * Template for comments and pingbacks.
     622    *
     623    * To override this walker in a child theme without modifying the comments template
     624    * simply create your own twentyeleven_comment(), and that function will be used instead.
     625    *
     626    * Used as a callback by wp_list_comments() for displaying the comments.
     627    *
     628    * @since Twenty Eleven 1.0
     629    *
     630    * @param object $comment The comment object.
     631    * @param array  $args    An array of comment arguments. @see get_comment_reply_link()
     632    * @param int    $depth   The depth of the comment.
     633    */
     634    function twentyeleven_comment( $comment, $args, $depth ) {
     635        $GLOBALS['comment'] = $comment;
     636        switch ( $comment->comment_type ) :
     637            case 'pingback':
     638            case 'trackback':
     639        ?>
     640        <li class="post pingback">
    612641        <p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
    613642    <?php
    614             break;
    615         default :
    616     ?>
    617     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
     643                break;
     644            default:
     645        ?>
     646        <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
    618647        <article id="comment-<?php comment_ID(); ?>" class="comment">
    619648            <footer class="comment-meta">
     
    621650                    <?php
    622651                        $avatar_size = 68;
    623                         if ( '0' != $comment->comment_parent )
    624                             $avatar_size = 39;
     652                    if ( '0' != $comment->comment_parent ) {
     653                        $avatar_size = 39;
     654                    }
    625655
    626656                        echo get_avatar( $comment, $avatar_size );
    627657
    628658                        /* translators: 1: comment author, 2: date and time */
    629                         printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
     659                        printf(
     660                            __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
    630661                            sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
    631                             sprintf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
     662                            sprintf(
     663                                '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
    632664                                esc_url( get_comment_link( $comment->comment_ID ) ),
    633665                                get_comment_time( 'c' ),
     
    636668                            )
    637669                        );
    638                     ?>
    639 
    640                     <?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
    641                 </div><!-- .comment-author .vcard -->
    642 
    643                 <?php if ( $comment->comment_approved == '0' ) : ?>
     670                        ?>
     671
     672                        <?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
     673                    </div><!-- .comment-author .vcard -->
     674
     675                    <?php if ( $comment->comment_approved == '0' ) : ?>
    644676                    <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyeleven' ); ?></em>
    645677                    <br />
    646678                <?php endif; ?>
    647679
    648             </footer>
    649 
    650             <div class="comment-content"><?php comment_text(); ?></div>
    651 
    652             <div class="reply">
    653                 <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    654             </div><!-- .reply -->
    655         </article><!-- #comment-## -->
    656 
    657     <?php
    658             break;
    659     endswitch;
    660 }
     680                </footer>
     681
     682                <div class="comment-content"><?php comment_text(); ?></div>
     683
     684                <div class="reply">
     685                    <?php
     686                    comment_reply_link(
     687                        array_merge(
     688                            $args, array(
     689                                'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ),
     690                                'depth'      => $depth,
     691                                'max_depth'  => $args['max_depth'],
     692                            )
     693                        )
     694                    );
     695?>
     696                </div><!-- .reply -->
     697            </article><!-- #comment-## -->
     698
     699        <?php
     700                break;
     701        endswitch;
     702    }
    661703endif; // ends check for twentyeleven_comment()
    662704
    663705if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
    664 /**
    665  * Print HTML with meta information for the current post-date/time and author.
    666  *
    667  * Create your own twentyeleven_posted_on to override in a child theme
    668  *
    669  * @since Twenty Eleven 1.0
    670  */
    671 function twentyeleven_posted_on() {
    672     printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
    673         esc_url( get_permalink() ),
    674         esc_attr( get_the_time() ),
    675         esc_attr( get_the_date( 'c' ) ),
    676         esc_html( get_the_date() ),
    677         esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    678         esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
    679         get_the_author()
    680     );
    681 }
     706    /**
     707     * Print HTML with meta information for the current post-date/time and author.
     708     *
     709     * Create your own twentyeleven_posted_on to override in a child theme
     710     *
     711     * @since Twenty Eleven 1.0
     712     */
     713    function twentyeleven_posted_on() {
     714        printf(
     715            __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
     716            esc_url( get_permalink() ),
     717            esc_attr( get_the_time() ),
     718            esc_attr( get_the_date( 'c' ) ),
     719            esc_html( get_the_date() ),
     720            esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
     721            esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
     722            get_the_author()
     723        );
     724    }
    682725endif;
    683726
     
    695738function twentyeleven_body_classes( $classes ) {
    696739
    697     if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
     740    if ( function_exists( 'is_multi_author' ) && ! is_multi_author() ) {
    698741        $classes[] = 'single-author';
    699 
    700     if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
     742    }
     743
     744    if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) {
    701745        $classes[] = 'singular';
     746    }
    702747
    703748    return $classes;
     
    720765    if ( function_exists( 'get_post_galleries' ) ) {
    721766        $galleries = get_post_galleries( get_the_ID(), false );
    722         if ( isset( $galleries[0]['ids'] ) )
     767        if ( isset( $galleries[0]['ids'] ) ) {
    723768            $images = explode( ',', $galleries[0]['ids'] );
     769        }
    724770    } else {
    725771        $pattern = get_shortcode_regex();
    726772        preg_match( "/$pattern/s", get_the_content(), $match );
    727773        $atts = shortcode_parse_atts( $match[3] );
    728         if ( isset( $atts['ids'] ) )
     774        if ( isset( $atts['ids'] ) ) {
    729775            $images = explode( ',', $atts['ids'] );
     776        }
    730777    }
    731778
    732779    if ( ! $images ) {
    733         $images = get_posts( array(
    734             'fields'         => 'ids',
    735             'numberposts'    => 999,
    736             'order'          => 'ASC',
    737             'orderby'        => 'menu_order',
    738             'post_mime_type' => 'image',
    739             'post_parent'    => get_the_ID(),
    740             'post_type'      => 'attachment',
    741         ) );
     780        $images = get_posts(
     781            array(
     782                'fields'         => 'ids',
     783                'numberposts'    => 999,
     784                'order'          => 'ASC',
     785                'orderby'        => 'menu_order',
     786                'post_mime_type' => 'image',
     787                'post_parent'    => get_the_ID(),
     788                'post_type'      => 'attachment',
     789            )
     790        );
    742791    }
    743792
Note: See TracChangeset for help on using the changeset viewer.