Changeset 13157 for trunk/wp-content/themes/twentyten/functions.php
- Timestamp:
- 02/14/2010 09:39:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyten/functions.php
r13152 r13157 2 2 3 3 // 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 4 if ( ! isset( $content_width ) ) 5 $content_width = 640; 6 7 if ( ! function_exists( 'twentyten_init' ) ) : 8 function 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 } 41 endif; 42 add_action( 'themes_loaded', 'twentyten_init' ); 43 44 if ( ! function_exists( 'twentyten_admin_header_style' ) ) : 14 45 function twentyten_admin_header_style() { 15 46 ?> … … 25 56 <?php 26 57 } 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 ); 58 endif; 51 59 52 60 // Get the page number 61 if ( ! function_exists( 'twentyten_get_page_number' ) ) : 53 62 function twentyten_get_page_number() { 54 63 if ( get_query_var('paged') ) 55 echo ' | ' . __( 'Page ' , 'twentyten' ) . get_query_var('paged'); 56 } 64 return ' | ' . __( 'Page ' , 'twentyten') . get_query_var('paged'); 65 } 66 endif; 67 68 // Echo the page number 69 if ( ! function_exists( 'twentyten_the_page_number' ) ) : 70 function twentyten_the_page_number() { 71 echo twentyten_get_page_number(); 72 } 73 endif; 57 74 58 75 // Control excerpt length 59 function twentyten_new_excerpt_length( $length ) { 76 if ( ! function_exists( 'twentyten_excerpt_length' ) ) : 77 function twentyten_excerpt_length( $length ) { 60 78 return 40; 61 79 } 62 add_filter( 'excerpt_length', 'twentyten_new_excerpt_length' ); 80 endif; 81 add_filter( 'excerpt_length', 'twentyten_excerpt_length' ); 63 82 64 83 65 84 // Make a nice read more link on excerpts 66 function twentyten_new_excerpt_more($more) { 85 if ( ! function_exists( 'twentyten_excerpt_more' ) ) : 86 function twentyten_excerpt_more($more) { 67 87 return ' … <a href="'. get_permalink() . '">' . 'Continue reading <span class="meta-nav">→</span>' . '</a>'; 68 88 } 69 add_filter( 'excerpt_more', 'twentyten_new_excerpt_more' ); 89 endif; 90 add_filter( 'excerpt_more', 'twentyten_excerpt_more' ); 70 91 71 92 72 93 // Template for comments and pingbacks 73 function twentyten_list_comment( $comment, $args, $depth ) { 74 $GLOBALS['comment'] = $comment; ?> 75 <?php if ( '' == $comment->comment_type ) { ?> 94 if ( ! function_exists( 'twentyten_comment' ) ) : 95 function twentyten_comment( $comment, $args, $depth ) { 96 $GLOBALS ['comment'] = $comment; ?> 97 <?php if ( '' == $comment->comment_type ) : ?> 76 98 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> 77 99 <div id="comment-<?php comment_ID(); ?>"> 78 100 <div class="comment-author vcard"> 79 101 <?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() ); ?> 81 103 </div> 82 104 <?php if ( $comment->comment_approved == '0' ) : ?> … … 85 107 <?php endif; ?> 86 108 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> 88 110 89 111 <div class="comment-body"><?php comment_text(); ?></div> 90 112 91 113 <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'] ) ) ); ?> 93 115 </div> 94 116 </div> 95 117 96 <?php } else {?>118 <?php else : ?> 97 119 <li class="post pingback"> 98 120 <p><?php _e( 'Pingback: ', 'twentyten' ); ?><?php comment_author_link(); ?><?php edit_comment_link ( __('edit', 'twentyten'), ' ', '' ); ?></p> 99 <?php } 100 } 121 <?php endif; 122 } 123 endif; 101 124 102 125 // Make the Visual Editor styles match the theme's styles 103 function twentyten_my_editor_style( $url ) { 104 if ( !empty($url) ) 126 if ( ! function_exists( 'twentyten_editor_style' ) ) : 127 function twentyten_editor_style( $url ) { 128 if ( ! empty( $url ) ) 105 129 $url .= ','; 106 130 … … 110 134 return $url; 111 135 } 112 add_filter( 'mce_css', 'twentyten_my_editor_style' );113 136 endif; 137 add_filter( 'mce_css', 'twentyten_editor_style' ); 114 138 115 139 // Remove inline styles on gallery shortcode 140 if ( ! function_exists( 'twentyten_remove_gallery_css' ) ) : 116 141 function twentyten_remove_gallery_css() { 117 return "<div class='gallery'>"; 118 } 142 return "\t\t<div class='gallery'>\n\t\t"; 143 } 144 endif; 119 145 add_filter( 'gallery_style', 'twentyten_remove_gallery_css' ); 120 146 147 if ( ! function_exists( 'twentyten_cat_list' ) ) : 121 148 function twentyten_cat_list() { 122 149 return twentyten_term_list('category', ', ', __('Posted in %s', 'twentyten'), __('Also posted in %s', 'twentyten') ); 123 150 } 151 endif; 152 153 if ( ! function_exists( 'twentyten_tag_list' ) ) : 124 154 function twentyten_tag_list() { 125 155 return twentyten_term_list('post_tag', ', ', __('Tagged %s', 'twentyten'), __('Also tagged %s', 'twentyten') ); 126 156 } 157 endif; 158 159 if ( ! function_exists( 'twentyten_term_list' ) ) : 127 160 function twentyten_term_list($taxonomy, $glue = ', ', $text = '', $also_text = '') { 128 161 global $wp_query, $post; … … 150 183 return ''; 151 184 } 185 endif; 152 186 153 187 // Register widgetized areas 188 if ( ! function_exists( 'twentyten_widgets_init' ) ) : 154 189 function twentyten_widgets_init() { 155 190 // Area 1 156 register_sidebar( array (191 register_sidebar( array ( 157 192 'name' => 'Primary Widget Area', 158 193 'id' => 'primary-widget-area', … … 165 200 166 201 // Area 2 167 register_sidebar( array (202 register_sidebar( array ( 168 203 'name' => 'Secondary Widget Area', 169 204 'id' => 'secondary-widget-area', … … 176 211 177 212 // Area 3 178 register_sidebar( array (213 register_sidebar( array ( 179 214 'name' => 'First Footer Widget Area', 180 215 'id' => 'first-footer-widget-area', … … 187 222 188 223 // Area 4 189 register_sidebar( array (224 register_sidebar( array ( 190 225 'name' => 'Second Footer Widget Area', 191 226 'id' => 'second-footer-widget-area', … … 198 233 199 234 // Area 5 200 register_sidebar( array (235 register_sidebar( array ( 201 236 'name' => 'Third Footer Widget Area', 202 237 'id' => 'third-footer-widget-area', … … 209 244 210 245 // Area 6 211 register_sidebar( array (246 register_sidebar( array ( 212 247 'name' => 'Fourth Footer Widget Area', 213 248 'id' => 'fourth-footer-widget-area', … … 219 254 ) ); 220 255 221 } // end theme_widgets_init 222 223 // Add all the groovy widget areas 256 } 257 endif; 224 258 add_action( 'init', 'twentyten_widgets_init' );
Note: See TracChangeset
for help on using the changeset viewer.