Better draft, private, and future post/page management from mdawaffe. fixes #3945

git-svn-id: http://svn.automattic.com/wordpress/trunk@5575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-05-28 18:34:06 +00:00
parent a5e4caba87
commit a438f8a92a
8 changed files with 307 additions and 251 deletions

View File

@ -4,24 +4,59 @@ $title = __('Pages');
$parent_file = 'edit.php'; $parent_file = 'edit.php';
wp_enqueue_script( 'listman' ); wp_enqueue_script( 'listman' );
require_once('admin-header.php'); require_once('admin-header.php');
$post_stati = array( // array( adj, noun )
'draft' => array(__('Draft'), __('Draft pages')),
'future' => array(__('Future dated'), __('Future dated pages')),
'private' => array(__('Private'), __('Private pages')),
'publish' => array(__('Published'), __('Published pages'))
);
$post_status_label = _c('Pages|manage pages header');
$post_listing_pageable = true;
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
$post_status_label = $post_stati[$_GET['post_status']][1];
$post_listing_pageable = false;
$post_status_q = '&post_status=' . $_GET['post_status'];
if ( 'publish' == $_GET['post_status'] );
$post_listing_pageable = true;
}
?> ?>
<div class="wrap"> <div class="wrap">
<h2><?php _e('Page Management'); ?></h2>
<h2><?php
// Use $_GET instead of is_ since they can override each other
$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : '';
printf( _c( '%1$s%2$s|manage pages header' ), $post_status_label, $h2_search );
?></h2>
<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page &raquo;'); ?></a></p> <p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page &raquo;'); ?></a></p>
<form name="searchform" id="searchform" action="" method="get"> <form name="searchform" id="searchform" action="" method="get">
<fieldset> <fieldset><legend><?php _e('Search Terms&hellip;') ?></legend>
<legend><?php _e('Search Pages&hellip;') ?></legend> <input type="text" name="s" id="s" value="<?php echo attribute_escape( stripslashes( $_GET['s'] ) ); ?>" size="17" />
<input type="text" name="s" id="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />
<input type="submit" name="submit" value="<?php _e('Search') ?>" />
</fieldset> </fieldset>
<fieldset><legend><?php _e('Page Type&hellip;'); ?></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 ) : ?>
<option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option>
<?php endforeach; ?>
</select>
</fieldset>
<input type="submit" id="post-query-submit" value="<?php _e('Go &#187;'); ?>" class="button" />
</form> </form>
<br style="clear:both;" /> <br style="clear:both;" />
<?php <?php
wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1&order=asc'); wp("post_type=page&orderby=menu_order&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc");
if ( $_GET['s'] ) if ( $_GET['s'] )
$all = false; $all = false;
@ -41,9 +76,7 @@ if ($posts) {
</tr> </tr>
</thead> </thead>
<tbody id="the-list"> <tbody id="the-list">
<?php <?php page_rows(0, 0, $posts, $all); ?>
page_rows(0, 0, $posts, $all);
?>
</tbody> </tbody>
</table> </table>
@ -52,7 +85,7 @@ page_rows(0, 0, $posts, $all);
<?php <?php
} else { } else {
?> ?>
<p><?php _e('No pages yet.') ?></p> <p><?php _e('No pages found.') ?></p>
<?php <?php
} // end if ($posts) } // end if ($posts)
?> ?>

103
wp-admin/edit-post-rows.php Normal file
View File

