mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Introducing post_status="pending". see #4446 and put any initial bug reports on that ticket
git-svn-id: http://svn.automattic.com/wordpress/trunk@5707 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e211aa64e7
commit
7f44512c5d
@ -101,9 +101,11 @@ addLoadEvent(focusit);
|
||||
|
||||
<fieldset id="poststatusdiv" class="dbx-box">
|
||||
<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>
|
||||
<div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
|
||||
<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>
|
||||
<div class="dbx-content">
|
||||
<?php if ( current_user_can('publish_posts') ) : ?>
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</fieldset>
|
||||
@ -167,6 +169,8 @@ if ('publish' != $post->post_status || 0 == $post_ID) {
|
||||
?>
|
||||
<?php if ( current_user_can('publish_posts') ) : ?>
|
||||
<input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
|
||||
<?php else : ?>
|
||||
<input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
</thead>
|
||||
<tbody id="the-list">
|
||||
<?php
|
||||
if ($posts) {
|
||||
if ( have_posts() ) {
|
||||
$bgcolor = '';
|
||||
while (have_posts()) : the_post();
|
||||
add_filter('the_title','wp_specialchars');
|
||||
@ -97,7 +97,7 @@ endwhile;
|
||||
<td colspan="8"><?php _e('No posts found.') ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
} // end if ($posts)
|
||||
} // end if ( have_posts() )
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -11,10 +11,13 @@ $_GET['cat'] = (int) $_GET['cat'];
|
||||
$post_stati = array( // array( adj, noun )
|
||||
'draft' => array(__('Draft'), _c('Drafts|manage posts header')),
|
||||
'future' => array(__('Scheduled'), __('Scheduled posts')),
|
||||
'pending' => array(__('Pending Review'), __('Pending posts')),
|
||||
'private' => array(__('Private'), __('Private posts')),
|
||||
'publish' => array(__('Published'), __('Published posts'))
|
||||
);
|
||||
|
||||
$avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'");
|
||||
|
||||
$post_status_q = '';
|
||||
$post_status_label = _c('Posts|manage posts header');
|
||||
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
|
||||
@ -30,14 +33,16 @@ if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($
|
||||
wp("what_to_show=posts$post_status_q&posts_per_page=15");
|
||||
|
||||
// define the columns to display, the syntax is 'internal name' => 'display name'
|
||||
$posts_columns = array(
|
||||
'id' => '<div style="text-align: center">' . __('ID') . '</div>',
|
||||
'date' => __('When'),
|
||||
'title' => __('Title'),
|
||||
'categories' => __('Categories'),
|
||||
'comments' => '<div style="text-align: center">' . __('Comments') . '</div>',
|
||||
'author' => __('Author')
|
||||
);
|
||||
$posts_columns = array();
|
||||
$posts_columns['id'] = '<div style="text-align: center">' . __('ID') . '</div>';
|
||||
if ( !in_array($_GET['post_status'], array('pending', 'draft')) )
|
||||
$posts_columns['date'] = __('When');
|
||||
$posts_columns['title'] = __('Title');
|
||||
$posts_columns['categories'] = __('Categories');
|
||||
if ( 'publish' == $_GET['post_status'] )
|
||||
$posts_columns['comments'] = '<div style="text-align: center">' . __('Comments') . '</div>';
|
||||
$posts_columns['author'] = __('Author');
|
||||
|
||||
$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
|
||||
|
||||
// you can not edit these at the moment
|
||||
@ -57,9 +62,14 @@ if ( is_single() ) {
|
||||
$h2_noun = $post_status_label;
|
||||
// Use $_GET instead of is_ since they can override each other
|
||||
$h2_author = '';
|
||||
if ( isset($_GET['author']) && $_GET['author'] ) {
|
||||
$author_user = get_userdata( get_query_var( 'author' ) );
|
||||
$h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
|
||||
$_GET['author'] = (int) $_GET['author'];
|
||||
if ( $_GET['author'] != 0 ) {
|
||||
if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion
|
||||
$h2_author = ' ' . __('by other authors');
|
||||
} else {
|
||||
$author_user = get_userdata( get_query_var( 'author' ) );
|
||||
$h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
|
||||
}
|
||||
}
|
||||
$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( get_search_query() ) ) : '';
|
||||
$h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : '';
|
||||
@ -73,10 +83,10 @@ if ( is_single() ) {
|
||||
<input type="text" name="s" id="s" value="<?php the_search_query(); ?>" size="17" />
|
||||
</fieldset>
|
||||
|
||||
<fieldset><legend><?php _e('Post Type…'); ?></legend>
|
||||
<fieldset><legend><?php _e('Status…'); ?></legend>
|
||||
<select name='post_status'>
|
||||
<option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option>
|
||||
<?php foreach ( $post_stati as $status => $label ) : ?>
|
||||
<?php foreach ( $post_stati as $status => $label ) : if ( !in_array($status, $avail_post_stati) ) continue; ?>
|
||||
<option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
@ -64,10 +64,10 @@ function edit_post() {
|
||||
|
||||
if ( 'page' == $_POST['post_type'] ) {
|
||||
if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' ))
|
||||
$_POST['post_status'] = 'draft';
|
||||
$_POST['post_status'] = 'pending';
|
||||
} else {
|
||||
if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' ))
|
||||
$_POST['post_status'] = 'draft';
|
||||
$_POST['post_status'] = 'pending';
|
||||
}
|
||||
|
||||
if (!isset( $_POST['comment_status'] ))
|
||||
@ -268,10 +268,10 @@ function wp_write_post() {
|
||||
|
||||
if ( 'page' == $_POST['post_type'] ) {
|
||||
if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) )
|
||||
$_POST['post_status'] = 'draft';
|
||||
$_POST['post_status'] = 'pending';
|
||||
} else {
|
||||
if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) )
|
||||
$_POST['post_status'] = 'draft';
|
||||
$_POST['post_status'] = 'pending';
|
||||
}
|
||||
|
||||
if (!isset( $_POST['comment_status'] ))
|
||||
|
@ -106,7 +106,7 @@ CREATE TABLE $wpdb->posts (
|
||||
post_title text NOT NULL,
|
||||
post_category int(4) NOT NULL default '0',
|
||||
post_excerpt text NOT NULL,
|
||||
post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish',
|
||||
post_status enum('publish','draft','private','static','object','attachment','inherit','future', 'pending') NOT NULL default 'publish',
|
||||
comment_status enum('open','closed','registered_only') NOT NULL default 'open',
|
||||
ping_status enum('open','closed') NOT NULL default 'open',
|
||||
post_password varchar(20) NOT NULL default '',
|
||||
|
@ -420,7 +420,7 @@ function touch_time( $edit = 1, $for_post = 1 ) {
|
||||
global $wp_locale, $post, $comment;
|
||||
|
||||
if ( $for_post )
|
||||
$edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
|
||||
$edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
|
||||
|
||||
echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>';
|
||||
|
||||
@ -592,4 +592,4 @@ function wp_remember_old_slug() {
|
||||
echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@ -181,21 +181,34 @@ function get_nonauthor_user_ids() {
|
||||
return $wpdb->get_col( $query );
|
||||
}
|
||||
|
||||
function get_others_drafts( $user_id ) {
|
||||
function get_others_unpublished_posts($user_id, $type='any') {
|
||||
global $wpdb;
|
||||
$user = get_userdata( $user_id );
|
||||
$level_key = $wpdb->prefix . 'user_level';
|
||||
|
||||
$editable = get_editable_user_ids( $user_id );
|
||||
|
||||
if ( in_array($type, array('draft', 'pending')) )
|
||||
$type_sql = " post_status = '$type' ";
|
||||
else
|
||||
$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
|
||||
|
||||
if( !$editable ) {
|
||||
$other_drafts = '';
|
||||
$other_unpubs = '';
|
||||
} else {
|
||||
$editable = join(',', $editable);
|
||||
$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' ");
|
||||
$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' ");
|
||||
}
|
||||
|
||||
return apply_filters('get_others_drafts', $other_drafts);
|
||||
return apply_filters('get_others_drafts', $other_unpubs);
|
||||
}
|
||||
|
||||
function get_others_drafts($user_id) {
|
||||
return get_others_unpublished_posts($user_id, 'draft');
|
||||
}
|
||||
|
||||
function get_others_pending($user_id) {
|
||||
return get_others_unpublished_posts($user_id, 'pending');
|
||||
}
|
||||
|
||||
function get_user_to_edit( $user_id ) {
|
||||
|
@ -24,31 +24,83 @@ if ( isset($_GET['posted']) && $_GET['posted'] ) : ?>
|
||||
<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 »'); ?></a></p></div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
|
||||
if ( $drafts = get_users_drafts( $user_ID ) ) { ?>
|
||||
<div class="wrap">
|
||||
<p><strong><?php _e('Your Drafts:') ?></strong>
|
||||
<?php
|
||||
// Show drafts.
|
||||
$num_drafts = count($drafts);
|
||||
if ( $num_drafts > 15 ) $num_drafts = 15;
|
||||
for ( $i = 0; $i < $num_drafts; $i++ ) {
|
||||
$draft = $drafts[$i];
|
||||
if ( 0 != $i )
|
||||
echo ', ';
|
||||
if ( empty($draft->post_title) )
|
||||
$draft->post_title = sprintf(__('Post # %s'), $draft->ID);
|
||||
echo "<a href='post.php?action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
|
||||
$my_drafts = get_users_drafts($user_ID);
|
||||
$pending = get_others_pending($user_ID);
|
||||
$others_drafts = get_others_drafts($user_ID);
|
||||
|
||||
if ( !empty($my_drafts) || !empty($pending) || !empty($others_drafts) ) {
|
||||
echo '<div class="wrap" id="draft-nag">';
|
||||
|
||||
if ( $my_drafts ) {
|
||||
echo '<p><strong>' . __( 'Your Drafts:' ) . '</strong> ';
|
||||
if ( count($my_drafts) < 3 ) {
|
||||
$i = 0;
|
||||
foreach ( $my_drafts as $post ) {
|
||||
if ( $i++ != 0 )
|
||||
echo ', ';
|
||||
echo '<a href="post.php?action=edit&post=' . $post->ID . '">';
|
||||
the_title();
|
||||
echo '</a>';
|
||||
}
|
||||
echo '.</p>';
|
||||
} else {
|
||||
printf(
|
||||
__( 'You have <a href="%s">%d drafts</a>.' ) . '</p>',
|
||||
'edit.php?post_status=draft&author=' . $user_ID, count($my_drafts)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( 15 < count($drafts) ) { ?>
|
||||
, <a href="edit.php"><?php echo sprintf(__('and %s more »'), (count($drafts) - 15) ); ?></a>
|
||||
<?php } ?>
|
||||
.</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
if ( $pending ) {
|
||||
echo '<p><strong>' . __( 'Pending Review:' ) . '</strong> ';
|
||||
if ( count($pending) < 3 ) {
|
||||
$i = 0;
|
||||
foreach ( $pending as $post ) {
|
||||
if ( $i++ != 0 )
|
||||
echo ', ';
|
||||
echo '<a href="post.php?action=edit&post=' . $post->ID . '">';
|
||||
the_title();
|
||||
echo '</a>';
|
||||
}
|
||||
echo '.</p>';
|
||||
} else {
|
||||
printf(
|
||||
__( 'There are <a href="%s">%d drafts pending review</a>.' ) . '</p>',
|
||||
'edit.php?post_status=pending', count($pending)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( $others_drafts ) {
|
||||
echo '<p><strong>' . __( 'Others’ Drafts:' ) . '</strong> ';
|
||||
if ( count($others_drafts) < 3 ) {
|
||||
$i = 0;
|
||||
foreach ( $others_drafts as $post ) {
|
||||
if ( $i++ != 0 )
|
||||
echo ', ';
|
||||
echo '<a href="post.php?action=edit&post=' . $post->ID . '">';
|
||||
the_title();
|
||||
echo '</a>';
|
||||
}
|
||||
echo '.</p>';
|
||||
} else {
|
||||
printf(
|
||||
__( 'There are <a href="%s">%d in-progress drafts by other authors</a>.' ) . '</p>',
|
||||
'edit.php?post_status=pending&author=-' . $user_ID, count($others_drafts)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
echo "</div>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
// Show post form.
|
||||
$post = get_default_post_to_edit();
|
||||
include('edit-form-advanced.php');
|
||||
|
@ -19,7 +19,7 @@ if ( empty($status->comment_status) ) {
|
||||
} elseif ( 'closed' == $status->comment_status ) {
|
||||
do_action('comment_closed', $comment_post_ID);
|
||||
wp_die( __('Sorry, comments are closed for this item.') );
|
||||
} elseif ( 'draft' == $status->post_status ) {
|
||||
} elseif ( in_array($status->post_status, array('draft', 'pending') ) ) {
|
||||
do_action('comment_on_draft', $comment_post_ID);
|
||||
exit;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ function wp_link_pages($args = '') {
|
||||
if ( 1 == $i ) {
|
||||
$output .= '<a href="' . get_permalink() . '">';
|
||||
} else {
|
||||
if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status )
|
||||
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
|
||||
$output .= '<a href="' . get_permalink() . '&page=' . $i . '">';
|
||||
else
|
||||
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';
|
||||
@ -181,7 +181,7 @@ function wp_link_pages($args = '') {
|
||||
if ( 1 == $i ) {
|
||||
$output .= '<a href="' . get_permalink() . '">' . $previouspagelink . '</a>';
|
||||
} else {
|
||||
if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status )
|
||||
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
|
||||
$output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $previouspagelink . '</a>';
|
||||
else
|
||||
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $previouspagelink . '</a>';
|
||||
@ -192,7 +192,7 @@ function wp_link_pages($args = '') {
|
||||
if ( 1 == $i ) {
|
||||
$output .= '<a href="' . get_permalink() . '">' . $nextpagelink . '</a>';
|
||||
} else {
|
||||
if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status )
|
||||
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
|
||||
$output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $nextpagelink . '</a>';
|
||||
else
|
||||
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $nextpagelink . '</a>';
|
||||
|
@ -553,12 +553,12 @@ function wp_insert_post($postarr = array()) {
|
||||
|
||||
// If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now
|
||||
if (empty($post_date)) {
|
||||
if ( 'draft' != $post_status )
|
||||
if ( !in_array($post_status, array('draft', 'pending')) )
|
||||
$post_date = current_time('mysql');
|
||||
}
|
||||
|
||||
if (empty($post_date_gmt)) {
|
||||
if ( 'draft' != $post_status )
|
||||
if ( !in_array($post_status, array('draft', 'pending')) )
|
||||
$post_date_gmt = get_gmt_from_date($post_date);
|
||||
}
|
||||
|
||||
@ -738,7 +738,7 @@ function wp_update_post($postarr = array()) {
|
||||
$post_cats = $post['post_category'];
|
||||
|
||||
// Drafts shouldn't be assigned a date unless explicitly done so by the user
|
||||
if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
|
||||
if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
|
||||
('0000-00-00 00:00:00' == $post['post_date']) )
|
||||
$clear_date = true;
|
||||
else
|
||||
|
@ -1006,6 +1006,8 @@ class WP_Query {
|
||||
$r_status = array();
|
||||
if ( in_array( 'draft' , $q_status ) )
|
||||
$r_status[] = "post_status = 'draft'";
|
||||
if ( in_array( 'pending', $q_status ) )
|
||||
$r_status[] = "post_status = 'pending'";
|
||||
if ( in_array( 'future' , $q_status ) )
|
||||
$r_status[] = "post_status = 'future'";
|
||||
if ( in_array( 'inherit' , $q_status ) )
|
||||
@ -1020,7 +1022,7 @@ class WP_Query {
|
||||
$where .= " AND (post_status = 'publish'";
|
||||
|
||||
if ( is_admin() )
|
||||
$where .= " OR post_status = 'future' OR post_status = 'draft'";
|
||||
$where .= " OR post_status = 'future' OR post_status = 'draft' OR post_status = 'pending'";
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
$where .= current_user_can( "read_private_{$post_type}s" ) ? " OR post_status = 'private'" : " OR post_author = $user_ID AND post_status = 'private'";
|
||||
@ -1128,7 +1130,7 @@ class WP_Query {
|
||||
// User must be logged in to view unpublished posts.
|
||||
$this->posts = array();
|
||||
} else {
|
||||
if ('draft' == $status) {
|
||||
if (in_array($status, array('draft', 'pending')) ) {
|
||||
// User must have edit permissions on the draft to preview.
|
||||
if (! current_user_can('edit_post', $this->posts[0]->ID)) {
|
||||
$this->posts = array();
|
||||
|
@ -3,6 +3,6 @@
|
||||
// This holds the version number in a separate file so we can bump it without cluttering the SVN
|
||||
|
||||
$wp_version = '2.3-alpha';
|
||||
$wp_db_version = 5539;
|
||||
$wp_db_version = 5540;
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user