mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
Allow draft pages. Use post_type for object types. Reserve post_status strictly for status. fixes #1820
git-svn-id: https://develop.svn.wordpress.org/trunk@3510 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -34,13 +34,13 @@ function write_post() {
|
||||
$_POST['post_status'] = 'publish';
|
||||
if ('' != $_POST['advanced'])
|
||||
$_POST['post_status'] = 'draft';
|
||||
if ('' != $_POST['savepage'])
|
||||
$_POST['post_status'] = 'static';
|
||||
//if ('' != $_POST['savepage']) {
|
||||
// $_POST['post_status'] = 'draft';
|
||||
|
||||
if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
|
||||
$_POST['post_status'] = 'draft';
|
||||
|
||||
if ('static' == $_POST['post_status'] && !current_user_can('edit_pages'))
|
||||
if ('page' == $_POST['post_type'] && !current_user_can('edit_pages'))
|
||||
die(__('This user cannot edit pages.'));
|
||||
|
||||
if (!empty ($_POST['edit_date'])) {
|
||||
@@ -154,8 +154,8 @@ function edit_post() {
|
||||
$_POST['post_status'] = 'publish';
|
||||
if ('' != $_POST['advanced'])
|
||||
$_POST['post_status'] = 'draft';
|
||||
if ('' != $_POST['savepage'])
|
||||
$_POST['post_status'] = 'static';
|
||||
//if ('' != $_POST['savepage'])
|
||||
// $_POST['post_status'] = 'static';
|
||||
|
||||
if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
|
||||
$_POST['post_status'] = 'draft';
|
||||
@@ -254,7 +254,7 @@ function get_post_to_edit($id) {
|
||||
$post->post_title = format_to_edit($post->post_title);
|
||||
$post->post_title = apply_filters('title_edit_pre', $post->post_title);
|
||||
|
||||
if ($post->post_status == 'static')
|
||||
if ($post->post_type == 'page')
|
||||
$post->page_template = get_post_meta($id, '_wp_page_template', true);
|
||||
|
||||
return $post;
|
||||
@@ -613,7 +613,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
|
||||
function page_rows($parent = 0, $level = 0, $pages = 0) {
|
||||
global $wpdb, $class, $post;
|
||||
if (!$pages)
|
||||
$pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order");
|
||||
$pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' ORDER BY menu_order");
|
||||
|
||||
if ($pages) {
|
||||
foreach ($pages as $post) {
|
||||
@@ -1176,7 +1176,7 @@ function page_template_dropdown($default = '') {
|
||||
|
||||
function parent_dropdown($default = 0, $parent = 0, $level = 0) {
|
||||
global $wpdb, $post_ID;
|
||||
$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");
|
||||
$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");
|
||||
|
||||
if ($items) {
|
||||
foreach ($items as $item) {
|
||||
@@ -1848,7 +1848,7 @@ function the_attachment_links($id = false) {
|
||||
$id = (int) $id;
|
||||
$post = & get_post($id);
|
||||
|
||||
if ( $post->post_status != 'attachment' )
|
||||
if ( $post->post_type != 'attachment' )
|
||||
return false;
|
||||
|
||||
$icon = get_attachment_icon($post->ID);
|
||||
|
||||
@@ -51,6 +51,7 @@ if (empty($post->post_status)) $post->post_status = 'draft';
|
||||
<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
|
||||
<input type="hidden" name="action" value="<?php echo $form_action ?>" />
|
||||
<input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" />
|
||||
<input type="hidden" name="post_type" value="post" />
|
||||
|
||||
<?php echo $form_extra ?>
|
||||
<?php if (isset($_GET['message']) && 2 > $_GET['message']) : ?>
|
||||
|
||||
@@ -30,7 +30,7 @@ if (isset($mode) && 'bookmarklet' == $mode) {
|
||||
<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
|
||||
<input type="hidden" name="action" value='<?php echo $form_action ?>' />
|
||||
<?php echo $form_extra ?>
|
||||
<input type="hidden" name="post_status" value="static" />
|
||||
<input type="hidden" name="post_type" value="page" />
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
@@ -55,6 +55,15 @@ addLoadEvent(focusit);
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="dbx-box">
|
||||
<h3 class="dbx-handle"><?php _e('Page Status') ?></h3>
|
||||
<div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
<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>
|
||||
<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>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="passworddiv" class="dbx-box">
|
||||
<h3 class="dbx-handle"><?php _e('Password-Protect Post') ?></h3>
|
||||
<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
|
||||
|
||||
@@ -25,7 +25,7 @@ $show_post_type = 'page';
|
||||
if ( isset($_GET['s']) )
|
||||
wp();
|
||||
else
|
||||
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");
|
||||
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page'");
|
||||
|
||||
if ($posts) {
|
||||
?>
|
||||
|
||||
@@ -60,7 +60,7 @@ foreach ($comments as $comment) {
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
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") ) :
|
||||
if ( $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") ) :
|
||||
?>
|
||||
<div>
|
||||
<h3><?php _e('Posts'); ?> <a href="edit.php" title="<?php _e('More posts...'); ?>">»</a></h3>
|
||||
@@ -79,7 +79,7 @@ foreach ($recentposts as $post) {
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
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") ) :
|
||||
if ( $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") ) :
|
||||
?>
|
||||
<div>
|
||||
<h3><?php _e('Scheduled Entries:') ?></h3>
|
||||
@@ -98,7 +98,7 @@ foreach ($scheduled as $post) {
|
||||
<div>
|
||||
<h3><?php _e('Blog Stats'); ?></h3>
|
||||
<?php
|
||||
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
|
||||
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");
|
||||
if (0 < $numposts) $numposts = number_format($numposts);
|
||||
|
||||
$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
|
||||
|
||||
@@ -60,7 +60,7 @@ $filename = basename($file);
|
||||
$attachment = array(
|
||||
'post_title' => $imgtitle ? $imgtitle : $filename,
|
||||
'post_content' => $descr,
|
||||
'post_status' => 'attachment',
|
||||
'post_type' => 'attachment',
|
||||
'post_parent' => $post,
|
||||
'post_mime_type' => $type,
|
||||
'guid' => $url
|
||||
@@ -124,7 +124,7 @@ if (! current_user_can('edit_others_posts') )
|
||||
$and_user = "AND post_author = " . $user_ID;
|
||||
|
||||
if ( $last )
|
||||
$start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment' $and_user $and_post") - $num;
|
||||
$start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment' $and_user $and_post") - $num;
|
||||
else
|
||||
$start = (int) $start;
|
||||
|
||||
@@ -134,7 +134,7 @@ if ( $start < 0 )
|
||||
if ( '' == $sort )
|
||||
$sort = "post_date_gmt DESC";
|
||||
|
||||
$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);
|
||||
$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);
|
||||
|
||||
if ( count($attachments) == 0 ) {
|
||||
header("Location: ".basename(__FILE__)."?post=$post&action=upload");
|
||||
@@ -643,7 +643,7 @@ th {
|
||||
<?php if ( $attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ) { ?>
|
||||
<li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&post=<?php echo $post; ?>&all=false"><?php _e('Browse'); ?></a></li>
|
||||
<?php } ?>
|
||||
<?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment'")) { ?>
|
||||
<?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment'")) { ?>
|
||||
<li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&post=<?php echo $post; ?>&all=true"><?php _e('Browse All'); ?></a></li>
|
||||
<?php } ?>
|
||||
<li> </li>
|
||||
|
||||
@@ -170,7 +170,7 @@ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comm
|
||||
|
||||
// First Page
|
||||
|
||||
$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', '', '', '')");
|
||||
$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', '', '', '')");
|
||||
$wp_rewrite->flush_rules();
|
||||
|
||||
// Set up admin user
|
||||
|
||||
@@ -16,7 +16,7 @@ if ( current_user_can('edit_pages') ) {
|
||||
get_currentuserinfo();
|
||||
|
||||
$post = get_default_post_to_edit();
|
||||
$post->post_status = 'static';
|
||||
$post->post_type = 'page';
|
||||
|
||||
include('edit-page-form.php');
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ $action = "delete";
|
||||
}
|
||||
|
||||
// Fix submenu highlighting for pages.
|
||||
if ( isset($_REQUEST['post']) && 'static' == get_post_status($_REQUEST['post']) )
|
||||
if ( isset($_REQUEST['post']) && 'page' == get_post_type($_REQUEST['post']) )
|
||||
$submenu_file = 'page-new.php';
|
||||
|
||||
$editing = true;
|
||||
@@ -50,7 +50,7 @@ case 'post':
|
||||
$location = 'post.php?posted=true';
|
||||
}
|
||||
|
||||
if ( 'static' == $_POST['post_status'] )
|
||||
if ( 'page' == $_POST['post_type'] )
|
||||
$location = "page-new.php?saved=true";
|
||||
|
||||
if ( isset($_POST['save']) )
|
||||
@@ -72,7 +72,7 @@ case 'edit':
|
||||
|
||||
$post = get_post_to_edit($post_ID);
|
||||
|
||||
if ($post->post_status == 'static')
|
||||
if ($post->post_type == 'page')
|
||||
include('edit-page-form.php');
|
||||
else
|
||||
include('edit-form-advanced.php');
|
||||
@@ -90,7 +90,7 @@ case 'editattachment':
|
||||
|
||||
// Don't let these be changed
|
||||
unset($_POST['guid']);
|
||||
$_POST['post_status'] = 'attachment';
|
||||
$_POST['post_type'] = 'attachment';
|
||||
|
||||
// Update the thumbnail filename
|
||||
$oldmeta = $newmeta = get_post_meta($post_id, '_wp_attachment_metadata', true);
|
||||
@@ -134,7 +134,7 @@ case 'delete':
|
||||
if ( !current_user_can('edit_post', $post_id) )
|
||||
die( __('You are not allowed to delete this post.') );
|
||||
|
||||
if ( $post->post_status == 'attachment' ) {
|
||||
if ( $post->post_type == 'attachment' ) {
|
||||
if ( ! wp_delete_attachment($post_id) )
|
||||
die( __('Error in deleting...') );
|
||||
} else {
|
||||
|
||||
@@ -33,6 +33,9 @@ function upgrade_all() {
|
||||
if ( $wp_current_db_version < 3308 )
|
||||
upgrade_160();
|
||||
|
||||
if ( $wp_current_db_version < 3506 )
|
||||
upgrade_210();
|
||||
|
||||
$wp_rewrite->flush_rules();
|
||||
|
||||
update_option('db_version', $wp_db_version);
|
||||
@@ -326,6 +329,28 @@ function upgrade_160() {
|
||||
}
|
||||
}
|
||||
|
||||
function upgrade_210() {
|
||||
global $wpdb, $table_prefix, $wp_current_db_version;
|
||||
|
||||
// Update status and type.
|
||||
$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
|
||||
|
||||
if ( ! empty($posts) ) foreach ($posts as $post) {
|
||||
$status = $post->post_status;
|
||||
$type = 'post';
|
||||
|
||||
if ( 'static' == $status ) {
|
||||
$status = 'publish';
|
||||
$type = 'page';
|
||||
} else if ( 'attachment' == $status ) {
|
||||
$status = 'inherit';
|
||||
$type = 'attachment';
|
||||
}
|
||||
|
||||
$wpdb->query("UPDATE $wpdb->posts SET post_status = '$status', post_type = '$type' WHERE ID = '$post->ID'");
|
||||
}
|
||||
}
|
||||
|
||||
// The functions we use to actually do stuff
|
||||
|
||||
// General
|
||||
|
||||
@@ -106,7 +106,7 @@ CREATE TABLE $wpdb->posts (
|
||||
post_title text NOT NULL,
|
||||
post_category int(4) NOT NULL default '0',
|
||||
post_excerpt text NOT NULL,
|
||||
post_status enum('publish','draft','private','static','object','attachment') NOT NULL default 'publish',
|
||||
post_status enum('publish','draft','private','static','object','attachment','inherit') NOT NULL default 'publish',
|
||||
comment_status enum('open','closed','registered_only') NOT NULL default 'open',
|
||||
ping_status enum('open','closed') NOT NULL default 'open',
|
||||
post_password varchar(20) NOT NULL default '',
|
||||
@@ -119,7 +119,7 @@ CREATE TABLE $wpdb->posts (
|
||||
post_parent bigint(20) NOT NULL default '0',
|
||||
guid varchar(255) NOT NULL default '',
|
||||
menu_order int(11) NOT NULL default '0',
|
||||
post_type varchar(100) NOT NULL default '',
|
||||
post_type varchar(100) NOT NULL default 'post',
|
||||
post_mime_type varchar(100) NOT NULL default '',
|
||||
comment_count bigint(20) NOT NULL default '0',
|
||||
PRIMARY KEY (ID),
|
||||
|
||||
@@ -234,7 +234,7 @@ default:
|
||||
if (strlen($short_url) > 35)
|
||||
$short_url = substr($short_url, 0, 32).'...';
|
||||
$style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
|
||||
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user_object->ID' and post_status = 'publish'");
|
||||
$numposts = get_usernumposts($user_object->ID);
|
||||
if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>";
|
||||
echo "
|
||||
<tr $style>
|
||||
|
||||
Reference in New Issue
Block a user