Changeset 3109477
- Timestamp:
- 06/28/2024 10:20:12 PM (6 weeks ago)
- Location:
- bbpress/trunk
- Files:
-
- 1 added
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
bbpress/trunk/bbpress.php
r3109424 r3109477 6 6 * bbPress is forum software with a twist from the creators of WordPress. 7 7 * 8 * $Id: bbpress.php 72 15 2021-10-15 14:25:11Z johnjamesjacoby $8 * $Id: bbpress.php 72Z johnjamesjacoby $ 9 9 * 10 10 * @package bbPress … … 18 18 * Author: The bbPress Contributors 19 19 * Author URI: https://bbpress.org 20 21 20 22 * Text Domain: bbpress 21 23 * Domain Path: /languages/ 22 * License: GPLv2 or later (license.txt)23 24 * Requires PHP: 5.6.20 24 25 * Requires at least: 6.0 25 26 * Tested up to: 6.5 26 * Version: 2.7.0-alpha 27 * Version: 2.7.0-alpha 27 28 */ 28 29 -
bbpress/trunk/includes/admin/assets/css/admin.css
r2476819 r3109477 1 1 2 /* Kludge for too-wide forums dropdown*/2 /* Kludge for too-wide */ 3 3 #poststuff #bbp_forum_attributes select#parent_id, 4 4 5 #poststuff #bbp_topic_attributes select#parent_id, 5 6 #poststuff #bbp_reply_attributes select#bbp_forum_id, 6 #poststuff #bbp_reply_attributes select#bbp_reply_to { 7 #poststuff #bbp_reply_attributes select#bbp_reply_to, 8 #poststuff #bbp_reply_attributes input#bbp_forum_id, 9 #poststuff #bbp_reply_attributes input#bbp_topic_id, 10 #poststuff #bbp_author_metabox input#bbp_author_id, 11 #poststuff #bbp_author_metabox input#bbp_author_ip_address { 7 12 max-width: 170px; 8 13 } … … 316 321 } 317 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 318 352 .column-bbp_forum_topic_count, 319 353 .column-bbp_forum_reply_count, -
bbpress/trunk/includes/admin/classes/class-bbp-admin.php
r2476819 r3109477 82 82 */ 83 83 public $notices = array(); 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 84 106 85 107 /** Functions *************************************************************/ -
bbpress/trunk/includes/admin/classes/class-bbp-converter-base.php
r2276672 r3109477 1047 1047 * @param string $password 1048 1048 */ 1049 public function callback_pass( $username, $password ) { 1049 public function callback_pass( $username = '', $password = '' ) { 1050 1051 // Get user – Bail if not found 1050 1052 $user = $this->get_row( $this->wpdb->prepare( "SELECT * FROM {$this->wpdb->users} WHERE user_login = %s AND user_pass = '' LIMIT 1", $username ) ); 1051 if ( ! empty( $user ) ) { 1052 $usermeta = $this->get_row( $this->wpdb->prepare( "SELECT * FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND user_id = %d LIMIT 1", '_bbp_password', $user->ID ) ); 1053 1054 if ( ! empty( $usermeta ) ) { 1055 if ( $this->authenticate_pass( $password, $usermeta->meta_value ) ) { 1056 $this->query( $this->wpdb->prepare( "UPDATE {$this->wpdb->users} SET user_pass = %s WHERE ID = %d", wp_hash_password( $password ), $user->ID ) ); 1057 $this->query( $this->wpdb->prepare( "DELETE FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND user_id = %d", '_bbp_password', $user->ID ) ); 1058 1059 // Clean the cache for this user since their password was 1060 // upgraded from the old platform to the new. 1061 clean_user_cache( $user->ID ); 1062 } 1063 } 1064 } 1053 if ( empty( $user ) ) { 1054 return; 1055 } 1056 1057 // Get usermeta – Bail if not found 1058 $usermeta = $this->get_row( $this->wpdb->prepare( "SELECT * FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND user_id = %d LIMIT 1", '_bbp_password', $user->ID ) ); 1059 if ( empty( $usermeta ) ) { 1060 return; 1061 } 1062 1063 // Bail if auth fails 1064 if ( ! $this->authenticate_pass( $password, $usermeta->meta_value ) ) { 1065 return; 1066 } 1067 1068 // Hash the password 1069 $new_pass = wp_hash_password( $password ); 1070 1071 // Update 1072 $this->query( $this->wpdb->prepare( "UPDATE {$this->wpdb->users} SET user_pass = %s WHERE ID = %d", $new_pass, $user->ID ) ); 1073 1074 // Clean up 1075 unset( $new_pass ); 1076 $this->query( $this->wpdb->prepare( "DELETE FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND user_id = %d", '_bbp_password', $user->ID ) ); 1077 $this->query( $this->wpdb->prepare( "DELETE FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND user_id = %d", '_bbp_class', $user->ID ) ); 1078 1079 // Clean the cache for this user since their password was 1080 // upgraded from the old platform to the new. 1081 clean_user_cache( $user->ID ); 1065 1082 } 1066 1083 -
bbpress/trunk/includes/admin/classes/class-bbp-converter-db.php
r2190832 r3109477 31 31 */ 32 32 public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) { 33 register_shutdown_function( array( $this, '__destruct' ) );34 33 35 34 if ( WP_DEBUG && WP_DEBUG_DISPLAY ) { -
bbpress/trunk/includes/admin/tools/repair.php
r2413629 r3109477 498 498 $result = esc_html__( 'Failed!', 'bbpress' ); 499 499 500 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`"; 500 $sql_type = bbp_get_topic_post_type(); 501 $sql_status = "'" . implode( "','", bbp_get_public_topic_statuses() ) . "'"; 502 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status}) GROUP BY `post_author`"; 501 503 $insert_rows = $bbp_db->get_results( $sql_select ); 502 504 … … 542 544 543 545 // Define variables 544 $bbp_db = bbp_db();546 $bbp_db = bbp_db(); 545 547 $statement = esc_html__( 'Counting the number of topics to which each user has replied… %s', 'bbpress' ); 546 548 $result = esc_html__( 'Failed!', 'bbpress' ); 547 549 548 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`"; 550 $sql_type = bbp_get_reply_post_type(); 551 $sql_status = "'" . implode( "','", bbp_get_public_reply_statuses() ) . "'"; 552 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status}) GROUP BY `post_author`"; 549 553 $insert_rows = $bbp_db->get_results( $sql_select ); 550 554 … … 602 606 } 603 607 604 $topics = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "'" ); 605 608 $sql_type = bbp_get_topic_post_type(); 609 $sql_status = "'" . implode( "','", bbp_get_public_topic_statuses() ) . "'"; 610 $sql_select = "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status})"; 611 612 $topics = $bbp_db->get_col( $sql_select ); 606 613 if ( is_wp_error( $topics ) ) { 607 614 return array( 2, sprintf( $statement, $result ) ); … … 668 675 } 669 676 670 $topics = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "'" ); 677 $sql_type = bbp_get_topic_post_type(); 678 $sql_status = "'" . implode( "','", bbp_get_public_topic_statuses() ) . "'"; 679 $sql_select = "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status})"; 680 681 $topics = $bbp_db->get_col( $sql_select ); 671 682 if ( is_wp_error( $topics ) ) { 672 683 return array( 2, sprintf( $statement, $result ) ); … … 733 744 } 734 745 735 $forums = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_forum_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "'" ); 746 $sql_type = bbp_get_forum_post_type(); 747 $sql_status = "'" . implode( "','", bbp_get_public_forum_statuses() ) . "'"; 748 $sql_select = "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status})"; 749 750 $forums = $bbp_db->get_col( $sql_select ); 736 751 if ( is_wp_error( $forums ) ) { 737 752 return array( 2, sprintf( $statement, $result ) ); -
bbpress/trunk/includes/common/functions.php
r2413629 r3109477 186 186 187 187 return $data; 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 188 215 } 189 216 … … 278 305 * 279 306 * @since 2.0.0 bbPress (r2769) 280 * @since 2.6.0 bbPress (r6055) Introduced the `count_pending_topics` and 281 * `count_pending_replies` arguments. 307 * @since 2.6.0 bbPress (r6055) Added: 308 * `count_pending_topics` 309 * `count_pending_replies` 310 * @since 2.6.10 bbPress (r7235) Renamed: 311 * `count_trashed_topics` to `count_trash_topics` 312 * `count_trashed_replies` to `count_trash_replies` 313 * `count_spammed_topics` to `count_spam_topics` 314 * `count_spammed_replies` to `count_spam_replies` 315 * Added: 316 * `count_hidden_topics` 317 * `count_hidden_replies` 282 318 * 283 319 * @param array $args Optional. The function supports these arguments (all 284 * default to true): 285 * - count_users: Count users? 286 * - count_forums: Count forums? 287 * - count_topics: Count topics? If set to false, private, spammed and trashed 288 * topics are also not counted. 289 * - count_pending_topics: Count pending topics? (only counted if the current 320 * default to true): 321 * 322 * - count_users: Count users? 323 * - count_forums: Count forums? 324 * - count_topics: Count topics? If set to false, private, spam and 325 * trash topics are also not counted. 326 * - count_pending_topics: Count pending topics? (only counted if the current 290 327 * user has edit_others_topics cap) 291 * - count_private_topics: Count private topics? (only counted if the current328 * - count_private_topics: Count private topics? (only counted if the current 292 329 * user has read_private_topics cap) 293 * - count_spammed_topics: Count spammed topics? (only counted if the current 330 * - count_hidden_topics: Count hidden topics? (only counted if the current 331 * user has read_hidden_topics cap) 332 * - count_spam_topics: Count spam topics? (only counted if the current 294 333 * user has edit_others_topics cap) 295 * - count_trash ed_topics: Count trashedtopics? (only counted if the current334 * - count_trash topics? (only counted if the current 296 335 * user has view_trash cap) 297 * - count_replies: Count replies? If set to false, private, spammedand298 * trashedreplies are also not counted.336 * - count_replies: and 337 * replies are also not counted. 299 338 * - count_pending_replies: Count pending replies? (only counted if the current 300 339 * user has edit_others_replies cap) 301 340 * - count_private_replies: Count private replies? (only counted if the current 302 341 * user has read_private_replies cap) 303 * - count_spammed_replies: Count spammed replies? (only counted if the current 342 * - count_hidden_replies: Count hidden replies? (only counted if the current 343 * user has read_hidden_replies cap) 344 * - count_spam_replies: Count spam replies? (only counted if the current 304 345 * user has edit_others_replies cap) 305 * - count_trash ed_replies: Count trashedreplies? (only counted if the current346 * - count_trash replies? (only counted if the current 306 347 * user has view_trash cap) 307 * - count_tags: Count tags? If set to false, empty tags are also not counted 308 * - count_empty_tags: Count empty tags? 309 * @return object Walked forum tree 348 * - count_tags: Count tags? If set to false, empty tags are also 349 * not counted 350 * - count_empty_tags: Count empty tags? 351 * 352 * @return array Array of statistics 310 353 */ 311 354 function bbp_get_statistics( $args = array() ) { … … 324 367 'count_pending_topics' => true, 325 368 'count_private_topics' => true, 326 'count_spammed_topics' => true, 327 'count_trashed_topics' => true, 369 'count_spam_topics' => true, 370 'count_trash_topics' => true, 371 'count_hidden_topics' => true, 328 372 329 373 // Replies … … 331 375 'count_pending_replies' => true, 332 376 'count_private_replies' => true, 333 'count_spammed_replies' => true, 334 'count_trashed_replies' => true, 377 'count_spam_replies' => true, 378 'count_trash_replies' => true, 379 'count_hidden_replies' => true, 335 380 336 381 // Topic tags … … 346 391 $hidden_topic_title = $hidden_reply_title = ''; 347 392 393 394 395 396 397 398 399 400 401 348 402 // Users 349 403 $user_count = ! empty( $r['count_users'] ) … … 353 407 // Forums 354 408 $forum_count = ! empty( $r['count_forums'] ) 355 ? wp_count_posts( bbp_get_forum_post_type() )-> publish409 ? wp_count_posts( bbp_get_forum_post_type() )-> 356 410 : 0; 357 411 358 // Post statuses 359 $pending = bbp_get_pending_status_id(); 360 $private = bbp_get_private_status_id(); 361 $spam = bbp_get_spam_status_id(); 362 $trash = bbp_get_trash_status_id(); 363 $closed = bbp_get_closed_status_id(); 412 // Default capabilities 413 $caps = array( 414 'view_trash' => false, 415 'read_private_topics' => false, 416 'edit_others_topics' => false, 417 'read_private_replies' => false, 418 'edit_others_replies' => false, 419 'edit_topic_tags' => false 420 ); 421 422 // Get capabilities 423 foreach ( $caps as $key => $cap ) { 424 $caps[ $key ] = current_user_can( $cap ); 425 } 364 426 365 427 // Topics 366 428 if ( ! empty( $r['count_topics'] ) ) { 429 430 367 431 $all_topics = wp_count_posts( bbp_get_topic_post_type() ); 368 432 369 433 // Published (publish + closed) 370 $topic_count = $all_topics->publish + $all_topics->{$closed}; 371 372 if ( current_user_can( 'read_private_topics' ) || current_user_can( 'edit_others_topics' ) || current_user_can( 'view_trash' ) ) { 373 374 // Declare empty arrays 375 $topics = $topic_titles = array(); 376 377 // Pending 378 $topics['pending'] = ( ! empty( $r['count_pending_topics'] ) && current_user_can( 'edit_others_topics' ) ) 379 ? (int) $all_topics->{$pending} 380 : 0; 381 382 // Private 383 $topics['private'] = ( ! empty( $r['count_private_topics'] ) && current_user_can( 'read_private_topics' ) ) 384 ? (int) $all_topics->{$private} 385 : 0; 386 387 // Spam 388 $topics['spammed'] = ( ! empty( $r['count_spammed_topics'] ) && current_user_can( 'edit_others_topics' ) ) 389 ? (int) $all_topics->{$spam} 390 : 0; 391 392 // Trash 393 $topics['trashed'] = ( ! empty( $r['count_trashed_topics'] ) && current_user_can( 'view_trash' ) ) 394 ? (int) $all_topics->{$trash} 395 : 0; 396 397 // Total hidden (pending + private + spam + trash) 398 $topic_count_hidden = $topics['pending'] + $topics['private'] + $topics['spammed'] + $topics['trashed']; 399 400 // Generate the hidden topic count's title attribute 401 $topic_titles[] = ! empty( $topics['pending'] ) 402 ? sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $topics['pending'] ) ) 403 : ''; 404 405 $topic_titles[] = ! empty( $topics['private'] ) 406 ? sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics['private'] ) ) 407 : ''; 408 409 $topic_titles[] = ! empty( $topics['spammed'] ) 410 ? sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['spammed'] ) ) 411 : ''; 412 413 $topic_titles[] = ! empty( $topics['trashed'] ) 414 ? sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['trashed'] ) ) 415 : ''; 416 417 // Compile the hidden topic title 418 $hidden_topic_title = implode( ' | ', array_filter( $topic_titles ) ); 419 } 434 $topic_count = $all_topics->{$publish} + $all_topics->{$closed}; 435 436 // Declare empty arrays 437 $topics = $topic_titles = array_fill_keys( bbp_get_non_public_topic_statuses(), '' ); 438 439 // Pending 440 if ( ! empty( $r['count_pending_topics'] ) && ! empty( $caps['edit_others_topics'] ) ) { 441 $topics[ $pending ] = bbp_number_not_negative( $all_topics->{$pending} ); 442 $topic_titles[ $pending ] = sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $pending ] ) ); 443 } 444 445 // Private 446 if ( ! empty( $r['count_private_topics'] ) && ! empty( $caps['read_private_topics'] ) ) { 447 $topics[ $private ] = bbp_number_not_negative( $all_topics->{$private} ); 448 $topic_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $private ] ) ); 449 } 450 451 // Hidden 452 if ( ! empty( $r['count_hidden_topics'] ) && ! empty( $caps['read_hidden_topics'] ) ) { 453 $topics[ $hidden ] = bbp_number_not_negative( $all_topics->{$hidden} ); 454 $topic_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $hidden ] ) ); 455 } 456 457 // Spam 458 if ( ! empty( $r['count_spam_topics'] ) && ! empty( $caps['edit_others_topics'] ) ) { 459 $topics[ $spam ] = bbp_number_not_negative( $all_topics->{$spam} ); 460 $topic_titles[ $spam ] = sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $spam ] ) ); 461 } 462 463 // Trash 464 if ( ! empty( $r['count_trash_topics'] ) && ! empty( $caps['view_trash'] ) ) { 465 $topics[ $trash ] = bbp_number_not_negative( $all_topics->{$trash} ); 466 $topic_titles[ $trash ] = sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $trash ] ) ); 467 } 468 469 // Total hidden (pending, private, hidden, spam, trash) 470 $topic_count_hidden = array_sum( array_filter( $topics ) ); 471 472 // Compile the hidden topic title 473 $hidden_topic_title = implode( ' | ', array_filter( $topic_titles ) ); 420 474 } 421 475 … … 423 477 if ( ! empty( $r['count_replies'] ) ) { 424 478 479 425 480 $all_replies = wp_count_posts( bbp_get_reply_post_type() ); 426 481 427 482 // Published 428 $reply_count = $all_replies->publish; 429 430 if ( current_user_can( 'read_private_replies' ) || current_user_can( 'edit_others_replies' ) || current_user_can( 'view_trash' ) ) { 431 432 // Declare empty arrays 433 $replies = $reply_titles = array(); 434 435 // Pending 436 $replies['pending'] = ( ! empty( $r['count_pending_replies'] ) && current_user_can( 'edit_others_replies' ) ) 437 ? (int) $all_replies->{$pending} 438 : 0; 439 440 // Private 441 $replies['private'] = ( ! empty( $r['count_private_replies'] ) && current_user_can( 'read_private_replies' ) ) 442 ? (int) $all_replies->{$private} 443 : 0; 444 445 // Spam 446 $replies['spammed'] = ( ! empty( $r['count_spammed_replies'] ) && current_user_can( 'edit_others_replies' ) ) 447 ? (int) $all_replies->{$spam} 448 : 0; 449 450 // Trash 451 $replies['trashed'] = ( ! empty( $r['count_trashed_replies'] ) && current_user_can( 'view_trash' ) ) 452 ? (int) $all_replies->{$trash} 453 : 0; 454 455 // Total hidden (pending + private + spam + trash) 456 $reply_count_hidden = $replies['pending'] + $replies['private'] + $replies['spammed'] + $replies['trashed']; 457 458 // Generate the hidden topic count's title attribute 459 $reply_titles[] = ! empty( $replies['pending'] ) 460 ? sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $replies['pending'] ) ) 461 : ''; 462 $reply_titles[] = ! empty( $replies['private'] ) 463 ? sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies['private'] ) ) 464 : ''; 465 466 $reply_titles[] = ! empty( $replies['spammed'] ) 467 ? sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['spammed'] ) ) 468 : ''; 469 470 $reply_titles[] = ! empty( $replies['trashed'] ) 471 ? sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['trashed'] ) ) 472 : ''; 473 474 // Compile the hidden replies title 475 $hidden_reply_title = implode( ' | ', array_filter( $reply_titles ) ); 476 } 483 $reply_count = $all_replies->{$publish}; 484 485 // Declare empty arrays 486 $replies = $reply_titles = array_fill_keys( bbp_get_non_public_reply_statuses(), '' ); 487 488 // Pending 489 if ( ! empty( $r['count_pending_replies'] ) && ! empty( $caps['edit_others_replies'] ) ) { 490 $replies[ $pending ] = bbp_number_not_negative( $all_replies->{$pending} ); 491 $reply_titles[ $pending ] = sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $pending ] ) ); 492 } 493 494 // Private 495 if ( ! empty( $r['count_private_replies'] ) && ! empty( $caps['read_private_replies'] ) ) { 496 $replies[ $private ] = bbp_number_not_negative( $all_replies->{$private} ); 497 $reply_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $private ] ) ); 498 } 499 500 // Hidden 501 if ( ! empty( $r['count_hidden_replies'] ) && ! empty( $caps['read_hidden_replies'] ) ) { 502 $replies[ $hidden ] = bbp_number_not_negative( $all_replies->{$hidden} ); 503 $reply_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $hidden ] ) ); 504 } 505 506 // Spam 507 if ( ! empty( $r['count_spam_replies'] ) && ! empty( $caps['edit_others_replies'] ) ) { 508 $replies[ $spam ] = bbp_number_not_negative( $all_replies->{$spam} ); 509 $reply_titles[ $spam ] = sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $spam ] ) ); 510 } 511 512 // Trash 513 if ( ! empty( $r['count_trash_replies'] ) && ! empty( $caps['view_trash'] ) ) { 514 $replies[ $trash ] = bbp_number_not_negative( $all_replies->{$trash} ); 515 $reply_titles[ $trash ] = sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $trash ] ) ); 516 } 517 518 // Total hidden (pending, private, hidden, spam, trash) 519 $reply_count_hidden = array_sum( array_filter( $replies ) ); 520 521 // Compile the hidden replies title 522 $hidden_reply_title = implode( ' | ', $reply_titles ); 477 523 } 478 524 … … 480 526 if ( ! empty( $r['count_tags'] ) && bbp_allow_topic_tags() ) { 481 527 528 529 530 482 531 // Get the count 483 $topic_tag_count = wp_count_terms( bbp_get_topic_tag_tax_id(), array( 'hide_empty' => true ) );532 $topic_tag_count = wp_count_terms( , array( 'hide_empty' => true ) ); 484 533 485 534 // Empty tags 486 if ( ! empty( $r['count_empty_tags'] ) && current_user_can( 'edit_topic_tags' ) ) {487 $empty_topic_tag_count = wp_count_terms( bbp_get_topic_tag_tax_id()) - $topic_tag_count;535 if ( ! empty( $r['count_empty_tags'] ) && ( 'edit_topic_tags' ) ) { 536 $empty_topic_tag_count = wp_count_terms( ) - $topic_tag_count; 488 537 } 489 538 } 490 539 491 540 // Tally the tallies 492 $counts = array_ filter( array_map( 'absint', compact(541 $counts = array_map( 'absint', compact( 493 542 'user_count', 494 543 'forum_count', … … 499 548 'topic_tag_count', 500 549 'empty_topic_tag_count' 501 ) ) );550 ) ); 502 551 503 552 // Define return value 504 553 $statistics = array(); 505 554 506 // Loop through and store the integer and i18n formatted counts .555 // Loop through and store the integer and i18n formatted counts 507 556 foreach ( $counts as $key => $count ) { 508 $ statistics[ $key ] = bbp_number_format_i18n( $count );509 $statistics[ "{$key}_int" ] = $count;510 }511 512 // Add the hidden (topic/reply) count title attribute strings because we 513 // don't need to run the math functions on these (see above)557 $( $count ); 558 $statistics[ ; 559 560 } 561 562 // 514 563 $statistics['hidden_topic_title'] = $hidden_topic_title; 515 564 $statistics['hidden_reply_title'] = $hidden_reply_title; … … 1091 1140 1092 1141 // Strip tags from text and setup mail data 1093 $ blog_name = wp_specialchars_decode( get_option( 'blogname'), ENT_QUOTES );1142 $ ), ENT_QUOTES ); 1094 1143 $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); 1095 1144 $reply_author_name = wp_specialchars_decode( strip_tags( $reply_author_name ), ENT_QUOTES ); … … 1121 1170 1122 1171 // For plugins to filter titles per reply/topic/user 1123 $subject = apply_filters( 'bbp_subscription_mail_title', '[' . $ blog_name . '] ' . $topic_title, $reply_id, $topic_id );1172 $subject = apply_filters( 'bbp_subscription_mail_title', '[' . $e . '] ' . $topic_title, $reply_id, $topic_id ); 1124 1173 if ( empty( $subject ) ) { 1125 1174 return; … … 1258 1307 1259 1308 // Strip tags from text and setup mail data 1260 $ blog_name = wp_specialchars_decode( get_option( 'blogname'), ENT_QUOTES );1309 $ ), ENT_QUOTES ); 1261 1310 $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); 1262 1311 $topic_author_name = wp_specialchars_decode( strip_tags( $topic_author_name ), ENT_QUOTES ); … … 1288 1337 1289 1338 // For plugins to filter titles per reply/topic/user 1290 $subject = apply_filters( 'bbp_forum_subscription_mail_title', '[' . $ blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id );1339 $subject = apply_filters( 'bbp_forum_subscription_mail_title', '[' . $e . '] ' . $topic_title, $topic_id, $forum_id, $user_id ); 1291 1340 if ( empty( $subject ) ) { 1292 1341 return; … … 2471 2520 $the_query = bbp_get_view_query_args( $view ); 2472 2521 2473 // Output the feed 2474 bbp_display_topics_feed_rss2( $the_query ); 2522 // Output the feed if view exists 2523 if ( ! empty( $the_query ) ) { 2524 bbp_display_topics_feed_rss2( $the_query ); 2525 } 2475 2526 } 2476 2527 } -
bbpress/trunk/includes/common/template.php
r2632704 r3109477 71 71 72 72 /** 73 * Add our custom head action to wp_head73 * Add our custom 74 74 * 75 75 * @since 2.0.0 bbPress (r2464) … … 1096 1096 // Filter & return 1097 1097 return (array) apply_filters( 'bbp_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes ); 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1098 1124 } 1099 1125 -
bbpress/trunk/includes/core/actions.php
r2313912 r3109477 130 130 add_action( 'bbp_init', 'bbp_topic_content_autoembed', 8 ); 131 131 132 133 134 135 132 136 /** 133 137 * bbp_ready - attached to end 'bbp_init' above … … 138 142 */ 139 143 add_action( 'bbp_ready', 'bbp_setup_akismet', 2 ); // Spam prevention for topics and replies 144 145 140 146 add_action( 'bp_include', 'bbp_setup_buddypress', 10 ); // Social network integration 141 147 -
bbpress/trunk/includes/core/capabilities.php
r2190832 r3109477 286 286 function bbp_add_forums_roles( $wp_roles = null ) { 287 287 288 289 290 291 292 293 294 295 296 297 288 298 // Get the dynamic roles 289 299 $bbp_roles = bbp_get_dynamic_roles(); -
bbpress/trunk/includes/core/filters.php
r2413629 r3109477 52 52 // Fix post author id for anonymous posts (set it back to 0) when the post status is changed 53 53 add_filter( 'wp_insert_post_data', 'bbp_fix_post_author', 30, 2 ); 54 55 56 54 57 55 58 // Force comments_status on bbPress post types -
bbpress/trunk/includes/extend/akismet.php
r2636925 r3109477 21 21 */ 22 22 class BBP_Akismet { 23 24 25 26 27 28 29 30 31 23 32 24 33 /** -
bbpress/trunk/includes/forums/functions.php
r2612664 r3109477 2302 2302 } 2303 2303 2304 // Get query post types array . 2305 $post_types = (array) $posts_query->get( 'post_type' ); 2304 // Bail to prevent unintended wp-admin post_row overrides 2305 if ( is_admin() && isset( $_REQUEST['post_status'] ) ) { 2306 return; 2307 } 2308 2309 // Get query post types as an array. 2310 $post_types = array_filter( (array) $posts_query->get( 'post_type' ) ); 2306 2311 2307 2312 // Forums 2308 if ( bbp_get_forum_post_type() === implode( '', $post_types ) ) { 2309 2310 // Prevent accidental wp-admin post_row override 2311 if ( is_admin() && isset( $_REQUEST['post_status'] ) ) { 2312 return; 2313 } 2313 if ( in_array( bbp_get_forum_post_type(), $post_types, true ) ) { 2314 2314 2315 2315 /** Default ***********************************************************/ … … 2319 2319 2320 2320 // Get forums to exclude 2321 $ hidden_ids = bbp_exclude_forum_ids( 'array' );2322 2323 // Bail if no forums to exclude2324 if ( empty( $hidden_ids ) ) {2325 return; 2326 }2327 2328 // Get any existing meta queries 2329 $not_in = $posts_query->get( 'post__not_in', array() );2330 2331 // Add our meta query to existing 2332 $not_in = array_unique( array_merge( $not_in, $hidden_ids ) );2333 2334 // Set the meta_query var2335 $posts_query->set( 'post__not_in', $not_in );2321 $_ids = bbp_exclude_forum_ids( 'array' ); 2322 2323 // 2324 if ( _ids ) ) { 2325 2326 2327 $not_in = $posts_query->get( 'post__not_in', array() ); 2328 2329 2330 $not_in = array_unique( array_merge( $not_in, $forum_ids ) ); 2331 2332 2333 $posts_query->set( 'post__not_in', $not_in ); 2334 2335 2336 2336 2337 2337 // Some other post type besides Forums, Topics, or Replies 2338 } elseif ( ! array_diff( $post_types, bbp_get_post_types() ) ) {2338 if ( ! array_diff( $post_types, bbp_get_post_types() ) ) { 2339 2339 2340 2340 // Get forums to exclude 2341 2341 $forum_ids = bbp_exclude_forum_ids( 'meta_query' ); 2342 2342 2343 // Bail if no forums to exclude 2344 if ( empty( $forum_ids ) ) { 2345 return; 2346 } 2347 2348 // Get any existing meta queries 2349 $meta_query = (array) $posts_query->get( 'meta_query', array() ); 2350 2351 // Add our meta query to existing 2352 $meta_query[] = $forum_ids; 2353 2354 // Set the meta_query var 2355 $posts_query->set( 'meta_query', $meta_query ); 2343 // Excluding some forums 2344 if ( ! empty( $forum_ids ) ) { 2345 2346 // Get any existing meta queries 2347 $meta_query = (array) $posts_query->get( 'meta_query', array() ); 2348 2349 // Add our meta query to existing 2350 $meta_query[] = $forum_ids; 2351 2352 // Set the new meta_query val 2353 $posts_query->set( 'meta_query', $meta_query ); 2354 } 2356 2355 } 2357 2356 } -
bbpress/trunk/includes/forums/template.php
r2276672 r3109477 1763 1763 * 1764 1764 * @param int $forum_id Optional. Forum id 1765 * id and forum id1765 * 1766 1766 * @return string Author of forum 1767 1767 */ -
bbpress/trunk/includes/replies/functions.php
r2612664 r3109477 641 641 /** Reply Status **********************************************************/ 642 642 643 644 645 643 646 // Use existing post_status 644 647 $reply_status = $reply->post_status; … … 647 650 if ( bbp_is_reply_public( $reply_id ) && ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) { 648 651 $reply_status = bbp_get_pending_status_id(); 652 653 654 655 656 657 658 659 660 661 662 663 649 664 } 650 665 … … 2060 2075 * 2061 2076 * @param string $where 2077 2062 2078 * @return string 2063 2079 */ … … 2412 2428 ), 'list_replies' ); 2413 2429 2414 // Get replies to loop through in $_replies 2415 echo '<ul>' . $r['walker']->paged_walk( $bbp->reply_query->posts, $r['max_depth'], $r['page'], $r['per_page'], $r ) . '</ul>'; 2416 2417 $bbp->max_num_pages = $r['walker']->max_pages; 2430 // Allowed styles (supported by BBP_Walker_Reply) 2431 $allowed = array( 'div', 'ol', 'ul' ); 2432 2433 // Get style 2434 $style = in_array( $r['style'], $allowed, true ) 2435 ? $r['style'] 2436 : 'ul'; 2437 2438 // Walk the replies 2439 $walked_html = $r['walker']->paged_walk( 2440 $bbp->reply_query->posts, 2441 $r['max_depth'], 2442 $r['page'], 2443 $r['per_page'], 2444 $r 2445 ); 2446 2447 // Override the "max_num_pages" setting 2448 $bbp->max_num_pages = $r['walker']->max_pages; 2449 2450 // No longer in reply loop 2418 2451 $bbp->reply_query->in_the_loop = false; 2452 2453 2454 2419 2455 } 2420 2456 -
bbpress/trunk/includes/replies/template.php
r2476819 r3109477 403 403 * 404 404 * @param int $reply_id Optional. Reply id 405 * and reply id405 * 406 406 * @return string Permanent link to reply 407 407 */ … … 466 466 $has_slug = ! empty( $topic ) ? $topic->post_name : ''; 467 467 $pretty = bbp_use_pretty_urls(); 468 $published = ! bbp_is_topic_pending( $topic_id );468 $published = ( $topic_id ); 469 469 470 470 // Don't include pagination if on first page … … 800 800 * 801 801 * @param int $reply_id Optional. Reply id 802 * @return stringreply revisions802 * @return reply revisions 803 803 */ 804 804 function bbp_get_reply_revisions( $reply_id = 0 ) { … … 1458 1458 * 1459 1459 * @param int $reply_id Optional. Reply id 1460 * id and reply id1460 * 1461 1461 * @return int The forum id of the reply 1462 1462 */ -
bbpress/trunk/includes/search/template.php
r2476819 r3109477 47 47 } 48 48 49 // What are the default allowed statuses (based on user caps) 50 if ( bbp_get_view_all() ) { 51 52 // Default view=all statuses 53 $post_statuses = array_keys( bbp_get_topic_statuses() ); 54 55 // Add support for private status 56 if ( current_user_can( 'read_private_topics' ) ) { 57 $post_statuses[] = bbp_get_private_status_id(); 58 } 59 60 // Join post statuses together 61 $default['post_status'] = $post_statuses; 62 63 // Lean on the 'perm' query var value of 'readable' to provide statuses 64 } else { 65 $default['perm'] = 'readable'; 66 } 49 // Default public statuses (topics coincidentally cover all post types) 50 $post_statuses = array_keys( bbp_get_public_topic_statuses() ); 51 52 // Add support for private status 53 if ( current_user_can( 'read_private_topics' ) ) { 54 $post_statuses[] = bbp_get_private_status_id(); 55 } 56 57 // Add support for hidden status 58 if ( current_user_can( 'read_hidden_topics' ) ) { 59 $post_statuses[] = bbp_get_hidden_status_id(); 60 } 61 62 // Join post statuses together 63 $default['post_status'] = $post_statuses; 67 64 68 65 /** Setup *****************************************************************/ -
bbpress/trunk/includes/topics/functions.php
r2612664 r3109477 580 580 581 581 // Maybe force into pending 582 if ( bbp_is_topic_public( $topic ->ID) && ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {582 if ( bbp_is_topic_public( $topic ) && ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) { 583 583 $topic_status = bbp_get_pending_status_id(); 584 584 … … 587 587 588 588 // Allow capable users to explicitly override the status 589 if ( current_user_can( 'moderate', $ forum_id ) ) {589 if ( current_user_can( 'moderate', $_id ) ) { 590 590 $topic_status = sanitize_key( $_POST['bbp_topic_status'] ); 591 591 -
bbpress/trunk/includes/topics/template.php
r2476819 r3109477 809 809 810 810 // If pretty permalinks are enabled, make our pagination pretty 811 $base = ! empty( $has_slug ) && bbp_use_pretty_urls() && ! bbp_is_topic_pending( $r['topic_id'] )811 $base = ! empty( $has_slug ) && bbp_use_pretty_urls() && ( $r['topic_id'] ) 812 812 ? trailingslashit( get_permalink( $r['topic_id'] ) ) . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' ) 813 813 : add_query_arg( 'paged', '%#%', get_permalink( $r['topic_id'] ) ); … … 964 964 * 965 965 * @param int $topic_id Optional. Topic id 966 * @return stringTopic revisions966 * @return Topic revisions 967 967 */ 968 968 function bbp_get_topic_revisions( $topic_id = 0 ) { -
bbpress/trunk/includes/users/functions.php
r2319217 r3109477 955 955 * 956 956 * @since 2.1.0 bbPress (r3813) 957 957 958 */ 958 959 function bbp_user_maybe_convert_pass() { 959 960 960 // Sanitize username961 $ username= ! empty( $_POST['log'] )962 ? sanitize_user( $_POST['log'])961 // Sanitize 962 $ = ! empty( $_POST['log'] ) 963 ? sanitize_user( ) 963 964 : ''; 964 965 965 // Bail if no username 966 if ( empty( $username ) ) { 967 return; 968 } 969 970 // Bail if no user password to convert 971 $bbp_db = bbp_db(); 972 $query = $bbp_db->prepare( "SELECT * FROM {$bbp_db->users} INNER JOIN {$bbp_db->usermeta} ON user_id = ID WHERE meta_key = %s AND user_login = %s LIMIT 1", '_bbp_class', $username ); 973 $row = $bbp_db->get_row( $query ); 974 if ( empty( $row ) || is_wp_error( $row ) ) { 966 // Sanitize password 967 $pass = ! empty( $_POST['pwd'] ) 968 ? trim( $_POST['pwd'] ) 969 : ''; 970 971 // Bail if no username or password 972 if ( empty( $login ) || empty( $pass ) ) { 973 return; 974 } 975 976 // Get user by login... 977 $user = get_user_by( 'login', $login ); 978 979 // ...or get user by email 980 if ( empty( $user ) && strpos( $login, '@' ) ) { 981 $user = get_user_by( 'email', $login ); 982 } 983 984 // Bail if no user 985 if ( empty( $user ) ) { 986 return; 987 } 988 989 // Get converter class from usermeta 990 $class = get_user_meta( $user->ID, '_bbp_class', true ); 991 992 // Bail if no converter class in meta 993 if ( empty( $class ) || ! is_string( $class ) ) { 975 994 return; 976 995 } … … 979 998 bbp_setup_converter(); 980 999 981 // Try to convert the old password for this user 982 $converter = bbp_new_converter( $row->meta_value ); 983 984 // Try to call the conversion method 1000 // Try to instantiate the converter class 1001 $converter = bbp_new_converter( $class ); 1002 1003 // Bail if no converter 1004 if ( empty( $converter ) ) { 1005 return; 1006 } 1007 1008 // Try to call the password conversion callback method 985 1009 if ( ( $converter instanceof BBP_Converter_Base ) && method_exists( $converter, 'callback_pass' ) ) { 986 $converter->callback_pass( $ username, $_POST['pwd']);987 } 988 } 1010 $converter->callback_pass( $ ); 1011 } 1012 } -
bbpress/trunk/readme.txt
r3109424 r3109477 7 7 License: GNU General Public License v2 or later 8 8 Tags: forum, forums, discussion, support 9 Requires PHP: 5.6. 409 Requires PHP: 5.6.0 10 10 Requires at least: 6.0 11 11 Tested up to: 6.5 -
bbpress/trunk/templates/default/bbpress/content-archive-topic.php
r2190832 r3109477 15 15 <div id="bbpress-forums" class="bbpress-wrapper"> 16 16 17 <?php if ( bbp_allow_search() ) : ?> 18 19 <div class="bbp-search-form"> 20 21 <?php bbp_get_template_part( 'form', 'search' ); ?> 22 23 </div> 24 25 <?php endif; ?> 17 <?php bbp_get_template_part( 'form', 'search' ); ?> 26 18 27 19 <?php bbp_breadcrumb(); ?> -
bbpress/trunk/templates/default/bbpress/content-search.php
r2235773 r3109477 15 15 <div id="bbpress-forums" class="bbpress-wrapper"> 16 16 17 18 17 19 <?php bbp_breadcrumb(); ?> 18 20 … … 29 31 <?php bbp_get_template_part( 'pagination', 'search' ); ?> 30 32 31 <?php else if ( bbp_get_search_terms() ): ?>33 <?php else : ?> 32 34 33 35 <?php bbp_get_template_part( 'feedback', 'no-search' ); ?> 34 35 <?php else : ?>36 37 <?php bbp_get_template_part( 'form', 'search' ); ?>38 36 39 37 <?php endif; ?> -
bbpress/trunk/templates/default/bbpress/content-statistics.php
r2276672 r3109477 14 14 $stats = bbp_get_statistics(); ?> 15 15 16 <dl role="main" >16 <dl role="main"> 17 17 18 18 <?php do_action( 'bbp_before_statistics' ); ?> -
bbpress/trunk/templates/default/bbpress/feedback-no-search.php
r2190832 r3109477 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 ?>13 ?> 14 14 15 15 <div class="bbp-template-notice"> … … 18 18 </ul> 19 19 </div> 20 21 22 23 24 25 26 27 28 29 -
bbpress/trunk/templates/default/bbpress/form-forum.php
r2276672 r3109477 85 85 <?php do_action( 'bbp_theme_after_forum_form_content' ); ?> 86 86 87 <?php if ( ! ( bbp_use_wp_editor() || current_user_can( 'unfiltered_html' ) ) ) : ?> 88 89 <p class="form-allowed-tags"> 90 <label><?php esc_html_e( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes:', 'bbpress' ); ?></label><br /> 91 <code><?php bbp_allowed_tags(); ?></code> 92 </p> 93 94 <?php endif; ?> 87 <?php bbp_get_template_part( 'form', 'allowed-tags' ); ?> 95 88 96 89 <?php if ( bbp_allow_forum_mods() && current_user_can( 'assign_moderators' ) ) : ?> -
bbpress/trunk/templates/default/bbpress/form-reply.php
r2276672 r3109477 74 74 <?php do_action( 'bbp_theme_after_reply_form_content' ); ?> 75 75 76 <?php if ( ! ( bbp_use_wp_editor() || current_user_can( 'unfiltered_html' ) ) ) : ?> 77 78 <p class="form-allowed-tags"> 79 <label><?php esc_html_e( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes:', 'bbpress' ); ?></label><br /> 80 <code><?php bbp_allowed_tags(); ?></code> 81 </p> 82 83 <?php endif; ?> 76 <?php bbp_get_template_part( 'form', 'allowed-tags' ); ?> 84 77 85 78 <?php if ( bbp_allow_topic_tags() && current_user_can( 'assign_topic_tags', bbp_get_topic_id() ) ) : ?> -
bbpress/trunk/templates/default/bbpress/form-topic.php
r2190832 r3109477 95 95 <?php do_action( 'bbp_theme_after_topic_form_content' ); ?> 96 96 97 <?php if ( ! ( bbp_use_wp_editor() || current_user_can( 'unfiltered_html' ) ) ) : ?> 98 99 <p class="form-allowed-tags"> 100 <label><?php printf( esc_html__( 'You may use these %s tags and attributes:', 'bbpress' ), '<abbr title="HyperText Markup Language">HTML</abbr>' ); ?></label><br /> 101 <code><?php bbp_allowed_tags(); ?></code> 102 </p> 103 104 <?php endif; ?> 97 <?php bbp_get_template_part( 'form', 'allowed-tags' ); ?> 105 98 106 99 <?php if ( bbp_allow_topic_tags() && current_user_can( 'assign_topic_tags', bbp_get_topic_id() ) ) : ?> -
bbpress/trunk/templates/default/bbpress/form-user-passwords.php
r2476819 r3109477 13 13 // Filters the display of the password fields 14 14 if ( apply_filters( 'show_password_fields', true, bbpress()->displayed_user ) ) : ?> 15 16 <script type="text/javascript">17 document.body.className = document.body.className.replace( 'no-js', 'js' );18 </script>19 15 20 16 <div id="password" class="user-pass1-wrap"> -
bbpress/trunk/templates/default/css/bbpress.css
r2476819 r3109477 10 10 11 11 .hidden, 12 . no-js .hide-if-no-js,13 . js .hide-if-js {12 .no-js .hide-if-no-js, 13 .js .hide-if-js { 14 14 display: none; 15 15 } 16 16 17 /* Hide visually but not from screen readers*/17 /* Hide visually */ 18 18 .screen-reader-text, 19 19 .screen-reader-text span,
Note: See TracChangeset
for help on using the changeset viewer.