Make WordPress Core

Changeset 3510


Ignore:
Timestamp:
02/09/2006 10:03:48 AM (19 years ago)
Author:
ryan
Message:

Allow draft pages. Use post_type for object types. Reserve post_status strictly for status. fixes #1820

Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r3501 r3510  
    3535    if ('' != $_POST['advanced'])
    3636        $_POST['post_status'] = 'draft';
    37     if ('' != $_POST['savepage'])
    38         $_POST['post_status'] = 'static';
     37    //if ('' != $_POST['savepage']) {
     38    //  $_POST['post_status'] = 'draft';
    3939
    4040    if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
    4141        $_POST['post_status'] = 'draft';
    4242
    43     if ('static' == $_POST['post_status'] && !current_user_can('edit_pages'))
     43    if ('page' == $_POST['post_type'] && !current_user_can('edit_pages'))
    4444        die(__('This user cannot edit pages.'));
    4545
     
    155155    if ('' != $_POST['advanced'])
    156156        $_POST['post_status'] = 'draft';
    157     if ('' != $_POST['savepage'])
    158         $_POST['post_status'] = 'static';
     157    //if ('' != $_POST['savepage'])
     158    //  $_POST['post_status'] = 'static';
    159159
    160160    if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
     
    255255    $post->post_title = apply_filters('title_edit_pre', $post->post_title);
    256256
    257     if ($post->post_status == 'static')
     257    if ($post->post_type == 'page')
    258258        $post->page_template = get_post_meta($id, '_wp_page_template', true);
    259259
     
    614614    global $wpdb, $class, $post;
    615615    if (!$pages)
    616         $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order");
     616        $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' ORDER BY menu_order");
    617617
    618618    if ($pages) {
     
    11771177function parent_dropdown($default = 0, $parent = 0, $level = 0) {
    11781178    global $wpdb, $post_ID;
    1179     $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_status = 'static' ORDER BY menu_order");
     1179    $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order");
    11801180
    11811181    if ($items) {
     
    18491849    $post = & get_post($id);
    18501850
    1851     if ( $post->post_status != 'attachment' )
     1851    if ( $post->post_type != 'attachment' )
    18521852        return false;
    18531853
  • trunk/wp-admin/edit-form-advanced.php

    r3456 r3510  
    5252<input type="hidden" name="action" value="<?php echo $form_action ?>" />
    5353<input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" />
     54<input type="hidden" name="post_type" value="post" />
    5455
    5556<?php echo $form_extra ?>
  • trunk/wp-admin/edit-page-form.php

    r3456 r3510  
    3131<input type="hidden" name="action" value='<?php echo $form_action ?>' />
    3232<?php echo $form_extra ?>
    33 <input type="hidden" name="post_status" value="static" />
     33<input type="hidden" name="post_type" value="page" />
    3434
    3535<script type="text/javascript">
     
    5454<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label>
    5555</div>
     56</fieldset>
     57
     58<fieldset class="dbx-box">
     59<h3 class="dbx-handle"><?php _e('Page Status') ?></h3>
     60<div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
     61<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'); ?> /> <?php _e('Published') ?></label>
     62<?php endif; ?>
     63      <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>
     64      <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>
    5665</fieldset>
    5766
  • trunk/wp-admin/edit-pages.php

    r3422 r3510  
    2626    wp();
    2727else
    28     $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");
     28    $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page'");
    2929
    3030if ($posts) {
  • trunk/wp-admin/index.php

    r3443 r3510  
    6161
    6262<?php
    63 if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :
     63if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :
    6464?>
    6565<div>
     
    8080
    8181<?php
    82 if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt > '$today' ORDER BY post_date ASC") ) :
     82if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_date_gmt > '$today' ORDER BY post_date ASC") ) :
    8383?>
    8484<div>
     
    9999<h3><?php _e('Blog Stats'); ?></h3>
    100100<?php
    101 $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
     101$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");
    102102if (0 < $numposts) $numposts = number_format($numposts);
    103103
  • trunk/wp-admin/inline-uploading.php

    r3469 r3510  
    6161    'post_title' => $imgtitle ? $imgtitle : $filename,
    6262    'post_content' => $descr,
    63     'post_status' => 'attachment',
     63    'post_type' => 'attachment',
    6464    'post_parent' => $post,
    6565    'post_mime_type' => $type,
     
    125125
    126126if ( $last )
    127     $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment' $and_user $and_post") - $num;
     127    $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment' $and_user $and_post") - $num;
    128128else
    129129    $start = (int) $start;
     
    135135    $sort = "post_date_gmt DESC";
    136136
    137 $attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_status = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
     137$attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_type = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
    138138
    139139if ( count($attachments) == 0 ) {
     
    644644<li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&amp;post=<?php echo $post; ?>&amp;all=false"><?php _e('Browse'); ?></a></li>
    645645<?php } ?>
    646 <?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment'")) { ?>
     646<?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment'")) { ?>
    647647<li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&amp;post=<?php echo $post; ?>&amp;all=true"><?php _e('Browse All'); ?></a></li>
    648648<?php } ?>
  • trunk/wp-admin/install.php

    r3373 r3510  
    171171// First Page
    172172
    173 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'static', '', '', '')");
     173$wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'publish', 'page', '', '', '')");
    174174$wp_rewrite->flush_rules();
    175175
  • trunk/wp-admin/page-new.php

    r2762 r3510  
    1717   
    1818    $post = get_default_post_to_edit();
    19     $post->post_status = 'static';
     19    $post->post_type = 'page';
    2020
    2121    include('edit-page-form.php');
  • trunk/wp-admin/post.php

    r3473 r3510  
    2424
    2525// Fix submenu highlighting for pages.
    26 if ( isset($_REQUEST['post']) && 'static' == get_post_status($_REQUEST['post']) )
     26if ( isset($_REQUEST['post']) && 'page' == get_post_type($_REQUEST['post']) )
    2727    $submenu_file = 'page-new.php';
    2828
     
    5151    }
    5252
    53     if ( 'static' == $_POST['post_status'] )
     53    if ( 'page' == $_POST['post_type'] )
    5454        $location = "page-new.php?saved=true";
    5555
     
    7373    $post = get_post_to_edit($post_ID);
    7474   
    75     if ($post->post_status == 'static')
     75    if ($post->post_type == 'page')
    7676        include('edit-page-form.php');
    7777    else
     
    9191    // Don't let these be changed
    9292    unset($_POST['guid']);
    93     $_POST['post_status'] = 'attachment';
     93    $_POST['post_type'] = 'attachment';
    9494
    9595    // Update the thumbnail filename
     
    135135        die( __('You are not allowed to delete this post.') );
    136136
    137     if ( $post->post_status == 'attachment' ) {
     137    if ( $post->post_type == 'attachment' ) {
    138138        if ( ! wp_delete_attachment($post_id) )
    139139            die( __('Error in deleting...') );
  • trunk/wp-admin/upgrade-functions.php

    r3373 r3510  
    3333    if ( $wp_current_db_version < 3308 )
    3434        upgrade_160();
     35
     36    if ( $wp_current_db_version < 3506 )
     37        upgrade_210();
    3538
    3639    $wp_rewrite->flush_rules();
     
    324327                add_post_meta($object->ID, '_wp_attached_file', $meta['file']);
    325328        }
     329    }
     330}
     331
     332function upgrade_210() {
     333    global $wpdb, $table_prefix, $wp_current_db_version;
     334
     335    // Update status and type.
     336    $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
     337   
     338    if ( ! empty($posts) ) foreach ($posts as $post) {
     339        $status = $post->post_status;
     340        $type = 'post';
     341
     342        if ( 'static' == $status ) {
     343            $status = 'publish';
     344            $type = 'page';
     345        } else if ( 'attachment' == $status ) {
     346            $status = 'inherit';
     347            $type = 'attachment';   
     348        }
     349       
     350        $wpdb->query("UPDATE $wpdb->posts SET post_status = '$status', post_type = '$type' WHERE ID = '$post->ID'");
    326351    }
    327352}
  • trunk/wp-admin/upgrade-schema.php

    r3453 r3510  
    107107  post_category int(4) NOT NULL default '0',
    108108  post_excerpt text NOT NULL,
    109   post_status enum('publish','draft','private','static','object','attachment') NOT NULL default 'publish',
     109  post_status enum('publish','draft','private','static','object','attachment','inherit') NOT NULL default 'publish',
    110110  comment_status enum('open','closed','registered_only') NOT NULL default 'open',
    111111  ping_status enum('open','closed') NOT NULL default 'open',
     
    120120  guid varchar(255) NOT NULL default '',
    121121  menu_order int(11) NOT NULL default '0',
    122   post_type varchar(100) NOT NULL default '',
     122  post_type varchar(100) NOT NULL default 'post',
    123123  post_mime_type varchar(100) NOT NULL default '',
    124124  comment_count bigint(20) NOT NULL default '0',
  • trunk/wp-admin/users.php

    r3483 r3510  
    235235        $short_url =  substr($short_url, 0, 32).'...';
    236236        $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
    237         $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user_object->ID' and post_status = 'publish'");
     237        $numposts = get_usernumposts($user_object->ID);
    238238        if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>";
    239239        echo "
  • trunk/wp-commentsrss2.php

    r3314 r3510  
    3333            $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
    3434            LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
    35             AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status IN ('publish', 'static', 'object')
     35            AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish')
    3636            AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'
    3737            ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') );
     
    4040            comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
    4141            $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
    42             LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status IN ('publish', 'static', 'object')
     42            LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'
    4343            AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "' 
    4444            ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') );
  • trunk/wp-includes/classes.php

    r3484 r3510  
    594594
    595595        if ( $this->is_attachment ) {
    596             $where .= ' AND (post_status = "attachment")';
     596            $where .= ' AND (post_type = "attachment")';
    597597        } elseif ($this->is_page) {
    598             $where .= ' AND (post_status = "static")';
     598            $where .= ' AND (post_type = "page")';
    599599        } elseif ($this->is_single) {
    600             $where .= ' AND (post_status != "static")';
     600            $where .= ' AND (post_type = "post")';
    601601        } else {
    602             $where .= ' AND (post_status = "publish"';
     602            $where .= ' AND (post_type = "post" AND post_status = "publish"';
    603603
    604604            if (isset($user_ID) && ('' != intval($user_ID)))
    605                 $where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
     605                $where .= " OR post_author = $user_ID AND post_status = 'private')";
    606606            else
    607607                $where .= ')';             
    608608        }
    609 
    610         if (! $this->is_attachment )
    611             $where .= ' AND post_status != "attachment"';
    612609
    613610        // Apply filters on where and join prior to paging so that any
     
    655652
    656653        // Check post status to determine if post should be displayed.
    657         if ($this->is_single) {
     654        if ($this->is_single || $this->is_page) {
    658655            $status = get_post_status($this->posts[0]);
    659             if ( ('publish' != $status) && ('static' != $status) ) {
    660                 if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
     656            if ( ('publish' != $status) ) {
     657                if ( ! is_user_logged_in() ) {
    661658                    // User must be logged in to view unpublished posts.
    662659                    $this->posts = array();
  • trunk/wp-includes/functions-post.php

    r3506 r3510  
    4444    if ( empty($post_status) )
    4545        $post_status = 'draft';
    46    
     46
     47    if ( empty($post_type) )
     48        $post_type = 'post';
     49
    4750    // Get the post ID.
    4851    if ( $update )
     
    102105        $post_password = '';
    103106
    104     if ( ('publish' == $post_status) || ('static' == $post_status) ) {
    105         $post_name_check = ('publish' == $post_status)
    106             ? $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1")
    107             : $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'static' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1");
     107    if ( 'draft' != $post_status ) {
     108        $post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_type = '$post_type' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1");
    108109
    109110        if ($post_name_check) {
     
    111112            while ($post_name_check) {
    112113                $alt_post_name = $post_name . "-$suffix";
    113                 $post_name_check = ('publish' == $post_status)
    114                     ? $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1")
    115                     : $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'static' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1");
     114                $post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_type = '$post_type' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1");
    116115                $suffix++;
    117116            }
     
    131130            post_excerpt = '$post_excerpt',
    132131            post_status = '$post_status',
     132            post_type = '$post_type',
    133133            comment_status = '$comment_status',
    134134            ping_status = '$ping_status',
     
    145145        $wpdb->query(
    146146            "INSERT IGNORE INTO $wpdb->posts
    147             (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
     147            (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
    148148            VALUES
    149             ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type')");
     149            ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$post_type', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type')");
    150150            $post_ID = $wpdb->insert_id;           
    151151    }
     
    158158    wp_set_post_cats('', $post_ID, $post_category);
    159159
    160     if ( 'static' == $post_status ) {
     160    if ( 'page' == $post_type ) {
    161161        clean_page_cache($post_ID);
    162162        wp_cache_delete($post_ID, 'pages');
     
    179179    }
    180180
    181     if ($post_status == 'publish') {
     181    if ($post_status == 'publish' && $post_type == 'post') {
    182182        do_action('publish_post', $post_ID);
    183183
     
    196196            spawn_pinger();
    197197        }
    198     } else if ($post_status == 'static') {
     198    } else if ($post_type == 'page') {
    199199        wp_cache_delete('all_page_ids', 'pages');
    200200        $wp_rewrite->flush_rules();
     
    239239        $post_author = $user_ID;
    240240
    241     $post_status = 'attachment';
     241    $post_type = 'attachment';
     242    $post_status = 'inherit';
    242243
    243244    // Are we updating or creating?
     
    306307            post_excerpt = '$post_excerpt',
    307308            post_status = '$post_status',
     309            post_type = '$post_type',
    308310            comment_status = '$comment_status',
    309311            ping_status = '$ping_status',
     
    322324        $wpdb->query(
    323325            "INSERT INTO $wpdb->posts
    324             (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid)
     326            (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid)
    325327            VALUES
    326             ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$guid')");
     328            ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$post_type', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$guid')");
    327329            $post_ID = $wpdb->insert_id;           
    328330    }
     
    356358        return $post;
    357359
    358     if ( 'attachment' != $post->post_status )
     360    if ( 'attachment' != $post->post_type )
    359361        return false;
    360362
     
    408410    }
    409411
    410     $sql = "SELECT * FROM $wpdb->posts WHERE post_status IN ('publish', 'draft', 'private') ORDER BY post_date DESC $limit";
     412    $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC $limit";
    411413    $result = $wpdb->get_results($sql,ARRAY_A);
    412414
     
    448450    }
    449451
    450     if ($postarr['post_status'] == 'attachment')
     452    if ($postarr['post_type'] == 'attachment')
    451453        return wp_insert_attachment($postarr);
    452454
     
    517519    $all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
    518520    foreach ( $all_affected_cats as $cat_id ) {
    519         $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status='publish' AND category_id = '$cat_id'");
     521        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
    520522        $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
    521523        wp_cache_delete($cat_id, 'category');       
     
    530532        return $post;
    531533
    532     if ( 'attachment' == $post->post_status )
     534    if ( 'attachment' == $post->post_type )
    533535        return wp_delete_attachment($postid);
    534536
    535537    do_action('delete_post', $postid);
    536538
    537     if ( 'publish' == $post->post_status) {
     539    if ( 'publish' == $post->post_status && 'post' == $post->post_type ) {
    538540        $categories = wp_get_post_cats('', $post->ID);
    539541        if( is_array( $categories ) ) {
     
    545547    }
    546548
    547     if ( 'static' == $post->post_status )
    548         $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_status = 'static'");
     549    if ( 'page' == $post->post_type )
     550        $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'page'");
    549551
    550552    $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid");
     
    556558    $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
    557559
    558     if ( 'static' == $post->post_status ) {
     560    if ( 'page' == $post->type ) {
    559561        wp_cache_delete('all_page_ids', 'pages');
    560562        $wp_rewrite->flush_rules();
     
    795797   
    796798    //get pages in order of hierarchy, i.e. children after parents
    797     $posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'static'"));
     799    $posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page'"));
    798800    //now reverse it, because we need parents after children for rewrite rules to work properly
    799801    $posts = array_reverse($posts, true);
     
    808810            // URI => page name
    809811            $uri = get_page_uri($id);
    810             $attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'attachment' AND post_parent = '$id'");
     812            $attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$id'");
    811813            if ( $attachments ) {
    812814                foreach ( $attachments as $attachment ) {
     
    830832
    831833    if ( is_object($post) ) {
    832         if ( ('attachment' == $post->post_status) && $post->post_parent && ($post->ID != $post->post_parent) )
     834        if ( ('attachment' == $post->post_type) && $post->post_parent && ($post->ID != $post->post_parent) )
    833835            return get_post_status($post->post_parent);
    834836        else
    835837            return $post->post_status;
    836838    }
     839
     840    return false;
     841}
     842
     843function get_post_type($post = false) {
     844    global $wpdb, $posts;
     845
     846    if ( false === $post )
     847        $post = $posts[0];
     848    elseif ( (int) $post )
     849        $post = get_post($post, OBJECT);
     850
     851    if ( is_object($post) )
     852        return $post->post_type;
    837853
    838854    return false;
  • trunk/wp-includes/functions.php

    r3495 r3510  
    172172function get_usernumposts($userid) {
    173173    global $wpdb;
    174     return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_status = 'publish'");
     174    return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_type = 'post' AND post_status = 'publish'");
    175175}
    176176
     
    575575            $_post = null;
    576576    } elseif ( is_object($post) ) {
    577         if ( 'static' == $post->post_status )
     577        if ( 'page' == $post->post_type )
    578578            return get_page($post, $output);
    579579        if ( !isset($post_cache[$post->ID]) )
     
    588588            $query = "SELECT * FROM $wpdb->posts WHERE ID = '$post' LIMIT 1";
    589589            $_post = & $wpdb->get_row($query);
    590             if ( 'static' == $_post->post_status )
     590            if ( 'page' == $_post->post_type )
    591591                return get_page($_post, $output);
    592592            $post_cache[$post] = & $_post;
     
    679679        }
    680680    } elseif ( is_object($page) ) {
    681         if ( 'static' != $page->post_status )
     681        if ( 'post' == $page->post_type )
    682682            return get_post($page, $output);
    683683        wp_cache_add($page->ID, $page, 'pages');
     
    694694            $query = "SELECT * FROM $wpdb->posts WHERE ID= '$page' LIMIT 1";
    695695            $_page = & $wpdb->get_row($query);
    696             if ( 'static' != $_page->post_status )
     696            if ( 'post' == $_page->post_type )
    697697                return get_post($_page, $output);
    698698            wp_cache_add($_page->ID, $_page, 'pages');
     
    702702    if (!isset($_page->fullpath)) {
    703703        $_page = set_page_path($_page);
    704         wp_cache_replace($_page->cat_ID, $_page, 'pages');
     704        wp_cache_replace($_page->ID, $_page, 'pages');
    705705    }
    706706
     
    816816   
    817817    if ( ! $page_ids = wp_cache_get('all_page_ids', 'pages') ) {
    818         $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status='static'");
     818        $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
    819819        wp_cache_add('all_page_ids', $page_ids, 'pages');
    820820    }
     
    13261326        "SELECT DISTINCT * FROM $wpdb->posts " .
    13271327        ( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
    1328         " WHERE post_date <= '$now' AND (post_status = 'publish') ".
     1328        " WHERE post_date <= '$now' AND (post_type = 'post' AND post_status = 'publish') ".
    13291329        ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
    13301330        " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
  • trunk/wp-includes/template-functions-category.php

    r3338 r3510  
    309309        UNIX_TIMESTAMP( MAX(post_date) ) AS ts
    310310        FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
    311         WHERE post_status = 'publish' AND post_id = ID $exclusions
     311        WHERE post_type = 'post' AND post_status = 'publish' AND post_id = ID $exclusions
    312312        GROUP BY category_id");
    313313        foreach ( $cat_dates as $cat_date ) {
  • trunk/wp-includes/template-functions-general.php

    r3493 r3510  
    331331
    332332    if ( 'monthly' == $type ) {
    333         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
     333        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
    334334        if ( $arcresults ) {
    335335            $afterafter = $after;
     
    346346        }
    347347    } elseif ( 'daily' == $type ) {
    348         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     348        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    349349        if ( $arcresults ) {
    350350            foreach ( $arcresults as $arcresult ) {
     
    357357    } elseif ( 'weekly' == $type ) {
    358358        $start_of_week = get_settings('start_of_week');
    359         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     359        $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    360360        $arc_w_last = '';
    361361        if ( $arcresults ) {
     
    374374        }
    375375    } elseif ( 'postbypost' == $type ) {
    376         $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     376        $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    377377        if ( $arcresults ) {
    378378            foreach ( $arcresults as $arcresult ) {
     
    404404    // Quick check. If we have no posts at all, abort!
    405405    if ( !$posts ) {
    406         $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
     406        $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
    407407        if ( !$gotsome )
    408408            return;
     
    444444        FROM $wpdb->posts
    445445        WHERE post_date < '$thisyear-$thismonth-01'
    446         AND post_status = 'publish'
     446        AND post_type = 'post' AND post_status = 'publish'
    447447            ORDER BY post_date DESC
    448448            LIMIT 1");
     
    451451        WHERE post_date >   '$thisyear-$thismonth-01'
    452452        AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
    453         AND post_status = 'publish'
     453        AND post_type = 'post' AND post_status = 'publish'
    454454            ORDER   BY post_date ASC
    455455            LIMIT 1");
     
    509509        FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
    510510        AND YEAR(post_date) = $thisyear
    511         AND post_status = 'publish'
     511        AND post_type = 'post' AND post_status = 'publish'
    512512        AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    513513    if ( $dayswithposts ) {
     
    532532        ."AND MONTH(post_date) = '$thismonth' "
    533533        ."AND post_date < '".current_time('mysql')."' "
    534         ."AND post_status = 'publish'"
     534        ."AND post_type = 'post' AND post_status = 'publish'"
    535535    );
    536536    if ( $ak_post_titles ) {
  • trunk/wp-includes/template-functions-links.php

    r3508 r3510  
    4343
    4444    $post = &get_post($id);
    45     if ( $post->post_status == 'static' )
     45    if ( $post->post_type == 'page' )
    4646        return get_page_link($post->ID);
    47     elseif ($post->post_status == 'attachment')
     47    elseif ($post->post_type == 'attachment')
    4848        return get_attachment_link($post->ID);
    4949
     
    262262    }
    263263
    264     return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $posts_in_ex_cats_sql ORDER BY post_date DESC LIMIT 1");
     264    return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql ORDER BY post_date DESC LIMIT 1");
    265265}
    266266
     
    297297    $now = current_time('mysql');
    298298   
    299     return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1");
     299    return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1");
    300300}
    301301
  • trunk/wp-includes/template-functions-post.php

    r3486 r3510  
    315315    $pages = $wpdb->get_results("SELECT * " .
    316316        "FROM $wpdb->posts " .
    317         "WHERE post_status = 'static' " .
     317        "WHERE post_type = 'page' AND post_status = 'publish' " .
    318318        "$exclusions " .
    319319        "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
     
    451451    $_post = & get_post($id);
    452452
    453     if ( ('attachment' != $_post->post_status) || ('' == $_post->guid) )
     453    if ( ('attachment' != $_post->post_type) || ('' == $_post->guid) )
    454454        return __('Missing Attachment');
    455455
  • trunk/wp-includes/version.php

    r3502 r3510  
    33// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
    44
    5 $wp_version = '2.0.1';
    6 $wp_db_version = 3437;
     5$wp_version = '2.1-aplha1';
     6$wp_db_version = 3506;
    77
    88?>
Note: See TracChangeset for help on using the changeset viewer.