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:
@@ -593,23 +593,20 @@ class WP_Query {
|
||||
}
|
||||
|
||||
if ( $this->is_attachment ) {
|
||||
$where .= ' AND (post_status = "attachment")';
|
||||
$where .= ' AND (post_type = "attachment")';
|
||||
} elseif ($this->is_page) {
|
||||
$where .= ' AND (post_status = "static")';
|
||||
$where .= ' AND (post_type = "page")';
|
||||
} elseif ($this->is_single) {
|
||||
$where .= ' AND (post_status != "static")';
|
||||
$where .= ' AND (post_type = "post")';
|
||||
} else {
|
||||
$where .= ' AND (post_status = "publish"';
|
||||
$where .= ' AND (post_type = "post" AND post_status = "publish"';
|
||||
|
||||
if (isset($user_ID) && ('' != intval($user_ID)))
|
||||
$where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
|
||||
$where .= " OR post_author = $user_ID AND post_status = 'private')";
|
||||
else
|
||||
$where .= ')';
|
||||
}
|
||||
|
||||
if (! $this->is_attachment )
|
||||
$where .= ' AND post_status != "attachment"';
|
||||
|
||||
// Apply filters on where and join prior to paging so that any
|
||||
// manipulations to them are reflected in the paging by day queries.
|
||||
$where = apply_filters('posts_where', $where);
|
||||
@@ -654,10 +651,10 @@ class WP_Query {
|
||||
$this->posts = $wpdb->get_results($this->request);
|
||||
|
||||
// Check post status to determine if post should be displayed.
|
||||
if ($this->is_single) {
|
||||
if ($this->is_single || $this->is_page) {
|
||||
$status = get_post_status($this->posts[0]);
|
||||
if ( ('publish' != $status) && ('static' != $status) ) {
|
||||
if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
|
||||
if ( ('publish' != $status) ) {
|
||||
if ( ! is_user_logged_in() ) {
|
||||
// User must be logged in to view unpublished posts.
|
||||
$this->posts = array();
|
||||
} else {
|
||||
|
||||
@@ -43,7 +43,10 @@ function wp_insert_post($postarr = array()) {
|
||||
|
||||
if ( empty($post_status) )
|
||||
$post_status = 'draft';
|
||||
|
||||
|
||||
if ( empty($post_type) )
|
||||
$post_type = 'post';
|
||||
|
||||
// Get the post ID.
|
||||
if ( $update )
|
||||
$post_ID = $ID;
|
||||
@@ -101,18 +104,14 @@ function wp_insert_post($postarr = array()) {
|
||||
if ( !isset($post_password) )
|
||||
$post_password = '';
|
||||
|
||||
if ( ('publish' == $post_status) || ('static' == $post_status) ) {
|
||||
$post_name_check = ('publish' == $post_status)
|
||||
? $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1")
|
||||
: $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");
|
||||
if ( 'draft' != $post_status ) {
|
||||
$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");
|
||||
|
||||
if ($post_name_check) {
|
||||
$suffix = 2;
|
||||
while ($post_name_check) {
|
||||
$alt_post_name = $post_name . "-$suffix";
|
||||
$post_name_check = ('publish' == $post_status)
|
||||
? $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")
|
||||
: $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");
|
||||
$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");
|
||||
$suffix++;
|
||||
}
|
||||
$post_name = $alt_post_name;
|
||||
@@ -130,6 +129,7 @@ function wp_insert_post($postarr = array()) {
|
||||
post_title = '$post_title',
|
||||
post_excerpt = '$post_excerpt',
|
||||
post_status = '$post_status',
|
||||
post_type = '$post_type',
|
||||
comment_status = '$comment_status',
|
||||
ping_status = '$ping_status',
|
||||
post_password = '$post_password',
|
||||
@@ -144,9 +144,9 @@ function wp_insert_post($postarr = array()) {
|
||||
} else {
|
||||
$wpdb->query(
|
||||
"INSERT IGNORE INTO $wpdb->posts
|
||||
(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)
|
||||
(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)
|
||||
VALUES
|
||||
('$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')");
|
||||
('$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')");
|
||||
$post_ID = $wpdb->insert_id;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ function wp_insert_post($postarr = array()) {
|
||||
|
||||
wp_set_post_cats('', $post_ID, $post_category);
|
||||
|
||||
if ( 'static' == $post_status ) {
|
||||
if ( 'page' == $post_type ) {
|
||||
clean_page_cache($post_ID);
|
||||
wp_cache_delete($post_ID, 'pages');
|
||||
} else {
|
||||
@@ -178,7 +178,7 @@ function wp_insert_post($postarr = array()) {
|
||||
do_action('edit_post', $post_ID);
|
||||
}
|
||||
|
||||
if ($post_status == 'publish') {
|
||||
if ($post_status == 'publish' && $post_type == 'post') {
|
||||
do_action('publish_post', $post_ID);
|
||||
|
||||
if ( !defined('WP_IMPORTING') ) {
|
||||
@@ -195,7 +195,7 @@ function wp_insert_post($postarr = array()) {
|
||||
");
|
||||
spawn_pinger();
|
||||
}
|
||||
} else if ($post_status == 'static') {
|
||||
} else if ($post_type == 'page') {
|
||||
wp_cache_delete('all_page_ids', 'pages');
|
||||
$wp_rewrite->flush_rules();
|
||||
|
||||
@@ -238,7 +238,8 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
|
||||
if ( empty($post_author) )
|
||||
$post_author = $user_ID;
|
||||
|
||||
$post_status = 'attachment';
|
||||
$post_type = 'attachment';
|
||||
$post_status = 'inherit';
|
||||
|
||||
// Are we updating or creating?
|
||||
$update = false;
|
||||
@@ -305,6 +306,7 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
|
||||
post_title = '$post_title',
|
||||
post_excerpt = '$post_excerpt',
|
||||
post_status = '$post_status',
|
||||
post_type = '$post_type',
|
||||
comment_status = '$comment_status',
|
||||
ping_status = '$ping_status',
|
||||
post_password = '$post_password',
|
||||
@@ -321,9 +323,9 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
|
||||
} else {
|
||||
$wpdb->query(
|
||||
"INSERT INTO $wpdb->posts
|
||||
(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)
|
||||
(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)
|
||||
VALUES
|
||||
('$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')");
|
||||
('$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')");
|
||||
$post_ID = $wpdb->insert_id;
|
||||
}
|
||||
|
||||
@@ -355,7 +357,7 @@ function wp_delete_attachment($postid) {
|
||||
if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
|
||||
return $post;
|
||||
|
||||
if ( 'attachment' != $post->post_status )
|
||||
if ( 'attachment' != $post->post_type )
|
||||
return false;
|
||||
|
||||
$meta = get_post_meta($postid, '_wp_attachment_metadata', true);
|
||||
@@ -407,7 +409,7 @@ function wp_get_recent_posts($num = 10) {
|
||||
$limit = "LIMIT $num";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM $wpdb->posts WHERE post_status IN ('publish', 'draft', 'private') ORDER BY post_date DESC $limit";
|
||||
$sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC $limit";
|
||||
$result = $wpdb->get_results($sql,ARRAY_A);
|
||||
|
||||
return $result?$result:array();
|
||||
@@ -447,7 +449,7 @@ function wp_update_post($postarr = array()) {
|
||||
$postarr['post_date_gmt'] = '';
|
||||
}
|
||||
|
||||
if ($postarr['post_status'] == 'attachment')
|
||||
if ($postarr['post_type'] == 'attachment')
|
||||
return wp_insert_attachment($postarr);
|
||||
|
||||
return wp_insert_post($postarr);
|
||||
@@ -516,7 +518,7 @@ function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array(
|
||||
// Update category counts.
|
||||
$all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
|
||||
foreach ( $all_affected_cats as $cat_id ) {
|
||||
$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'");
|
||||
$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'");
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
|
||||
wp_cache_delete($cat_id, 'category');
|
||||
}
|
||||
@@ -529,12 +531,12 @@ function wp_delete_post($postid = 0) {
|
||||
if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
|
||||
return $post;
|
||||
|
||||
if ( 'attachment' == $post->post_status )
|
||||
if ( 'attachment' == $post->post_type )
|
||||
return wp_delete_attachment($postid);
|
||||
|
||||
do_action('delete_post', $postid);
|
||||
|
||||
if ( 'publish' == $post->post_status) {
|
||||
if ( 'publish' == $post->post_status && 'post' == $post->post_type ) {
|
||||
$categories = wp_get_post_cats('', $post->ID);
|
||||
if( is_array( $categories ) ) {
|
||||
foreach ( $categories as $cat_id ) {
|
||||
@@ -544,8 +546,8 @@ function wp_delete_post($postid = 0) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'static' == $post->post_status )
|
||||
$wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_status = 'static'");
|
||||
if ( 'page' == $post->post_type )
|
||||
$wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'page'");
|
||||
|
||||
$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid");
|
||||
|
||||
@@ -555,7 +557,7 @@ function wp_delete_post($postid = 0) {
|
||||
|
||||
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
|
||||
|
||||
if ( 'static' == $post->post_status ) {
|
||||
if ( 'page' == $post->type ) {
|
||||
wp_cache_delete('all_page_ids', 'pages');
|
||||
$wp_rewrite->flush_rules();
|
||||
}
|
||||
@@ -794,7 +796,7 @@ function generate_page_rewrite_rules() {
|
||||
global $wpdb;
|
||||
|
||||
//get pages in order of hierarchy, i.e. children after parents
|
||||
$posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'static'"));
|
||||
$posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page'"));
|
||||
//now reverse it, because we need parents after children for rewrite rules to work properly
|
||||
$posts = array_reverse($posts, true);
|
||||
|
||||
@@ -807,7 +809,7 @@ function generate_page_rewrite_rules() {
|
||||
|
||||
// URI => page name
|
||||
$uri = get_page_uri($id);
|
||||
$attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'attachment' AND post_parent = '$id'");
|
||||
$attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$id'");
|
||||
if ( $attachments ) {
|
||||
foreach ( $attachments as $attachment ) {
|
||||
$attach_uri = get_page_uri($attachment->ID);
|
||||
@@ -829,7 +831,7 @@ function get_post_status($ID = '') {
|
||||
$post = get_post($ID);
|
||||
|
||||
if ( is_object($post) ) {
|
||||
if ( ('attachment' == $post->post_status) && $post->post_parent && ($post->ID != $post->post_parent) )
|
||||
if ( ('attachment' == $post->post_type) && $post->post_parent && ($post->ID != $post->post_parent) )
|
||||
return get_post_status($post->post_parent);
|
||||
else
|
||||
return $post->post_status;
|
||||
@@ -838,6 +840,20 @@ function get_post_status($ID = '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_post_type($post = false) {
|
||||
global $wpdb, $posts;
|
||||
|
||||
if ( false === $post )
|
||||
$post = $posts[0];
|
||||
elseif ( (int) $post )
|
||||
$post = get_post($post, OBJECT);
|
||||
|
||||
if ( is_object($post) )
|
||||
return $post->post_type;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Takes a post ID, returns its mime type.
|
||||
function get_post_mime_type($ID = '') {
|
||||
$post = & get_post($ID);
|
||||
|
||||
@@ -171,7 +171,7 @@ function user_pass_ok($user_login,$user_pass) {
|
||||
|
||||
function get_usernumposts($userid) {
|
||||
global $wpdb;
|
||||
return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_status = 'publish'");
|
||||
return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_type = 'post' AND post_status = 'publish'");
|
||||
}
|
||||
|
||||
|
||||
@@ -574,7 +574,7 @@ function &get_post(&$post, $output = OBJECT) {
|
||||
else
|
||||
$_post = null;
|
||||
} elseif ( is_object($post) ) {
|
||||
if ( 'static' == $post->post_status )
|
||||
if ( 'page' == $post->post_type )
|
||||
return get_page($post, $output);
|
||||
if ( !isset($post_cache[$post->ID]) )
|
||||
$post_cache[$post->ID] = &$post;
|
||||
@@ -587,7 +587,7 @@ function &get_post(&$post, $output = OBJECT) {
|
||||
else {
|
||||
$query = "SELECT * FROM $wpdb->posts WHERE ID = '$post' LIMIT 1";
|
||||
$_post = & $wpdb->get_row($query);
|
||||
if ( 'static' == $_post->post_status )
|
||||
if ( 'page' == $_post->post_type )
|
||||
return get_page($_post, $output);
|
||||
$post_cache[$post] = & $_post;
|
||||
}
|
||||
@@ -678,7 +678,7 @@ function &get_page(&$page, $output = OBJECT) {
|
||||
$_page = null;
|
||||
}
|
||||
} elseif ( is_object($page) ) {
|
||||
if ( 'static' != $page->post_status )
|
||||
if ( 'post' == $page->post_type )
|
||||
return get_post($page, $output);
|
||||
wp_cache_add($page->ID, $page, 'pages');
|
||||
$_page = $page;
|
||||
@@ -693,7 +693,7 @@ function &get_page(&$page, $output = OBJECT) {
|
||||
} else {
|
||||
$query = "SELECT * FROM $wpdb->posts WHERE ID= '$page' LIMIT 1";
|
||||
$_page = & $wpdb->get_row($query);
|
||||
if ( 'static' != $_page->post_status )
|
||||
if ( 'post' == $_page->post_type )
|
||||
return get_post($_page, $output);
|
||||
wp_cache_add($_page->ID, $_page, 'pages');
|
||||
}
|
||||
@@ -701,7 +701,7 @@ function &get_page(&$page, $output = OBJECT) {
|
||||
|
||||
if (!isset($_page->fullpath)) {
|
||||
$_page = set_page_path($_page);
|
||||
wp_cache_replace($_page->cat_ID, $_page, 'pages');
|
||||
wp_cache_replace($_page->ID, $_page, 'pages');
|
||||
}
|
||||
|
||||
if ( $output == OBJECT ) {
|
||||
@@ -815,7 +815,7 @@ function get_all_page_ids() {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! $page_ids = wp_cache_get('all_page_ids', 'pages') ) {
|
||||
$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status='static'");
|
||||
$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
|
||||
wp_cache_add('all_page_ids', $page_ids, 'pages');
|
||||
}
|
||||
|
||||
@@ -1325,7 +1325,7 @@ function get_posts($args) {
|
||||
$posts = $wpdb->get_results(
|
||||
"SELECT DISTINCT * FROM $wpdb->posts " .
|
||||
( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
|
||||
" WHERE post_date <= '$now' AND (post_status = 'publish') ".
|
||||
" WHERE post_date <= '$now' AND (post_type = 'post' AND post_status = 'publish') ".
|
||||
( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
|
||||
" GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
|
||||
$cat_dates = $wpdb->get_results(" SELECT category_id,
|
||||
UNIX_TIMESTAMP( MAX(post_date) ) AS ts
|
||||
FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
|
||||
WHERE post_status = 'publish' AND post_id = ID $exclusions
|
||||
WHERE post_type = 'post' AND post_status = 'publish' AND post_id = ID $exclusions
|
||||
GROUP BY category_id");
|
||||
foreach ( $cat_dates as $cat_date ) {
|
||||
$category_timestamp["$cat_date->category_id"] = $cat_date->ts;
|
||||
|
||||
@@ -330,7 +330,7 @@ function get_archives($type='', $limit='', $format='html', $before = '', $after
|
||||
$now = current_time('mysql');
|
||||
|
||||
if ( 'monthly' == $type ) {
|
||||
$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);
|
||||
$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);
|
||||
if ( $arcresults ) {
|
||||
$afterafter = $after;
|
||||
foreach ( $arcresults as $arcresult ) {
|
||||
@@ -345,7 +345,7 @@ function get_archives($type='', $limit='', $format='html', $before = '', $after
|
||||
}
|
||||
}
|
||||
} elseif ( 'daily' == $type ) {
|
||||
$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);
|
||||
$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);
|
||||
if ( $arcresults ) {
|
||||
foreach ( $arcresults as $arcresult ) {
|
||||
$url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
|
||||
@@ -356,7 +356,7 @@ function get_archives($type='', $limit='', $format='html', $before = '', $after
|
||||
}
|
||||
} elseif ( 'weekly' == $type ) {
|
||||
$start_of_week = get_settings('start_of_week');
|
||||
$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);
|
||||
$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);
|
||||
$arc_w_last = '';
|
||||
if ( $arcresults ) {
|
||||
foreach ( $arcresults as $arcresult ) {
|
||||
@@ -373,7 +373,7 @@ function get_archives($type='', $limit='', $format='html', $before = '', $after
|
||||
}
|
||||
}
|
||||
} elseif ( 'postbypost' == $type ) {
|
||||
$arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
|
||||
$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);
|
||||
if ( $arcresults ) {
|
||||
foreach ( $arcresults as $arcresult ) {
|
||||
if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
|
||||
@@ -403,7 +403,7 @@ function get_calendar($daylength = 1) {
|
||||
|
||||
// Quick check. If we have no posts at all, abort!
|
||||
if ( !$posts ) {
|
||||
$gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
|
||||
$gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
|
||||
if ( !$gotsome )
|
||||
return;
|
||||
}
|
||||
@@ -443,14 +443,14 @@ function get_calendar($daylength = 1) {
|
||||
$previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date < '$thisyear-$thismonth-01'
|
||||
AND post_status = 'publish'
|
||||
AND post_type = 'post' AND post_status = 'publish'
|
||||
ORDER BY post_date DESC
|
||||
LIMIT 1");
|
||||
$next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date > '$thisyear-$thismonth-01'
|
||||
AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
|
||||
AND post_status = 'publish'
|
||||
AND post_type = 'post' AND post_status = 'publish'
|
||||
ORDER BY post_date ASC
|
||||
LIMIT 1");
|
||||
|
||||
@@ -508,7 +508,7 @@ function get_calendar($daylength = 1) {
|
||||
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
|
||||
FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
|
||||
AND YEAR(post_date) = $thisyear
|
||||
AND post_status = 'publish'
|
||||
AND post_type = 'post' AND post_status = 'publish'
|
||||
AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
|
||||
if ( $dayswithposts ) {
|
||||
foreach ( $dayswithposts as $daywith ) {
|
||||
@@ -531,7 +531,7 @@ function get_calendar($daylength = 1) {
|
||||
."WHERE YEAR(post_date) = '$thisyear' "
|
||||
."AND MONTH(post_date) = '$thismonth' "
|
||||
."AND post_date < '".current_time('mysql')."' "
|
||||
."AND post_status = 'publish'"
|
||||
."AND post_type = 'post' AND post_status = 'publish'"
|
||||
);
|
||||
if ( $ak_post_titles ) {
|
||||
foreach ( $ak_post_titles as $ak_post_title ) {
|
||||
|
||||
@@ -42,9 +42,9 @@ function get_permalink($id = 0) {
|
||||
);
|
||||
|
||||
$post = &get_post($id);
|
||||
if ( $post->post_status == 'static' )
|
||||
if ( $post->post_type == 'page' )
|
||||
return get_page_link($post->ID);
|
||||
elseif ($post->post_status == 'attachment')
|
||||
elseif ($post->post_type == 'attachment')
|
||||
return get_attachment_link($post->ID);
|
||||
|
||||
$permalink = get_settings('permalink_structure');
|
||||
@@ -261,7 +261,7 @@ function get_previous_post($in_same_cat = false, $excluded_categories = '') {
|
||||
$posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')';
|
||||
}
|
||||
|
||||
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");
|
||||
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");
|
||||
}
|
||||
|
||||
function get_next_post($in_same_cat = false, $excluded_categories = '') {
|
||||
@@ -296,7 +296,7 @@ function get_next_post($in_same_cat = false, $excluded_categories = '') {
|
||||
|
||||
$now = current_time('mysql');
|
||||
|
||||
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");
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ function &get_pages($args = '') {
|
||||
|
||||
$pages = $wpdb->get_results("SELECT * " .
|
||||
"FROM $wpdb->posts " .
|
||||
"WHERE post_status = 'static' " .
|
||||
"WHERE post_type = 'page' AND post_status = 'publish' " .
|
||||
"$exclusions " .
|
||||
"ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
|
||||
|
||||
@@ -450,7 +450,7 @@ function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false)
|
||||
$id = (int) $id;
|
||||
$_post = & get_post($id);
|
||||
|
||||
if ( ('attachment' != $_post->post_status) || ('' == $_post->guid) )
|
||||
if ( ('attachment' != $_post->post_type) || ('' == $_post->guid) )
|
||||
return __('Missing Attachment');
|
||||
|
||||
if (! empty($_post->guid) ) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
|
||||
|
||||
$wp_version = '2.0.1';
|
||||
$wp_db_version = 3437;
|
||||
$wp_version = '2.1-aplha1';
|
||||
$wp_db_version = 3506;
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user