Make WordPress Core


Ignore:
Timestamp:
11/06/2005 07:04:46 AM (19 years ago)
Author:
ryan
Message:

Preview future dated posts. Props davidhouse. fixes #1795

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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                }
Note: See TracChangeset for help on using the changeset viewer.