@ -0,0 +1,103 @@
<table class="widefat">
<thead>
<tr>
<?php foreach($posts_columns as $column_display_name) { ?>
<th scope="col"><?php echo $column_display_name; ?></th>
<?php } ?>
</tr>
</thead>
<tbody id="the-list">
<?php
if ($posts) {
$bgcolor = '';
while (have_posts()) : the_post();
add_filter('the_title','wp_specialchars');
$class = ('alternate' == $class) ? '' : 'alternate';
?>
<tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>
<?php
foreach($posts_columns as $column_name=>$column_display_name) {
switch($column_name) {
case 'id':
?>
<th scope="row" style="text-align: center"><?php echo $id ?></th>
<?php
break;
case 'date':
?>
<td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td>
<?php
break;
case 'title':
?>
<td><?php the_title() ?>
<?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
<?php
break;
case 'categories':
?>
<td><?php the_category(','); ?></td>
<?php
break;
case 'comments':
?>
<td style="text-align: center">
<?php comments_number("<a href='edit.php?p=$id&amp;c=1'>" . __('0') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('%') . '</a>') ?>
</td>
<?php
break;
case 'author':
?>
<td><?php the_author() ?></td>
<?php
break;
case 'control_view':
?>
<td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
<?php
break;
case 'control_edit':
?>
<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<?php
break;
case 'control_delete':
?>
<td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . js_escape(sprintf(__("You are about to delete this post '%s'.\n'OK' to delete, 'Cancel' to stop."), get_the_title())) . "' );\">" . __('Delete') . "</a>"; } ?></td>
<?php
break;
default:
?>
<td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
<?php
break;
}
}
?>
</tr>
<?php
endwhile;
} else {
?>
<tr style='background-color: <?php echo $bgcolor; ?>'>
<td colspan="8"><?php _e('No posts found.') ?></td>
</tr>
<?php
} // end if ($posts)
?>
</tbody>
</table>

View File

