Changeset 3001

Show
Ignore:
Timestamp:
11/06/05 07:04:46 (3 years ago)
Author:
ryan
Message:

Preview future dated posts. Props davidhouse. fixes #1795

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/classes.php

    r2968 r3001  
    1414 
    1515    var $is_single = false; 
     16    var $is_preview = false; 
    1617    var $is_page = false; 
    1718    var $is_archive = false; 
     
    535536 
    536537        $now = gmdate('Y-m-d H:i:59'); 
    537  
    538         if ($pagenow != 'post.php' && $pagenow != 'edit.php') { 
     538         
     539        //only select past-dated posts, except if a logged in user is viewing a single: then, if they 
     540        //can edit the post, we let them through 
     541        if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) { 
    539542            $where .= " AND post_date_gmt <= '$now'"; 
    540543            $distinct = 'DISTINCT'; 
     
    610613                    if ('draft' == $status) { 
    611614                        // User must have edit permissions on the draft to preview. 
    612                         if (! user_can_edit_post($user_ID, $this->posts[0]->ID)) 
     615                        if (! user_can_edit_post($user_ID, $this->posts[0]->ID)) { 
    613616                            $this->posts = array(); 
     617                        } else { 
     618                            $this->is_preview = true; 
     619                        } 
    614620                    } elseif ('private' == $status) { 
    615621                        if ($this->posts[0]->post_author != $user_ID) 
    616622                            $this->posts = array(); 
     623                    } 
     624                } 
     625            } else { 
     626                if (mysql2date('U', $this->posts[0]->post_date) > mysql2date('U', $now)) { //it's future dated 
     627                    $this->is_preview = true; 
     628                    if (!current_user_can('edit_post', $this->posts[0]->ID)) { 
     629                        $this->posts = array ( ); 
    617630                    } 
    618631                } 
  • trunk/wp-includes/functions.php

    r2977 r3001  
    14051405} 
    14061406 
     1407function is_preview() { 
     1408    global $wp_query; 
     1409     
     1410    return $wp_query->is_preview; 
     1411} 
     1412 
    14071413function is_archive () { 
    14081414    global $wp_query;