Changeset 570 for trunk/b2-include/b2template.functions.php
- Timestamp:
- 12/05/2003 01:27:00 AM (23 years ago)
- File:
-
- 1 edited
-
trunk/b2-include/b2template.functions.php (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/b2-include/b2template.functions.php
r565 r570 127 127 function get_archives($type='', $limit='', $format='html', $before = "", $after = "", $show_post_count = false) { 128 128 global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename; 129 global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week , $querycount;129 global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week; 130 130 131 131 if ('' == $type) { … … 164 164 165 165 if ('monthly' == $type) { 166 ++$querycount;167 166 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); 168 167 if ($arcresults) { … … 179 178 } 180 179 } elseif ('daily' == $type) { 181 ++$querycount;182 180 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 183 181 if ($arcresults) { … … 193 191 $start_of_week = 1; 194 192 } 195 ++$querycount;196 193 $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 $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 197 194 $arc_w_last = ''; … … 213 210 } 214 211 } elseif ('postbypost' == $type) { 215 ++$querycount;216 212 $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 217 213 if ($arcresults) { … … 233 229 234 230 function get_calendar($daylength = 1) { 235 global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts , $querycount;231 global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts; 236 232 237 233 // Quick check. If we have no posts at all, abort! 238 234 if (!$posts) { 239 235 $gotsome = $wpdb->get_var("SELECT ID from $tableposts WHERE post_status = 'publish' AND post_category > 0 ORDER BY post_date DESC LIMIT 1"); 240 ++$querycount;241 236 if (!$gotsome) 242 237 return; … … 255 250 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's 256 251 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); 257 ++$querycount;258 252 } elseif (!empty($m)) { 259 253 $calendar = substr($m, 0, 6); … … 278 272 ORDER BY post_date DESC 279 273 LIMIT 1"); 280 ++$querycount;281 274 $next = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year 282 275 FROM $tableposts … … 286 279 ORDER BY post_date ASC 287 280 LIMIT 1"); 288 ++$querycount;289 281 290 282 echo '<table id="wp-calendar"> … … 334 326 AND post_status = 'publish' 335 327 AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N); 336 ++$querycount;337 328 if ($dayswithposts) { 338 329 foreach ($dayswithposts as $daywith) { … … 360 351 ."AND post_status = 'publish'" 361 352 ); 362 ++$querycount;363 353 if ($ak_post_titles) { 364 354 foreach ($ak_post_titles as $ak_post_title) { … … 411 401 function get_permalink($id=false) { 412 402 global $post, $wpdb, $tableposts; 413 global $siteurl, $blogfilename, $querystring_start, $querystring_equal , $querycount;403 global $siteurl, $blogfilename, $querystring_start, $querystring_equal; 414 404 415 405 $rewritecode = array( … … 435 425 } else { // if an ID is given 436 426 $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id"); 437 ++$querycount;438 427 if ('' != get_settings('permalink_structure')) { 439 428 $unixtime = strtotime($idpost->post_date); … … 1035 1024 1036 1025 function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { 1037 global $tableposts, $id, $post, $siteurl, $blogfilename, $ querycount, $wpdb;1026 global $tableposts, $id, $post, $siteurl, $blogfilename, $wpdb; 1038 1027 global $p, $posts, $posts_per_page, $s, $single; 1039 1028 global $querystring_start, $querystring_equal, $querystring_separator; … … 1060 1049 $limitprev--; 1061 1050 $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $tableposts WHERE post_date < '$current_post_date' AND post_category > 0 AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1"); 1062 ++$querycount;1063 1051 if ($lastpost) { 1064 1052 $string = '<a href="'.get_permalink($lastpost->ID).'">'.$previous; … … 1074 1062 1075 1063 function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { 1076 global $tableposts, $p, $posts, $id, $post, $siteurl, $blogfilename, $ querycount, $wpdb;1064 global $tableposts, $p, $posts, $id, $post, $siteurl, $blogfilename, $wpdb; 1077 1065 global $time_difference, $single; 1078 1066 global $querystring_start, $querystring_equal, $querystring_separator; … … 1101 1089 1102 1090 $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $tableposts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_category > 0 AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date ASC LIMIT $limitnext,1"); 1103 ++$querycount;1104 1091 if ($nextpost) { 1105 1092 $string = '<a href="'.get_permalink($nextpost->ID).'">'.$next; … … 1286 1273 1287 1274 function get_the_category_by_ID($cat_ID) { 1288 global $tablecategories, $ querycount, $cache_categories, $use_cache, $wpdb;1275 global $tablecategories, $cache_categories, $use_cache, $wpdb; 1289 1276 if ((!$cache_categories[$cat_ID]) OR (!$use_cache)) { 1290 1277 $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'"); 1291 ++$querycount;1292 1278 $cache_categories[$cat_ID] = $cat_name; 1293 1279 } else { … … 1319 1305 function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', 1320 1306 $optiondates = 0, $optioncount = 0, $hide_empty = 1) { 1321 global $cat, $tablecategories, $tableposts, $ querycount, $wpdb;1307 global $cat, $tablecategories, $tableposts, $wpdb; 1322 1308 $sort_column = 'cat_'.$sort_column; 1323 1309 … … 1334 1320 1335 1321 $categories = $wpdb->get_results($query); 1336 ++$querycount;1337 1322 echo "<select name='cat' class='postform'>\n"; 1338 1323 if (intval($optionall) == 1) { … … 1362 1347 function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', 1363 1348 $file = 'blah', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1) { 1364 global $tablecategories, $tableposts, $ querycount, $wpdb;1349 global $tablecategories, $tableposts, $wpdb; 1365 1350 global $pagenow, $siteurl, $blogfilename; 1366 1351 global $querystring_start, $querystring_equal, $querystring_separator; … … 1382 1367 1383 1368 $categories = $wpdb->get_results($query); 1384 ++$querycount;1385 1369 if (!$categories) { 1386 1370 if ($list) { … … 1435 1419 1436 1420 function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $include_unapproved = false) { 1437 global $id, $comment, $tablecomments, $ querycount, $wpdb;1421 global $id, $comment, $tablecomments, $wpdb; 1438 1422 $query = "SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id"; 1439 1423 if (false == $include_unapproved) { … … 1441 1425 } 1442 1426 $number = $wpdb->get_var($query); 1443 ++$querycount;1444 1427 if ($number == 0) { 1445 1428 $blah = $zero; … … 1470 1453 1471 1454 function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { 1472 global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $ querycount, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash;1455 global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash; 1473 1456 global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; 1474 1457 $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'"); 1475 ++$querycount;1476 1458 if (0 == $number && 'closed' == $post->comment_status) { 1477 1459 echo $none;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)