web/wp-content/themes/twentyeleven/functions.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    99 
    99 
   100 	$theme_options = twentyeleven_get_theme_options();
   100 	$theme_options = twentyeleven_get_theme_options();
   101 	if ( 'dark' == $theme_options['color_scheme'] )
   101 	if ( 'dark' == $theme_options['color_scheme'] )
   102 		$default_background_color = '1d1d1d';
   102 		$default_background_color = '1d1d1d';
   103 	else
   103 	else
   104 		$default_background_color = 'f1f1f1';
   104 		$default_background_color = 'e2e2e2';
   105 
   105 
   106 	// Add support for custom backgrounds.
   106 	// Add support for custom backgrounds.
   107 	add_theme_support( 'custom-background', array(
   107 	add_theme_support( 'custom-background', array(
   108 		// Let WordPress know what our default background color is.
   108 		// Let WordPress know what our default background color is.
   109 		// This is dependent on our current color scheme.
   109 		// This is dependent on our current color scheme.
   129 		// Callback for styling the header preview in the admin.
   129 		// Callback for styling the header preview in the admin.
   130 		'admin-head-callback' => 'twentyeleven_admin_header_style',
   130 		'admin-head-callback' => 'twentyeleven_admin_header_style',
   131 		// Callback used to display the header preview in the admin.
   131 		// Callback used to display the header preview in the admin.
   132 		'admin-preview-callback' => 'twentyeleven_admin_header_image',
   132 		'admin-preview-callback' => 'twentyeleven_admin_header_image',
   133 	);
   133 	);
   134 	
   134 
   135 	add_theme_support( 'custom-header', $custom_header_support );
   135 	add_theme_support( 'custom-header', $custom_header_support );
   136 
   136 
   137 	if ( ! function_exists( 'get_custom_header' ) ) {
   137 	if ( ! function_exists( 'get_custom_header' ) ) {
   138 		// This is all for compatibility with versions of WordPress prior to 3.4.
   138 		// This is all for compatibility with versions of WordPress prior to 3.4.
   139 		define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
   139 		define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
   219 	$text_color = get_header_textcolor();
   219 	$text_color = get_header_textcolor();
   220 
   220 
   221 	// If no custom options for text are set, let's bail.
   221 	// If no custom options for text are set, let's bail.
   222 	if ( $text_color == HEADER_TEXTCOLOR )
   222 	if ( $text_color == HEADER_TEXTCOLOR )
   223 		return;
   223 		return;
   224 		
   224 
   225 	// If we get this far, we have custom styles. Let's do this.
   225 	// If we get this far, we have custom styles. Let's do this.
   226 	?>
   226 	?>
   227 	<style type="text/css">
   227 	<style type="text/css">
   228 	<?php
   228 	<?php
   229 		// Has the text been hidden?
   229 		// Has the text been hidden?
   335 function twentyeleven_excerpt_length( $length ) {
   335 function twentyeleven_excerpt_length( $length ) {
   336 	return 40;
   336 	return 40;
   337 }
   337 }
   338 add_filter( 'excerpt_length', 'twentyeleven_excerpt_length' );
   338 add_filter( 'excerpt_length', 'twentyeleven_excerpt_length' );
   339 
   339 
       
   340 if ( ! function_exists( 'twentyeleven_continue_reading_link' ) ) :
   340 /**
   341 /**
   341  * Returns a "Continue Reading" link for excerpts
   342  * Returns a "Continue Reading" link for excerpts
   342  */
   343  */
   343 function twentyeleven_continue_reading_link() {
   344 function twentyeleven_continue_reading_link() {
   344 	return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>';
   345 	return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>';
   345 }
   346 }
       
   347 endif; // twentyeleven_continue_reading_link
   346 
   348 
   347 /**
   349 /**
   348  * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyeleven_continue_reading_link().
   350  * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyeleven_continue_reading_link().
   349  *
   351  *
   350  * To override this in a child theme, remove the filter and add your own
   352  * To override this in a child theme, remove the filter and add your own
   371 
   373 
   372 /**
   374 /**
   373  * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
   375  * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
   374  */
   376  */
   375 function twentyeleven_page_menu_args( $args ) {
   377 function twentyeleven_page_menu_args( $args ) {
   376 	$args['show_home'] = true;
   378 	if ( ! isset( $args['show_home'] ) )
       
   379 		$args['show_home'] = true;
   377 	return $args;
   380 	return $args;
   378 }
   381 }
   379 add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' );
   382 add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' );
   380 
   383 
   381 /**
   384 /**
   440 
   443 
   441 if ( ! function_exists( 'twentyeleven_content_nav' ) ) :
   444 if ( ! function_exists( 'twentyeleven_content_nav' ) ) :
   442 /**
   445 /**
   443  * Display navigation to next/previous pages when applicable
   446  * Display navigation to next/previous pages when applicable
   444  */
   447  */
   445 function twentyeleven_content_nav( $nav_id ) {
   448 function twentyeleven_content_nav( $html_id ) {
   446 	global $wp_query;
   449 	global $wp_query;
   447 
   450 
   448 	if ( $wp_query->max_num_pages > 1 ) : ?>
   451 	if ( $wp_query->max_num_pages > 1 ) : ?>
   449 		<nav id="<?php echo $nav_id; ?>">
   452 		<nav id="<?php echo esc_attr( $html_id ); ?>">
   450 			<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
   453 			<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
   451 			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
   454 			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
   452 			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
   455 			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
   453 		</nav><!-- #nav-above -->
   456 		</nav><!-- #nav-above -->
   454 	<?php endif;
   457 	<?php endif;
   536 						echo get_avatar( $comment, $avatar_size );
   539 						echo get_avatar( $comment, $avatar_size );
   537 
   540 
   538 						/* translators: 1: comment author, 2: date and time */
   541 						/* translators: 1: comment author, 2: date and time */
   539 						printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
   542 						printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
   540 							sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
   543 							sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
   541 							sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>',
   544 							sprintf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
   542 								esc_url( get_comment_link( $comment->comment_ID ) ),
   545 								esc_url( get_comment_link( $comment->comment_ID ) ),
   543 								get_comment_time( 'c' ),
   546 								get_comment_time( 'c' ),
   544 								/* translators: 1: date, 2: time */
   547 								/* translators: 1: date, 2: time */
   545 								sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
   548 								sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
   546 							)
   549 							)
   576  * Create your own twentyeleven_posted_on to override in a child theme
   579  * Create your own twentyeleven_posted_on to override in a child theme
   577  *
   580  *
   578  * @since Twenty Eleven 1.0
   581  * @since Twenty Eleven 1.0
   579  */
   582  */
   580 function twentyeleven_posted_on() {
   583 function twentyeleven_posted_on() {
   581 	printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
   584 	printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
   582 		esc_url( get_permalink() ),
   585 		esc_url( get_permalink() ),
   583 		esc_attr( get_the_time() ),
   586 		esc_attr( get_the_time() ),
   584 		esc_attr( get_the_date( 'c' ) ),
   587 		esc_attr( get_the_date( 'c' ) ),
   585 		esc_html( get_the_date() ),
   588 		esc_html( get_the_date() ),
   586 		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
   589 		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),