<!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>[14752] trunk/wp-admin/includes/template.php:
Meta box and screen option phpdoc and cleanup.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14752">14752</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-05-19 19:11:33 +0000 (Wed, 19 May 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Meta box and screen option phpdoc and cleanup. Props hakre. fixes <a href="http://trac.wordpress.org/ticket/13017">#13017</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (14751 => 14752)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-05-19 18:52:37 UTC (rev 14751)
+++ trunk/wp-admin/includes/template.php        2010-05-19 19:11:33 UTC (rev 14752)
</span><span class="lines">@@ -2837,24 +2837,22 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * {@internal Missing Short Description}}
</del><ins>+ * Meta-Box template function
</ins><span class="cx"> *
</span><del>- * @since unknown
</del><ins>+ * @since 2.5.0
</ins><span class="cx"> *
</span><del>- * @param unknown_type $page
- * @param unknown_type $context
- * @param unknown_type $object
</del><ins>+ * @param string $page page identifier, also known as screen identifier
+ * @param string $context box context
+ * @param mixed $object gets passed to the box callback function as first parameter
</ins><span class="cx"> * @return int number of meta_boxes
</span><span class="cx"> */
</span><span class="cx"> function do_meta_boxes($page, $context, $object) {
</span><span class="cx">         global $wp_meta_boxes;
</span><span class="cx">         static $already_sorted = false;
</span><span class="cx">
</span><del>-        //do_action('do_meta_boxes', $page, $context, $object);
-
</del><span class="cx">         $hidden = get_hidden_meta_boxes($page);
</span><span class="cx">
</span><del>-        echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
</del><ins>+        printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
</ins><span class="cx">
</span><span class="cx">         $i = 0;
</span><span class="cx">         do {
</span><span class="lines">@@ -2954,14 +2952,22 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-function get_hidden_meta_boxes($screen) {
-        if ( is_string($screen) )
-                $screen = convert_to_screen($screen);
</del><ins>+/**
+ * Get Hidden Meta Boxes
+ *
+ * @since 2.7
+ *
+ * @param string|object $screen Screen identifier
+ * @return array Hidden Meta Boxes
+ */
+function get_hidden_meta_boxes( $screen ) {
+        if ( is_string( $screen ) )
+                $screen = convert_to_screen( $screen );
</ins><span class="cx">
</span><del>-        $hidden = get_user_option( "metaboxhidden_$screen->id" );
</del><ins>+        $hidden = get_user_option( "metaboxhidden_{$screen->id}" );
</ins><span class="cx">
</span><span class="cx">         // Hide slug boxes by default
</span><del>-        if ( !is_array($hidden) )
</del><ins>+        if ( !is_array( $hidden ) )
</ins><span class="cx">                 $hidden = array('slugdiv');
</span><span class="cx">
</span><span class="cx">         return $hidden;
</span><span class="lines">@@ -3240,20 +3246,20 @@
</span><span class="cx"> *
</span><span class="cx"> * @param unknown_type $page
</span><span class="cx"> */
</span><del>-function manage_columns_prefs($page) {
-        $columns = get_column_headers($page);
</del><ins>+function manage_columns_prefs( $page ) {
+        $columns = get_column_headers( $page );
+        $hidden = get_hidden_columns( $page );        
+        $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username');
</ins><span class="cx">
</span><del>-        $hidden = get_hidden_columns($page);
-
</del><span class="cx">         foreach ( $columns as $column => $title ) {
</span><span class="cx">                 // Can't hide these or they are special
</span><del>-                if ( '_title' == $column || 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
</del><ins>+                if ( in_array( $column, $special ) )
</ins><span class="cx">                         continue;
</span><del>-                if ( empty($title) )
</del><ins>+                if ( empty( $title ) )
</ins><span class="cx">                         continue;
</span><span class="cx">
</span><span class="cx">                 if ( 'comments' == $column )
</span><del>-                        $title = __('Comments');
</del><ins>+                        $title = __( 'Comments' );
</ins><span class="cx">                 $id = "$column-hide";
</span><span class="cx">                 echo '<label for="' . $id . '">';
</span><span class="cx">                 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
</span><span class="lines">@@ -3549,17 +3555,16 @@
</span><span class="cx"> /**
</span><span class="cx"> * Convert a screen string to a screen object
</span><span class="cx"> *
</span><ins>+ * @since 3.0.0
+ *
</ins><span class="cx"> * @param string $screen The name of the screen
</span><span class="cx"> * @return object An object containing the safe screen name and id
</span><span class="cx"> */
</span><span class="cx"> function convert_to_screen( $screen ) {
</span><del>-        $screen = str_replace('.php', '', $screen);
-        $screen = str_replace('-new', '', $screen);
-        $screen = str_replace('-add', '', $screen);
-        $screen = apply_filters('screen_meta_screen', $screen);
-
-        $screen = array('id' => $screen, 'base' => $screen);
-        return (object) $screen;
</del><ins>+        $screen = str_replace( array('.php', '-new', '-add' ), '', $screen);
+        $screen = (string) apply_filters( 'screen_meta_screen', $screen );
+        $screen = (object) array('id' => $screen, 'base' => $screen);
+        return $screen;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function screen_meta($screen) {
</span><span class="lines">@@ -3595,7 +3600,7 @@
</span><span class="cx">                         $show_screen = true;
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><del>-        if( !empty($settings) )
</del><ins>+        if( ! empty( $settings ) )
</ins><span class="cx">                 $show_screen = true;
</span><span class="cx"> ?>
</span><span class="cx"> <div id="screen-meta">
</span></span></pre>
</div>
</div>
</body>
</html>