<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[14698] trunk/wp-content/themes/twentyten:
Twenty Ten documentation and functions.php improvements.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14698">14698</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-05-16 20:53:36 +0000 (Sun, 16 May 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Twenty Ten documentation and functions.php improvements. see <a href="http://trac.wordpress.org/ticket/12695">#12695</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentytenattachmentphp">trunk/wp-content/themes/twentyten/attachment.php</a></li>
<li><a href="#trunkwpcontentthemestwentytenfunctionsphp">trunk/wp-content/themes/twentyten/functions.php</a></li>
<li><a href="#trunkwpcontentthemestwentytenloopphp">trunk/wp-content/themes/twentyten/loop.php</a></li>
<li><a href="#trunkwpcontentthemestwentytensinglephp">trunk/wp-content/themes/twentyten/single.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpcontentthemestwentytenattachmentphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/attachment.php (14697 => 14698)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/attachment.php        2010-05-16 20:48:09 UTC (rev 14697)
+++ trunk/wp-content/themes/twentyten/attachment.php        2010-05-16 20:53:36 UTC (rev 14698)
</span><span class="lines">@@ -58,8 +58,19 @@
</span><span class="cx">
</span><span class="cx">                                         <div class="entry-content">
</span><span class="cx">                                                 <div class="entry-attachment">
</span><del>-<?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
</del><ins>+<?php if ( wp_attachment_is_image() ) :
+        $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
</ins><span class="cx">                                                         $attachment_size = apply_filters( 'twentyten_attachment_size', 900 );
</span><span class="cx">                                                         echo wp_get_attachment_image( $post->ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height.
</span><span class="cx">                                                 ?></a></p>
</span><span class="lines">@@ -80,7 +91,7 @@
</span><span class="cx">                                         </div><!-- .entry-content -->
</span><span class="cx">
</span><span class="cx">                                         <div class="entry-utility">
</span><del>-                                                <?php echo twentyten_posted_in(); ?>
</del><ins>+                                                <?php twentyten_posted_in(); ?>
</ins><span class="cx">                                                 <?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?>
</span><span class="cx">                                         </div><!-- .entry-utility -->
</span><span class="cx">                                 </div><!-- #post-<?php the_ID(); ?> -->
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytenfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/functions.php (14697 => 14698)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/functions.php        2010-05-16 20:48:09 UTC (rev 14697)
+++ trunk/wp-content/themes/twentyten/functions.php        2010-05-16 20:53:36 UTC (rev 14698)
</span><span class="lines">@@ -9,11 +9,11 @@
</span><span class="cx"> * The first function, twentyten_setup(), sets up the theme by registering support
</span><span class="cx"> * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
</span><span class="cx"> *
</span><del>- * When using a child theme (see http://codex.wordpress.org/Theme_Development), you can
- * override certain functions (those wrapped in a function_exists() call) by defining
- * them first in your child theme's functions.php file. The child theme's functions.php
- * file is included before the parent theme's file, so the child theme functions would
- * be used.
</del><ins>+ * When using a child theme (see http://codex.wordpress.org/Theme_Development and
+ * http://codex.wordpress.org/Theme_Development), you can override certain functions
+ * (those wrapped in a function_exists() call) by defining them first in your child theme's
+ * functions.php file. The child theme's functions.php file is included before the parent
+ * theme's file, so the child theme functions would be used.
</ins><span class="cx"> *
</span><span class="cx"> * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
</span><span class="cx"> * to a filter or action hook. The hook can be removed by using remove_action() or
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage Twenty_Ten
</span><del>- * @since 3.0.0
</del><ins>+ * @since Twenty Ten 1.0
</ins><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> * @uses register_default_headers() To register the default custom header images provided with the theme.
</span><span class="cx"> * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
</span><span class="cx"> *
</span><del>- * @since 3.0.0
</del><ins>+ * @since Twenty Ten 1.0
</ins><span class="cx"> */
</span><span class="cx"> function twentyten_setup() {
</span><span class="cx">
</span><span class="lines">@@ -182,7 +182,7 @@
</span><span class="cx"> *
</span><span class="cx"> * Referenced via add_custom_image_header() in twentyten_setup().
</span><span class="cx"> *
</span><del>- * @since 3.0.0
</del><ins>+ * @since Twenty Ten 1.0
</ins><span class="cx"> */
</span><span class="cx"> function twentyten_admin_header_style() {
</span><span class="cx"> ?>
</span><span class="lines">@@ -205,7 +205,7 @@
</span><span class="cx"> *
</span><span class="cx"> * Used in Twenty Ten's header.php to add the page number to the <title> HTML tag.
</span><span class="cx"> *
</span><del>- * @since 3.0.0
</del><ins>+ * @since Twenty Ten 1.0
</ins><span class="cx"> */
</span><span class="cx"> function twentyten_the_page_number() {
</span><span class="cx">         global $paged; // Contains page number.
</span><span class="lines">@@ -214,16 +214,19 @@
</span><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx">
</span><del>-if ( ! function_exists( 'twentyten_page_menu_args' ) ) :
</del><span class="cx"> /**
</span><span class="cx"> * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
</span><ins>+ *
+ * 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
</ins><span class="cx"> */
</span><del>-function twentyten_page_menu_args($args) {
</del><ins>+function twentyten_page_menu_args( $args ) {
</ins><span class="cx">         $args['show_home'] = true;
</span><span class="cx">         return $args;
</span><span class="cx"> }
</span><del>-add_filter('wp_page_menu_args', 'twentyten_page_menu_args');
-endif;
</del><ins>+add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Sets the post excerpt length to 40 characters.
</span><span class="lines">@@ -231,6 +234,7 @@
</span><span class="cx"> * To override this length in a child theme, remove the filter and add your own
</span><span class="cx"> * function tied to the excerpt_length filter hook.
</span><span class="cx"> *
</span><ins>+ * @since Twenty Ten 1.0
</ins><span class="cx"> * @return int
</span><span class="cx"> */
</span><span class="cx"> function twentyten_excerpt_length( $length ) {
</span><span class="lines">@@ -244,7 +248,7 @@
</span><span class="cx"> * To override this link in a child theme, remove the filter and add your own
</span><span class="cx"> * function tied to the excerpt_more filter hook.
</span><span class="cx"> *
</span><del>- * @since 3.0.0
</del><ins>+ * @since Twenty Ten 1.0
</ins><span class="cx"> * @return string A pretty 'Continue reading' link.
</span><span class="cx"> */
</span><span class="cx"> function twentyten_excerpt_more( $more ) {
</span><span class="lines">@@ -257,6 +261,7 @@
</span><span class="cx"> *
</span><span class="cx"> * Galleries are styled by the theme in Twenty Ten's style.css.
</span><span class="cx"> *
</span><ins>+ * @since Twenty Ten 1.0
</ins><span class="cx"> * @return string The gallery style filter, with the styles themselves removed.
</span><span class="cx"> */
</span><span class="cx"> function twentyten_remove_gallery_css( $css ) {
</span><span class="lines">@@ -273,7 +278,7 @@
</span><span class="cx"> *
</span><span class="cx"> * Used as a callback by wp_list_comments() for displaying the comments.
</span><span class="cx"> *
</span><del>- * @since 3.0.0
</del><ins>+ * @since Twenty Ten 1.0
</ins><span class="cx"> */
</span><span class="cx"> function twentyten_comment( $comment, $args, $depth ) {
</span><span class="cx">         $GLOBALS['comment'] = $comment; ?>
</span><span class="lines">@@ -315,6 +320,8 @@
</span><span class="cx"> *
</span><span class="cx"> * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
</span><span class="cx"> * function tied to the init hook.
</span><ins>+ *
+ * @since Twenty Ten 1.0
</ins><span class="cx"> * @uses register_sidebar
</span><span class="cx"> */
</span><span class="cx"> function twentyten_widgets_init() {
</span><span class="lines">@@ -384,10 +391,16 @@
</span><span class="cx">                 'after_title' => '</h3>',
</span><span class="cx">         ) );
</span><span class="cx"> }
</span><del>-add_action( 'init', 'twentyten_widgets_init' );
</del><ins>+/** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
+add_action( 'widgets_init', 'twentyten_widgets_init' );
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Removes the default styles that are packaged with the Recent Comments widget.
</span><ins>+ *
+ * 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
</ins><span class="cx"> */
</span><span class="cx"> function twentyten_remove_recent_comments_style() {
</span><span class="cx">         global $wp_widget_factory;
</span><span class="lines">@@ -395,30 +408,14 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
</span><span class="cx">
</span><ins>+if ( ! function_exists( 'twentyten_posted_on' ) ) :
</ins><span class="cx"> /**
</span><del>- * Get the URL of the next image in a gallery for attachment pages
</del><ins>+ * Prints HTML with meta information for the current post—date/time and author.
+ *
+ * @since Twenty Ten 1.0
</ins><span class="cx"> */
</span><del>-function twentyten_get_next_attachment_url() {
-        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.
- */
</del><span class="cx"> function twentyten_posted_on() {
</span><del>-        return sprintf( __( '<span %1$s>Posted on</span> %2$s by %3$s', 'twentyten' ),
</del><ins>+        printf( __( '<span %1$s>Posted on</span> %2$s by %3$s', 'twentyten' ),
</ins><span class="cx">                 'class="meta-prep meta-prep-author"',
</span><span class="cx">                 sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">',
</span><span class="cx">                         get_permalink(),
</span><span class="lines">@@ -433,24 +430,29 @@
</span><span class="cx">         );
</span><span class="cx">         
</span><span class="cx"> }
</span><ins>+endif;
</ins><span class="cx">
</span><ins>+if ( ! function_exists( 'twentyten_posted_in' ) ) :
</ins><span class="cx"> /**
</span><del>- * Returns HTML with meta information for the current post—category, tags and permalink
</del><ins>+ * Prints HTML with meta information for the current post (category, tags and permalink).
+ *
+ * @since Twenty Ten 1.0
</ins><span class="cx"> */
</span><del>-
</del><span class="cx"> function twentyten_posted_in() {
</span><del>-        $tag_list = get_the_tag_list( '', ', ', '' );
</del><ins>+        // Retrieves tag list of current post, separated by commas.
+        $tag_list = get_the_tag_list( '', ', ' );
</ins><span class="cx">         if ( $tag_list ) {
</span><del>-                $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' );
</del><ins>+                $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' );
</ins><span class="cx">         } else {
</span><del>-                $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' );
</del><ins>+                $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' );
</ins><span class="cx">         }
</span><del>-        return sprintf(
-                $utility_text,
</del><ins>+        // Prints the string, replacing the placeholders.
+        printf(
+                $posted_in,
</ins><span class="cx">                 get_the_category_list( ', ' ),
</span><span class="cx">                 $tag_list,
</span><span class="cx">                 get_permalink(),
</span><del>-                the_title_attribute( 'echo=0' ),
-                get_post_comments_feed_link()
</del><ins>+                the_title_attribute( 'echo=0' )
</ins><span class="cx">         );        
</span><span class="cx"> }
</span><ins>+endif;
</ins></span></pre></div>
<a id="trunkwpcontentthemestwentytenloopphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/loop.php (14697 => 14698)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/loop.php        2010-05-16 20:48:09 UTC (rev 14697)
+++ trunk/wp-content/themes/twentyten/loop.php        2010-05-16 20:53:36 UTC (rev 14698)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx">                         <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>
</span><span class="cx">
</span><span class="cx">                         <div class="entry-meta">
</span><del>-                                <?php echo twentyten_posted_on(); ?>
</del><ins>+                                <?php twentyten_posted_on(); ?>
</ins><span class="cx">                         </div><!-- .entry-meta -->
</span><span class="cx">
</span><span class="cx">                         <div class="entry-content">
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx">         <?php endif; ?>
</span><span class="cx">
</span><span class="cx">                         <div class="entry-utility">
</span><del>-                                <?php echo twentyten_posted_on(); ?>
</del><ins>+                                <?php twentyten_posted_on(); ?>
</ins><span class="cx">                                 <span class="meta-sep">|</span>
</span><span class="cx">                                 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
</span><span class="cx">                                 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx">                         <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>
</span><span class="cx">
</span><span class="cx">                         <div class="entry-meta">
</span><del>-                                <?php echo twentyten_posted_on(); ?>
</del><ins>+                                <?php twentyten_posted_on(); ?>
</ins><span class="cx">                         </div><!-- .entry-meta -->
</span><span class="cx">
</span><span class="cx">         <?php if ( is_archive() || is_search() ) : // Only display Excerpts for archives & search ?>
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytensinglephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/single.php (14697 => 14698)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/single.php        2010-05-16 20:48:09 UTC (rev 14697)
+++ trunk/wp-content/themes/twentyten/single.php        2010-05-16 20:53:36 UTC (rev 14698)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx">                                         <h1 class="entry-title"><?php the_title(); ?></h1>
</span><span class="cx">
</span><span class="cx">                                         <div class="entry-meta">
</span><del>-                                                <?php echo twentyten_posted_on(); ?>
</del><ins>+                                                <?php twentyten_posted_on(); ?>
</ins><span class="cx">                                         </div><!-- .entry-meta -->
</span><span class="cx">
</span><span class="cx">                                         <div class="entry-content">
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx"> <?php endif; ?>
</span><span class="cx">
</span><span class="cx">                                         <div class="entry-utility">
</span><del>-                                                <?php echo twentyten_posted_in(); ?>
</del><ins>+                                                <?php twentyten_posted_in(); ?>
</ins><span class="cx">                                                 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
</span><span class="cx">                                         </div><!-- .entry-utility -->
</span><span class="cx">                                 </div><!-- #post-<?php the_ID(); ?> -->
</span></span></pre>
</div>
</div>
</body>
</html>