Changeset 5860
- Timestamp:
- 09/03/2017 09:29:57 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php
r5657 r5860 264 264 } 265 265 266 /** 267 * Return the raw database count of topics by a user, excluding reviews. 268 * 269 * @global wpdb $wpdb WordPress database abstraction object. 270 * 271 * @param int $user_id User ID to get count for. 272 * @return int Raw DB count of topics. 273 */ 274 public function get_user_topics_count( $user_id = 0 ) { 275 global $wpdb; 276 277 $user_id = bbp_get_user_id( $user_id ); 278 if ( empty( $user_id ) ) { 279 return 0; 280 } 281 282 if ( ! class_exists( 'WordPressdotorg\Forums\Plugin' ) ) { 283 return 0; 284 } 285 286 $count = (int) $wpdb->get_var( $wpdb->prepare( 287 "SELECT COUNT(*) 288 FROM {$wpdb->posts} 289 WHERE post_type = 'topic' 290 AND post_status IN ( 'publish', 'closed' ) 291 AND post_parent <> %d 292 AND post_author = %d", 293 Plugin::REVIEWS_FORUM_ID, 294 $user_id 295 ) ); 296 297 return $count; 298 } 299 300 /** 301 * Cle the raw database count of reviews by a user. 302 * 303 * @global wpdb $wpdb WordPress database abstraction object. 304 * 305 * @param int $user_id User ID to get count for. 306 * @return int Raw DB count of reviews. 307 */ 308 public function get_user_reviews_count( $user_id = 0 ) { 309 global $wpdb; 310 311 $user_id = bbp_get_user_id( $user_id ); 312 if ( empty( $user_id ) ) { 313 return 0; 314 } 315 316 if ( ! class_exists( 'WordPressdotorg\Forums\Plugin' ) ) { 317 return 0; 318 } 319 320 $count = (int) $wpdb->get_var( $wpdb->prepare( 321 "SELECT COUNT(*) 322 FROM {$wpdb->posts} 323 WHERE post_type = 'topic' 324 AND post_status IN ( 'publish', 'closed' ) 325 AND post_parent = %d 326 AND post_author = %d", 327 Plugin::REVIEWS_FORUM_ID, 328 $user_id 329 ) ); 330 331 return $count; 332 } 333 266 334 }
Note: See TracChangeset
for help on using the changeset viewer.