<!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>[13172] trunk: Flag post statuses as public, private, protected,
  or internal.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13172">13172</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-16 21:13:44 +0000 (Tue, 16 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Flag post statuses as public, private, protected, or internal. Add flags for showing the type in the admin all query and the admin status list. see <a href="http://trac.wordpress.org/ticket/9674">#9674</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditphp">trunk/wp-admin/edit.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
<li><a href="#trunkwpincludesqueryphp">trunk/wp-includes/query.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit.php (13171 => 13172)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit.php        2010-02-16 17:54:19 UTC (rev 13171)
+++ trunk/wp-admin/edit.php        2010-02-16 21:13:44 UTC (rev 13172)
</span><span class="lines">@@ -232,7 +232,7 @@
</span><span class="cx"> $class = empty($class) &amp;&amp; empty($_GET['post_status']) ? ' class=&quot;current&quot;' : '';
</span><span class="cx"> $status_links[] = &quot;&lt;li&gt;&lt;a href='edit.php?post_type=$post_type{$allposts}'$class&gt;&quot; . sprintf( _nx( 'All &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'All &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '&lt;/a&gt;';
</span><span class="cx"> 
</span><del>-foreach ( get_post_stati(array('show_in_admin_edit' =&gt; true), 'objects') as $status ) {
</del><ins>+foreach ( get_post_stati(array('show_in_admin_status_list' =&gt; true), 'objects') as $status ) {
</ins><span class="cx">         $class = '';
</span><span class="cx"> 
</span><span class="cx">         $status_name = $status-&gt;name;
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (13171 => 13172)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-02-16 17:54:19 UTC (rev 13171)
+++ trunk/wp-includes/post.php        2010-02-16 21:13:44 UTC (rev 13172)
</span><span class="lines">@@ -70,33 +70,38 @@
</span><span class="cx">                                                                                 ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_status( 'future', array(        'label' =&gt; _x('Scheduled', 'post'),
</span><del>-                                                                                        'public' =&gt; true,
</del><ins>+                                                                                        'protected' =&gt; true,
</ins><span class="cx">                                                                                         '_builtin' =&gt; true,
</span><span class="cx">                                                                                         'label_count' =&gt; _n_noop('Scheduled &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Scheduled &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;')
</span><span class="cx">                                                                                 ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_status( 'draft', array(        'label' =&gt; _x('Draft', 'post'),
</span><del>-                                                                                        'public' =&gt; true,
</del><ins>+                                                                                        'protected' =&gt; true,
</ins><span class="cx">                                                                                         '_builtin' =&gt; true,
</span><span class="cx">                                                                                         'label_count' =&gt; _n_noop('Draft &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Drafts &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;')
</span><span class="cx">                                                                                 ) );
</span><span class="cx"> 
</span><ins>+        register_post_status( 'pending', array(        'label' =&gt; _x('Pending', 'post'),
+                                                                                        'protected' =&gt; true,
+                                                                                        '_builtin' =&gt; true,
+                                                                                        'label_count' =&gt; _n_noop('Pending &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Pending &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;')
+                                                                                ) );
+
</ins><span class="cx">         register_post_status( 'private', array(        'label' =&gt; _x('Private', 'post'),
</span><del>-                                                                                        'public' =&gt; true,
</del><ins>+                                                                                        'private' =&gt; true,
</ins><span class="cx">                                                                                         '_builtin' =&gt; true,
</span><span class="cx">                                                                                         'label_count' =&gt; _n_noop('Private &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Private &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;')
</span><span class="cx">                                                                                 ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_status( 'trash', array(        'label' =&gt; _x('Trash', 'post'),
</span><del>-                                                                                        'public' =&gt; true,
-                                                                                        'exclude_from_search' =&gt; true,
</del><ins>+                                                                                        'internal' =&gt; true,
+                                                                                        'show_in_admin_status_list' =&gt; true,
</ins><span class="cx">                                                                                         '_builtin' =&gt; true,
</span><span class="cx">                                                                                         'label_count' =&gt; _n_noop('Trash &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Trash &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;')
</span><span class="cx">                                                                                 ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_status( 'auto-draft', array(        'label' =&gt; _x('Auto-Draft', 'post'),
</span><del>-                                                                                        'public' =&gt; false,
-                                                                                        'exclude_from_search' =&gt; true,
</del><ins>+                                                                                        'internal' =&gt; true,
</ins><span class="cx">                                                                                         '_builtin' =&gt; true,
</span><span class="cx">                                                                                         'label_count' =&gt; _n_noop('Auto-Draft &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Auto-Drafts &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;')
</span><span class="cx">                                                                                 ) );
</span><span class="lines">@@ -526,25 +531,43 @@
</span><span class="cx">                 $wp_post_statuses = array();
</span><span class="cx"> 
</span><span class="cx">         // Args prefixed with an underscore are reserved for internal use.
</span><del>-        $defaults = array('label' =&gt; false, 'label_count' =&gt; false, 'exclude_from_search' =&gt; null, '_builtin' =&gt; false, '_edit_link' =&gt; 'post.php?post=%d', 'capability_type' =&gt; 'post', 'hierarchical' =&gt; false, 'public' =&gt; false, 'publicly_queryable' =&gt; null, 'show_in_admin_edit' =&gt; null);
</del><ins>+        $defaults = array('label' =&gt; false, 'label_count' =&gt; false, 'exclude_from_search' =&gt; null, '_builtin' =&gt; false, '_edit_link' =&gt; 'post.php?post=%d', 'capability_type' =&gt; 'post', 'hierarchical' =&gt; false, 'public' =&gt; null, 'internal' =&gt; null, 'protected' =&gt; null, 'private' =&gt; null, 'show_in_admin_all' =&gt; null, 'publicly_queryable' =&gt; null, 'show_in_admin_status_list' =&gt; null, 'show_in_admin_all_list' =&gt; null, 'single_view_cap' =&gt; null);
</ins><span class="cx">         $args = wp_parse_args($args, $defaults);
</span><span class="cx">         $args = (object) $args;
</span><span class="cx"> 
</span><span class="cx">         $post_status = sanitize_user($post_status, true);
</span><span class="cx">         $args-&gt;name = $post_status;
</span><span class="cx"> 
</span><del>-        // If not set, default to the setting for public.
</del><ins>+        if ( null === $args-&gt;public &amp;&amp; null === $args-&gt;internal &amp;&amp; null === $args-&gt;protected &amp;&amp; null === $args-&gt;private )
+                $args-&gt;internal = true;
+
+        if ( null === $args-&gt;public  )
+                $args-&gt;public = false;
+
+        if ( null === $args-&gt;private  )
+                $args-&gt;private = false;
+
+        if ( null === $args-&gt;protected  )
+                $args-&gt;protected = false;
+
+        if ( null === $args-&gt;internal  )
+                $args-&gt;internal = false;
+
</ins><span class="cx">         if ( null === $args-&gt;publicly_queryable )
</span><span class="cx">                 $args-&gt;publicly_queryable = $args-&gt;public;
</span><span class="cx"> 
</span><del>-        // If not set, default to true if not public, false if public.
</del><span class="cx">         if ( null === $args-&gt;exclude_from_search )
</span><del>-                $args-&gt;exclude_from_search = !$args-&gt;public;
</del><ins>+                $args-&gt;exclude_from_search = $args-&gt;internal;
</ins><span class="cx"> 
</span><del>-        // If not set, default to the setting for public.
-        if ( null === $args-&gt;show_in_admin_edit )
-                $args-&gt;show_in_admin_edit = $args-&gt;public;
</del><ins>+        if ( null === $args-&gt;show_in_admin_all_list )
+                $args-&gt;show_in_admin_all_list = !$args-&gt;internal;
</ins><span class="cx"> 
</span><ins>+        if ( null === $args-&gt;show_in_admin_status_list )
+                        $args-&gt;show_in_admin_status_list = !$args-&gt;internal;
+
+        if ( null === $args-&gt;single_view_cap )
+                $args-&gt;single_view_cap = $args-&gt;public ? '' : 'edit';
+
</ins><span class="cx">         if ( false === $args-&gt;label )
</span><span class="cx">                 $args-&gt;label = $post_status;
</span><span class="cx"> 
</span><span class="lines">@@ -591,15 +614,21 @@
</span><span class="cx">  * @param array|string $args An array of key =&gt; value arguments to match against the post statuses.
</span><span class="cx">  *  Only post statuses having attributes that match all arguments are returned.
</span><span class="cx">  * @param string $output The type of output to return, either post status 'names' or 'objects'. 'names' is the default.
</span><ins>+ * @param string $operator Whether the elements in $args should be logicallly 'or'ed or 'and'ed together. 'or' means only one element from the array needs to match. 'and' means all elements must match. The default is 'or'.
</ins><span class="cx">  * @return array A list of post type names or objects
</span><span class="cx">  */
</span><del>-function get_post_stati( $args = array(), $output = 'names' ) {
</del><ins>+function get_post_stati( $args = array(), $output = 'names', $operator = 'or' ) {
</ins><span class="cx">         global $wp_post_statuses;
</span><span class="cx"> 
</span><span class="cx">         $do_names = false;
</span><span class="cx">         if ( 'names' == $output )
</span><span class="cx">                 $do_names = true;
</span><span class="cx"> 
</span><ins>+        if ( 'and' == $operator )
+                $arg_count = count($args);
+        else
+                $arg_count = 0;
+
</ins><span class="cx">         $post_statuses = array();
</span><span class="cx">         foreach ( (array) $wp_post_statuses as $post_status ) {
</span><span class="cx">                 if ( empty($args) ) {
</span><span class="lines">@@ -607,7 +636,9 @@
</span><span class="cx">                                 $post_statuses[] = $post_status-&gt;name;
</span><span class="cx">                         else
</span><span class="cx">                                 $post_statuses[] = $post_status;
</span><del>-                } elseif ( array_intersect_assoc((array) $post_status, $args) ) {
</del><ins>+                } elseif ( $intersect = array_intersect_assoc((array) $post_status, $args) ) {
+                        if ( $arg_count &amp;&amp; ( $arg_count != count($intersect) ) )
+                                continue;
</ins><span class="cx">                         if ( $do_names )
</span><span class="cx">                                 $post_statuses[] = $post_status-&gt;name;
</span><span class="cx">                         else
</span><span class="lines">@@ -787,6 +818,8 @@
</span><span class="cx">                 $args-&gt;publish_cap = 'publish_' . $args-&gt;capability_type . 's';
</span><span class="cx">         if ( empty($args-&gt;read_cap) )
</span><span class="cx">                 $args-&gt;read_cap = 'read_' . $args-&gt;capability_type;
</span><ins>+        if ( empty($args-&gt;read_private_cap) )
+                $args-&gt;read_private_cap = 'read_private_' . $args-&gt;capability_type . 's';
</ins><span class="cx">         if ( empty($args-&gt;delete_cap) )
</span><span class="cx">                 $args-&gt;delete_cap = 'delete_' . $args-&gt;capability_type;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesqueryphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/query.php (13171 => 13172)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/query.php        2010-02-16 17:54:19 UTC (rev 13171)
+++ trunk/wp-includes/query.php        2010-02-16 21:13:44 UTC (rev 13172)
</span><span class="lines">@@ -2061,9 +2061,9 @@
</span><span class="cx">                                 $q['orderby'] = &quot;$wpdb-&gt;posts.post_date &quot;.$q['order'];
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if ( is_array($post_type) )
</del><ins>+                if ( is_array($post_type) ) {
</ins><span class="cx">                         $post_type_cap = 'multiple_post_type';
</span><del>-                else {
</del><ins>+                } else {
</ins><span class="cx">                         $post_type_object = get_post_type_object ( $post_type );
</span><span class="cx">                         if ( !empty($post_type_object) )
</span><span class="cx">                                 $post_type_cap = $post_type_object-&gt;capability_type;
</span><span class="lines">@@ -2081,17 +2081,31 @@
</span><span class="cx">                         $where .= &quot; AND $wpdb-&gt;posts.post_type IN ('&quot; . join(&quot;', '&quot;, $post_type) . &quot;')&quot;;
</span><span class="cx">                 } elseif ( ! empty( $post_type ) ) {
</span><span class="cx">                         $where .= &quot; AND $wpdb-&gt;posts.post_type = '$post_type'&quot;;
</span><ins>+                        $post_type_object = get_post_type_object ( $post_type );
</ins><span class="cx">                 } elseif ( $this-&gt;is_attachment ) {
</span><span class="cx">                         $where .= &quot; AND $wpdb-&gt;posts.post_type = 'attachment'&quot;;
</span><del>-                        $post_type_cap = 'post';
</del><ins>+                        $post_type_object = get_post_type_object ( 'attachment' );
</ins><span class="cx">                 } elseif ($this-&gt;is_page) {
</span><span class="cx">                         $where .= &quot; AND $wpdb-&gt;posts.post_type = 'page'&quot;;
</span><del>-                        $post_type_cap = 'page';
</del><ins>+                        $post_type_object = get_post_type_object ( 'page' );
</ins><span class="cx">                 } else {
</span><span class="cx">                         $where .= &quot; AND $wpdb-&gt;posts.post_type = 'post'&quot;;
</span><del>-                        $post_type_cap = 'post';
</del><ins>+                        $post_type_object = get_post_type_object ( 'post' );
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><ins>+                if ( !empty($post_type_object) ) {
+                        $post_type_cap = $post_type_object-&gt;capability_type;
+                        $edit_cap = $post_type_object-&gt;edit_cap;
+                        $read_cap = $post_type_object-&gt;read_cap;
+                        $edit_others_cap = $post_type_object-&gt;edit_others_cap;
+                        $read_private_cap = $post_type_object-&gt;read_private_cap;
+                } else {
+                        $edit_cap = 'edit_' . $post_type_cap;
+                        $read_cap = 'read_' . $post_type_cap;
+                        $edit_others_cap = 'edit_others_' . $post_type_cap . 's';
+                        $read_private_cap = 'read_private_' . $post_type_cap . 's';
+                }
+
</ins><span class="cx">                 if ( isset($q['post_status']) &amp;&amp; '' != $q['post_status'] ) {
</span><span class="cx">                         $statuswheres = array();
</span><span class="cx">                         $q_status = explode(',', $q['post_status']);
</span><span class="lines">@@ -2121,13 +2135,13 @@
</span><span class="cx">                                 $statuswheres[] = &quot;(&quot; . join( ' AND ', $e_status ) . &quot;)&quot;;
</span><span class="cx">                         }
</span><span class="cx">                         if ( !empty($r_status) ) {
</span><del>-                                if ( !empty($q['perm'] ) &amp;&amp; 'editable' == $q['perm'] &amp;&amp; !current_user_can(&quot;edit_others_{$post_type_cap}s&quot;) )
</del><ins>+                                if ( !empty($q['perm'] ) &amp;&amp; 'editable' == $q['perm'] &amp;&amp; !current_user_can($edit_others_cap) )
</ins><span class="cx">                                         $statuswheres[] = &quot;($wpdb-&gt;posts.post_author = $user_ID &quot; .  &quot;AND (&quot; . join( ' OR ', $r_status ) . &quot;))&quot;;
</span><span class="cx">                                 else
</span><span class="cx">                                         $statuswheres[] = &quot;(&quot; . join( ' OR ', $r_status ) . &quot;)&quot;;
</span><span class="cx">                         }
</span><span class="cx">                         if ( !empty($p_status) ) {
</span><del>-                                if ( !empty($q['perm'] ) &amp;&amp; 'readable' == $q['perm'] &amp;&amp; !current_user_can(&quot;read_private_{$post_type_cap}s&quot;) )
</del><ins>+                                if ( !empty($q['perm'] ) &amp;&amp; 'readable' == $q['perm'] &amp;&amp; !current_user_can($read_private_cap) )
</ins><span class="cx">                                         $statuswheres[] = &quot;($wpdb-&gt;posts.post_author = $user_ID &quot; .  &quot;AND (&quot; . join( ' OR ', $p_status ) . &quot;))&quot;;
</span><span class="cx">                                 else
</span><span class="cx">                                         $statuswheres[] = &quot;(&quot; . join( ' OR ', $p_status ) . &quot;)&quot;;
</span><span class="lines">@@ -2142,11 +2156,26 @@
</span><span class="cx">                 } elseif ( !$this-&gt;is_singular ) {
</span><span class="cx">                         $where .= &quot; AND ($wpdb-&gt;posts.post_status = 'publish'&quot;;
</span><span class="cx"> 
</span><del>-                        if ( is_admin() )
-                                $where .= &quot; OR $wpdb-&gt;posts.post_status = 'future' OR $wpdb-&gt;posts.post_status = 'draft' OR $wpdb-&gt;posts.post_status = 'pending'&quot;;
</del><ins>+                        // Add public states.
+                        $public_states = get_post_stati( array('public' =&gt; true) );
+                        foreach ( (array) $public_states as $state ) {
+                                if ( 'publish' == $state ) // Publish is hard-coded above.
+                                        continue;
+                                $where .= &quot; OR $wpdb-&gt;posts.post_status = '$state'&quot;;
+                        }
</ins><span class="cx"> 
</span><ins>+                        if ( is_admin() ) {
+                                // Add protected states that should show in the admin all list.
+                                $admin_all_states = get_post_stati( array('protected' =&gt; true, 'show_in_admin_all_list' =&gt; true), 'names', 'and' );
+                                foreach ( (array) $admin_all_states as $state )
+                                        $where .= &quot; OR $wpdb-&gt;posts.post_status = '$state'&quot;;
+                        }
+
</ins><span class="cx">                         if ( is_user_logged_in() ) {
</span><del>-                                $where .= current_user_can( &quot;read_private_{$post_type_cap}s&quot; ) ? &quot; OR $wpdb-&gt;posts.post_status = 'private'&quot; : &quot; OR $wpdb-&gt;posts.post_author = $user_ID AND $wpdb-&gt;posts.post_status = 'private'&quot;;
</del><ins>+                                // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states.
+                                $private_states = get_post_stati( array('private' =&gt; true) );
+                                foreach ( (array) $private_states as $state )
+                                        $where .= current_user_can( $read_private_cap ) ? &quot; OR $wpdb-&gt;posts.post_status = '$state'&quot; : &quot; OR $wpdb-&gt;posts.post_author = $user_ID AND $wpdb-&gt;posts.post_status = '$state'&quot;;
</ins><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         $where .= ')';
</span><span class="lines">@@ -2296,33 +2325,32 @@
</span><span class="cx">                 // Check post status to determine if post should be displayed.
</span><span class="cx">                 if ( !empty($this-&gt;posts) &amp;&amp; ($this-&gt;is_single || $this-&gt;is_page) ) {
</span><span class="cx">                         $status = get_post_status($this-&gt;posts[0]);
</span><ins>+                        $post_status_obj = get_post_status_object($status);
</ins><span class="cx">                         //$type = get_post_type($this-&gt;posts[0]);
</span><del>-                        if ( ('publish' != $status) ) {
</del><ins>+                        if ( !$post_status_obj-&gt;public ) {
</ins><span class="cx">                                 if ( ! is_user_logged_in() ) {
</span><span class="cx">                                         // User must be logged in to view unpublished posts.
</span><span class="cx">                                         $this-&gt;posts = array();
</span><span class="cx">                                 } else {
</span><del>-                                        if  (in_array($status, array('draft', 'pending', 'trash')) ) {
</del><ins>+                                        if  ( $post_status_obj-&gt;protected ) {
</ins><span class="cx">                                                 // User must have edit permissions on the draft to preview.
</span><del>-                                                if (! current_user_can(&quot;edit_$post_type_cap&quot;, $this-&gt;posts[0]-&gt;ID)) {
</del><ins>+                                                if (! current_user_can($edit_cap, $this-&gt;posts[0]-&gt;ID)) {
</ins><span class="cx">                                                         $this-&gt;posts = array();
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         $this-&gt;is_preview = true;
</span><del>-                                                        $this-&gt;posts[0]-&gt;post_date = current_time('mysql');
</del><ins>+                                                        if ('future' != $status)
+                                                                $this-&gt;posts[0]-&gt;post_date = current_time('mysql');
</ins><span class="cx">                                                 }
</span><del>-                                        }  else if ('future' == $status) {
-                                                $this-&gt;is_preview = true;
-                                                if (!current_user_can(&quot;edit_$post_type_cap&quot;, $this-&gt;posts[0]-&gt;ID)) {
-                                                        $this-&gt;posts = array ( );
-                                                }
</del><ins>+                                        } elseif ( $post_status_obj-&gt;private ) {
+                                                if ( ! current_user_can($read_cap, $this-&gt;posts[0]-&gt;ID) )
+                                                        $this-&gt;posts = array();
</ins><span class="cx">                                         } else {
</span><del>-                                                if (! current_user_can(&quot;read_$post_type_cap&quot;, $this-&gt;posts[0]-&gt;ID))
-                                                        $this-&gt;posts = array();
</del><ins>+                                                $this-&gt;posts = array();
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        if ( $this-&gt;is_preview &amp;&amp; current_user_can( &quot;edit_{$post_type_cap}&quot;, $this-&gt;posts[0]-&gt;ID ) )
</del><ins>+                        if ( $this-&gt;is_preview &amp;&amp; current_user_can( $edit_cap, $this-&gt;posts[0]-&gt;ID ) )
</ins><span class="cx">                                 $this-&gt;posts[0] = apply_filters('the_preview', $this-&gt;posts[0]);
</span><span class="cx">                 }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>