Ticket #4446: pending_posts.001.diff

File pending_posts.001.diff, 18.7 KB (added by markjaquith, 6 years ago)
  • wp-comments-post.php

     
    1919} elseif ( 'closed' ==  $status->comment_status ) { 
    2020        do_action('comment_closed', $comment_post_ID); 
    2121        wp_die( __('Sorry, comments are closed for this item.') ); 
    22 } elseif ( 'draft' == $status->post_status ) { 
     22} elseif ( in_array($status->post_status, array('draft', 'pending') ) ) { 
    2323        do_action('comment_on_draft', $comment_post_ID); 
    2424        exit; 
    2525} 
  • wp-includes/post-template.php

     
    162162                                        if ( 1 == $i ) { 
    163163                                                $output .= '<a href="' . get_permalink() . '">'; 
    164164                                        } else { 
    165                                                 if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) 
     165                                                if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 
    166166                                                        $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">'; 
    167167                                                else 
    168168                                                        $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">'; 
     
    181181                                        if ( 1 == $i ) { 
    182182                                                $output .= '<a href="' . get_permalink() . '">' . $previouspagelink . '</a>'; 
    183183                                        } else { 
    184                                                 if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) 
     184                                                if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 
    185185                                                        $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $previouspagelink . '</a>'; 
    186186                                                else 
    187187                                                        $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $previouspagelink . '</a>'; 
     
    192192                                        if ( 1 == $i ) { 
    193193                                                $output .= '<a href="' . get_permalink() . '">' . $nextpagelink . '</a>'; 
    194194                                        } else { 
    195                                                 if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) 
     195                                                if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 
    196196                                                        $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $nextpagelink . '</a>'; 
    197197                                                else 
    198198                                                        $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $nextpagelink . '</a>'; 
  • wp-includes/query.php

     
    10061006                        $r_status = array(); 
    10071007                        if ( in_array( 'draft'  , $q_status ) ) 
    10081008                                $r_status[] = "post_status = 'draft'"; 
     1009                        if ( in_array( 'pending', $q_status ) ) 
     1010                                $r_status[] = "post_status = 'pending'"; 
    10091011                        if ( in_array( 'future' , $q_status ) ) 
    10101012                                $r_status[] = "post_status = 'future'"; 
    10111013                        if ( in_array( 'inherit' , $q_status ) ) 
     
    10201022                        $where .= " AND (post_status = 'publish'"; 
    10211023 
    10221024                        if ( is_admin() ) 
    1023                                 $where .= " OR post_status = 'future' OR post_status = 'draft'"; 
     1025                                $where .= " OR post_status = 'future' OR post_status = 'draft' OR post_status = 'pending'"; 
    10241026                         
    10251027                        if ( is_user_logged_in() ) { 
    10261028                                $where .= current_user_can( "read_private_{$post_type}s" ) ? " OR post_status = 'private'" : " OR post_author = $user_ID AND post_status = 'private'"; 
     
    11281130                                        // User must be logged in to view unpublished posts. 
    11291131                                        $this->posts = array(); 
    11301132                                } else { 
    1131                                         if ('draft' == $status) { 
     1133                                        if  (in_array($status, array('draft', 'pending')) ) { 
    11321134                                                // User must have edit permissions on the draft to preview. 
    11331135                                                if (! current_user_can('edit_post', $this->posts[0]->ID)) { 
    11341136                                                        $this->posts = array(); 
  • wp-includes/post.php

     
    553553 
    554554        // If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now 
    555555        if (empty($post_date)) { 
    556                 if ( 'draft' != $post_status ) 
     556                if ( !in_array($post_status, array('draft', 'pending')) ) 
    557557                        $post_date = current_time('mysql'); 
    558558        } 
    559559 
    560560        if (empty($post_date_gmt)) { 
    561                 if ( 'draft' != $post_status ) 
     561                if ( !in_array($post_status, array('draft', 'pending')) ) 
    562562                        $post_date_gmt = get_gmt_from_date($post_date); 
    563563        } 
    564564 
     
    738738                $post_cats = $post['post_category']; 
    739739 
    740740        // Drafts shouldn't be assigned a date unless explicitly done so by the user 
    741         if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) && 
     741        if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) && empty($postarr['post_date']) && 
    742742                         ('0000-00-00 00:00:00' == $post['post_date']) ) 
    743743                $clear_date = true; 
    744744        else 
  • wp-includes/version.php

     
    33// This holds the version number in a separate file so we can bump it without cluttering the SVN 
    44 
    55$wp_version = '2.3-alpha'; 
    6 $wp_db_version = 5539; 
     6$wp_db_version = 5540; 
    77 
    88?> 
  • wp-admin/post-new.php

     
    2424<div id="message" class="updated fade"><p><strong><?php _e('Post saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post &raquo;'); ?></a></p></div> 
    2525<?php 
    2626endif; 
     27?> 
    2728 
    28 if ( $drafts = get_users_drafts( $user_ID ) ) { ?> 
    29 <div class="wrap"> 
    30 <p><strong><?php _e('Your Drafts:') ?></strong> 
     29 
    3130<?php 
    32 // Show drafts. 
    33         $num_drafts = count($drafts); 
    34         if ( $num_drafts > 15 ) $num_drafts = 15; 
    35         for ( $i = 0; $i < $num_drafts; $i++ ) { 
    36                 $draft = $drafts[$i]; 
    37                 if ( 0 != $i ) 
    38                         echo ', '; 
    39                 if ( empty($draft->post_title) ) 
    40                         $draft->post_title = sprintf(__('Post # %s'), $draft->ID); 
    41                 echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>"; 
     31$my_drafts = get_users_drafts($user_ID); 
     32$pending = get_others_pending($user_ID); 
     33$others_drafts = get_others_drafts($user_ID); 
     34 
     35if ( !empty($my_drafts) || !empty($pending) || !empty($others_drafts) ) { 
     36        echo '<div class="wrap" id="draft-nag">'; 
     37 
     38        if ( $my_drafts ) { 
     39                echo '<p><strong>' . __( 'Your Drafts:' ) . '</strong> '; 
     40                if ( count($my_drafts) < 3 ) { 
     41                        $i = 0; 
     42                        foreach ( $my_drafts as $post ) { 
     43                                if ( $i++ != 0 ) 
     44                                        echo ', '; 
     45                                echo '<a href="post.php?action=edit&amp;post=' . $post->ID . '">'; 
     46                                the_title(); 
     47                                echo '</a>'; 
     48                        } 
     49                        echo '.</p>'; 
     50                } else { 
     51                        printf( 
     52                                __( 'You have <a href="%s">%d drafts</a>.' ) . '</p>',  
     53                                'edit.php?post_status=draft&author=' . $user_ID, count($my_drafts) 
     54                        ); 
     55                } 
    4256        } 
    4357 
    44         if ( 15 < count($drafts) ) { ?> 
    45                 , <a href="edit.php"><?php echo sprintf(__('and %s more &raquo;'), (count($drafts) - 15) ); ?></a> 
    46         <?php } ?> 
    47 .</p> 
    48 </div> 
    49 <?php 
     58        if ( $pending ) { 
     59                echo '<p><strong>' . __( 'Pending Review:' ) . '</strong> '; 
     60                if ( count($pending) < 3 ) { 
     61                        $i = 0; 
     62                        foreach ( $pending as $post ) { 
     63                                if ( $i++ != 0 ) 
     64                                        echo ', '; 
     65                                echo '<a href="post.php?action=edit&amp;post=' . $post->ID . '">'; 
     66                                the_title(); 
     67                                echo '</a>'; 
     68                        } 
     69                        echo '.</p>'; 
     70                } else { 
     71                        printf( 
     72                                __( 'There are <a href="%s">%d drafts pending review</a>.' ) . '</p>',  
     73                                'edit.php?post_status=pending', count($pending) 
     74                        ); 
     75                } 
     76        } 
     77 
     78        if ( $others_drafts ) { 
     79                echo '<p><strong>' . __( 'Others&#8217; Drafts:' ) . '</strong> '; 
     80                if ( count($others_drafts) < 3 ) { 
     81                        $i = 0; 
     82                        foreach ( $others_drafts as $post ) { 
     83                                if ( $i++ != 0 ) 
     84                                        echo ', '; 
     85                                echo '<a href="post.php?action=edit&amp;post=' . $post->ID . '">'; 
     86                                the_title(); 
     87                                echo '</a>'; 
     88                        } 
     89                        echo '.</p>'; 
     90                } else { 
     91                        printf( 
     92                                __( 'There are <a href="%s">%d in-progress drafts by other authors</a>.' ) . '</p>',  
     93                                'edit.php?post_status=pending&author=-' . $user_ID, count($others_drafts) 
     94                        ); 
     95                } 
     96        } 
     97 
     98        echo "</div>\n"; 
    5099} 
     100?> 
    51101 
     102 
     103<?php 
    52104// Show post form. 
    53105$post = get_default_post_to_edit(); 
    54106include('edit-form-advanced.php'); 
  • wp-admin/includes/schema.php

     
    106106  post_title text NOT NULL, 
    107107  post_category int(4) NOT NULL default '0', 
    108108  post_excerpt text NOT NULL, 
    109   post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish', 
     109  post_status enum('publish','draft','private','static','object','attachment','inherit','future', 'pending') NOT NULL default 'publish', 
    110110  comment_status enum('open','closed','registered_only') NOT NULL default 'open', 
    111111  ping_status enum('open','closed') NOT NULL default 'open', 
    112112  post_password varchar(20) NOT NULL default '', 
  • wp-admin/includes/template.php

     
    420420        global $wp_locale, $post, $comment; 
    421421 
    422422        if ( $for_post ) 
    423                 $edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true; 
     423                $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true; 
    424424  
    425425        echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>'; 
    426426 
     
    592592                echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />'; 
    593593} 
    594594 
    595 ?> 
     595?> 
     596 No newline at end of file 
  • wp-admin/includes/user.php

     
    181181        return $wpdb->get_col( $query ); 
    182182} 
    183183 
    184 function get_others_drafts( $user_id ) { 
     184function get_others_unpublished_posts($user_id, $type='any') { 
    185185        global $wpdb; 
    186186        $user = get_userdata( $user_id ); 
    187187        $level_key = $wpdb->prefix . 'user_level'; 
    188188 
    189189        $editable = get_editable_user_ids( $user_id ); 
    190190 
     191        if ( in_array($type, array('draft', 'pending')) ) 
     192                $type_sql = " post_status = '$type' "; 
     193        else 
     194                $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; 
     195 
    191196        if( !$editable ) { 
    192                 $other_drafts = ''; 
     197                $other_unpubs = ''; 
    193198        } else { 
    194199                $editable = join(',', $editable); 
    195                 $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' "); 
     200                $other_unpubs = $wpdb->get_results("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != '$user_id' "); 
    196201        } 
    197202 
    198         return apply_filters('get_others_drafts', $other_drafts); 
     203        return apply_filters('get_others_drafts', $other_unpubs); 
    199204} 
    200205 
     206function get_others_drafts($user_id) { 
     207        return get_others_unpublished_posts($user_id, 'draft'); 
     208} 
     209 
     210function get_others_pending($user_id) { 
     211        return get_others_unpublished_posts($user_id, 'pending'); 
     212} 
     213 
    201214function get_user_to_edit( $user_id ) { 
    202215        $user = new WP_User( $user_id ); 
    203216        $user->user_login   = attribute_escape($user->user_login); 
  • wp-admin/includes/post.php

     
    6464 
    6565        if ( 'page' == $_POST['post_type'] ) { 
    6666                if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' )) 
    67                         $_POST['post_status'] = 'draft'; 
     67                        $_POST['post_status'] = 'pending'; 
    6868        } else { 
    6969                if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' )) 
    70                         $_POST['post_status'] = 'draft'; 
     70                        $_POST['post_status'] = 'pending'; 
    7171        } 
    7272 
    7373        if (!isset( $_POST['comment_status'] )) 
     
    268268 
    269269        if ( 'page' == $_POST['post_type'] ) { 
    270270                if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) ) 
    271                         $_POST['post_status'] = 'draft'; 
     271                        $_POST['post_status'] = 'pending'; 
    272272        } else { 
    273273                if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) ) 
    274                         $_POST['post_status'] = 'draft'; 
     274                        $_POST['post_status'] = 'pending'; 
    275275        } 
    276276 
    277277        if (!isset( $_POST['comment_status'] )) 
  • wp-admin/edit-post-rows.php

     
    1010        </thead> 
    1111        <tbody id="the-list"> 
    1212<?php 
    13 if ($posts) { 
     13if ( have_posts() ) { 
    1414$bgcolor = ''; 
    1515while (have_posts()) : the_post(); 
    1616add_filter('the_title','wp_specialchars'); 
     
    9797    <td colspan="8"><?php _e('No posts found.') ?></td>  
    9898  </tr>  
    9999<?php 
    100 } // end if ($posts) 
     100} // end if ( have_posts() ) 
    101101?> 
    102102        </tbody> 
    103103</table> 
  • wp-admin/edit-form-advanced.php

     
    101101 
    102102<fieldset id="poststatusdiv" class="dbx-box"> 
    103103<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>  
    104 <div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?> 
    105 <label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label> 
     104<div class="dbx-content"> 
     105<?php if ( current_user_can('publish_posts') ) : ?> 
     106        <label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label> 
    106107<?php endif; ?> 
     108        <label for="post_status_pending" class="selectit"><input id="post_status_pending" name="post_status" type="radio" value="pending" <?php checked($post->post_status, 'pending'); ?> /> <?php _e('Pending Review') ?></label> 
    107109          <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label> 
    108110          <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div> 
    109111</fieldset> 
     
    167169?> 
    168170<?php if ( current_user_can('publish_posts') ) : ?> 
    169171        <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />  
     172<?php else : ?> 
     173        <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />  
    170174<?php endif; ?> 
    171175<?php 
    172176} 
  • wp-admin/edit.php

     
    1111$post_stati  = array(   //      array( adj, noun ) 
    1212                        'draft' => array(__('Draft'), _c('Drafts|manage posts header')), 
    1313                        'future' => array(__('Scheduled'), __('Scheduled posts')), 
     14                        'pending' => array(__('Pending Review'), __('Pending posts')), 
    1415                        'private' => array(__('Private'), __('Private posts')), 
    1516                        'publish' => array(__('Published'), __('Published posts')) 
    1617                ); 
    1718 
     19$avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'"); 
     20 
    1821$post_status_q = ''; 
    1922$post_status_label = _c('Posts|manage posts header'); 
    2023if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { 
     
    3033wp("what_to_show=posts$post_status_q&posts_per_page=15"); 
    3134 
    3235// define the columns to display, the syntax is 'internal name' => 'display name' 
    33 $posts_columns = array( 
    34         'id'         => '<div style="text-align: center">' . __('ID') . '</div>', 
    35         'date'       => __('When'), 
    36         'title'      => __('Title'), 
    37         'categories' => __('Categories'), 
    38         'comments'   => '<div style="text-align: center">' . __('Comments') . '</div>', 
    39         'author'     => __('Author') 
    40 ); 
     36$posts_columns = array(); 
     37$posts_columns['id'] = '<div style="text-align: center">' . __('ID') . '</div>'; 
     38if ( !in_array($_GET['post_status'], array('pending', 'draft')) ) 
     39        $posts_columns['date'] = __('When'); 
     40$posts_columns['title'] = __('Title'); 
     41$posts_columns['categories'] = __('Categories'); 
     42if ( 'publish' == $_GET['post_status'] ) 
     43        $posts_columns['comments'] = '<div style="text-align: center">' . __('Comments') . '</div>'; 
     44$posts_columns['author'] = __('Author'); 
     45 
    4146$posts_columns = apply_filters('manage_posts_columns', $posts_columns); 
    4247 
    4348// you can not edit these at the moment 
     
    5762                $h2_noun = $post_status_label; 
    5863        // Use $_GET instead of is_ since they can override each other 
    5964        $h2_author = ''; 
    60         if ( isset($_GET['author']) && $_GET['author'] ) { 
    61                 $author_user = get_userdata( get_query_var( 'author' ) ); 
    62                 $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); 
     65        $_GET['author'] = (int) $_GET['author']; 
     66        if ( $_GET['author'] != 0 ) { 
     67                if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion 
     68                        $h2_author = ' ' . __('by other authors'); 
     69                } else { 
     70                        $author_user = get_userdata( get_query_var( 'author' ) ); 
     71                        $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));  
     72                } 
    6373        } 
    6474        $h2_search = isset($_GET['s'])   && $_GET['s']   ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( get_search_query() ) ) : ''; 
    6575        $h2_cat    = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in &#8220;%s&#8221;'), single_cat_title('', false) ) : ''; 
     
    7383                <input type="text" name="s" id="s" value="<?php the_search_query(); ?>" size="17" />  
    7484        </fieldset> 
    7585 
    76         <fieldset><legend><?php _e('Post Type&hellip;'); ?></legend>  
     86        <fieldset><legend><?php _e('Status&hellip;'); ?></legend>  
    7787                <select name='post_status'> 
    7888                        <option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option> 
    79 <?php   foreach ( $post_stati as $status => $label ) : ?> 
     89<?php   foreach ( $post_stati as $status => $label ) : if ( !in_array($status, $avail_post_stati) ) continue; ?> 
    8090                        <option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option> 
    8191<?php   endforeach; ?> 
    8292                </select>