Make WordPress Core

Changeset 760


Ignore:
Timestamp:
01/12/2004 11:52:35 AM (21 years ago)
Author:
saxmatt
Message:

Performance optimizations.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r737 r760  
    22/* Don't remove these lines. */
    33$blog = 1;
    4 require_once('wp-blog-header.php');
     4require('wp-blog-header.php');
    55// Uncomment the next line if you want to track blog updates from weblogs.com
    66//include_once(ABSPATH.WPINC.'/links-update-xml.php');
  • trunk/wp-blog-header.php

    r756 r760  
    99    die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='wp-admin/install-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
    1010
    11 require_once ($curpath.'/wp-config.php');
     11require($curpath.'/wp-config.php');
    1212
    1313$wpvarstoreset = array('m','p','posts','w','c', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'name', 'category_name');
     
    340340
    341341    // Do the same for comment numbers
    342 
     342    $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
     343        FROM $tableposts
     344        LEFT JOIN $tablecomments ON ( comment_post_ID = ID  AND comment_approved =  '1')
     345        WHERE post_status =  'publish' AND ID IN ($post_id_list)
     346        GROUP BY ID");
     347   
     348    foreach ($comment_counts as $comment_count) {
     349        $comment_count_cache["$comment_count->ID"] = $comment_count->ccount;
     350    }
    343351
    344352    if (1 == count($posts)) {
  • trunk/wp-includes/template-functions.php

    r752 r760  
    863863}
    864864
    865 function the_title($before='', $after='', $echo=true) {
     865function the_title($before = '', $after = '', $echo = true) {
    866866    $title = get_the_title();
    867     $title = convert_bbcode($title);
    868     $title = convert_gmcode($title);
    869867    $title = convert_smilies($title);
    870     if ($title) {
     868    if (!empty($title)) {
    871869        $title = convert_chars($before.$title.$after);
    872870        $title = apply_filters('the_title', $title);
     
    879877function the_title_rss() {
    880878    $title = get_the_title();
    881     $title = convert_bbcode($title);
    882     $title = convert_gmcode($title);
    883879    $title = strip_tags($title);
    884880    if (trim($title)) {
     
    897893}
    898894function get_the_title() {
    899     global $id, $post;
     895    global $post;
    900896    $output = stripslashes($post->post_title);
    901897    if (!empty($post->post_password)) { // if there's a password
     
    14471443}
    14481444
    1449 // out of the b2 loop
     1445// out of the WordPress loop
    14501446function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc',
    14511447                       $optiondates = 0, $optioncount = 0, $hide_empty = 1) {
     
    14891485}
    14901486
    1491 // out of the b2 loop
    1492 function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc',
    1493                    $file = 'blah', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1) {
     1487// out of the WordPress loop
     1488function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1) {
    14941489    global $tablecategories, $tableposts, $tablepost2cat, $wpdb;
    14951490    global $pagenow, $siteurl, $blogfilename;
    14961491    global $querystring_start, $querystring_equal, $querystring_separator;
    1497     if (($file == 'blah') || ($file == '')) {
     1492    // Optiondates does not currently work
     1493    if ('' == $file) {
    14981494        $file = "$siteurl/$blogfilename";
    14991495    }
     
    15011497
    15021498    $query  = "
    1503         SELECT cat_ID, cat_name, category_nicename,
    1504         COUNT($tablepost2cat.post_id) AS cat_count,
    1505         DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
    1506         FROM $tablecategories LEFT JOIN $tablepost2cat ON (cat_ID = category_id)
    1507         LEFT JOIN $tableposts ON (ID = post_id)
     1499        SELECT cat_ID, cat_name, category_nicename
     1500        FROM $tablecategories
    15081501        WHERE cat_ID > 0
    1509         GROUP BY category_id
    15101502        ";
     1503    $query .= " ORDER BY $sort_column $sort_order";
     1504
     1505    $categories = $wpdb->get_results($query);
     1506
    15111507    if (intval($hide_empty) == 1) {
    1512         $query .= " HAVING cat_count > 0";
     1508        $cat_counts = $wpdb->get_results("  SELECT cat_ID,
     1509        COUNT(wp_post2cat.post_id) AS cat_count
     1510        FROM wp_categories LEFT JOIN wp_post2cat ON (cat_ID = category_id)
     1511        LEFT JOIN wp_posts ON (ID = post_id)
     1512        GROUP BY category_id");
     1513        foreach ($cat_counts as $cat_count) {
     1514            $category_posts["$cat_count->cat_ID"] = $cat_count->cat_count;
     1515        }
    15131516    }
    1514     $query .= " ORDER BY $sort_column $sort_order, post_date DESC";
    1515 
    1516     $categories = $wpdb->get_results($query);
     1517
     1518   if (intval($optioncount) == 1) {
     1519        $link .= '&nbsp;('.$category->cat_count.')';
     1520    }
     1521
    15171522    if (!$categories) {
    15181523        if ($list) {
     
    15231528        return;
    15241529    }
    1525     if (intval($optionall) == 1) {
    1526         $all = apply_filters('list_cats', $all);
    1527         $link = "<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a>";
    1528         if ($list) echo "\n\t<li>$link</li>";
    1529         else echo "\t$link<br />\n";
    1530     }
    15311530
    15321531    foreach ($categories as $category) {
    1533         $cat_name = apply_filters('list_cats', $category->cat_name);
    15341532        $link = '<a href="'.get_category_link(0, $category->cat_ID, $category->category_nicename).'" title="View all posts filed under ' . $category->cat_name . '">';
    1535         $link .= stripslashes($cat_name).'</a>';
     1533        $link .= stripslashes($category->cat_name).'</a>';
    15361534        if (intval($optioncount) == 1) {
    1537             $link .= '&nbsp;('.$category->cat_count.')';
     1535            $link .= ' ('.$category_posts["$category->cat_ID"].')';
    15381536        }
    15391537        if (intval($optiondates) == 1) {
    1540             $link .= '&nbsp;'.$category->lastday.'/'.$category->lastmonth;
     1538            $link .= ' '.$category->lastday.'/'.$category->lastmonth;
    15411539        }
    15421540        if ($list) {
     
    15811579function comments_link($file='', $echo=true) {
    15821580    global $id, $pagenow;
    1583     global $querystring_start, $querystring_equal, $querystring_separator;
    15841581    if ($file == '')    $file = $pagenow;
    15851582    if ($file == '/')   $file = '';
     
    15991596    global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash;
    16001597    global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
    1601     $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1';");
     1598    global $comment_count_cache;
     1599    if ('' == $comment_count_cache["$id"]) {
     1600        $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1';");
     1601    } else {
     1602        $number = $comment_count_cache["$id"];
     1603    }
    16021604    if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
    16031605        echo $none;
Note: See TracChangeset for help on using the changeset viewer.