Changeset 13885 for trunk/wp-content/themes/twentyten/functions.php
- Timestamp:
- 03/29/2010 10:03:15 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-content/themes/twentyten/functions.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyten/functions.php
r13830 r13885 1 1 <?php 2 3 // Set the content width based on the Theme CSS 2 /** 3 * TwentyTen functions and definitions 4 * 5 * Sets up the theme and provides some helper functions used 6 * in other parts of the theme. All functions are pluggable 7 * 8 * @package WordPress 9 * @subpackage Twenty Ten 10 * @since 3.0.0 11 */ 12 13 /** 14 * Set the content width based on the Theme CSS. Can be overriden 15 * 16 * Used in attachment.php to set the width of images. Should 17 * be equal to the width set for .onecolumn #content in style.css 18 */ 4 19 if ( ! isset( $content_width ) ) 5 20 $content_width = 640; 6 21 7 22 if ( ! function_exists( 'twentyten_init' ) ) : 23 /** 24 * Set up defaults for our theme. 25 * 26 * Sets up theme defaults and tells wordpress that this is a 27 * theme that will take advantage of Post Thumbnails, Custom 28 * Background, Nav Menus and automatic feed links. To 29 * override any of the settings in a child theme, create your 30 * own twentyten_init function 31 * 32 * @uses add_theme_support() 33 */ 8 34 function twentyten_init() { 35 // This theme allows users to set a custom background 36 add_custom_background(); 37 38 // This theme styles the visual editor with editor-style.css to match the theme style. 39 add_editor_style(); 40 41 // This theme needs post thumbnails 42 add_theme_support( 'post-thumbnails' ); 43 44 // This theme uses wp_nav_menu() 45 add_theme_support( 'nav-menus' ); 46 47 // We'll be using them for custom header images on posts and pages 48 // so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit) 49 set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); 50 51 // Add default posts and comments RSS feed links to head 52 add_theme_support( 'automatic-feed-links' ); 53 54 // Make theme available for translation 55 // Translations can be filed in the /languages/ directory 56 load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' ); 57 58 $locale = get_locale(); 59 $locale_file = TEMPLATEPATH . "/languages/$locale.php"; 60 if ( is_readable( $locale_file ) ) 61 require_once( $locale_file ); 62 9 63 // Your Changeable header business starts here 10 64 // No CSS, just IMG call 11 65 define( 'HEADER_TEXTCOLOR', '' ); 12 66 define( 'HEADER_IMAGE', '%s/images/headers/forestfloor.jpg' ); // %s is theme dir uri 67 68 // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values 13 69 define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) ); 14 70 define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) ); 71 15 72 define( 'NO_HEADER_TEXT', true ); 16 73 17 74 add_custom_image_header( '', 'twentyten_admin_header_style' ); 18 75 // and thus ends the changeable header business 76 77 // Default custom headers. %s is a placeholder for the theme template directory 19 78 20 79 register_default_headers( array ( … … 60 119 ) 61 120 ) ); 62 63 add_custom_background();64 65 // This theme styles the visual editor with editor-style.css to match the theme style.66 add_editor_style();67 68 // This theme needs post thumbnails69 add_theme_support( 'post-thumbnails' );70 71 // This theme uses wp_nav_menu()72 add_theme_support( 'nav-menus' );73 74 // We'll be using them for custom header images on posts and pages75 // so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit)76 set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );77 78 // Add default posts and comments RSS feed links to head79 add_theme_support( 'automatic-feed-links' );80 81 // Make theme available for translation82 // Translations can be filed in the /languages/ directory83 load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );84 85 $locale = get_locale();86 $locale_file = TEMPLATEPATH . "/languages/$locale.php";87 if ( is_readable( $locale_file ) )88 require_once( $locale_file );89 121 } 90 122 endif; … … 92 124 93 125 if ( ! function_exists( 'twentyten_admin_header_style' ) ) : 126 /** 127 * Callback to style the header image inside the admin 128 */ 94 129 function twentyten_admin_header_style() { 95 130 ?> … … 107 142 endif; 108 143 109 // Get the page number110 144 if ( ! function_exists( 'twentyten_get_page_number' ) ) : 145 /** 146 * Returns the page number currently being browsed 147 * 148 * Returns a vertical bar followed by page and the page 149 * number. Is pluggable 150 * 151 * @retun string 152 */ 111 153 function twentyten_get_page_number() { 112 154 if ( get_query_var( 'paged' ) ) … … 115 157 endif; 116 158 117 // Echo the page number118 159 if ( ! function_exists( 'twentyten_the_page_number' ) ) : 160 /** 161 * Echos the page number being browsed 162 * 163 * @uses twentyten_get_page_number 164 * 165 */ 119 166 function twentyten_the_page_number() { 120 167 echo twentyten_get_page_number(); … … 122 169 endif; 123 170 124 // Control excerpt length125 171 if ( ! function_exists( 'twentyten_excerpt_length' ) ) : 172 /** 173 * Sets the excerpt length to 40 charachters. Is pluggable 174 * 175 * @return int 176 */ 126 177 function twentyten_excerpt_length( $length ) { 127 178 return 40; … … 130 181 add_filter( 'excerpt_length', 'twentyten_excerpt_length' ); 131 182 132 133 // Make a nice read more link on excerpts134 183 if ( ! function_exists( 'twentyten_excerpt_more' ) ) : 184 /** 185 * Sets the read more link for excerpts to something pretty 186 * 187 * @return string 188 * 189 */ 135 190 function twentyten_excerpt_more( $more ) { 136 191 return ' … <a href="'. get_permalink() . '">' . __('Continue reading <span class="meta-nav">→</span>', 'twentyten') . '</a>'; … … 139 194 add_filter( 'excerpt_more', 'twentyten_excerpt_more' ); 140 195 141 142 // Template for comments and pingbacks143 196 if ( ! function_exists( 'twentyten_comment' ) ) : 197 /** 198 * Template for comments and pingbacks 199 * 200 * Used as a callback by wp_list_comments for displaying the 201 * comments. Is pluggable 202 * 203 */ 144 204 function twentyten_comment( $comment, $args, $depth ) { 145 205 $GLOBALS ['comment'] = $comment; ?> … … 172 232 endif; 173 233 174 // Remove inline styles on gallery shortcode175 234 if ( ! function_exists( 'twentyten_remove_gallery_css' ) ) : 235 /** 236 * Remove inline styles on gallery shortcode 237 * 238 * @return string 239 */ 176 240 function twentyten_remove_gallery_css( $css ) { 177 241 return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css ); … … 181 245 182 246 if ( ! function_exists( 'twentyten_cat_list' ) ) : 247 /** 248 * Returns the list of categories 249 * 250 * Returns the list of categories based on if we are or are 251 * not browsing a category archive page. 252 * 253 * @uses twentyten_term_list 254 * 255 * @return string 256 */ 183 257 function twentyten_cat_list() { 184 258 return twentyten_term_list( 'category', ', ', __( 'Posted in %s', 'twentyten' ), __( 'Also posted in %s', 'twentyten' ) ); … … 187 261 188 262 if ( ! function_exists( 'twentyten_tag_list' ) ) : 263 /** 264 * Returns the list of tags 265 * 266 * Returns the list of tags based on if we are or are not 267 * browsing a tag archive page 268 * 269 * @uses twentyten_term_list 270 * 271 * @return string 272 */ 189 273 function twentyten_tag_list() { 190 274 return twentyten_term_list( 'post_tag', ', ', __( 'Tagged %s', 'twentyten' ), __( 'Also tagged %s', 'twentyten' ) ); … … 193 277 194 278 if ( ! function_exists( 'twentyten_term_list' ) ) : 279 /** 280 * Returns the list of taxonomy items in multiple ways 281 * 282 * Returns the list of taxonomy items differently based on 283 * if we are browsing a term archive page or a different 284 * type of page. If browsing a term archive page and the 285 * post has no other taxonomied terms, it returns empty 286 * 287 * @return string 288 */ 195 289 function twentyten_term_list( $taxonomy, $glue = ', ', $text = '', $also_text = '' ) { 196 290 global $wp_query, $post; … … 220 314 endif; 221 315 222 // Register widgetized areas223 316 if ( ! function_exists( 'twentyten_widgets_init' ) ) : 317 /** 318 * Register widgetized areas 319 * 320 * @uses register_sidebar 321 */ 224 322 function twentyten_widgets_init() { 225 323 // Area 1
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)