mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-30 16:17:56 +02:00
Preview future dated posts. Props davidhouse. fixes #1795
git-svn-id: http://svn.automattic.com/wordpress/trunk@3001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
56289508f3
commit
e19c9ab70c
@ -13,6 +13,7 @@ class WP_Query {
|
|||||||
var $post;
|
var $post;
|
||||||
|
|
||||||
var $is_single = false;
|
var $is_single = false;
|
||||||
|
var $is_preview = false;
|
||||||
var $is_page = false;
|
var $is_page = false;
|
||||||
var $is_archive = false;
|
var $is_archive = false;
|
||||||
var $is_date = false;
|
var $is_date = false;
|
||||||
@ -535,7 +536,9 @@ class WP_Query {
|
|||||||
|
|
||||||
$now = gmdate('Y-m-d H:i:59');
|
$now = gmdate('Y-m-d H:i:59');
|
||||||
|
|
||||||
if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
|
//only select past-dated posts, except if a logged in user is viewing a single: then, if they
|
||||||
|
//can edit the post, we let them through
|
||||||
|
if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {
|
||||||
$where .= " AND post_date_gmt <= '$now'";
|
$where .= " AND post_date_gmt <= '$now'";
|
||||||
$distinct = 'DISTINCT';
|
$distinct = 'DISTINCT';
|
||||||
}
|
}
|
||||||
@ -609,13 +612,23 @@ class WP_Query {
|
|||||||
} else {
|
} else {
|
||||||
if ('draft' == $status) {
|
if ('draft' == $status) {
|
||||||
// User must have edit permissions on the draft to preview.
|
// User must have edit permissions on the draft to preview.
|
||||||
if (! user_can_edit_post($user_ID, $this->posts[0]->ID))
|
if (! user_can_edit_post($user_ID, $this->posts[0]->ID)) {
|
||||||
$this->posts = array();
|
$this->posts = array();
|
||||||
|
} else {
|
||||||
|
$this->is_preview = true;
|
||||||
|
}
|
||||||
} elseif ('private' == $status) {
|
} elseif ('private' == $status) {
|
||||||
if ($this->posts[0]->post_author != $user_ID)
|
if ($this->posts[0]->post_author != $user_ID)
|
||||||
$this->posts = array();
|
$this->posts = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (mysql2date('U', $this->posts[0]->post_date) > mysql2date('U', $now)) { //it's future dated
|
||||||
|
$this->is_preview = true;
|
||||||
|
if (!current_user_can('edit_post', $this->posts[0]->ID)) {
|
||||||
|
$this->posts = array ( );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1404,6 +1404,12 @@ function is_subpost () {
|
|||||||
return $wp_query->is_subpost;
|
return $wp_query->is_subpost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_preview() {
|
||||||
|
global $wp_query;
|
||||||
|
|
||||||
|
return $wp_query->is_preview;
|
||||||
|
}
|
||||||
|
|
||||||
function is_archive () {
|
function is_archive () {
|
||||||
global $wp_query;
|
global $wp_query;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user