<!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>[13468] trunk/wp-includes: Add some whitespace to get_body_class().</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13468">13468</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-02-27 20:06:35 +0000 (Sat, 27 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add some whitespace to get_body_class(). props coffee2code. Clarify fallback parameter in sanitize_html_class(). see <a href="http://trac.wordpress.org/ticket/11331">#11331</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesformattingphp">trunk/wp-includes/formatting.php</a></li>
<li><a href="#trunkwpincludesposttemplatephp">trunk/wp-includes/post-template.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesformattingphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/formatting.php (13467 => 13468)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/formatting.php        2010-02-27 18:57:04 UTC (rev 13467)
+++ trunk/wp-includes/formatting.php        2010-02-27 20:06:35 UTC (rev 13468)
</span><span class="lines">@@ -842,20 +842,21 @@
</span><span class="cx"> * @since 2.8.0
</span><span class="cx"> *
</span><span class="cx"> * @param string $class The classname to be sanitized
</span><del>- * @param string $fallback The value to return if the sanitization end's up as an empty string.
</del><ins>+ * @param string $fallback Optional. The value to return if the sanitization end's up as an empty string.
+ *         Defaults to an empty string.
</ins><span class="cx"> * @return string The sanitized value
</span><span class="cx"> */
</span><del>-function sanitize_html_class($class, $fallback){
</del><ins>+function sanitize_html_class( $class, $fallback = '' ) {
</ins><span class="cx">         //Strip out any % encoded octets
</span><span class="cx">         $sanitized = preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $class);
</span><span class="cx">
</span><span class="cx">         //Limit to A-Z,a-z,0-9,'-'
</span><span class="cx">         $sanitized = preg_replace('/[^A-Za-z0-9-]/', '', $sanitized);
</span><span class="cx">
</span><del>-        if ('' == $sanitized)
</del><ins>+        if ( '' == $sanitized )
</ins><span class="cx">                 $sanitized = $fallback;
</span><span class="cx">
</span><del>-        return apply_filters('sanitize_html_class',$sanitized, $class, $fallback);
</del><ins>+        return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludesposttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-template.php (13467 => 13468)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-template.php        2010-02-27 18:57:04 UTC (rev 13467)
+++ trunk/wp-includes/post-template.php        2010-02-27 20:06:35 UTC (rev 13468)
</span><span class="lines">@@ -372,7 +372,7 @@
</span><span class="cx">
</span><span class="cx">         $classes = array();
</span><span class="cx">
</span><del>-        if ( 'rtl' == get_bloginfo('text_direction') )
</del><ins>+        if ( 'rtl' == get_bloginfo( 'text_direction' ) )
</ins><span class="cx">                 $classes[] = 'rtl';
</span><span class="cx">
</span><span class="cx">         if ( is_front_page() )
</span><span class="lines">@@ -404,21 +404,21 @@
</span><span class="cx">                         $mime_type = get_post_mime_type($post_id);
</span><span class="cx">                         $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
</span><span class="cx">                         $classes[] = 'attachmentid-' . $post_id;
</span><del>-                        $classes[] = 'attachment-' . str_replace($mime_prefix, '', $mime_type);
</del><ins>+                        $classes[] = 'attachment-' . str_replace( $mime_prefix, '', $mime_type );
</ins><span class="cx">                 }
</span><span class="cx">         } elseif ( is_archive() ) {
</span><span class="cx">                 if ( is_author() ) {
</span><span class="cx">                         $author = $wp_query->get_queried_object();
</span><span class="cx">                         $classes[] = 'author';
</span><del>-                        $classes[] = 'author-' . sanitize_html_class($author->user_nicename , $author->ID);
</del><ins>+                        $classes[] = 'author-' . sanitize_html_class( $author->user_nicename , $author->ID );
</ins><span class="cx">                 } elseif ( is_category() ) {
</span><span class="cx">                         $cat = $wp_query->get_queried_object();
</span><span class="cx">                         $classes[] = 'category';
</span><del>-                        $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID);
</del><ins>+                        $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->cat_ID );
</ins><span class="cx">                 } elseif ( is_tag() ) {
</span><span class="cx">                         $tags = $wp_query->get_queried_object();
</span><span class="cx">                         $classes[] = 'tag';
</span><del>-                        $classes[] = 'tag-' . sanitize_html_class($tags->slug, $tags->term_id);
</del><ins>+                        $classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id );
</ins><span class="cx">                 }
</span><span class="cx">         } elseif ( is_page() ) {
</span><span class="cx">                 $classes[] = 'page';
</span><span class="lines">@@ -441,7 +441,7 @@
</span><span class="cx">                         $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_post_meta( $page_id, '_wp_page_template', true ) ), '' );
</span><span class="cx">                 }
</span><span class="cx">         } elseif ( is_search() ) {
</span><del>-                if ( !empty($wp_query->posts) )
</del><ins>+                if ( !empty( $wp_query->posts ) )
</ins><span class="cx">                         $classes[] = 'search-results';
</span><span class="cx">                 else
</span><span class="cx">                         $classes[] = 'search-no-results';
</span><span class="lines">@@ -450,10 +450,10 @@
</span><span class="cx">         if ( is_user_logged_in() )
</span><span class="cx">                 $classes[] = 'logged-in';
</span><span class="cx">
</span><del>-        $page = $wp_query->get('page');
</del><ins>+        $page = $wp_query->get( 'page' );
</ins><span class="cx">
</span><span class="cx">         if ( !$page || $page < 2)
</span><del>-                $page = $wp_query->get('paged');
</del><ins>+                $page = $wp_query->get( 'paged' );
</ins><span class="cx">
</span><span class="cx">         if ( $page && $page > 1 ) {
</span><span class="cx">                 $classes[] = 'paged-' . $page;
</span><span class="lines">@@ -474,15 +474,15 @@
</span><span class="cx">                         $classes[] = 'search-paged-' . $page;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( !empty($class) ) {
</del><ins>+        if ( !empty( $class ) ) {
</ins><span class="cx">                 if ( !is_array( $class ) )
</span><del>-                        $class = preg_split('#\s+#', $class);
-                $classes = array_merge($classes, $class);
</del><ins>+                        $class = preg_split( '#\s+#', $class );
+                $classes = array_merge( $classes, $class );
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        $classes = array_map('esc_attr', $classes);
</del><ins>+        $classes = array_map( 'esc_attr', $classes );
</ins><span class="cx">
</span><del>-        return apply_filters('body_class', $classes, $class);
</del><ins>+        return apply_filters( 'body_class', $classes, $class );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>
</body>
</html>