mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
Duplicate comment number queries.
git-svn-id: http://svn.automattic.com/wordpress/trunk@681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d4e328c130
commit
11d47e1330
@ -1556,13 +1556,9 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
|
|||||||
|
|
||||||
// generic comments/trackbacks/pingbacks numbering
|
// generic comments/trackbacks/pingbacks numbering
|
||||||
|
|
||||||
function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $include_unapproved = false) {
|
function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number) {
|
||||||
global $id, $comment, $tablecomments, $wpdb;
|
global $id, $comment, $tablecomments, $wpdb;
|
||||||
$query = "SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id";
|
if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
|
||||||
if (false == $include_unapproved) {
|
|
||||||
$query .= " AND comment_approved = '1'";
|
|
||||||
}
|
|
||||||
$number = $wpdb->get_var($query);
|
|
||||||
if ($number == 0) {
|
if ($number == 0) {
|
||||||
$blah = $zero;
|
$blah = $zero;
|
||||||
} elseif ($number == 1) {
|
} elseif ($number == 1) {
|
||||||
@ -1593,7 +1589,7 @@ function comments_popup_script($width=400, $height=400, $file='wp-comments-popup
|
|||||||
function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
|
function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
|
||||||
global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash;
|
global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash;
|
||||||
global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
|
global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
|
||||||
$number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
|
$number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1';");
|
||||||
if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
|
if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
|
||||||
echo $none;
|
echo $none;
|
||||||
return;
|
return;
|
||||||
@ -1618,7 +1614,7 @@ function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Com
|
|||||||
echo ' class="'.$CSSclass.'"';
|
echo ' class="'.$CSSclass.'"';
|
||||||
}
|
}
|
||||||
echo '>';
|
echo '>';
|
||||||
comments_number($zero, $one, $more);
|
comments_number($zero, $one, $more, $number);
|
||||||
echo '</a>';
|
echo '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
define('OBJECT', 'OBJECT', true);
|
define('OBJECT', 'OBJECT', true);
|
||||||
define('ARRAY_A', 'ARRAY_A', true);
|
define('ARRAY_A', 'ARRAY_A', true);
|
||||||
define('ARRAY_N', 'ARRAY_N', true);
|
define('ARRAY_N', 'ARRAY_N', true);
|
||||||
|
define('SAVEQUERIES', true);
|
||||||
|
|
||||||
// The Main Class, renamed to avoid conflicts.
|
// The Main Class, renamed to avoid conflicts.
|
||||||
|
|
||||||
@ -155,6 +156,9 @@
|
|||||||
// Perform the query via std mysql_query function..
|
// Perform the query via std mysql_query function..
|
||||||
$this->result = mysql_query($query, $this->dbh);
|
$this->result = mysql_query($query, $this->dbh);
|
||||||
++$this->querycount;
|
++$this->querycount;
|
||||||
|
if (SAVEQUERIES) {
|
||||||
|
$this->savedqueries[] = $query;
|
||||||
|
}
|
||||||
|
|
||||||
// If there was an insert, delete or update see how many rows were affected
|
// If there was an insert, delete or update see how many rows were affected
|
||||||
// (Also, If there there was an insert take note of the insert_id
|
// (Also, If there there was an insert take note of the insert_id
|
||||||
|
Loading…
Reference in New Issue
Block a user