mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-18 16:45:31 +01:00
Reducing queries and forward thinking database fields.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1185 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f8e2f4f2f4
commit
51335f97bb
@ -803,6 +803,11 @@ function upgrade_110() {
|
||||
foreach ($unusedoptions as $option) :
|
||||
delete_option($option);
|
||||
endforeach;
|
||||
|
||||
// Forward-thinking
|
||||
$wpdb->query("ALTER TABLE `$tableposts` CHANGE `post_status` `post_status` ENUM( 'publish', 'draft', 'private', 'static' ) DEFAULT 'publish' NOT NULL");
|
||||
}
|
||||
|
||||
maybe_add_column($tableposts, 'post_parent', "ALTER TABLE `$tableposts` ADD `post_parent` INT NOT NULL ;");
|
||||
|
||||
?>
|
@ -30,8 +30,9 @@ function clean_url($url) {
|
||||
}
|
||||
|
||||
function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') {
|
||||
global $id, $comment, $tablecomments, $wpdb;
|
||||
if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
|
||||
global $id, $comment, $tablecomments, $wpdb, $comment_count_cache;
|
||||
if ('' == $comment_count_cache["$id"]) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
|
||||
else $number = $comment_count_cache["$id"];
|
||||
if ($number == 0) {
|
||||
$blah = $zero;
|
||||
} elseif ($number == 1) {
|
||||
|
@ -92,7 +92,7 @@ function get_bloginfo($show='') {
|
||||
|
||||
function wp_title($sep = '»', $display = true) {
|
||||
global $wpdb, $tableposts, $tablecategories;
|
||||
global $year, $monthnum, $day, $cat, $p, $name, $month;
|
||||
global $year, $monthnum, $day, $cat, $p, $name, $month, $posts, $single;
|
||||
|
||||
// If there's a category
|
||||
if(!empty($cat)) {
|
||||
@ -122,26 +122,8 @@ function wp_title($sep = '»', $display = true) {
|
||||
}
|
||||
|
||||
// If there's a post
|
||||
if (intval($p) || '' != $name) {
|
||||
if (!$p) {
|
||||
if ($year != '') {
|
||||
$year = '' . intval($year);
|
||||
$where .= ' AND YEAR(post_date)=' . $year;
|
||||
}
|
||||
|
||||
if ($monthnum != '') {
|
||||
$monthnum = '' . intval($monthnum);
|
||||
$where .= ' AND MONTH(post_date)=' . $monthnum;
|
||||
}
|
||||
|
||||
if ($day != '') {
|
||||
$day = '' . intval($day);
|
||||
$where .= ' AND DAYOFMONTH(post_date)=' . $day;
|
||||
}
|
||||
$p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name' $where");
|
||||
}
|
||||
$post_data = get_postdata($p);
|
||||
$title = strip_tags(stripslashes($post_data['Title']));
|
||||
if ($single) {
|
||||
$title = strip_tags(stripslashes($posts[0]->post_title));
|
||||
$title = apply_filters('single_post_title', $title);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user