Changeset 6542
- Timestamp:
- 06/14/2017 02:14:39 PM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bbpress.php
r6535 r6542 205 205 /** Versions **********************************************************/ 206 206 207 $this->version = '2.6-rc-65 35';207 $this->version = '2.6-rc-6541'; 208 208 $this->db_version = '262'; 209 209 -
trunk/src/includes/admin/assets/css/admin.css
r6537 r6542 53 53 #dashboard_right_now a.bbp-glance-topic-tags:before { 54 54 content: "\f323"; 55 } 56 57 #dashboard_right_now a.bbp-glance-users:before { 58 content: "\f110"; 55 59 } 56 60 -
trunk/src/includes/admin/metaboxes.php
r6438 r6542 20 20 function bbp_filter_dashboard_glance_items( $elements = array() ) { 21 21 22 // Bail if user cannot spectate 23 if ( ! current_user_can( 'spectate' ) ) { 24 return $elements; 25 } 26 22 27 // Get the statistics 23 $r = bbp_get_statistics(); 28 $r = bbp_get_statistics( array( 29 'count_pending_topics' => false, 30 'count_private_topics' => false, 31 'count_spammed_topics' => false, 32 'count_trashed_topics' => false, 33 'count_pending_replies' => false, 34 'count_private_replies' => false, 35 'count_spammed_replies' => false, 36 'count_trashed_replies' => false, 37 'count_empty_tags' => false 38 )); 39 40 // Users 41 if ( isset( $r['user_count'] ) ) { 42 $link = admin_url( 'users.php' ); 43 $text = sprintf( _n( '%s User', '%s Users', $r['user_count_int'], 'bbpress' ), $r['user_count'] ); 44 $elements[] = current_user_can( 'edit_users' ) 45 ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-users">' . esc_html( $text ) . '</a>' 46 : esc_html( $text ); 47 } 24 48 25 49 // Forums 26 if ( current_user_can( 'publish_forums') ) {27 $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), get_admin_url( null,'edit.php' ) );50 if ( isset( $r['forum_count'] ) ) { 51 $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), admin_url( 'edit.php' ) ); 28 52 $text = sprintf( _n( '%s Forum', '%s Forums', $r['forum_count_int'], 'bbpress' ), $r['forum_count'] ); 29 $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-forums">' . esc_html( $text ) . '</a>'; 53 $elements[] = current_user_can( 'publish_forums' ) 54 ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-forums">' . esc_html( $text ) . '</a>' 55 : esc_html( $text ); 30 56 } 31 57 32 58 // Topics 33 if ( current_user_can( 'publish_topics') ) {34 $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null,'edit.php' ) );59 if ( isset( $r['topic_count'] ) ) { 60 $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); 35 61 $text = sprintf( _n( '%s Topic', '%s Topics', $r['topic_count_int'], 'bbpress' ), $r['topic_count'] ); 36 $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-topics">' . esc_html( $text ) . '</a>'; 62 $elements[] = current_user_can( 'publish_topics' ) 63 ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-topics">' . esc_html( $text ) . '</a>' 64 : esc_html( $text ); 37 65 } 38 66 39 67 // Replies 40 if ( current_user_can( 'publish_replies') ) {41 $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null,'edit.php' ) );68 if ( isset( $r['reply_count'] ) ) { 69 $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); 42 70 $text = sprintf( _n( '%s Reply', '%s Replies', $r['reply_count_int'], 'bbpress' ), $r['reply_count'] ); 43 $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-replies">' . esc_html( $text ) . '</a>'; 71 $elements[] = current_user_can( 'publish_replies' ) 72 ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-replies">' . esc_html( $text ) . '</a>' 73 : esc_html( $text ); 44 74 } 45 75 46 76 // Topic Tags 47 if ( bbp_allow_topic_tags() && current_user_can( 'manage_topic_tags') ) {48 $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null,'edit-tags.php' ) );77 if ( bbp_allow_topic_tags() && isset( $r['topic_tag_count'] ) ) { 78 $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit-tags.php' ) ); 49 79 $text = sprintf( _n( '%s Topic Tag', '%s Topic Tags', $r['topic_tag_count_int'], 'bbpress' ), $r['topic_tag_count'] ); 50 $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-topic-tags">' . esc_html( $text ) . '</a>'; 80 $elements[] = current_user_can( 'manage_topic_tags' ) 81 ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-topic-tags">' . esc_html( $text ) . '</a>' 82 : esc_html( $text ); 51 83 } 52 84 … … 97 129 $text = _n( 'Forum', 'Forums', $r['forum_count_int'], 'bbpress' ); 98 130 if ( current_user_can( 'publish_forums' ) ) { 99 $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), get_admin_url( null,'edit.php' ) );131 $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), admin_url( 'edit.php' ) ); 100 132 $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 101 133 $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; … … 114 146 $text = _n( 'Topic', 'Topics', $r['topic_count_int'], 'bbpress' ); 115 147 if ( current_user_can( 'publish_topics' ) ) { 116 $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null,'edit.php' ) );148 $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); 117 149 $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 118 150 $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; … … 131 163 $text = _n( 'Reply', 'Replies', $r['reply_count_int'], 'bbpress' ); 132 164 if ( current_user_can( 'publish_replies' ) ) { 133 $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null,'edit.php' ) );165 $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); 134 166 $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 135 167 $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; … … 150 182 $text = _n( 'Topic Tag', 'Topic Tags', $r['topic_tag_count_int'], 'bbpress' ); 151 183 if ( current_user_can( 'manage_topic_tags' ) ) { 152 $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null,'edit-tags.php' ) );184 $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit-tags.php' ) ); 153 185 $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 154 186 $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; … … 182 214 $text = _n( 'User', 'Users', $r['user_count_int'], 'bbpress' ); 183 215 if ( current_user_can( 'edit_users' ) ) { 184 $link = get_admin_url( null,'users.php' );216 $link = admin_url( 'users.php' ); 185 217 $num = '<a href="' . $link . '">' . $num . '</a>'; 186 218 $text = '<a href="' . $link . '">' . $text . '</a>'; … … 200 232 $num = $r['topic_count_hidden']; 201 233 $text = _n( 'Hidden Topic', 'Hidden Topics', $r['topic_count_hidden_int'], 'bbpress' ); 202 $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null,'edit.php' ) );234 $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); 203 235 if ( '0' !== $num ) { 204 236 $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); … … 222 254 $num = $r['reply_count_hidden']; 223 255 $text = _n( 'Hidden Reply', 'Hidden Replies', $r['reply_count_hidden_int'], 'bbpress' ); 224 $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null,'edit.php' ) );256 $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); 225 257 if ( '0' !== $num ) { 226 258 $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); … … 244 276 $num = $r['empty_topic_tag_count']; 245 277 $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $r['empty_topic_tag_count_int'], 'bbpress' ); 246 $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null,'edit-tags.php' ) );278 $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit-tags.php' ) ); 247 279 $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; 248 280 $text = '<a class="waiting" href="' . esc_url( $link ) . '">' . $text . '</a>'; -
trunk/src/includes/common/functions.php
r6529 r6542 323 323 324 324 // Defaults 325 $user_count = 0; 326 $forum_count = 0; 327 $topic_count = 0; 328 $topic_count_hidden = 0; 329 $reply_count = 0; 330 $reply_count_hidden = 0; 331 $topic_tag_count = 0; 332 $empty_topic_tag_count = 0; 325 $topic_count = $topic_count_hidden = 0; 326 $reply_count = $reply_count_hidden = 0; 327 $topic_tag_count = $empty_topic_tag_count = 0; 333 328 334 329 // Users 335 if ( ! empty( $r['count_users'] ) ) {336 $user_count = bbp_get_total_users();337 }330 $user_count = ! empty( $r['count_users'] ) 331 ? bbp_get_total_users() 332 : 0; 338 333 339 334 // Forums 340 if ( ! empty( $r['count_forums'] ) ) {341 $forum_count = wp_count_posts( bbp_get_forum_post_type() )->publish;342 }335 $forum_count = ! empty( $r['count_forums'] ) 336 ? wp_count_posts( bbp_get_forum_post_type() )->publish 337 : 0; 343 338 344 339 // Post statuses … … 362 357 363 358 // Pending 364 $topics['pending'] = ( ! empty( $r['count_pending_topics'] ) && current_user_can( 'edit_others_topics' ) ) ? (int) $all_topics->{$pending} : 0; 359 $topics['pending'] = ( ! empty( $r['count_pending_topics'] ) && current_user_can( 'edit_others_topics' ) ) 360 ? (int) $all_topics->{$pending} 361 : 0; 365 362 366 363 // Private 367 $topics['private'] = ( ! empty( $r['count_private_topics'] ) && current_user_can( 'read_private_topics' ) ) ? (int) $all_topics->{$private} : 0; 364 $topics['private'] = ( ! empty( $r['count_private_topics'] ) && current_user_can( 'read_private_topics' ) ) 365 ? (int) $all_topics->{$private} 366 : 0; 368 367 369 368 // Spam 370 $topics['spammed'] = ( ! empty( $r['count_spammed_topics'] ) && current_user_can( 'edit_others_topics' ) ) ? (int) $all_topics->{$spam} : 0; 369 $topics['spammed'] = ( ! empty( $r['count_spammed_topics'] ) && current_user_can( 'edit_others_topics' ) ) 370 ? (int) $all_topics->{$spam} 371 : 0; 371 372 372 373 // Trash 373 $topics['trashed'] = ( ! empty( $r['count_trashed_topics'] ) && current_user_can( 'view_trash' ) ) ? (int) $all_topics->{$trash} : 0; 374 $topics['trashed'] = ( ! empty( $r['count_trashed_topics'] ) && current_user_can( 'view_trash' ) ) 375 ? (int) $all_topics->{$trash} 376 : 0; 374 377 375 378 // Total hidden (pending + private + spam + trash) … … 377 380 378 381 // Generate the hidden topic count's title attribute 379 $topic_titles[] = ! empty( $topics['pending'] ) ? sprintf( __( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $topics['pending'] ) ) : ''; 380 $topic_titles[] = ! empty( $topics['private'] ) ? sprintf( __( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics['private'] ) ) : ''; 381 $topic_titles[] = ! empty( $topics['spammed'] ) ? sprintf( __( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['spammed'] ) ) : ''; 382 $topic_titles[] = ! empty( $topics['trashed'] ) ? sprintf( __( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['trashed'] ) ) : ''; 382 $topic_titles[] = ! empty( $topics['pending'] ) 383 ? sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $topics['pending'] ) ) 384 : ''; 385 386 $topic_titles[] = ! empty( $topics['private'] ) 387 ? sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics['private'] ) ) 388 : ''; 389 390 $topic_titles[] = ! empty( $topics['spammed'] ) 391 ? sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['spammed'] ) ) 392 : ''; 393 394 $topic_titles[] = ! empty( $topics['trashed'] ) 395 ? sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['trashed'] ) ) 396 : ''; 383 397 384 398 // Compile the hidden topic title … … 401 415 402 416 // Pending 403 $replies['pending'] = ( ! empty( $r['count_pending_replies'] ) && current_user_can( 'edit_others_replies' ) ) ? (int) $all_replies->{$pending} : 0; 417 $replies['pending'] = ( ! empty( $r['count_pending_replies'] ) && current_user_can( 'edit_others_replies' ) ) 418 ? (int) $all_replies->{$pending} 419 : 0; 404 420 405 421 // Private 406 $replies['private'] = ( ! empty( $r['count_private_replies'] ) && current_user_can( 'read_private_replies' ) ) ? (int) $all_replies->{$private} : 0; 422 $replies['private'] = ( ! empty( $r['count_private_replies'] ) && current_user_can( 'read_private_replies' ) ) 423 ? (int) $all_replies->{$private} 424 : 0; 407 425 408 426 // Spam 409 $replies['spammed'] = ( ! empty( $r['count_spammed_replies'] ) && current_user_can( 'edit_others_replies' ) ) ? (int) $all_replies->{$spam} : 0; 427 $replies['spammed'] = ( ! empty( $r['count_spammed_replies'] ) && current_user_can( 'edit_others_replies' ) ) 428 ? (int) $all_replies->{$spam} 429 : 0; 410 430 411 431 // Trash 412 $replies['trashed'] = ( ! empty( $r['count_trashed_replies'] ) && current_user_can( 'view_trash' ) ) ? (int) $all_replies->{$trash} : 0; 432 $replies['trashed'] = ( ! empty( $r['count_trashed_replies'] ) && current_user_can( 'view_trash' ) ) 433 ? (int) $all_replies->{$trash} 434 : 0; 413 435 414 436 // Total hidden (pending + private + spam + trash) … … 416 438 417 439 // Generate the hidden topic count's title attribute 418 $reply_titles[] = ! empty( $replies['pending'] ) ? sprintf( __( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $replies['pending'] ) ) : ''; 419 $reply_titles[] = ! empty( $replies['private'] ) ? sprintf( __( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies['private'] ) ) : ''; 420 $reply_titles[] = ! empty( $replies['spammed'] ) ? sprintf( __( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['spammed'] ) ) : ''; 421 $reply_titles[] = ! empty( $replies['trashed'] ) ? sprintf( __( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['trashed'] ) ) : ''; 440 $reply_titles[] = ! empty( $replies['pending'] ) 441 ? sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $replies['pending'] ) ) 442 : ''; 443 $reply_titles[] = ! empty( $replies['private'] ) 444 ? sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies['private'] ) ) 445 : ''; 446 447 $reply_titles[] = ! empty( $replies['spammed'] ) 448 ? sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['spammed'] ) ) 449 : ''; 450 451 $reply_titles[] = ! empty( $replies['trashed'] ) 452 ? sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['trashed'] ) ) 453 : ''; 422 454 423 455 // Compile the hidden replies title … … 439 471 440 472 // Tally the tallies 441 $counts = array_ map( 'absint', compact(473 $counts = array_filter( array_map( 'absint', compact( 442 474 'user_count', 443 475 'forum_count', … … 448 480 'topic_tag_count', 449 481 'empty_topic_tag_count' 450 ) ) ;482 ) ) ); 451 483 452 484 // Loop through and store the integer and i18n formatted counts. … … 462 494 463 495 // Filter & return 464 return apply_filters( 'bbp_get_statistics', $statistics, $r, $args );496 return (array) apply_filters( 'bbp_get_statistics', $statistics, $r, $args ); 465 497 } 466 498 … … 506 538 $r['bbp_anonymous_name'] = apply_filters( 'bbp_pre_anonymous_post_author_name', $r['bbp_anonymous_name'] ); 507 539 if ( empty( $r['bbp_anonymous_name'] ) ) { 508 bbp_add_error( 'bbp_anonymous_name', __( '<strong>ERROR</strong>: Invalid author name.', 'bbpress' ) );540 bbp_add_error( 'bbp_anonymous_name', esc_html__( '<strong>ERROR</strong>: Invalid author name.', 'bbpress' ) ); 509 541 } 510 542 … … 512 544 $r['bbp_anonymous_email'] = apply_filters( 'bbp_pre_anonymous_post_author_email', $r['bbp_anonymous_email'] ); 513 545 if ( empty( $r['bbp_anonymous_email'] ) ) { 514 bbp_add_error( 'bbp_anonymous_email', __( '<strong>ERROR</strong>: Invalid email address.', 'bbpress' ) );546 bbp_add_error( 'bbp_anonymous_email', esc_html__( '<strong>ERROR</strong>: Invalid email address.', 'bbpress' ) ); 515 547 } 516 548 … … 1135 1167 1136 1168 // For plugins to filter messages per reply/topic/user 1137 $message = sprintf( __( '%1$s wrote:1169 $message = sprintf( esc_html__( '%1$s wrote: 1138 1170 1139 1171 %2$s … … 1300 1332 1301 1333 // For plugins to filter messages per reply/topic/user 1302 $message = sprintf( __( '%1$s wrote:1334 $message = sprintf( esc_html__( '%1$s wrote: 1303 1335 1304 1336 %2$s … … 2124 2156 2125 2157 if ( ! isset( $wp_query ) ) { 2126 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '3.1' );2158 _doing_it_wrong( __FUNCTION__, esc_html__( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '3.1' ); 2127 2159 return false; 2128 2160 } -
trunk/src/includes/core/abstraction.php
r6438 r6542 169 169 function bbp_is_large_install() { 170 170 171 // Default to false 172 $retval = false; 171 // Multisite has a function specifically for this 172 $retval = function_exists( 'wp_is_large_network' ) 173 ? wp_is_large_network( 'users' ) 174 : ( bbp_get_total_users() > 10000 ); 173 175 174 // Multisite has a function specifically for this 175 if ( function_exists( 'wp_is_large_network' ) ) { 176 $retval = wp_is_large_network( 'users' ); 177 } else { 178 $bbp_db = bbp_db(); 179 $count = $bbp_db->get_var( "SELECT COUNT(ID) as c FROM {$bbp_db->users} WHERE user_status = '0'" ); 180 $retval = apply_filters( 'wp_is_large_network', ( $count > 10000 ), 'users', $count ); 181 } 176 // Filter & return 177 return (bool) apply_filters( 'bbp_is_large_install', $retval ); 178 } 182 179 183 return (bool) $retval; 180 /** 181 * Get the total number of users on the forums 182 * 183 * @since 2.0.0 bbPress (r2769) 184 * 185 * @uses apply_filters() Calls 'bbp_get_total_users' with number of users 186 * @return int Total number of users 187 */ 188 function bbp_get_total_users() { 189 $bbp_db = bbp_db(); 190 $count = $bbp_db->get_var( "SELECT COUNT(ID) as c FROM {$bbp_db->users} WHERE user_status = '0'" ); 191 192 // Filter & return 193 return (int) apply_filters( 'bbp_get_total_users', (int) $count ); 184 194 } -
trunk/src/includes/users/functions.php
r6505 r6542 592 592 593 593 /** 594 * Get the total number of users on the forums595 *596 * @since 2.0.0 bbPress (r2769)597 *598 * @uses count_users() To execute our query and get the var back599 * @uses apply_filters() Calls 'bbp_get_total_users' with number of users600 * @return int Total number of users601 */602 function bbp_get_total_users() {603 $user_count = count_users();604 605 // Filter & return606 return (int) apply_filters( 'bbp_get_total_users', (int) $user_count['total_users'] );607 }608 609 /**610 594 * Get user IDs from nicenames 611 595 *
Note: See TracChangeset
for help on using the changeset viewer.