@ -7,124 +7,37 @@ wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' );
require_once('admin-header.php'); require_once('admin-header.php');
$_GET['m'] = (int) $_GET['m']; $_GET['m'] = (int) $_GET['m'];
$_GET['cat'] = (int) $_GET['cat'];
$post_stati = array( // array( adj, noun )
'draft' => array(__('Draft'), _c('Drafts|manage posts header')),
'future' => array(__('Future dated'), __('Future dated posts')),
'private' => array(__('Private'), __('Private posts')),
'publish' => array(__('Published'), __('Published posts'))
);
$drafts = get_users_drafts( $user_ID ); $post_status_q = '';
$other_drafts = get_others_drafts( $user_ID); $author_q = '';
$post_status_label = _c('Posts|manage posts header');
if ($drafts || $other_drafts) { $post_listing_pageable = true;
?> if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
<div class="wrap"> $post_status_label = $post_stati[$_GET['post_status']][1];
<?php if ($drafts) { ?> $post_listing_pageable = false;
<p><strong><?php _e('Your Drafts:') ?></strong> $post_status_q = '&post_status=' . $_GET['post_status'];
<?php if ( in_array( $_GET['post_status'], array('draft', 'private') ) )
$i = 0; $author_q = "&author=$user_ID";
foreach ($drafts as $draft) { elseif ( 'publish' == $_GET['post_status'] );
if (0 != $i) $post_listing_pageable = true;
echo ', ';
$draft->post_title = apply_filters('the_title', stripslashes($draft->post_title));
if ($draft->post_title == '')
$draft->post_title = sprintf(__('Post #%s'), $draft->ID);
echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
++$i;
} }
?> ?>
.</p>
<?php } ?>
<?php if ($other_drafts) { ?>
<p><strong><?php _e('Other&#8217;s Drafts:') ?></strong>
<?php
$i = 0;
foreach ($other_drafts as $draft) {
if (0 != $i)
echo ', ';
$draft->post_title = apply_filters('the_title', stripslashes($draft->post_title));
if ($draft->post_title == '')
$draft->post_title = sprintf(__('Post #%s'), $draft->ID);
echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
++$i;
}
?>
.</p>
<?php } ?>
</div>
<?php } ?>
<div class="wrap"> <div class="wrap">
<h2>
<?php
wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1');
if ( is_month() ) {
single_month_title(' ');
} elseif ( is_search() ) {
printf(__('Search for &#8220;%s&#8221;'), wp_specialchars($_GET['s']) );
} else {
if ( is_single() )
printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title));
elseif ( ! is_paged() || get_query_var('paged') == 1 )
_e('Last 15 Posts');
else
_e('Previous Posts');
}
?>
</h2>
<form name="searchform" id="searchform" action="" method="get">
<fieldset>
<legend><?php _e('Search Posts&hellip;') ?></legend>
<input type="text" name="s" id="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" />
<input type="submit" name="submit" value="<?php _e('Search') ?>" class="button" />
</fieldset>
</form>
<?php $arc_result = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC");
if ( count($arc_result) ) { ?>
<form name="viewarc" id="viewarc" action="" method="get">
<fieldset>
<legend><?php _e('Browse Month&hellip;') ?></legend>
<select name='m'>
<?php
foreach ($arc_result as $arc_row) {
if ( $arc_row->yyear == 0 )
continue;
$arc_row->mmonth = zeroise($arc_row->mmonth, 2);
if( isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == (int) $_GET['m'] )
$default = 'selected="selected"';
else
$default = null;
echo "<option $default value='$arc_row->yyear$arc_row->mmonth'>";
echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
echo "</option>\n";
}
?>
</select>
<input type="submit" name="submit" value="<?php _e('Show Month') ?>" class="button" />
</fieldset>
</form>
<?php } ?>
<form name="viewcat" id="viewcat" action="" method="get">
<fieldset>
<legend><?php _e('Browse Category&hellip;') ?></legend>
<?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?>
<input type="submit" name="submit" value="<?php _e('Show Category') ?>" class="button" />
</fieldset>
</form>
<?php do_action('restrict_manage_posts'); ?>
<br style="clear:both;" />
<?php <?php
wp("what_to_show=posts$author_q$post_status_q&posts_per_page=15&posts_per_archive_page=-1");
do_action('restrict_manage_posts');
// define the columns to display, the syntax is 'internal name' => 'display name' // define the columns to display, the syntax is 'internal name' => 'display name'
$posts_columns = array( $posts_columns = array(
'id' => '<div style="text-align: center">' . __('ID') . '</div>', 'id' => '<div style="text-align: center">' . __('ID') . '</div>',
@ -143,109 +56,104 @@ $posts_columns['control_delete'] = '';
?> ?>
<table class="widefat"> <h2><?php
<thead> if ( is_single() ) {
<tr> printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title));
} else {
if ( $post_listing_pageable && !is_archive() && !is_search() )
$h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_status_label) : sprintf(__('Latest %s'), $post_status_label);
else
$h2_noun = $post_status_label;
// Use $_GET instead of is_ since they can override each other
$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( get_search_query() ) ) : '';
$h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in &#8220;%s&#8221;'), single_cat_title('', false) ) : '';
$h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : '';
printf( _c( '%1$s%2$s%3$s%4$s|manage posts header' ), $h2_noun, $h2_search, $h2_cat, $h2_month );
}
?></h2>
<form name="searchform" id="searchform" action="" method="get">
<fieldset><legend><?php _e('Search terms&hellip;'); ?></legend>
<input type="text" name="s" id="s" value="<?php the_search_query(); ?>" size="17" />
</fieldset>
<fieldset><legend><?php _e('Post Type&hellip;'); ?></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 ) : ?>
<option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option>
<?php endforeach; ?>
</select>
</fieldset>
<?php
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
$arc_result = $wpdb->get_results( $arc_query );
$month_count = count($arc_result);
if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
<fieldset><legend><?php _e('Month&hellip;') ?></legend>
<select name='m'>
<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Any'); ?></option>
<?php
foreach ($arc_result as $arc_row) {
if ( $arc_row->yyear == 0 )
continue;
$arc_row->mmonth = zeroise($arc_row->mmonth, 2);
if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] )
$default = ' selected="selected"';
else
$default = '';
echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>";
echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
echo "</option>\n";
}
?>
</select>
</fieldset>
<?php foreach($posts_columns as $column_display_name) { ?>
<th scope="col"><?php echo $column_display_name; ?></th>
<?php } ?> <?php } ?>
</tr> <fieldset><legend><?php _e('Category&hellip;') ?></legend>
</thead> <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?>
<tbody id="the-list"> </fieldset>
<?php <input type="submit" id="post-query-submit" value="<?php _e('Go &#187;'); ?>" class="button" />
if ($posts) { </form>
$bgcolor = '';
while (have_posts()) : the_post(); <br style="clear:both;" />
add_filter('the_title','wp_specialchars');
$class = ('alternate' == $class) ? '' : 'alternate';
?>
<tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>
<?php <?php
if ( $post_status_q && ( false !== strpos($post_status_q, 'draft') || false !== strpos($post_status_q, 'private') ) ) {
echo '<h3>' . __('Your Posts') . "</h3>\n";
include( 'edit-post-rows.php' );
foreach($posts_columns as $column_name=>$column_display_name) { $editable_ids = get_editable_user_ids( $user_ID );
switch($column_name) { if ( $editable_ids && count($editable_ids) > 1 ) {
$_editable_ids = join(',', array_diff($editable_ids, array($user_ID)));
case 'id': $post_status_q = "&post_status=" . $_GET['post_status'];
?>
<th scope="row" style="text-align: center"><?php echo $id ?></th>
<?php
break;
case 'date': unset($GLOBALS['day']); // setup_postdata does this
?> wp("what_to_show=posts&author=$_editable_ids$post_status_q&posts_per_page=-1&posts_per_archive_page=-1");
<td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td>
<?php
break;
case 'title':
?>
<td><?php the_title() ?>
<?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
<?php
break;
case 'categories': if ( have_posts() ) {
?> echo '<h3>' . __("Others' Posts") . "</h3>\n";
<td><?php the_category(','); ?></td> include( 'edit-post-rows.php' );
<?php
break;
case 'comments':
?>
<td style="text-align: center">
<?php comments_number("<a href='edit.php?p=$id&amp;c=1'>" . __('0') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('%') . '</a>') ?>
</td>
<?php
break;
case 'author':
?>
<td><?php the_author() ?></td>
<?php
break;
case 'control_view':
?>
<td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
<?php
break;
case 'control_edit':
?>
<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<?php
break;
case 'control_delete':
?>
<td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . js_escape(sprintf(__("You are about to delete this post '%s'.\n'OK' to delete, 'Cancel' to stop."), get_the_title())) . "' );\">" . __('Delete') . "</a>"; } ?></td>
<?php
break;
default:
?>
<td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
<?php
break;
} }
} }
?>
</tr>
<?php
endwhile;
} else { } else {
include( 'edit-post-rows.php' );
}
?> ?>
<tr style='background-color: <?php echo $bgcolor; ?>'>
<td colspan="8"><?php _e('No posts found.') ?></td>
</tr>
<?php
} // end if ($posts)
?>
</tbody>
</table>
<div id="ajax-response"></div> <div id="ajax-response"></div>
@ -255,6 +163,7 @@ endwhile;
</div> </div>
<?php <?php
if ( 1 == count($posts) ) { if ( 1 == count($posts) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date"); $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
@ -301,6 +210,5 @@ if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
?> ?>
<?php } ?> <?php } ?>
</div> </div>
<?php
include('admin-footer.php'); <?php include('admin-footer.php'); ?>
?>

