Twenty Ten documentation and functions.php improvements. see #12695.

git-svn-id: http://svn.automattic.com/wordpress/trunk@14698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-05-16 20:53:36 +00:00
parent 746846da5b
commit c40e204b6c
4 changed files with 67 additions and 54 deletions

View File

@ -58,8 +58,19 @@
<div class="entry-content"> <div class="entry-content">
<div class="entry-attachment"> <div class="entry-attachment">
<?php if ( wp_attachment_is_image() ) : ?> <?php if ( wp_attachment_is_image() ) :
<p class="attachment"><a href="<?php echo twentyten_get_next_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
foreach ( $attachments as $k => $attachment ) {
if ( $attachment->ID == $post->ID )
break;
}
$k++;
if ( isset( $attachments[ $k ] ) )
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
else
$next_attachment_url = get_permalink( $post->post_parent );
?>
<p class="attachment"><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
$attachment_size = apply_filters( 'twentyten_attachment_size', 900 ); $attachment_size = apply_filters( 'twentyten_attachment_size', 900 );
echo wp_get_attachment_image( $post->ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height. echo wp_get_attachment_image( $post->ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height.
?></a></p> ?></a></p>
@ -80,7 +91,7 @@
</div><!-- .entry-content --> </div><!-- .entry-content -->
<div class="entry-utility"> <div class="entry-utility">
<?php echo twentyten_posted_in(); ?> <?php twentyten_posted_in(); ?>
<?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?> <?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-utility --> </div><!-- .entry-utility -->
</div><!-- #post-<?php the_ID(); ?> --> </div><!-- #post-<?php the_ID(); ?> -->

View File

@ -9,11 +9,11 @@
* The first function, twentyten_setup(), sets up the theme by registering support * The first function, twentyten_setup(), sets up the theme by registering support
* for various features in WordPress, such as post thumbnails, navigation menus, and the like. * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
* *
* When using a child theme (see http://codex.wordpress.org/Theme_Development), you can * When using a child theme (see http://codex.wordpress.org/Theme_Development and
* override certain functions (those wrapped in a function_exists() call) by defining * http://codex.wordpress.org/Theme_Development), you can override certain functions
* them first in your child theme's functions.php file. The child theme's functions.php * (those wrapped in a function_exists() call) by defining them first in your child theme's
* file is included before the parent theme's file, so the child theme functions would * functions.php file. The child theme's functions.php file is included before the parent
* be used. * theme's file, so the child theme functions would be used.
* *
* Functions that are not pluggable (not wrapped in function_exists()) are instead attached * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
* to a filter or action hook. The hook can be removed by using remove_action() or * to a filter or action hook. The hook can be removed by using remove_action() or
@ -35,7 +35,7 @@
* *
* @package WordPress * @package WordPress
* @subpackage Twenty_Ten * @subpackage Twenty_Ten
* @since 3.0.0 * @since Twenty Ten 1.0
*/ */
/** /**
@ -69,7 +69,7 @@ if ( ! function_exists( 'twentyten_setup' ) ):
* @uses register_default_headers() To register the default custom header images provided with the theme. * @uses register_default_headers() To register the default custom header images provided with the theme.
* @uses set_post_thumbnail_size() To set a custom post thumbnail size. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
* *
* @since 3.0.0 * @since Twenty Ten 1.0
*/ */
function twentyten_setup() { function twentyten_setup() {
@ -182,7 +182,7 @@ if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
* *
* Referenced via add_custom_image_header() in twentyten_setup(). * Referenced via add_custom_image_header() in twentyten_setup().
* *
* @since 3.0.0 * @since Twenty Ten 1.0
*/ */
function twentyten_admin_header_style() { function twentyten_admin_header_style() {
?> ?>
@ -205,7 +205,7 @@ if ( ! function_exists( 'twentyten_the_page_number' ) ) :
* *
* Used in Twenty Ten's header.php to add the page number to the <title> HTML tag. * Used in Twenty Ten's header.php to add the page number to the <title> HTML tag.
* *
* @since 3.0.0 * @since Twenty Ten 1.0
*/ */
function twentyten_the_page_number() { function twentyten_the_page_number() {
global $paged; // Contains page number. global $paged; // Contains page number.
@ -214,16 +214,19 @@ function twentyten_the_page_number() {
} }
endif; endif;
if ( ! function_exists( 'twentyten_page_menu_args' ) ) :
/** /**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*
* To override this in a child theme, remove the filter and optionally add
* your own function tied to the wp_page_menu_args filter hook.
*
* @since Twenty Ten 1.0
*/ */
function twentyten_page_menu_args($args) { function twentyten_page_menu_args( $args ) {
$args['show_home'] = true; $args['show_home'] = true;
return $args; return $args;
} }
add_filter('wp_page_menu_args', 'twentyten_page_menu_args'); add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
endif;
/** /**
* Sets the post excerpt length to 40 characters. * Sets the post excerpt length to 40 characters.
@ -231,6 +234,7 @@ endif;
* To override this length in a child theme, remove the filter and add your own * To override this length in a child theme, remove the filter and add your own
* function tied to the excerpt_length filter hook. * function tied to the excerpt_length filter hook.
* *
* @since Twenty Ten 1.0
* @return int * @return int
*/ */
function twentyten_excerpt_length( $length ) { function twentyten_excerpt_length( $length ) {
@ -244,7 +248,7 @@ add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
* To override this link in a child theme, remove the filter and add your own * To override this link in a child theme, remove the filter and add your own
* function tied to the excerpt_more filter hook. * function tied to the excerpt_more filter hook.
* *
* @since 3.0.0 * @since Twenty Ten 1.0
* @return string A pretty 'Continue reading' link. * @return string A pretty 'Continue reading' link.
*/ */
function twentyten_excerpt_more( $more ) { function twentyten_excerpt_more( $more ) {
@ -257,6 +261,7 @@ add_filter( 'excerpt_more', 'twentyten_excerpt_more' );
* *
* Galleries are styled by the theme in Twenty Ten's style.css. * Galleries are styled by the theme in Twenty Ten's style.css.
* *
* @since Twenty Ten 1.0
* @return string The gallery style filter, with the styles themselves removed. * @return string The gallery style filter, with the styles themselves removed.
*/ */
function twentyten_remove_gallery_css( $css ) { function twentyten_remove_gallery_css( $css ) {
@ -273,7 +278,7 @@ if ( ! function_exists( 'twentyten_comment' ) ) :
* *
* Used as a callback by wp_list_comments() for displaying the comments. * Used as a callback by wp_list_comments() for displaying the comments.
* *
* @since 3.0.0 * @since Twenty Ten 1.0
*/ */
function twentyten_comment( $comment, $args, $depth ) { function twentyten_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment; ?> $GLOBALS['comment'] = $comment; ?>
@ -315,6 +320,8 @@ endif;
* *
* To override twentyten_widgets_init() in a child theme, remove the action hook and add your own * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
* function tied to the init hook. * function tied to the init hook.
*
* @since Twenty Ten 1.0
* @uses register_sidebar * @uses register_sidebar
*/ */
function twentyten_widgets_init() { function twentyten_widgets_init() {
@ -384,10 +391,16 @@ function twentyten_widgets_init() {
'after_title' => '</h3>', 'after_title' => '</h3>',
) ); ) );
} }
add_action( 'init', 'twentyten_widgets_init' ); /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
add_action( 'widgets_init', 'twentyten_widgets_init' );
/** /**
* Removes the default styles that are packaged with the Recent Comments widget. * Removes the default styles that are packaged with the Recent Comments widget.
*
* To override this in a child theme, remove the filter and optionally add your own
* function tied to the widgets_init action hook.
*
* @since Twenty Ten 1.0
*/ */
function twentyten_remove_recent_comments_style() { function twentyten_remove_recent_comments_style() {
global $wp_widget_factory; global $wp_widget_factory;
@ -395,30 +408,14 @@ function twentyten_remove_recent_comments_style() {
} }
add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' ); add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
if ( ! function_exists( 'twentyten_posted_on' ) ) :
/** /**
* Get the URL of the next image in a gallery for attachment pages * Prints HTML with meta information for the current post—date/time and author.
*/ *
function twentyten_get_next_attachment_url() { * @since Twenty Ten 1.0
global $post;
$post = get_post( $post );
$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
foreach ( $attachments as $k => $attachment ) {
if ( $attachment->ID == $post->ID )
break;
}
$k++;
if ( isset( $attachments[ $k ] ) )
return get_attachment_link( $attachments[ $k ]->ID );
else
return get_permalink( $post->post_parent );
}
/**
* Returns HTML with meta information for the current post—date/time and author.
*/ */
function twentyten_posted_on() { function twentyten_posted_on() {
return sprintf( __( '<span %1$s>Posted on</span> %2$s by %3$s', 'twentyten' ), printf( __( '<span %1$s>Posted on</span> %2$s by %3$s', 'twentyten' ),
'class="meta-prep meta-prep-author"', 'class="meta-prep meta-prep-author"',
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">', sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">',
get_permalink(), get_permalink(),
@ -433,24 +430,29 @@ function twentyten_posted_on() {
); );
} }
endif;
if ( ! function_exists( 'twentyten_posted_in' ) ) :
/** /**
* Returns HTML with meta information for the current post—category, tags and permalink * Prints HTML with meta information for the current post (category, tags and permalink).
*
* @since Twenty Ten 1.0
*/ */
function twentyten_posted_in() { function twentyten_posted_in() {
$tag_list = get_the_tag_list( '', ', ', '' ); // Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) { if ( $tag_list ) {
$utility_text = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' ); $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
} else { } else {
$utility_text = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' ); $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
} }
return sprintf( // Prints the string, replacing the placeholders.
$utility_text, printf(
$posted_in,
get_the_category_list( ', ' ), get_the_category_list( ', ' ),
$tag_list, $tag_list,
get_permalink(), get_permalink(),
the_title_attribute( 'echo=0' ), the_title_attribute( 'echo=0' )
get_post_comments_feed_link()
); );
} }
endif;

View File

@ -41,7 +41,7 @@
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="entry-meta"> <div class="entry-meta">
<?php echo twentyten_posted_on(); ?> <?php twentyten_posted_on(); ?>
</div><!-- .entry-meta --> </div><!-- .entry-meta -->
<div class="entry-content"> <div class="entry-content">
@ -84,7 +84,7 @@
<?php endif; ?> <?php endif; ?>
<div class="entry-utility"> <div class="entry-utility">
<?php echo twentyten_posted_on(); ?> <?php twentyten_posted_on(); ?>
<span class="meta-sep">|</span> <span class="meta-sep">|</span>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?> <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
@ -97,7 +97,7 @@
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="entry-meta"> <div class="entry-meta">
<?php echo twentyten_posted_on(); ?> <?php twentyten_posted_on(); ?>
</div><!-- .entry-meta --> </div><!-- .entry-meta -->
<?php if ( is_archive() || is_search() ) : // Only display Excerpts for archives & search ?> <?php if ( is_archive() || is_search() ) : // Only display Excerpts for archives & search ?>

View File

@ -24,7 +24,7 @@
<h1 class="entry-title"><?php the_title(); ?></h1> <h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-meta"> <div class="entry-meta">
<?php echo twentyten_posted_on(); ?> <?php twentyten_posted_on(); ?>
</div><!-- .entry-meta --> </div><!-- .entry-meta -->
<div class="entry-content"> <div class="entry-content">
@ -50,7 +50,7 @@
<?php endif; ?> <?php endif; ?>
<div class="entry-utility"> <div class="entry-utility">
<?php echo twentyten_posted_in(); ?> <?php twentyten_posted_in(); ?>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?> <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-utility --> </div><!-- .entry-utility -->
</div><!-- #post-<?php the_ID(); ?> --> </div><!-- #post-<?php the_ID(); ?> -->