Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 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/twentyten/functions.php

    r41756 r42343  
    4545 * is designed for, generally via the style.css stylesheet.
    4646 */
    47 if ( ! isset( $content_width ) )
     47if ( ! isset( $content_width ) ) {
    4848    $content_width = 640;
     49}
    4950
    5051/* Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
    5152add_action( 'after_setup_theme', 'twentyten_setup' );
    5253
    53 if ( ! function_exists( 'twentyten_setup' ) ):
    54 /**
    55  * Set up theme defaults and registers support for various WordPress features.
    56  *
    57  * Note that this function is hooked into the after_setup_theme hook, which runs
    58  * before the init hook. The init hook is too late for some features, such as indicating
    59  * support post thumbnails.
    60  *
    61  * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
    62  * functions.php file.
    63  *
    64  * @uses add_theme_support()        To add support for post thumbnails, custom headers and backgrounds, and automatic feed links.
    65  * @uses register_nav_menus()       To add support for navigation menus.
    66  * @uses add_editor_style()         To style the visual editor.
    67  * @uses load_theme_textdomain()    For translation/localization support.
    68  * @uses register_default_headers() To register the default custom header images provided with the theme.
    69  * @uses set_post_thumbnail_size()  To set a custom post thumbnail size.
    70  *
    71  * @since Twenty Ten 1.0
    72  */
    73 function twentyten_setup() {
    74 
    75     // This theme styles the visual editor with editor-style.css to match the theme style.
    76     add_editor_style();
    77 
    78     // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
    79     add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
    80 
    81     // This theme uses post thumbnails
    82     add_theme_support( 'post-thumbnails' );
    83 
    84     // Add default posts and comments RSS feed links to head
    85     add_theme_support( 'automatic-feed-links' );
    86 
    87     /*
    88      * Make theme available for translation.
    89      * Translations can be filed in the /languages/ directory
     54if ( ! function_exists( 'twentyten_setup' ) ) :
     55    /**
     56     * Set up theme defaults and registers support for various WordPress features.
     57     *
     58     * Note that this function is hooked into the after_setup_theme hook, which runs
     59     * before the init hook. The init hook is too late for some features, such as indicating
     60     * support post thumbnails.
     61     *
     62     * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
     63     * functions.php file.
     64     *
     65     * @uses add_theme_support()        To add support for post thumbnails, custom headers and backgrounds, and automatic feed links.
     66     * @uses register_nav_menus()       To add support for navigation menus.
     67     * @uses add_editor_style()         To style the visual editor.
     68     * @uses load_theme_textdomain()    For translation/localization support.
     69     * @uses register_default_headers() To register the default custom header images provided with the theme.
     70     * @uses set_post_thumbnail_size()  To set a custom post thumbnail size.
     71     *
     72     * @since Twenty Ten 1.0
    9073     */
    91     load_theme_textdomain( 'twentyten', get_template_directory() . '/languages' );
    92 
    93     // This theme uses wp_nav_menu() in one location.
    94     register_nav_menus( array(
    95         'primary' => __( 'Primary Navigation', 'twentyten' ),
    96     ) );
    97 
    98     // This theme allows users to set a custom background.
    99     add_theme_support( 'custom-background', array(
    100         // Let WordPress know what our default background color is.
    101         'default-color' => 'f1f1f1',
    102     ) );
    103 
    104     // The custom header business starts here.
    105 
    106     $custom_header_support = array(
     74    function twentyten_setup() {
     75
     76        // This theme styles the visual editor with editor-style.css to match the theme style.
     77        add_editor_style();
     78
     79        // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
     80        add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
     81
     82        // This theme uses post thumbnails
     83        add_theme_support( 'post-thumbnails' );
     84
     85        // Add default posts and comments RSS feed links to head
     86        add_theme_support( 'automatic-feed-links' );
     87
    10788        /*
    108          * The default image to use.
    109          * The %s is a placeholder for the theme template directory URI.
     89         * Make theme available for translation.
     90         * Translations can be filed in the /languages/ directory
    11091         */
    111         'default-image' => '%s/images/headers/path.jpg',
    112         // The height and width of our custom header.
    113         /**
    114          * Filter the Twenty Ten default header image width.
    115          *
    116          * @since Twenty Ten 1.0
    117          *
    118          * @param int The default header image width in pixels. Default 940.
     92        load_theme_textdomain( 'twentyten', get_template_directory() . '/languages' );
     93
     94        // This theme uses wp_nav_menu() in one location.
     95        register_nav_menus(
     96            array(
     97                'primary' => __( 'Primary Navigation', 'twentyten' ),
     98            )
     99        );
     100
     101        // This theme allows users to set a custom background.
     102        add_theme_support(
     103            'custom-background', array(
     104                // Let WordPress know what our default background color is.
     105                'default-color' => 'f1f1f1',
     106            )
     107        );
     108
     109        // The custom header business starts here.
     110
     111        $custom_header_support = array(
     112            /*
     113             * The default image to use.
     114             * The %s is a placeholder for the theme template directory URI.
     115             */
     116            'default-image'       => '%s/images/headers/path.jpg',
     117            // The height and width of our custom header.
     118            /**
     119             * Filter the Twenty Ten default header image width.
     120             *
     121             * @since Twenty Ten 1.0
     122             *
     123             * @param int The default header image width in pixels. Default 940.
     124             */
     125            'width'               => apply_filters( 'twentyten_header_image_width', 940 ),
     126            /**
     127             * Filter the Twenty Ten defaul header image height.
     128             *
     129             * @since Twenty Ten 1.0
     130             *
     131             * @param int The default header image height in pixels. Default 198.
     132             */
     133               'height'           => apply_filters( 'twentyten_header_image_height', 198 ),
     134            // Support flexible heights.
     135            'flex-height'         => true,
     136            // Don't support text inside the header image.
     137            'header-text'         => false,
     138            // Callback for styling the header preview in the admin.
     139            'admin-head-callback' => 'twentyten_admin_header_style',
     140        );
     141
     142        add_theme_support( 'custom-header', $custom_header_support );
     143
     144        if ( ! function_exists( 'get_custom_header' ) ) {
     145            // This is all for compatibility with versions of WordPress prior to 3.4.
     146            define( 'HEADER_TEXTCOLOR', '' );
     147            define( 'NO_HEADER_TEXT', true );
     148            define( 'HEADER_IMAGE', $custom_header_support['default-image'] );
     149            define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
     150            define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
     151            add_custom_image_header( '', $custom_header_support['admin-head-callback'] );
     152            add_custom_background();
     153        }
     154
     155        /*
     156         * We'll be using post thumbnails for custom header images on posts and pages.
     157         * We want them to be 940 pixels wide by 198 pixels tall.
     158         * Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
    119159         */
    120         'width' => apply_filters( 'twentyten_header_image_width', 940 ),
    121         /**
    122          * Filter the Twenty Ten defaul header image height.
    123          *
    124          * @since Twenty Ten 1.0
    125          *
    126          * @param int The default header image height in pixels. Default 198.
    127          */
    128         'height' => apply_filters( 'twentyten_header_image_height', 198 ),
    129         // Support flexible heights.
    130         'flex-height' => true,
    131         // Don't support text inside the header image.
    132         'header-text' => false,
    133         // Callback for styling the header preview in the admin.
    134         'admin-head-callback' => 'twentyten_admin_header_style',
    135     );
    136 
    137     add_theme_support( 'custom-header', $custom_header_support );
    138 
    139     if ( ! function_exists( 'get_custom_header' ) ) {
    140         // This is all for compatibility with versions of WordPress prior to 3.4.
    141         define( 'HEADER_TEXTCOLOR', '' );
    142         define( 'NO_HEADER_TEXT', true );
    143         define( 'HEADER_IMAGE', $custom_header_support['default-image'] );
    144         define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
    145         define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
    146         add_custom_image_header( '', $custom_header_support['admin-head-callback'] );
    147         add_custom_background();
    148     }
    149 
    150     /*
    151      * We'll be using post thumbnails for custom header images on posts and pages.
    152      * We want them to be 940 pixels wide by 198 pixels tall.
    153      * Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
     160        set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
     161
     162        // ... and thus ends the custom header business.
     163
     164        // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
     165        register_default_headers(
     166            array(
     167                'berries'       => array(
     168                    'url'           => '%s/images/headers/berries.jpg',
     169                    'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
     170                    /* translators: header image description */
     171                    'description'   => __( 'Berries', 'twentyten' ),
     172                ),
     173                'cherryblossom' => array(
     174                    'url'           => '%s/images/headers/cherryblossoms.jpg',
     175                    'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
     176                    /* translators: header image description */
     177                    'description'   => __( 'Cherry Blossoms', 'twentyten' ),
     178                ),
     179                'concave'       => array(
     180                    'url'           => '%s/images/headers/concave.jpg',
     181                    'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
     182                    /* translators: header image description */
     183                    'description'   => __( 'Concave', 'twentyten' ),
     184                ),
     185                'fern'          => array(
     186                    'url'           => '%s/images/headers/fern.jpg',
     187                    'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
     188                    /* translators: header image description */
     189                    'description'   => __( 'Fern', 'twentyten' ),
     190                ),
     191                'forestfloor'   => array(
     192                    'url'           => '%s/images/headers/forestfloor.jpg',
     193                    'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
     194                    /* translators: header image description */
     195                    'description'   => __( 'Forest Floor', 'twentyten' ),
     196                ),
     197                'inkwell'       => array(
     198                    'url'           => '%s/images/headers/inkwell.jpg',
     199                    'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
     200                    /* translators: header image description */
     201                    'description'   => __( 'Inkwell', 'twentyten' ),
     202                ),
     203                'path'          => array(
     204                    'url'           => '%s/images/headers/path.jpg',
     205                    'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
     206                    /* translators: header image description */
     207                    'description'   => __( 'Path', 'twentyten' ),
     208                ),
     209                'sunset'        => array(
     210                    'url'           => '%s/images/headers/sunset.jpg',
     211                    'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
     212                    /* translators: header image description */
     213                    'description'   => __( 'Sunset', 'twentyten' ),
     214                ),
     215            )
     216        );
     217    }
     218endif;
     219
     220if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
     221    /**
     222     * Style the header image displayed on the Appearance > Header admin panel.
     223     *
     224     * Referenced via add_custom_image_header() in twentyten_setup().
     225     *
     226     * @since Twenty Ten 1.0
    154227     */
    155     set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
    156 
    157     // ... and thus ends the custom header business.
    158 
    159     // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
    160     register_default_headers( array(
    161         'berries' => array(
    162             'url' => '%s/images/headers/berries.jpg',
    163             'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
    164             /* translators: header image description */
    165             'description' => __( 'Berries', 'twentyten' )
    166         ),
    167         'cherryblossom' => array(
    168             'url' => '%s/images/headers/cherryblossoms.jpg',
    169             'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
    170             /* translators: header image description */
    171             'description' => __( 'Cherry Blossoms', 'twentyten' )
    172         ),
    173         'concave' => array(
    174             'url' => '%s/images/headers/concave.jpg',
    175             'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
    176             /* translators: header image description */
    177             'description' => __( 'Concave', 'twentyten' )
    178         ),
    179         'fern' => array(
    180             'url' => '%s/images/headers/fern.jpg',
    181             'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
    182             /* translators: header image description */
    183             'description' => __( 'Fern', 'twentyten' )
    184         ),
    185         'forestfloor' => array(
    186             'url' => '%s/images/headers/forestfloor.jpg',
    187             'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
    188             /* translators: header image description */
    189             'description' => __( 'Forest Floor', 'twentyten' )
    190         ),
    191         'inkwell' => array(
    192             'url' => '%s/images/headers/inkwell.jpg',
    193             'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
    194             /* translators: header image description */
    195             'description' => __( 'Inkwell', 'twentyten' )
    196         ),
    197         'path' => array(
    198             'url' => '%s/images/headers/path.jpg',
    199             'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
    200             /* translators: header image description */
    201             'description' => __( 'Path', 'twentyten' )
    202         ),
    203         'sunset' => array(
    204             'url' => '%s/images/headers/sunset.jpg',
    205             'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
    206             /* translators: header image description */
    207             'description' => __( 'Sunset', 'twentyten' )
    208         )
    209     ) );
    210 }
    211 endif;
    212 
    213 if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
    214 /**
    215  * Style the header image displayed on the Appearance > Header admin panel.
    216  *
    217  * Referenced via add_custom_image_header() in twentyten_setup().
    218  *
    219  * @since Twenty Ten 1.0
    220  */
    221 function twentyten_admin_header_style() {
    222 ?>
    223 <style type="text/css" id="twentyten-admin-header-css">
    224 /* Shows the same border as on front end */
    225 #headimg {
     228    function twentyten_admin_header_style() {
     229    ?>
     230    <style type="text/css" id="twentyten-admin-header-css">
     231    /* Shows the same border as on front end */
     232    #headimg {
    226233    border-bottom: 1px solid #000;
    227234    border-top: 4px solid #000;
    228 }
    229 /* If header-text was supported, you would style the text with these selectors:
     235    }
     236    /* If header-text was supported, you would style the text with these selectors:
    230237    #headimg #name { }
    231238    #headimg #desc { }
    232 */
    233 </style>
    234 <?php
    235 }
     239    */
     240    </style>
     241    <?php
     242    }
    236243endif;
    237244
     
    247254 */
    248255function twentyten_page_menu_args( $args ) {
    249     if ( ! isset( $args['show_home'] ) )
     256    if ( ! isset( $args['show_home'] ) ) {
    250257        $args['show_home'] = true;
     258    }
    251259    return $args;
    252260}
     
    270278
    271279if ( ! function_exists( 'twentyten_continue_reading_link' ) ) :
    272 /**
    273  * Return a "Continue Reading" link for excerpts.
    274  *
    275  * @since Twenty Ten 1.0
    276  *
    277  * @return string "Continue Reading" link.
    278  */
    279 function twentyten_continue_reading_link() {
    280     return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
    281 }
     280    /**
     281    * Return a "Continue Reading" link for excerpts.
     282    *
     283    * @since Twenty Ten 1.0
     284    *
     285    * @return string "Continue Reading" link.
     286    */
     287    function twentyten_continue_reading_link() {
     288        return ' <a href="' . get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
     289    }
    282290endif;
    283291
     
    347355}
    348356// Backwards compatibility with WordPress 3.0.
    349 if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
     357if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) ) {
    350358    add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
     359}
    351360
    352361if ( ! function_exists( 'twentyten_comment' ) ) :
    353 /**
    354  * Template for comments and pingbacks.
    355  *
    356  * To override this walker in a child theme without modifying the comments template
    357  * simply create your own twentyten_comment(), and that function will be used instead.
    358  *
    359  * Used as a callback by wp_list_comments() for displaying the comments.
    360  *
    361  * @since Twenty Ten 1.0
    362  *
    363  * @param object $comment The comment object.
    364  * @param array  $args    An array of arguments. @see get_comment_reply_link()
    365  * @param int    $depth   The depth of the comment.
    366  */
    367 function twentyten_comment( $comment, $args, $depth ) {
    368     $GLOBALS['comment'] = $comment;
    369     switch ( $comment->comment_type ) :
    370         case '' :
    371     ?>
    372     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
     362    /**
     363    * Template for comments and pingbacks.
     364    *
     365    * To override this walker in a child theme without modifying the comments template
     366    * simply create your own twentyten_comment(), and that function will be used instead.
     367    *
     368    * Used as a callback by wp_list_comments() for displaying the comments.
     369    *
     370    * @since Twenty Ten 1.0
     371    *
     372    * @param object $comment The comment object.
     373    * @param array  $args    An array of arguments. @see get_comment_reply_link()
     374    * @param int    $depth   The depth of the comment.
     375    */
     376    function twentyten_comment( $comment, $args, $depth ) {
     377        $GLOBALS['comment'] = $comment;
     378        switch ( $comment->comment_type ) :
     379            case '':
     380        ?>
     381        <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
    373382        <div id="comment-<?php comment_ID(); ?>">
    374383            <div class="comment-author vcard">
     
    384393                <?php
    385394                    /* translators: 1: date, 2: time */
    386                     printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
     395                    printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() );
     396                    ?>
     397                    </a>
     398                    <?php
     399                    edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
    387400                ?>
    388             </div><!-- .comment-meta .commentmetadata -->
    389 
    390             <div class="comment-body"><?php comment_text(); ?></div>
    391 
    392             <div class="reply">
    393                 <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    394             </div><!-- .reply -->
    395         </div><!-- #comment-##  -->
    396 
    397     <?php
    398             break;
    399         case 'pingback'  :
    400         case 'trackback' :
    401     ?>
    402     <li class="post pingback">
     401                </div><!-- .comment-meta .commentmetadata -->
     402
     403                <div class="comment-body"><?php comment_text(); ?></div>
     404
     405                <div class="reply">
     406                <?php
     407                comment_reply_link(
     408                    array_merge(
     409                        $args, array(
     410                            'depth'     => $depth,
     411                            'max_depth' => $args['max_depth'],
     412                        )
     413                    )
     414                );
     415?>
     416                </div><!-- .reply -->
     417            </div><!-- #comment-##  -->
     418
     419        <?php
     420                break;
     421            case 'pingback':
     422            case 'trackback':
     423        ?>
     424        <li class="post pingback">
    403425        <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
    404426    <?php
    405             break;
    406     endswitch;
    407 }
     427                break;
     428        endswitch;
     429    }
    408430endif;
    409431
     
    420442function twentyten_widgets_init() {
    421443    // Area 1, located at the top of the sidebar.
    422     register_sidebar( array(
    423         'name' => __( 'Primary Widget Area', 'twentyten' ),
    424         'id' => 'primary-widget-area',
    425         'description' => __( 'Add widgets here to appear in your sidebar.', 'twentyten' ),
    426         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    427         'after_widget' => '</li>',
    428         'before_title' => '<h3 class="widget-title">',
    429         'after_title' => '</h3>',
    430     ) );
     444    register_sidebar(
     445        array(
     446            'name'          => __( 'Primary Widget Area', 'twentyten' ),
     447            'id'            => 'primary-widget-area',
     448            'description'   => __( 'Add widgets here to appear in your sidebar.', 'twentyten' ),
     449            'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
     450            'after_widget'  => '</li>',
     451            'before_title'  => '<h3 class="widget-title">',
     452            'after_title'   => '</h3>',
     453        )
     454    );
    431455
    432456    // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
    433     register_sidebar( array(
    434         'name' => __( 'Secondary Widget Area', 'twentyten' ),
    435         'id' => 'secondary-widget-area',
    436         'description' => __( 'An optional secondary widget area, displays below the primary widget area in your sidebar.', 'twentyten' ),
    437         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    438         'after_widget' => '</li>',
    439         'before_title' => '<h3 class="widget-title">',
    440         'after_title' => '</h3>',
    441     ) );
     457    register_sidebar(
     458        array(
     459            'name'          => __( 'Secondary Widget Area', 'twentyten' ),
     460            'id'            => 'secondary-widget-area',
     461            'description'   => __( 'An optional secondary widget area, displays below the primary widget area in your sidebar.', 'twentyten' ),
     462            'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
     463            'after_widget'  => '</li>',
     464            'before_title'  => '<h3 class="widget-title">',
     465            'after_title'   => '</h3>',
     466        )
     467    );
    442468
    443469    // Area 3, located in the footer. Empty by default.
    444     register_sidebar( array(
    445         'name' => __( 'First Footer Widget Area', 'twentyten' ),
    446         'id' => 'first-footer-widget-area',
    447         'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
    448         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    449         'after_widget' => '</li>',
    450         'before_title' => '<h3 class="widget-title">',
    451         'after_title' => '</h3>',
    452     ) );
     470    register_sidebar(
     471        array(
     472            'name'          => __( 'First Footer Widget Area', 'twentyten' ),
     473            'id'            => 'first-footer-widget-area',
     474            'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
     475            'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
     476            'after_widget'  => '</li>',
     477            'before_title'  => '<h3 class="widget-title">',
     478            'after_title'   => '</h3>',
     479        )
     480    );
    453481
    454482    // Area 4, located in the footer. Empty by default.
    455     register_sidebar( array(
    456         'name' => __( 'Second Footer Widget Area', 'twentyten' ),
    457         'id' => 'second-footer-widget-area',
    458         'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
    459         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    460         'after_widget' => '</li>',
    461         'before_title' => '<h3 class="widget-title">',
    462         'after_title' => '</h3>',
    463     ) );
     483    register_sidebar(
     484        array(
     485            'name'          => __( 'Second Footer Widget Area', 'twentyten' ),
     486            'id'            => 'second-footer-widget-area',
     487            'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
     488            'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
     489            'after_widget'  => '</li>',
     490            'before_title'  => '<h3 class="widget-title">',
     491            'after_title'   => '</h3>',
     492        )
     493    );
    464494
    465495    // Area 5, located in the footer. Empty by default.
    466     register_sidebar( array(
    467         'name' => __( 'Third Footer Widget Area', 'twentyten' ),
    468         'id' => 'third-footer-widget-area',
    469         'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
    470         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    471         'after_widget' => '</li>',
    472         'before_title' => '<h3 class="widget-title">',
    473         'after_title' => '</h3>',
    474     ) );
     496    register_sidebar(
     497        array(
     498            'name'          => __( 'Third Footer Widget Area', 'twentyten' ),
     499            'id'            => 'third-footer-widget-area',
     500            'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
     501            'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
     502            'after_widget'  => '</li>',
     503            'before_title'  => '<h3 class="widget-title">',
     504            'after_title'   => '</h3>',
     505        )
     506    );
    475507
    476508    // Area 6, located in the footer. Empty by default.
    477     register_sidebar( array(
    478         'name' => __( 'Fourth Footer Widget Area', 'twentyten' ),
    479         'id' => 'fourth-footer-widget-area',
    480         'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
    481         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    482         'after_widget' => '</li>',
    483         'before_title' => '<h3 class="widget-title">',
    484         'after_title' => '</h3>',
    485     ) );
     509    register_sidebar(
     510        array(
     511            'name'          => __( 'Fourth Footer Widget Area', 'twentyten' ),
     512            'id'            => 'fourth-footer-widget-area',
     513            'description'   => __( 'An optional widget area for your site footer.', 'twentyten' ),
     514            'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
     515            'after_widget'  => '</li>',
     516            'before_title'  => '<h3 class="widget-title">',
     517            'after_title'   => '</h3>',
     518        )
     519    );
    486520}
    487521/** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
     
    506540
    507541if ( ! function_exists( 'twentyten_posted_on' ) ) :
    508 /**
    509  * Print HTML with meta information for the current post-date/time and author.
    510  *
    511  * @since Twenty Ten 1.0
    512  */
    513 function twentyten_posted_on() {
    514     printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
    515         'meta-prep meta-prep-author',
    516         sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
     542    /**
     543     * Print HTML with meta information for the current post-date/time and author.
     544     *
     545     * @since Twenty Ten 1.0
     546     */
     547    function twentyten_posted_on() {
     548        printf(
     549            __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
     550            'meta-prep meta-prep-author',
     551            sprintf(
     552                '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
     553                get_permalink(),
     554                esc_attr( get_the_time() ),
     555                get_the_date()
     556            ),
     557            sprintf(
     558                '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
     559                get_author_posts_url( get_the_author_meta( 'ID' ) ),
     560                esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
     561                get_the_author()
     562            )
     563        );
     564    }
     565endif;
     566
     567if ( ! function_exists( 'twentyten_posted_in' ) ) :
     568    /**
     569     * Print HTML with meta information for the current post (category, tags and permalink).
     570     *
     571     * @since Twenty Ten 1.0
     572     */
     573    function twentyten_posted_in() {
     574        // Retrieves tag list of current post, separated by commas.
     575        $tag_list = get_the_tag_list( '', ', ' );
     576        if ( $tag_list && ! is_wp_error( $tag_list ) ) {
     577            $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
     578        } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
     579            $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
     580        } else {
     581            $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
     582        }
     583        // Prints the string, replacing the placeholders.
     584        printf(
     585            $posted_in,
     586            get_the_category_list( ', ' ),
     587            $tag_list,
    517588            get_permalink(),
    518             esc_attr( get_the_time() ),
    519             get_the_date()
    520         ),
    521         sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
    522             get_author_posts_url( get_the_author_meta( 'ID' ) ),
    523             esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
    524             get_the_author()
    525         )
    526     );
    527 }
    528 endif;
    529 
    530 if ( ! function_exists( 'twentyten_posted_in' ) ) :
    531 /**
    532  * Print HTML with meta information for the current post (category, tags and permalink).
    533  *
    534  * @since Twenty Ten 1.0
    535  */
    536 function twentyten_posted_in() {
    537     // Retrieves tag list of current post, separated by commas.
    538     $tag_list = get_the_tag_list( '', ', ' );
    539     if ( $tag_list && ! is_wp_error( $tag_list ) ) {
    540         $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
    541     } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
    542         $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
    543     } else {
    544         $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
    545     }
    546     // Prints the string, replacing the placeholders.
    547     printf(
    548         $posted_in,
    549         get_the_category_list( ', ' ),
    550         $tag_list,
    551         get_permalink(),
    552         the_title_attribute( 'echo=0' )
    553     );
    554 }
     589            the_title_attribute( 'echo=0' )
     590        );
     591    }
    555592endif;
    556593
     
    570607    if ( function_exists( 'get_post_galleries' ) ) {
    571608        $galleries = get_post_galleries( get_the_ID(), false );
    572         if ( isset( $galleries[0]['ids'] ) )
     609        if ( isset( $galleries[0]['ids'] ) ) {
    573610            $images = explode( ',', $galleries[0]['ids'] );
     611        }
    574612    } else {
    575613        $pattern = get_shortcode_regex();
    576614        preg_match( "/$pattern/s", get_the_content(), $match );
    577615        $atts = shortcode_parse_atts( $match[3] );
    578         if ( isset( $atts['ids'] ) )
     616        if ( isset( $atts['ids'] ) ) {
    579617            $images = explode( ',', $atts['ids'] );
     618        }
    580619    }
    581620
    582621    if ( ! $images ) {
    583         $images = get_posts( array(
    584             'fields'         => 'ids',
    585             'numberposts'    => 999,
    586             'order'          => 'ASC',
    587             'orderby'        => 'menu_order',
    588             'post_mime_type' => 'image',
    589             'post_parent'    => get_the_ID(),
    590             'post_type'      => 'attachment',
    591         ) );
     622        $images = get_posts(
     623            array(
     624                'fields'         => 'ids',
     625                'numberposts'    => 999,
     626                'order'          => 'ASC',
     627                'orderby'        => 'menu_order',
     628                'post_mime_type' => 'image',
     629                'post_parent'    => get_the_ID(),
     630                'post_type'      => 'attachment',
     631            )
     632        );
    592633    }
    593634
Note: See TracChangeset for help on using the changeset viewer.