- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyten/functions.php
r14955 r15222 62 62 * functions.php file. 63 63 * 64 * @uses add_theme_support() To add support for post thumbnails, navigation menus, and automatic feed links. 64 * @uses add_theme_support() To add support for post thumbnails and automatic feed links. 65 * @uses register_nav_menus() To add support for navigation menus. 65 66 * @uses add_custom_background() To add support for a custom background. 66 67 * @uses add_editor_style() To style the visual editor. … … 191 192 /* Shows the same border as on front end */ 192 193 #headimg { 193 border-bottom: 1px solid #000000; 194 border-top: 4px solid #000000; 195 } 196 197 /* If NO_HEADER_TEXT is false, you can style here the header text preview */ 198 #headimg #name { 199 } 200 201 #headimg #desc { 202 } 194 border-bottom: 1px solid #000; 195 border-top: 4px solid #000; 196 } 197 /* If NO_HEADER_TEXT is false, you would style the text with these selectors: 198 #headimg #name { } 199 #headimg #desc { } 200 */ 203 201 </style> 204 202 <?php … … 206 204 endif; 207 205 208 if ( ! function_exists( 'twentyten_the_page_number' ) ) : 209 /** 210 * Prints the page number currently being browsed, with a vertical bar before it. 211 * 212 * Used in Twenty Ten's header.php to add the page number to the <title> HTML tag. 213 * 214 * @since Twenty Ten 1.0 215 */ 216 function twentyten_the_page_number() { 217 global $paged; // Contains page number. 218 if ( $paged >= 2 ) 219 echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), $paged ); 220 } 221 endif; 206 /** 207 * Makes some changes to the <title> tag, by filtering the output of wp_title(). 208 * 209 * If we have a site description and we're viewing the home page or a blog posts 210 * page (when using a static front page), then we will add the site description. 211 * 212 * If we're viewing a search result, then we're going to recreate the title entirely. 213 * We're going to add page numbers to all titles as well, to the middle of a search 214 * result title and the end of all other titles. 215 * 216 * The site title also gets added to all titles. 217 * 218 * @since Twenty Ten 1.0 219 * 220 * @param string $title Title generated by wp_title() 221 * @param string $separator The separator passed to wp_title(). Twenty Ten uses a 222 * vertical bar, "|", as a separator in header.php. 223 * @return string The new title, ready for the <title> tag. 224 */ 225 function twentyten_filter_wp_title( $title, $separator ) { 226 // The $paged global variable contains the page number of a listing of posts. 227 // The $page global variable contains the page number of a single post that is paged. 228 // We'll display whichever one applies, if we're not looking at the first page. 229 global $paged, $page; 230 231 if ( is_search() ) { 232 // If we're a search, let's start over: 233 $title = sprintf( __( 'Search results for %s', 'twentyten' ), '"' . get_search_query() . '"' ); 234 // Add a page number if we're on page 2 or more: 235 if ( $paged >= 2 ) 236 $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), $paged ); 237 // Add the site name to the end: 238 $title .= " $separator " . get_bloginfo( 'name', 'display' ); 239 // We're done. Let's send the new title back to wp_title(): 240 return $title; 241 } 242 243 // Otherwise, let's start by adding the site name to the end: 244 $title .= get_bloginfo( 'name', 'display' ); 245 246 // If we have a site description and we're on the home/front page, add the description: 247 $site_description = get_bloginfo( 'description', 'display' ); 248 if ( $site_description && ( is_home() || is_front_page() ) ) 249 $title .= " $separator " . $site_description; 250 251 // Add a page number if necessary: 252 if ( $paged >= 2 || $page >= 2 ) 253 $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) ); 254 255 // Return the new title to wp_title(): 256 return $title; 257 } 258 add_filter( 'wp_title', 'twentyten_filter_wp_title', 10, 2 ); 222 259 223 260 /** … … 250 287 251 288 /** 252 * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis. 289 * Returns a "Continue Reading" link for excerpts 290 * 291 * @since Twenty Ten 1.0 292 * @return string "Continue Reading" link 293 */ 294 function twentyten_continue_reading_link() { 295 return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) . '</a>'; 296 } 297 298 /** 299 * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link(). 253 300 * 254 301 * To override this in a child theme, remove the filter and add your own … … 259 306 */ 260 307 function twentyten_auto_excerpt_more( $more ) { 261 return ' …' ;308 return ' …' . twentyten_continue_reading_link(); 262 309 } 263 310 add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' ); 264 311 265 312 /** 266 * Adds a pretty "Continue Reading" link to post excerpts.313 * Adds a pretty "Continue Reading" link to custom post excerpts. 267 314 * 268 315 * To override this link in a child theme, remove the filter and add your own … … 273 320 */ 274 321 function twentyten_custom_excerpt_more( $output ) { 275 return $output . ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) . '</a>'; 322 if ( has_excerpt() && ! is_attachment() ) { 323 $output .= twentyten_continue_reading_link(); 324 } 325 return $output; 276 326 } 277 327 add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' ); … … 302 352 */ 303 353 function twentyten_comment( $comment, $args, $depth ) { 304 $GLOBALS['comment'] = $comment; ?> 305 <?php if ( '' == $comment->comment_type ) : ?> 354 $GLOBALS['comment'] = $comment; 355 switch ( $comment->comment_type ) : 356 case '' : 357 ?> 306 358 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> 307 359 <div id="comment-<?php comment_ID(); ?>"> … … 329 381 </div><!-- #comment-## --> 330 382 331 <?php else : ?> 383 <?php 384 break; 385 case 'pingback' : 386 case 'trackback' : 387 ?> 332 388 <li class="post pingback"> 333 389 <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'twentyten'), ' ' ); ?></p> 334 <?php endif; 390 <?php 391 break; 392 endswitch; 335 393 } 336 394 endif; … … 436 494 */ 437 495 function twentyten_posted_on() { 438 printf( __( '<span %1$s>Posted on</span> %2$s by%3$s', 'twentyten' ),439 ' class="meta-prep meta-prep-author"',440 sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">',496 printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ), 497 'meta-prep meta-prep-author', 498 sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>', 441 499 get_permalink(), 442 500 esc_attr( get_the_time() ), 443 501 get_the_date() 444 502 ), 445 sprintf( '< /span> <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',503 sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>', 446 504 get_author_posts_url( get_the_author_meta( 'ID' ) ), 447 505 sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
Note: See TracChangeset
for help on using the changeset viewer.