Changeset 5861
- Timestamp:
- 09/03/2017 09:58:57 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
r5859 r5861 232 232 * Return the raw database count of topics by a user, excluding reviews. 233 233 * 234 * @global wpdb $wpdb WordPress database abstraction object.235 *236 234 * @param int $user_id User ID to get count for. 237 235 * @return int Raw DB count of topics. 238 236 */ 239 237 function wporg_support_get_user_topics_count( $user_id = 0 ) { 240 global $wpdb;241 242 $user_id = bbp_get_user_id( $user_id );243 if ( empty( $user_id ) ) {244 return 0;245 }246 247 238 if ( ! class_exists( 'WordPressdotorg\Forums\Plugin' ) ) { 248 239 return 0; 249 240 } 250 241 251 $count = (int) $wpdb->get_var( $wpdb->prepare( 252 "SELECT COUNT(*) 253 FROM {$wpdb->posts} 254 WHERE post_type = 'topic' 255 AND post_status IN ( 'publish', 'closed' ) 256 AND post_parent <> %d 257 AND post_author = %d", 258 WordPressdotorg\Forums\Plugin::REVIEWS_FORUM_ID, 259 $user_id 260 ) ); 261 262 return $count; 242 $plugin_instance = WordPressdotorg\Forums\Plugin::get_instance(); 243 244 return $plugin_instance->users->get_user_topics_count( $user_id ); 263 245 } 264 246 265 247 /** 266 248 * Return the raw database count of reviews by a user. 267 *268 * @global wpdb $wpdb WordPress database abstraction object.269 249 * 270 250 * @param int $user_id User ID to get count for. … … 272 252 */ 273 253 function wporg_support_get_user_reviews_count( $user_id = 0 ) { 274 global $wpdb;275 276 $user_id = bbp_get_user_id( $user_id );277 if ( empty( $user_id ) ) {278 return 0;279 }280 281 254 if ( ! class_exists( 'WordPressdotorg\Forums\Plugin' ) ) { 282 255 return 0; 283 256 } 284 257 285 $count = (int) $wpdb->get_var( $wpdb->prepare( 286 "SELECT COUNT(*) 287 FROM {$wpdb->posts} 288 WHERE post_type = 'topic' 289 AND post_status IN ( 'publish', 'closed' ) 290 AND post_parent = %d 291 AND post_author = %d", 292 WordPressdotorg\Forums\Plugin::REVIEWS_FORUM_ID, 293 $user_id 294 ) ); 295 296 return $count; 258 $plugin_instance = WordPressdotorg\Forums\Plugin::get_instance(); 259 260 return $plugin_instance->users->get_user_reviews_count( $user_id ); 297 261 } 298 262
Note: See TracChangeset
for help on using the changeset viewer.