View File

@ -790,22 +790,25 @@ input.delete:hover {
width: 320px; width: 320px;
} }
#searchform { #searchform fieldset {
float: left; float: left;
margin-right: 1em; margin: 0 1.5ex 1em 0;
width: 18em; padding: 0;
} }
#viewarc { #searchform fieldset legend {
float: left; padding: 0 0 .2em 1px;
width: 23em;
margin-bottom: 1em;
} }
#viewcat { #searchform #s {
padding: 4px 3px;
}
#searchform #post-query-submit {
float: left; float: left;
width: 30em; margin: 14px 0 1em;
margin-bottom: 1em; position: relative;
top: .35em;
} }
#postcustom .updatemeta, #postcustom .deletemeta { #postcustom .updatemeta, #postcustom .deletemeta {

View File

@ -445,12 +445,12 @@ function map_meta_cap($cap, $user_id) {
function current_user_can($capability) { function current_user_can($capability) {
$current_user = wp_get_current_user(); $current_user = wp_get_current_user();
$args = array_slice(func_get_args(), 1);
$args = array_merge(array($capability), $args);
if ( empty($current_user) ) if ( empty($current_user) )
return false; return false;
$args = array_slice(func_get_args(), 1);
$args = array_merge(array($capability), $args);
return call_user_func_array(array(&$current_user, 'has_cap'), $args); return call_user_func_array(array(&$current_user, 'has_cap'), $args);
} }

View File

@ -3,7 +3,7 @@
class WP { class WP {
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots'); var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type'); var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status');
var $extra_query_vars = array(); var $extra_query_vars = array();
var $query_vars; var $query_vars;

View File

@ -471,7 +471,7 @@ function get_pagenum_link($pagenum = 1) {
$request = preg_replace('|^'. $home_root . '|', '', $request); $request = preg_replace('|^'. $home_root . '|', '', $request);
$request = preg_replace('|^/+|', '', $request); $request = preg_replace('|^/+|', '', $request);
if ( !$wp_rewrite->using_permalinks() ) { if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
$base = trailingslashit( get_bloginfo( 'home' ) ); $base = trailingslashit( get_bloginfo( 'home' ) );
if ( $pagenum > 1 ) { if ( $pagenum > 1 ) {

View File

@ -995,30 +995,39 @@ class WP_Query {
} }
if ( $this->is_attachment ) { if ( $this->is_attachment ) {
$where .= " AND (post_type = 'attachment')"; $where .= " AND post_type = 'attachment'";
} elseif ($this->is_page) { } elseif ($this->is_page) {
$where .= " AND (post_type = 'page')"; $where .= " AND post_type = 'page'";
} elseif ($this->is_single) { } elseif ($this->is_single) {
$where .= " AND (post_type = 'post')"; $where .= " AND post_type = 'post'";
} else { } else {
$where .= " AND (post_type = '$post_type' AND (post_status = 'publish'"; $where .= " AND post_type = '$post_type'";
}
if ( isset($q['post_status']) && '' != $q['post_status'] ) {
$q_status = explode(',', $q['post_status']);
$r_status = array();
if ( in_array( 'draft' , $q_status ) )
$r_status[] = "post_status = 'draft'";
if ( in_array( 'future' , $q_status ) )
$r_status[] = "post_status = 'future'";
if ( in_array( 'inherit' , $q_status ) )
$r_status[] = "post_status = 'inherit'";
if ( in_array( 'private', $q_status ) )
$r_status[] = "post_status = 'private'";
if ( in_array( 'publish', $q_status ) )
$r_status[] = "post_status = 'publish'";
if ( !empty($r_status) )
$where .= " AND (" . join( ' OR ', $r_status ) . ")";
} elseif ( !$this->is_singular ) {
$where .= " AND (post_status = 'publish'";
if ( is_admin() ) if ( is_admin() )
$where .= " OR post_status = 'future' OR post_status = 'draft'"; $where .= " OR post_status = 'future' OR post_status = 'draft'";
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'";
if ( 'post' == $post_type )
$cap = 'read_private_posts';
else
$cap = 'read_private_pages';
if ( current_user_can($cap) ) $where .= ')';
$where .= " OR post_status = 'private'";
else
$where .= " OR post_author = $user_ID AND post_status = 'private'";
}
$where .= '))';
} }
// Apply filters on where and join prior to paging so that any // Apply filters on where and join prior to paging so that any