Make WordPress Core

Changeset 13157


Ignore:
Timestamp:
02/14/2010 09:39:20 PM (17 years ago)
Author:
dd32
Message:

Twentyten whitespace cleanup, Wrap functions in function_exists() call to allow child themes to override them. Props sivel. See #9015

Location:
trunk/wp-content/themes/twentyten
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyten/attachment.php

    r13147 r13157  
    2222                                        <div class="entry-content">
    2323                                                <div class="entry-attachment">
    24                                                 <?php if ( wp_attachment_is_image() ) : ?>
    25                                                         <p class="attachment"><a href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
    26                                                                 echo wp_get_attachment_image( $post->ID, array($content_width, $content_width) ); // max $content_width wide or high.
    27                                                         ?></a></p>
     24<?php if ( wp_attachment_is_image() ) : ?>
     25                                                <p class="attachment"><a href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
     26                                                        echo wp_get_attachment_image( $post->ID, array( $content_width, $content_width ) ); // max $content_width wide or high.
     27                                                ?></a></p>
    2828
    29                                                         <div id="nav-below" class="navigation">
    30                                                                 <div class="nav-previous"><?php previous_image_link( false ); ?></div>
    31                                                                 <div class="nav-next"><?php next_image_link( false ); ?></div>
    32                                                         </div><!-- #nav-below -->
    33                                                 <?php else : ?>
    34                                                         <a href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php echo basename(get_permalink()); ?></a>
    35                                                 <?php endif; ?>
     29                                                <div id="nav-below" class="navigation">
     30                                                        <div class="nav-previous"><?php previous_image_link( false ); ?></div>
     31                                                        <div class="nav-next"><?php next_image_link( false ); ?></div>
     32                                                </div><!-- #nav-below -->
     33<?php else : ?>
     34                                                <a href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php echo basename( get_permalink() ); ?></a>
     35<?php endif; ?>
    3636                                                </div>
    3737                                                <div class="entry-caption"><?php if ( !empty($post->post_excerpt) ) the_excerpt(); ?></div>
    3838
    39                                                 <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' )  ); ?>
    40                                                 <?php wp_link_pages( 'before=<div class="page-link">' . __( 'Pages:', 'twentyten' ) . '&after=</div>' ); ?>
     39<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' )  ); ?>
     40<?php wp_link_pages( 'before=<div class="page-link">' . __( 'Pages:', 'twentyten' ) . '&after=</div>' ); ?>
    4141
    4242                                        </div><!-- .entry-content -->
  • trunk/wp-content/themes/twentyten/functions.php

    r13152 r13157  
    22
    33// Set the content width based on the Theme CSS
    4 $content_width = apply_filters( 'twentyten_content_width', 640 );
    5 
    6 // Your Changeable header business starts here
    7 // No CSS, just IMG call
    8 define( 'HEADER_TEXTCOLOR', '');
    9 define( 'HEADER_IMAGE', '%s/images/header-1.jpg'); // %s is theme dir uri
    10 define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width',  940 ) );
    11 define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height',  198 ) );
    12 define( 'NO_HEADER_TEXT', true );
    13 
     4if ( ! isset( $content_width ) )
     5   $content_width = 640;
     6
     7if ( ! function_exists( 'twentyten_init' ) ) :
     8function twentyten_init() {
     9        // Your Changeable header business starts here
     10        // No CSS, just IMG call
     11        define( 'HEADER_TEXTCOLOR', '');
     12        define( 'HEADER_IMAGE', '%s/images/header-1.jpg'); // %s is theme dir uri
     13        define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width',  940 ) );
     14        define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height',  198 ) );
     15        define( 'NO_HEADER_TEXT', true );
     16
     17        add_custom_image_header( '', 'twentyten_admin_header_style' );
     18        // and thus ends the changeable header business
     19
     20        add_custom_background();
     21
     22        // This theme needs post thumbnails
     23        add_theme_support( 'post-thumbnails' );
     24
     25        // We'll be using them for custom header images on posts and pages
     26        // so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit)
     27        set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
     28
     29        // Add default posts and comments RSS feed links to head.
     30        automatic_feed_links();
     31
     32        // Make theme available for translation
     33        // Translations can be filed in the /languages/ directory
     34        load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
     35
     36        $locale = get_locale();
     37        $locale_file = TEMPLATEPATH . "/languages/$locale.php";
     38        if ( is_readable( $locale_file ) )
     39                require_once( $locale_file );
     40}
     41endif;
     42add_action( 'themes_loaded', 'twentyten_init' );
     43
     44if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
    1445function twentyten_admin_header_style() {
    1546?>
    … …  
    2556<?php
    2657}
    27 
    28 add_custom_image_header( '', 'twentyten_admin_header_style' );
    29 // and thus ends the changeable header business
    30 
    31 add_custom_background();
    32 
    33 // This theme needs post thumbnails
    34 add_theme_support( 'post-thumbnails' );
    35 
    36 // We'll be using them for custom header images on posts and pages
    37 // so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit)
    38 set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
    39 
    40 // Add default posts and comments RSS feed links to head.
    41 automatic_feed_links();
    42 
    43 // Make theme available for translation
    44 // Translations can be filed in the /languages/ directory
    45 load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
    46 
    47 $locale = get_locale();
    48 $locale_file = TEMPLATEPATH . "/languages/$locale.php";
    49 if ( is_readable($locale_file) )
    50         require_once( $locale_file );
     58endif;
    5159
    5260// Get the page number
     61if ( ! function_exists( 'twentyten_get_page_number' ) ) :
    5362function twentyten_get_page_number() {
    5463        if ( get_query_var('paged') )
    55                 echo ' | ' . __( 'Page ' , 'twentyten' ) . get_query_var('paged');
    56 }
     64                return ' | ' . __( 'Page ' , 'twentyten') . get_query_var('paged');
     65}
     66endif;
     67
     68// Echo the page number
     69if ( ! function_exists( 'twentyten_the_page_number' ) ) :
     70function twentyten_the_page_number() {
     71        echo twentyten_get_page_number();
     72}
     73endif;
    5774
    5875// Control excerpt length
    59 function twentyten_new_excerpt_length( $length ) {
     76if ( ! function_exists( 'twentyten_excerpt_length' ) ) :
     77function twentyten_excerpt_length( $length ) {
    6078        return 40;
    6179}
    62 add_filter( 'excerpt_length', 'twentyten_new_excerpt_length' );
     80endif;
     81add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
    6382
    6483
    6584// Make a nice read more link on excerpts
    66 function twentyten_new_excerpt_more($more) {
     85if ( ! function_exists( 'twentyten_excerpt_more' ) ) :
     86function twentyten_excerpt_more($more) {
    6787        return '&nbsp;&hellip; <a href="'. get_permalink() . '">' . 'Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>' . '</a>';
    6888}
    69 add_filter( 'excerpt_more', 'twentyten_new_excerpt_more' );
     89endif;
     90add_filter( 'excerpt_more', 'twentyten_excerpt_more' );
    7091
    7192
    7293// Template for comments and pingbacks
    73 function twentyten_list_comment( $comment, $args, $depth ) {
    74         $GLOBALS['comment'] = $comment; ?>
    75         <?php if ( '' == $comment->comment_type ) { ?>
     94if ( ! function_exists( 'twentyten_comment' ) ) :
     95function twentyten_comment( $comment, $args, $depth ) {
     96        $GLOBALS ['comment'] = $comment; ?>
     97        <?php if ( '' == $comment->comment_type ) : ?>
    7698        <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
    7799                <div id="comment-<?php comment_ID(); ?>">
    78100                <div class="comment-author vcard">
    79101                        <?php echo get_avatar( $comment, 40 ); ?>
    80                         <?php printf( __('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link() ); ?>
     102                        <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>
    81103                </div>
    82104                <?php if ( $comment->comment_approved == '0' ) : ?>
    … …  
    85107                <?php endif; ?>
    86108
    87                 <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()); ?></a><?php edit_comment_link(__('(Edit)', 'twentyten'),'  ',''); ?></div>
     109                <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( __( '%1$s at %2$s' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ),'  ','' ); ?></div>
    88110
    89111                <div class="comment-body"><?php comment_text(); ?></div>
    90112
    91113                <div class="reply">
    92                         <?php comment_reply_link( array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth'])) ); ?>
     114                        <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    93115                </div>
    94116        </div>
    95117
    96         <?php } else { ?>
     118        <?php else : ?>
    97119        <li class="post pingback">
    98120                <p><?php _e( 'Pingback: ', 'twentyten' ); ?><?php comment_author_link(); ?><?php edit_comment_link ( __('edit', 'twentyten'), '&nbsp;&nbsp;', '' ); ?></p>
    99         <?php }
    100 }
     121        <?php endif;
     122}
     123endif;
    101124
    102125// Make the Visual Editor styles match the theme's styles
    103 function twentyten_my_editor_style( $url ) {
    104         if ( !empty($url) )
     126if ( ! function_exists( 'twentyten_editor_style' ) ) :
     127function twentyten_editor_style( $url ) {
     128        if ( ! empty( $url ) )
    105129                $url .= ',';
    106130
    … …  
    110134        return $url;
    111135}
    112 add_filter( 'mce_css', 'twentyten_my_editor_style' );
    113 
     136endif;
     137add_filter( 'mce_css', 'twentyten_editor_style' );
    114138
    115139// Remove inline styles on gallery shortcode
     140if ( ! function_exists( 'twentyten_remove_gallery_css' ) ) :
    116141function twentyten_remove_gallery_css() {
    117         return "<div class='gallery'>";
    118 }
     142        return "\t\t<div class='gallery'>\n\t\t";
     143}
     144endif;
    119145add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
    120146
     147if ( ! function_exists( 'twentyten_cat_list' ) ) :
    121148function twentyten_cat_list() {
    122149        return twentyten_term_list('category', ', ', __('Posted in %s', 'twentyten'), __('Also posted in %s', 'twentyten') );
    123150}
     151endif;
     152
     153if ( ! function_exists( 'twentyten_tag_list' ) ) :
    124154function twentyten_tag_list() {
    125155        return twentyten_term_list('post_tag', ', ', __('Tagged %s', 'twentyten'), __('Also tagged %s', 'twentyten') );
    126156}
     157endif;
     158
     159if ( ! function_exists( 'twentyten_term_list' ) ) :
    127160function twentyten_term_list($taxonomy, $glue = ', ', $text = '', $also_text = '') {
    128161        global $wp_query, $post;
    … …  
    150183        return '';
    151184}
     185endif;
    152186
    153187// Register widgetized areas
     188if ( ! function_exists( 'twentyten_widgets_init' ) ) :
    154189function twentyten_widgets_init() {
    155190        // Area 1
    156         register_sidebar( array(
     191        register_sidebar( array (
    157192                'name' => 'Primary Widget Area',
    158193                'id' => 'primary-widget-area',
    … …  
    165200
    166201        // Area 2
    167         register_sidebar( array(
     202        register_sidebar( array (
    168203                'name' => 'Secondary Widget Area',
    169204                'id' => 'secondary-widget-area',
    … …  
    176211
    177212        // Area 3
    178         register_sidebar( array(
     213        register_sidebar( array (
    179214                'name' => 'First Footer Widget Area',
    180215                'id' => 'first-footer-widget-area',
    … …  
    187222
    188223        // Area 4
    189         register_sidebar( array(
     224        register_sidebar( array (
    190225                'name' => 'Second Footer Widget Area',
    191226                'id' => 'second-footer-widget-area',
    … …  
    198233
    199234        // Area 5
    200         register_sidebar( array(
     235        register_sidebar( array (
    201236                'name' => 'Third Footer Widget Area',
    202237                'id' => 'third-footer-widget-area',
    … …  
    209244
    210245        // Area 6
    211         register_sidebar( array(
     246        register_sidebar( array (
    212247                'name' => 'Fourth Footer Widget Area',
    213248                'id' => 'fourth-footer-widget-area',
    … …  
    219254        ) );
    220255
    221 } // end theme_widgets_init
    222 
    223 // Add all the groovy widget areas
     256}
     257endif;
    224258add_action( 'init', 'twentyten_widgets_init' );
  • trunk/wp-content/themes/twentyten/header.php

    r13152 r13157  
    66                        single_post_title(); echo ' | '; bloginfo('name');
    77                } elseif ( is_home() || is_front_page() ) {
    8                         bloginfo('name'); echo ' | '; bloginfo('description'); twentyten_get_page_number();
     8                        bloginfo('name'); echo ' | '; bloginfo('description'); twentyten_the_page_number();
    99                } elseif ( is_page() ) {
    1010                        single_post_title(''); echo ' | '; bloginfo('name');
    1111                } elseif ( is_search() ) {
    12                         printf(__('Search results for "%s"', 'twentyten'), esc_html($s)); twentyten_get_page_number(); echo ' | '; bloginfo('name');
     12                        printf(__('Search results for "%s"', 'twentyten'), esc_html($s)); twentyten_the_page_number(); echo ' | '; bloginfo('name');
    1313                } elseif ( is_404() ) {
    1414                        _e('Not Found', 'twentyten'); echo ' | '; bloginfo('name');
    1515                } else {
    16                         wp_title(''); echo ' | '; bloginfo('name'); twentyten_get_page_number();
     16                        wp_title(''); echo ' | '; bloginfo('name'); twentyten_the_page_number();
    1717                }
    1818    ?></title>
    … …  
    2525
    2626        <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
     27
    2728        <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
     29
    2830        <?php wp_head(); ?>
    2931</head>
Note: See TracChangeset for help on using the changeset viewer.