diff --git a/wp-content/plugins/bbpress/bbpress.php b/wp-content/plugins/bbpress/bbpress.php index 37281f52b2..677454bdb2 100644 --- a/wp-content/plugins/bbpress/bbpress.php +++ b/wp-content/plugins/bbpress/bbpress.php @@ -5,7 +5,7 @@ * * bbPress is forum software with a twist from the creators of WordPress. * - * $Id: bbpress.php 7228 2021-11-29 15:22:27Z johnjamesjacoby $ + * $Id: bbpress.php 7273 2024-06-29 16:56:00Z johnjamesjacoby $ * * @package bbPress * @subpackage Main @@ -17,12 +17,14 @@ * Description: bbPress is forum software with a twist from the creators of WordPress. * Author: The bbPress Contributors * Author URI: https://bbpress.org - * Version: 2.6.9 + * License: GNU General Public License v2 or later + * License URI: https://www.gnu.org/licenses/gpl-2.0.html * Text Domain: bbpress * Domain Path: /languages/ - * License: GPLv2 or later (license.txt) * Requires PHP: 5.6.20 - * Requires at least: 5.0 + * Requires at least: 6.0 + * Tested up to: 6.5 + * Version: 2.6.11 */ // Exit if accessed directly @@ -205,7 +207,7 @@ private function setup_environment() { /** Versions **********************************************************/ - $this->version = '2.6.9'; + $this->version = '2.6.11'; $this->db_version = '263'; /** Paths *************************************************************/ diff --git a/wp-content/plugins/bbpress/includes/admin/assets/css/admin.css b/wp-content/plugins/bbpress/includes/admin/assets/css/admin.css index 4acd310408..43a8d023d5 100644 --- a/wp-content/plugins/bbpress/includes/admin/assets/css/admin.css +++ b/wp-content/plugins/bbpress/includes/admin/assets/css/admin.css @@ -1,9 +1,14 @@ -/* Kludge for too-wide forums dropdown */ +/* Kludge for too-wide inputs & selects */ #poststuff #bbp_forum_attributes select#parent_id, +#poststuff #bbp_forum_attributes input#menu_order, #poststuff #bbp_topic_attributes select#parent_id, #poststuff #bbp_reply_attributes select#bbp_forum_id, -#poststuff #bbp_reply_attributes select#bbp_reply_to { +#poststuff #bbp_reply_attributes select#bbp_reply_to, +#poststuff #bbp_reply_attributes input#bbp_forum_id, +#poststuff #bbp_reply_attributes input#bbp_topic_id, +#poststuff #bbp_author_metabox input#bbp_author_id, +#poststuff #bbp_author_metabox input#bbp_author_ip_address { max-width: 170px; } @@ -315,6 +320,35 @@ body.post-type-reply strong.label { width: 60px; } +body.post-type-forum .wp-list-table thead th a, +body.post-type-forum .wp-list-table tfoot th a, +body.post-type-topic .wp-list-table thead th a, +body.post-type-topic .wp-list-table tfoot th a, +body.post-type-reply .wp-list-table thead th a, +body.post-type-reply .wp-list-table tfoot th a { + display: flex; +} + +body.post-type-forum .wp-list-table thead th:not(.sortable), +body.post-type-forum .wp-list-table tfoot th:not(.sortable), +body.post-type-forum .wp-list-table thead th a > span:first-child, +body.post-type-forum .wp-list-table tfoot th a > span:first-child, +body.post-type-forum .wp-list-table tbody td, +body.post-type-topic .wp-list-table thead th:not(.sortable), +body.post-type-topic .wp-list-table tfoot th:not(.sortable), +body.post-type-topic .wp-list-table thead th a > span:first-child, +body.post-type-topic .wp-list-table tfoot th a > span:first-child, +body.post-type-topic .wp-list-table tbody td, +body.post-type-reply .wp-list-table thead th:not(.sortable), +body.post-type-reply .wp-list-table tfoot th:not(.sortable), +body.post-type-reply .wp-list-table thead th a > span:first-child, +body.post-type-reply .wp-list-table tfoot th a > span:first-child, +body.post-type-reply .wp-list-table tbody td { + overflow-x: hidden; + text-overflow: ellipsis; + word-wrap: normal; +} + .column-bbp_forum_topic_count, .column-bbp_forum_reply_count, .column-bbp_topic_reply_count, diff --git a/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-admin.php b/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-admin.php index cf18787c59..fe0bc12e03 100644 --- a/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-admin.php +++ b/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-admin.php @@ -82,6 +82,28 @@ class BBP_Admin { */ public $notices = array(); + /** Components ************************************************************/ + + /** + * @var BBP_Forums_Admin Forums admin + */ + public $forums = null; + + /** + * @var BBP_Topics_Admin Topics admin + */ + public $topics = null; + + /** + * @var BBP_Replies_Admin Replies admin + */ + public $replies = null; + + /** + * @var BBP_Converter Converter admin + */ + public $converter = null; + /** Functions *************************************************************/ /** diff --git a/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-converter-base.php b/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-converter-base.php index e346ec71a1..82953a3ba1 100644 --- a/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-converter-base.php +++ b/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-converter-base.php @@ -1046,22 +1046,39 @@ private function count_rows_by_table( $table_name = '' ) { * @param string $username * @param string $password */ - public function callback_pass( $username, $password ) { + public function callback_pass( $username = '', $password = '' ) { + + // Get user – Bail if not found $user = $this->get_row( $this->wpdb->prepare( "SELECT * FROM {$this->wpdb->users} WHERE user_login = %s AND user_pass = '' LIMIT 1", $username ) ); - if ( ! empty( $user ) ) { - $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 ) ); + if ( empty( $user ) ) { + return; + } - if ( ! empty( $usermeta ) ) { - if ( $this->authenticate_pass( $password, $usermeta->meta_value ) ) { - $this->query( $this->wpdb->prepare( "UPDATE {$this->wpdb->users} SET user_pass = %s WHERE ID = %d", wp_hash_password( $password ), $user->ID ) ); - $this->query( $this->wpdb->prepare( "DELETE FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND user_id = %d", '_bbp_password', $user->ID ) ); + // Get usermeta – Bail if not found + $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 ) ); + if ( empty( $usermeta ) ) { + return; + } - // Clean the cache for this user since their password was - // upgraded from the old platform to the new. - clean_user_cache( $user->ID ); - } - } + // Bail if auth fails + if ( ! $this->authenticate_pass( $password, $usermeta->meta_value ) ) { + return; } + + // Hash the password + $new_pass = wp_hash_password( $password ); + + // Update + $this->query( $this->wpdb->prepare( "UPDATE {$this->wpdb->users} SET user_pass = %s WHERE ID = %d", $new_pass, $user->ID ) ); + + // Clean up + unset( $new_pass ); + $this->query( $this->wpdb->prepare( "DELETE FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND user_id = %d", '_bbp_password', $user->ID ) ); + $this->query( $this->wpdb->prepare( "DELETE FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND user_id = %d", '_bbp_class', $user->ID ) ); + + // Clean the cache for this user since their password was + // upgraded from the old platform to the new. + clean_user_cache( $user->ID ); } /** diff --git a/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-converter-db.php b/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-converter-db.php index c8926e8106..8fc68f744f 100644 --- a/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-converter-db.php +++ b/wp-content/plugins/bbpress/includes/admin/classes/class-bbp-converter-db.php @@ -30,7 +30,6 @@ class BBP_Converter_DB extends wpdb { * @param string $dbhost MySQL database host */ public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) { - register_shutdown_function( array( $this, '__destruct' ) ); if ( WP_DEBUG && WP_DEBUG_DISPLAY ) { $this->show_errors(); diff --git a/wp-content/plugins/bbpress/includes/admin/tools/repair.php b/wp-content/plugins/bbpress/includes/admin/tools/repair.php index 149b519807..4504edfc1d 100644 --- a/wp-content/plugins/bbpress/includes/admin/tools/repair.php +++ b/wp-content/plugins/bbpress/includes/admin/tools/repair.php @@ -497,7 +497,9 @@ function bbp_admin_repair_user_topic_count() { $statement = esc_html__( 'Counting the number of topics each user has created… %s', 'bbpress' ); $result = esc_html__( 'Failed!', 'bbpress' ); - $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`"; + $sql_type = bbp_get_topic_post_type(); + $sql_status = "'" . implode( "','", bbp_get_public_topic_statuses() ) . "'"; + $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`"; $insert_rows = $bbp_db->get_results( $sql_select ); if ( is_wp_error( $insert_rows ) ) { @@ -541,11 +543,13 @@ function bbp_admin_repair_user_topic_count() { function bbp_admin_repair_user_reply_count() { // Define variables - $bbp_db = bbp_db(); + $bbp_db = bbp_db(); $statement = esc_html__( 'Counting the number of topics to which each user has replied… %s', 'bbpress' ); $result = esc_html__( 'Failed!', 'bbpress' ); - $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`"; + $sql_type = bbp_get_reply_post_type(); + $sql_status = "'" . implode( "','", bbp_get_public_reply_statuses() ) . "'"; + $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`"; $insert_rows = $bbp_db->get_results( $sql_select ); if ( is_wp_error( $insert_rows ) ) { @@ -601,8 +605,11 @@ function bbp_admin_repair_user_favorites() { return array( 1, sprintf( $statement, $result ) ); } - $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() . "'" ); + $sql_type = bbp_get_topic_post_type(); + $sql_status = "'" . implode( "','", bbp_get_public_topic_statuses() ) . "'"; + $sql_select = "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status})"; + $topics = $bbp_db->get_col( $sql_select ); if ( is_wp_error( $topics ) ) { return array( 2, sprintf( $statement, $result ) ); } @@ -667,7 +674,11 @@ function bbp_admin_repair_user_topic_subscriptions() { return array( 1, sprintf( $statement, $result ) ); } - $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() . "'" ); + $sql_type = bbp_get_topic_post_type(); + $sql_status = "'" . implode( "','", bbp_get_public_topic_statuses() ) . "'"; + $sql_select = "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status})"; + + $topics = $bbp_db->get_col( $sql_select ); if ( is_wp_error( $topics ) ) { return array( 2, sprintf( $statement, $result ) ); } @@ -732,7 +743,11 @@ function bbp_admin_repair_user_forum_subscriptions() { return array( 1, sprintf( $statement, $result ) ); } - $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() . "'" ); + $sql_type = bbp_get_forum_post_type(); + $sql_status = "'" . implode( "','", bbp_get_public_forum_statuses() ) . "'"; + $sql_select = "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status})"; + + $forums = $bbp_db->get_col( $sql_select ); if ( is_wp_error( $forums ) ) { return array( 2, sprintf( $statement, $result ) ); } diff --git a/wp-content/plugins/bbpress/includes/common/functions.php b/wp-content/plugins/bbpress/includes/common/functions.php index 0e18bb88c9..3477692171 100644 --- a/wp-content/plugins/bbpress/includes/common/functions.php +++ b/wp-content/plugins/bbpress/includes/common/functions.php @@ -187,6 +187,33 @@ function bbp_fix_post_author( $data = array(), $postarr = array() ) { return $data; } +/** + * Use the previous status when restoring a topic or reply. + * + * Fixes an issue since WordPress 5.6.0. See + * {@link https://bbpress.trac.wordpress.org/ticket/3433}. + * + * @since 2.6.10 bbPress (r7233) + * + * @param string $new_status New status to use when untrashing. Default: 'draft' + * @param int $post_id Post ID + * @param string $previous_status Previous post status from '_wp_trash_meta_status' meta key. Default: 'pending' + */ +function bbp_fix_untrash_post_status( $new_status = 'draft', $post_id = 0, $previous_status = 'pending' ) { + + // Bail if not Topic or Reply + if ( ! bbp_is_topic( $post_id ) && ! bbp_is_reply( $post_id ) ) { + return $new_status; + } + + // Prefer the previous status, falling back to the new status + $retval = ! empty( $previous_status ) + ? $previous_status + : $new_status; + + return $retval; +} + /** * Check a date against the length of time something can be edited. * @@ -277,36 +304,52 @@ function bbp_get_trash_days( $context = 'forum' ) { * Get the forum statistics * * @since 2.0.0 bbPress (r2769) - * @since 2.6.0 bbPress (r6055) Introduced the `count_pending_topics` and - * `count_pending_replies` arguments. + * @since 2.6.0 bbPress (r6055) Added: + * `count_pending_topics` + * `count_pending_replies` + * @since 2.6.10 bbPress (r7235) Renamed: + * `count_trashed_topics` to `count_trash_topics` + * `count_trashed_replies` to `count_trash_replies` + * `count_spammed_topics` to `count_spam_topics` + * `count_spammed_replies` to `count_spam_replies` + * Added: + * `count_hidden_topics` + * `count_hidden_replies` * * @param array $args Optional. The function supports these arguments (all - * default to true): - * - count_users: Count users? - * - count_forums: Count forums? - * - count_topics: Count topics? If set to false, private, spammed and trashed - * topics are also not counted. - * - count_pending_topics: Count pending topics? (only counted if the current + * default to true): + * + * - count_users: Count users? + * - count_forums: Count forums? + * - count_topics: Count topics? If set to false, private, spam and + * trash topics are also not counted. + * - count_pending_topics: Count pending topics? (only counted if the current * user has edit_others_topics cap) - * - count_private_topics: Count private topics? (only counted if the current + * - count_private_topics: Count private topics? (only counted if the current * user has read_private_topics cap) - * - count_spammed_topics: Count spammed topics? (only counted if the current + * - count_hidden_topics: Count hidden topics? (only counted if the current + * user has read_hidden_topics cap) + * - count_spam_topics: Count spam topics? (only counted if the current * user has edit_others_topics cap) - * - count_trashed_topics: Count trashed topics? (only counted if the current + * - count_trash_topics: Count trash topics? (only counted if the current * user has view_trash cap) - * - count_replies: Count replies? If set to false, private, spammed and - * trashed replies are also not counted. + * - count_replies: Count replies? If set to false, private, spam and + * trash replies are also not counted. * - count_pending_replies: Count pending replies? (only counted if the current * user has edit_others_replies cap) * - count_private_replies: Count private replies? (only counted if the current * user has read_private_replies cap) - * - count_spammed_replies: Count spammed replies? (only counted if the current + * - count_hidden_replies: Count hidden replies? (only counted if the current + * user has read_hidden_replies cap) + * - count_spam_replies: Count spam replies? (only counted if the current * user has edit_others_replies cap) - * - count_trashed_replies: Count trashed replies? (only counted if the current + * - count_trash_replies: Count trash replies? (only counted if the current * user has view_trash cap) - * - count_tags: Count tags? If set to false, empty tags are also not counted - * - count_empty_tags: Count empty tags? - * @return object Walked forum tree + * - count_tags: Count tags? If set to false, empty tags are also + * not counted + * - count_empty_tags: Count empty tags? + * + * @return array Array of statistics */ function bbp_get_statistics( $args = array() ) { @@ -323,15 +366,17 @@ function bbp_get_statistics( $args = array() ) { 'count_topics' => true, 'count_pending_topics' => true, 'count_private_topics' => true, - 'count_spammed_topics' => true, - 'count_trashed_topics' => true, + 'count_spam_topics' => true, + 'count_trash_topics' => true, + 'count_hidden_topics' => true, // Replies 'count_replies' => true, 'count_pending_replies' => true, 'count_private_replies' => true, - 'count_spammed_replies' => true, - 'count_trashed_replies' => true, + 'count_spam_replies' => true, + 'count_trash_replies' => true, + 'count_hidden_replies' => true, // Topic tags 'count_tags' => true, @@ -345,6 +390,15 @@ function bbp_get_statistics( $args = array() ) { $topic_tag_count = $empty_topic_tag_count = 0; $hidden_topic_title = $hidden_reply_title = ''; + // Post statuses + $publish = bbp_get_public_status_id(); + $closed = bbp_get_closed_status_id(); + $pending = bbp_get_pending_status_id(); + $private = bbp_get_private_status_id(); + $hidden = bbp_get_hidden_status_id(); + $spam = bbp_get_spam_status_id(); + $trash = bbp_get_trash_status_id(); + // Users $user_count = ! empty( $r['count_users'] ) ? bbp_get_total_users() @@ -352,145 +406,139 @@ function bbp_get_statistics( $args = array() ) { // Forums $forum_count = ! empty( $r['count_forums'] ) - ? wp_count_posts( bbp_get_forum_post_type() )->publish + ? wp_count_posts( bbp_get_forum_post_type() )->{$publish} : 0; - // Post statuses - $pending = bbp_get_pending_status_id(); - $private = bbp_get_private_status_id(); - $spam = bbp_get_spam_status_id(); - $trash = bbp_get_trash_status_id(); - $closed = bbp_get_closed_status_id(); + // Default capabilities + $caps = array( + 'view_trash' => false, + 'read_private_topics' => false, + 'edit_others_topics' => false, + 'read_private_replies' => false, + 'edit_others_replies' => false, + 'edit_topic_tags' => false + ); + + // Get capabilities + foreach ( $caps as $key => $cap ) { + $caps[ $key ] = current_user_can( $cap ); + } // Topics if ( ! empty( $r['count_topics'] ) ) { + + // Count all topics $all_topics = wp_count_posts( bbp_get_topic_post_type() ); // Published (publish + closed) - $topic_count = $all_topics->publish + $all_topics->{$closed}; - - if ( current_user_can( 'read_private_topics' ) || current_user_can( 'edit_others_topics' ) || current_user_can( 'view_trash' ) ) { - - // Declare empty arrays - $topics = $topic_titles = array(); - - // Pending - $topics['pending'] = ( ! empty( $r['count_pending_topics'] ) && current_user_can( 'edit_others_topics' ) ) - ? (int) $all_topics->{$pending} - : 0; - - // Private - $topics['private'] = ( ! empty( $r['count_private_topics'] ) && current_user_can( 'read_private_topics' ) ) - ? (int) $all_topics->{$private} - : 0; + $topic_count = $all_topics->{$publish} + $all_topics->{$closed}; - // Spam - $topics['spammed'] = ( ! empty( $r['count_spammed_topics'] ) && current_user_can( 'edit_others_topics' ) ) - ? (int) $all_topics->{$spam} - : 0; + // Declare empty arrays + $topics = $topic_titles = array_fill_keys( bbp_get_non_public_topic_statuses(), '' ); - // Trash - $topics['trashed'] = ( ! empty( $r['count_trashed_topics'] ) && current_user_can( 'view_trash' ) ) - ? (int) $all_topics->{$trash} - : 0; + // Pending + if ( ! empty( $r['count_pending_topics'] ) && ! empty( $caps['edit_others_topics'] ) ) { + $topics[ $pending ] = bbp_number_not_negative( $all_topics->{$pending} ); + $topic_titles[ $pending ] = sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $pending ] ) ); + } - // Total hidden (pending + private + spam + trash) - $topic_count_hidden = $topics['pending'] + $topics['private'] + $topics['spammed'] + $topics['trashed']; + // Private + if ( ! empty( $r['count_private_topics'] ) && ! empty( $caps['read_private_topics'] ) ) { + $topics[ $private ] = bbp_number_not_negative( $all_topics->{$private} ); + $topic_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $private ] ) ); + } - // Generate the hidden topic count's title attribute - $topic_titles[] = ! empty( $topics['pending'] ) - ? sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $topics['pending'] ) ) - : ''; + // Hidden + if ( ! empty( $r['count_hidden_topics'] ) && ! empty( $caps['read_hidden_topics'] ) ) { + $topics[ $hidden ] = bbp_number_not_negative( $all_topics->{$hidden} ); + $topic_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $hidden ] ) ); + } - $topic_titles[] = ! empty( $topics['private'] ) - ? ''//sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics['private'] ) ) - : ''; + // Spam + if ( ! empty( $r['count_spam_topics'] ) && ! empty( $caps['edit_others_topics'] ) ) { + $topics[ $spam ] = bbp_number_not_negative( $all_topics->{$spam} ); + $topic_titles[ $spam ] = sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $spam ] ) ); + } - $topic_titles[] = ! empty( $topics['spammed'] ) - ? sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['spammed'] ) ) - : ''; + // Trash + if ( ! empty( $r['count_trash_topics'] ) && ! empty( $caps['view_trash'] ) ) { + $topics[ $trash ] = bbp_number_not_negative( $all_topics->{$trash} ); + $topic_titles[ $trash ] = sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $trash ] ) ); + } - $topic_titles[] = ! empty( $topics['trashed'] ) - ? sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['trashed'] ) ) - : ''; + // Total hidden (pending, private, hidden, spam, trash) + $topic_count_hidden = array_sum( array_filter( $topics ) ); - // Compile the hidden topic title - $hidden_topic_title = implode( ' | ', array_filter( $topic_titles ) ); - } + // Compile the hidden topic title + $hidden_topic_title = implode( ' | ', array_filter( $topic_titles ) ); } // Replies if ( ! empty( $r['count_replies'] ) ) { + // Count all replies $all_replies = wp_count_posts( bbp_get_reply_post_type() ); // Published - $reply_count = $all_replies->publish; - - if ( current_user_can( 'read_private_replies' ) || current_user_can( 'edit_others_replies' ) || current_user_can( 'view_trash' ) ) { + $reply_count = $all_replies->{$publish}; - // Declare empty arrays - $replies = $reply_titles = array(); + // Declare empty arrays + $replies = $reply_titles = array_fill_keys( bbp_get_non_public_reply_statuses(), '' ); - // Pending - $replies['pending'] = ( ! empty( $r['count_pending_replies'] ) && current_user_can( 'edit_others_replies' ) ) - ? (int) $all_replies->{$pending} - : 0; - - // Private - $replies['private'] = ( ! empty( $r['count_private_replies'] ) && current_user_can( 'read_private_replies' ) ) - ? (int) $all_replies->{$private} - : 0; - - // Spam - $replies['spammed'] = ( ! empty( $r['count_spammed_replies'] ) && current_user_can( 'edit_others_replies' ) ) - ? (int) $all_replies->{$spam} - : 0; - - // Trash - $replies['trashed'] = ( ! empty( $r['count_trashed_replies'] ) && current_user_can( 'view_trash' ) ) - ? (int) $all_replies->{$trash} - : 0; + // Pending + if ( ! empty( $r['count_pending_replies'] ) && ! empty( $caps['edit_others_replies'] ) ) { + $replies[ $pending ] = bbp_number_not_negative( $all_replies->{$pending} ); + $reply_titles[ $pending ] = sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $pending ] ) ); + } - // Total hidden (pending + private + spam + trash) - $reply_count_hidden = $replies['pending'] + $replies['private'] + $replies['spammed'] + $replies['trashed']; + // Private + if ( ! empty( $r['count_private_replies'] ) && ! empty( $caps['read_private_replies'] ) ) { + $replies[ $private ] = bbp_number_not_negative( $all_replies->{$private} ); + $reply_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $private ] ) ); + } - // Generate the hidden topic count's title attribute - $reply_titles[] = ! empty( $replies['pending'] ) - ? sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $replies['pending'] ) ) - : ''; + // Hidden + if ( ! empty( $r['count_hidden_replies'] ) && ! empty( $caps['read_hidden_replies'] ) ) { + $replies[ $hidden ] = bbp_number_not_negative( $all_replies->{$hidden} ); + $reply_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $hidden ] ) ); + } - $reply_titles[] = ! empty( $replies['private'] ) - ? sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies['private'] ) ) - : ''; + // Spam + if ( ! empty( $r['count_spam_replies'] ) && ! empty( $caps['edit_others_replies'] ) ) { + $replies[ $spam ] = bbp_number_not_negative( $all_replies->{$spam} ); + $reply_titles[ $spam ] = sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $spam ] ) ); + } - $reply_titles[] = ! empty( $replies['spammed'] ) - ? sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['spammed'] ) ) - : ''; + // Trash + if ( ! empty( $r['count_trash_replies'] ) && ! empty( $caps['view_trash'] ) ) { + $replies[ $trash ] = bbp_number_not_negative( $all_replies->{$trash} ); + $reply_titles[ $trash ] = sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $trash ] ) ); + } - $reply_titles[] = ! empty( $replies['trashed'] ) - ? sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['trashed'] ) ) - : ''; + // Total hidden (pending, private, hidden, spam, trash) + $reply_count_hidden = array_sum( array_filter( $replies ) ); - // Compile the hidden replies title - $hidden_reply_title = implode( ' | ', array_filter( $reply_titles ) ); - } + // Compile the hidden replies title + $hidden_reply_title = implode( ' | ', $reply_titles ); } // Topic Tags if ( ! empty( $r['count_tags'] ) && bbp_allow_topic_tags() ) { + // Get the topic-tag taxonomy ID + $tt_id = bbp_get_topic_tag_tax_id(); + // Get the count - $topic_tag_count = wp_count_terms( bbp_get_topic_tag_tax_id(), array( 'hide_empty' => true ) ); + $topic_tag_count = wp_count_terms( $tt_id, array( 'hide_empty' => true ) ); // Empty tags - if ( ! empty( $r['count_empty_tags'] ) && current_user_can( 'edit_topic_tags' ) ) { - $empty_topic_tag_count = wp_count_terms( bbp_get_topic_tag_tax_id() ) - $topic_tag_count; + if ( ! empty( $r['count_empty_tags'] ) && ! empty( 'edit_topic_tags' ) ) { + $empty_topic_tag_count = wp_count_terms( $tt_id ) - $topic_tag_count; } } // Tally the tallies - $counts = array_filter( array_map( 'absint', compact( + $counts = compact( 'user_count', 'forum_count', 'topic_count', @@ -499,19 +547,19 @@ function bbp_get_statistics( $args = array() ) { 'reply_count_hidden', 'topic_tag_count', 'empty_topic_tag_count' - ) ) ); + ); // Define return value $statistics = array(); - // Loop through and store the integer and i18n formatted counts. + // Loop through and store the integer and i18n formatted counts foreach ( $counts as $key => $count ) { - $statistics[ $key ] = bbp_number_format_i18n( $count ); - $statistics[ "{$key}_int" ] = $count; + $not_negative = bbp_number_not_negative( $count ); + $statistics[ $key ] = bbp_number_format_i18n( $not_negative ); + $statistics[ "{$key}_int" ] = $not_negative; } - // Add the hidden (topic/reply) count title attribute strings because we - // don't need to run the math functions on these (see above) + // Add the hidden (topic/reply) count title attribute strings $statistics['hidden_topic_title'] = $hidden_topic_title; $statistics['hidden_reply_title'] = $hidden_reply_title; @@ -794,7 +842,7 @@ function bbp_check_for_flood( $anonymous_data = array(), $author_id = 0 ) { * @param int $author_id Topic or reply author ID * @param string $title The title of the content * @param string $content The content being posted - * @param mixed $strict False for moderation_keys. True for blacklist_keys. + * @param mixed $strict False for moderation_keys. True for disallow_keys. * String for custom keys. * @return bool True if test is passed, false if fail */ @@ -818,7 +866,7 @@ function bbp_check_for_moderation( $anonymous_data = array(), $author_id = 0, $t // Strict mode uses WordPress "blacklist" settings if ( true === $strict ) { $hook_name = 'blacklist'; - $option_name = 'blacklist_keys'; + $option_name = 'disallow_keys'; // Non-strict uses WordPress "moderation" settings } elseif ( false === $strict ) { @@ -1091,7 +1139,7 @@ function bbp_notify_topic_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = bbp_remove_all_filters( 'the_title' ); // Strip tags from text and setup mail data - $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); + $forum_title = wp_specialchars_decode( strip_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); $reply_author_name = wp_specialchars_decode( strip_tags( $reply_author_name ), ENT_QUOTES ); $reply_content = wp_specialchars_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); @@ -1121,7 +1169,7 @@ function bbp_notify_topic_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = } // For plugins to filter titles per reply/topic/user - $subject = apply_filters( 'bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id ); + $subject = apply_filters( 'bbp_subscription_mail_title', '[' . $forum_title . '] ' . $topic_title, $reply_id, $topic_id ); if ( empty( $subject ) ) { return; } @@ -1258,7 +1306,7 @@ function bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_ bbp_remove_all_filters( 'the_title' ); // Strip tags from text and setup mail data - $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); + $forum_title = wp_specialchars_decode( strip_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); $topic_author_name = wp_specialchars_decode( strip_tags( $topic_author_name ), ENT_QUOTES ); $topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); @@ -1288,7 +1336,7 @@ function bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_ } // For plugins to filter titles per reply/topic/user - $subject = apply_filters( 'bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id ); + $subject = apply_filters( 'bbp_forum_subscription_mail_title', '[' . $forum_title . '] ' . $topic_title, $topic_id, $forum_id, $user_id ); if ( empty( $subject ) ) { return; } @@ -2471,8 +2519,10 @@ function bbp_request_feed_trap( $query_vars = array() ) { // Get the view query $the_query = bbp_get_view_query_args( $view ); - // Output the feed - bbp_display_topics_feed_rss2( $the_query ); + // Output the feed if view exists + if ( ! empty( $the_query ) ) { + bbp_display_topics_feed_rss2( $the_query ); + } } } diff --git a/wp-content/plugins/bbpress/includes/common/template.php b/wp-content/plugins/bbpress/includes/common/template.php index bc87304f6c..eba7a1ef0a 100644 --- a/wp-content/plugins/bbpress/includes/common/template.php +++ b/wp-content/plugins/bbpress/includes/common/template.php @@ -70,7 +70,7 @@ function bbp_head() { } /** - * Add our custom head action to wp_head + * Add our custom footer action to wp_footer * * @since 2.0.0 bbPress (r2464) */ @@ -1082,7 +1082,7 @@ function bbp_body_class( $wp_classes = array(), $custom_classes = false ) { // Any page with bbPress content if ( ! empty( $bbp_classes ) ) { $bbp_classes[] = 'bbpress'; - $bbp_classes[] = 'no-js'; + $bbp_classes[] = 'bbp-no-js'; } /** Clean up **************************************************************/ @@ -1097,6 +1097,32 @@ function bbp_body_class( $wp_classes = array(), $custom_classes = false ) { return (array) apply_filters( 'bbp_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes ); } +/** + * Output a small piece of JavaScript to replace the "bbp-no-js" body class + * with "bbp-js" to allow interactive & dynamic elements to work as intended. + * + * @since 2.6.10 bbPress (r7229) + */ +function bbp_swap_no_js_body_class() { + static $done = false; + + // Bail if already done + if ( true === $done ) { + return; + } + + // Mark as done + $done = true; + +?> + + + + class swap from "bbp-no-js" to "bbp-js" +add_action( 'wp_body_open', 'bbp_swap_no_js_body_class' ); +add_action( 'bbp_footer', 'bbp_swap_no_js_body_class' ); + /** * bbp_ready - attached to end 'bbp_init' above * @@ -137,7 +141,9 @@ * v---Load order */ add_action( 'bbp_ready', 'bbp_setup_akismet', 2 ); // Spam prevention for topics and replies -add_action( 'bp_loaded', 'bbp_setup_buddypress', 1 ); // Social network integration + +// Setup BuddyPress using its own hook +add_action( 'bp_include', 'bbp_setup_buddypress', 10 ); // Social network integration // Try to load the bbpress-functions.php file from the active themes add_action( 'bbp_after_setup_theme', 'bbp_load_theme_functions', 10 ); diff --git a/wp-content/plugins/bbpress/includes/core/capabilities.php b/wp-content/plugins/bbpress/includes/core/capabilities.php index 4ce3748a7b..3726c8c03f 100644 --- a/wp-content/plugins/bbpress/includes/core/capabilities.php +++ b/wp-content/plugins/bbpress/includes/core/capabilities.php @@ -285,6 +285,16 @@ function bbp_get_blog_roles() { */ function bbp_add_forums_roles( $wp_roles = null ) { + // Maybe initialize WP_Roles just-in-time, but + if ( empty( $wp_roles ) && ! doing_action( 'wp_roles_init' ) ) { + $wp_roles = wp_roles(); + } + + // Bail if unexpected param type + if ( ! is_a( $wp_roles, 'WP_Roles' ) ) { + return; + } + // Get the dynamic roles $bbp_roles = bbp_get_dynamic_roles(); diff --git a/wp-content/plugins/bbpress/includes/core/extend.php b/wp-content/plugins/bbpress/includes/core/extend.php index 86411d90d9..7524cce548 100644 --- a/wp-content/plugins/bbpress/includes/core/extend.php +++ b/wp-content/plugins/bbpress/includes/core/extend.php @@ -68,15 +68,9 @@ function buddypress() { return; } - add_action( - 'bp_setup_components', - function() { - // Include the BuddyPress Component - require_once bbpress()->includes_dir . 'extend/buddypress/loader.php'; + // Include the BuddyPress Component + require_once bbpress()->includes_dir . 'extend/buddypress/loader.php'; - // Instantiate BuddyPress for bbPress - bbpress()->extend->buddypress = new BBP_Forums_Component(); - }, - 7 - ); + // Instantiate BuddyPress for bbPress + bbpress()->extend->buddypress = new BBP_Forums_Component(); } diff --git a/wp-content/plugins/bbpress/includes/core/filters.php b/wp-content/plugins/bbpress/includes/core/filters.php index c20457a9ba..ce96ce63e9 100644 --- a/wp-content/plugins/bbpress/includes/core/filters.php +++ b/wp-content/plugins/bbpress/includes/core/filters.php @@ -52,6 +52,9 @@ // Fix post author id for anonymous posts (set it back to 0) when the post status is changed add_filter( 'wp_insert_post_data', 'bbp_fix_post_author', 30, 2 ); +// Fix untrash post status after a topic or reply is re-instated +add_filter( 'wp_untrash_post_status', 'bbp_fix_untrash_post_status', 10, 3 ); + // Force comments_status on bbPress post types add_filter( 'comments_open', 'bbp_force_comment_status' ); diff --git a/wp-content/plugins/bbpress/includes/extend/akismet.php b/wp-content/plugins/bbpress/includes/extend/akismet.php index 3ff6ecb370..1617ae6afa 100644 --- a/wp-content/plugins/bbpress/includes/extend/akismet.php +++ b/wp-content/plugins/bbpress/includes/extend/akismet.php @@ -21,6 +21,15 @@ */ class BBP_Akismet { + /** + * The last post checked by Akismet. + * + * @since 2.0.0 bbPress (r3277) + * + * @var array $last_post Default empty array. + */ + protected $last_post = array(); + /** * The main bbPress Akismet loader * diff --git a/wp-content/plugins/bbpress/includes/extend/buddypress/groups.php b/wp-content/plugins/bbpress/includes/extend/buddypress/groups.php index f9062644de..147486dee4 100644 --- a/wp-content/plugins/bbpress/includes/extend/buddypress/groups.php +++ b/wp-content/plugins/bbpress/includes/extend/buddypress/groups.php @@ -155,52 +155,6 @@ private function setup_filters() { add_filter( 'bbp_current_user_can_access_create_topic_form', array( $this, 'form_permissions' ) ); add_filter( 'bbp_current_user_can_access_create_reply_form', array( $this, 'form_permissions' ) ); } - - // Fix rewrite pagination. - add_filter( 'bbp_get_global_object', array( $this, 'fix_rewrite_pagination' ), 10, 2 ); - } - - /** - * Fixes rewrite pagination. - * - * Required for compatibility with BP 12.0, where the /groups/ rewrite rule will - * be caught before bbPress's /page/ rule. - */ - public function fix_rewrite_pagination( $object, $type ) { - if ( 'wp_query' !== $type ) { - return $object; - } - - if ( ! bp_is_group() ) { - return $object; - } - - if ( ! bp_is_current_action( 'forum' ) ) { - return $object; - } - - $page_number = null; - - // Can't use bbp_is_single_topic() because it triggers a loop. - $is_single_topic = bp_is_action_variable( 'topic', 0 ); - - if ( $is_single_topic ) { - if ( bp_is_action_variable( 'page', 2 ) ) { - $page_number = bp_action_variable( 3 ); - } - } else { - if ( bp_is_action_variable( 'page', 0 ) ) { - $page_number = bp_action_variable( 1 ); - } - } - - if ( ! $page_number ) { - return $object; - } - - $object->set( 'paged', $page_number ); - - return $object; } /** diff --git a/wp-content/plugins/bbpress/includes/extend/buddypress/loader.php b/wp-content/plugins/bbpress/includes/extend/buddypress/loader.php index b217384dfd..7339a4da2b 100644 --- a/wp-content/plugins/bbpress/includes/extend/buddypress/loader.php +++ b/wp-content/plugins/bbpress/includes/extend/buddypress/loader.php @@ -30,8 +30,6 @@ * @subpackage BuddyPress */ class BBP_Forums_Component extends BP_Component { - public $activity; - public $members; /** * Start the forums component creation process @@ -54,18 +52,6 @@ public function __construct() { * Include BuddyPress classes and functions */ public function includes( $includes = array() ) { - static $included; - - // Bail if already included - if ( $included ) { - return; - } - - $included = true; - - if ( ! is_array( $includes ) ) { - $includes = array(); - } // Helper BuddyPress functions $includes[] = 'functions.php'; @@ -88,7 +74,19 @@ public function includes( $includes = array() ) { $includes[] = 'groups.php'; } - parent::includes( $includes ); + // Require files if they exist + foreach ( $includes as $file ) { + if ( @is_file( $this->path . $file ) ) { + require $this->path . $file; + } + } + + /** + * Hook for plugins to include files, if necessary. + * + * @since 2.6.0 bbPress (r3552) + */ + do_action( "bp_{$this->id}_includes" ); } /** diff --git a/wp-content/plugins/bbpress/includes/forums/functions.php b/wp-content/plugins/bbpress/includes/forums/functions.php index fba069755b..20f9bf1864 100644 --- a/wp-content/plugins/bbpress/includes/forums/functions.php +++ b/wp-content/plugins/bbpress/includes/forums/functions.php @@ -2308,16 +2308,21 @@ function bbp_pre_get_posts_normalize_forum_visibility( $posts_query = null ) { return; } - // Get query post types array . - $post_types = (array) $posts_query->get( 'post_type' ); + // Bail to prevent unintended wp-admin post_row overrides + if ( is_admin() && isset( $_REQUEST['post_status'] ) ) { + return; + } - // Forums - if ( bbp_get_forum_post_type() === implode( '', $post_types ) ) { + // Get query post types as an array. + $post_types = array_filter( (array) $posts_query->get( 'post_type' ) ); - // Prevent accidental wp-admin post_row override - if ( is_admin() && isset( $_REQUEST['post_status'] ) ) { - return; - } + // Bail if no post types to normalize + if ( empty( $post_types ) ) { + return; + } + + // Forums + if ( in_array( bbp_get_forum_post_type(), $post_types, true ) ) { /** Default ***********************************************************/ @@ -2325,41 +2330,40 @@ function bbp_pre_get_posts_normalize_forum_visibility( $posts_query = null ) { $posts_query->set( 'post_status', array_keys( bbp_get_forum_visibilities() ) ); // Get forums to exclude - $hidden_ids = bbp_exclude_forum_ids( 'array' ); + $forum_ids = bbp_exclude_forum_ids( 'array' ); - // Bail if no forums to exclude - if ( empty( $hidden_ids ) ) { - return; - } + // Excluding some forums + if ( ! empty( $forum_ids ) ) { - // Get any existing meta queries - $not_in = $posts_query->get( 'post__not_in', array() ); + // Get any existing not-in queries + $not_in = $posts_query->get( 'post__not_in', array() ); - // Add our meta query to existing - $not_in = array_unique( array_merge( $not_in, $hidden_ids ) ); + // Add our not-in to existing + $not_in = array_unique( array_merge( $not_in, $forum_ids ) ); - // Set the meta_query var - $posts_query->set( 'post__not_in', $not_in ); + // Set the new not-in val + $posts_query->set( 'post__not_in', $not_in ); + } + } - // Some other post type besides Forums, Topics, or Replies - } elseif ( ! array_diff( $post_types, bbp_get_post_types() ) ) { + // Any bbPress post type + if ( ! array_diff( $post_types, bbp_get_post_types() ) ) { // Get forums to exclude $forum_ids = bbp_exclude_forum_ids( 'meta_query' ); - // Bail if no forums to exclude - if ( empty( $forum_ids ) ) { - return; - } + // Excluding some forums + if ( ! empty( $forum_ids ) ) { - // Get any existing meta queries - $meta_query = (array) $posts_query->get( 'meta_query', array() ); + // Get any existing meta queries + $meta_query = (array) $posts_query->get( 'meta_query', array() ); - // Add our meta query to existing - $meta_query[] = $forum_ids; + // Add our meta query to existing + $meta_query[] = $forum_ids; - // Set the meta_query var - $posts_query->set( 'meta_query', $meta_query ); + // Set the new meta_query val + $posts_query->set( 'meta_query', $meta_query ); + } } } diff --git a/wp-content/plugins/bbpress/includes/forums/template.php b/wp-content/plugins/bbpress/includes/forums/template.php index 8c1cacb562..8bd54745c7 100644 --- a/wp-content/plugins/bbpress/includes/forums/template.php +++ b/wp-content/plugins/bbpress/includes/forums/template.php @@ -1762,7 +1762,7 @@ function bbp_forum_author_id( $forum_id = 0 ) { * @since 2.1.0 bbPress (r3675) * * @param int $forum_id Optional. Forum id - * id and forum id + * * @return string Author of forum */ function bbp_get_forum_author_id( $forum_id = 0 ) { diff --git a/wp-content/plugins/bbpress/includes/replies/functions.php b/wp-content/plugins/bbpress/includes/replies/functions.php index bf4d073dfa..fc3f5fd6ac 100644 --- a/wp-content/plugins/bbpress/includes/replies/functions.php +++ b/wp-content/plugins/bbpress/includes/replies/functions.php @@ -640,12 +640,27 @@ function bbp_edit_reply_handler( $action = '' ) { /** Reply Status **********************************************************/ + // Get available reply statuses + $reply_statuses = bbp_get_reply_statuses( $reply_id ); + // Use existing post_status $reply_status = $reply->post_status; // Maybe force into pending if ( bbp_is_reply_public( $reply_id ) && ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) { $reply_status = bbp_get_pending_status_id(); + + // Check for possible posted reply status + } elseif ( ! empty( $_POST['bbp_reply_status'] ) && in_array( $_POST['bbp_reply_status'], array_keys( $reply_statuses ), true ) ) { + + // Allow capable users to explicitly override the status + if ( current_user_can( 'moderate', $reply_id ) ) { + $reply_status = sanitize_key( $_POST['bbp_reply_status'] ); + + // Not capable + } else { + bbp_add_error( 'bbp_edit_reply_status', __( 'Error: You do not have permission to do that.', 'bbpress' ) ); + } } /** Reply To **************************************************************/ @@ -2056,6 +2071,7 @@ function bbp_reply_content_autoembed() { * @since 2.1.0 bbPress (r4058) * * @param string $where + * @param WP_Query $query * @return string */ function _bbp_has_replies_where( $where = '', $query = false ) { @@ -2408,11 +2424,31 @@ function bbp_list_replies( $args = array() ) { 'per_page' => -1 ), 'list_replies' ); - // Get replies to loop through in $_replies - echo ''; + // Allowed styles (supported by BBP_Walker_Reply) + $allowed = array( 'div', 'ol', 'ul' ); + + // Get style + $style = in_array( $r['style'], $allowed, true ) + ? $r['style'] + : 'ul'; + + // Walk the replies + $walked_html = $r['walker']->paged_walk( + $bbp->reply_query->posts, + $r['max_depth'], + $r['page'], + $r['per_page'], + $r + ); + + // Override the "max_num_pages" setting + $bbp->max_num_pages = $r['walker']->max_pages; - $bbp->max_num_pages = $r['walker']->max_pages; + // No longer in reply loop $bbp->reply_query->in_the_loop = false; + + // Output the replies list + echo "<{$style} class='bbp-replies-list'>" . $walked_html . ""; } /** diff --git a/wp-content/plugins/bbpress/includes/replies/template.php b/wp-content/plugins/bbpress/includes/replies/template.php index 8caefaf2a0..aa7cfbeb86 100644 --- a/wp-content/plugins/bbpress/includes/replies/template.php +++ b/wp-content/plugins/bbpress/includes/replies/template.php @@ -402,7 +402,7 @@ function bbp_reply_permalink( $reply_id = 0 ) { * @since 2.0.0 bbPress (r2553) * * @param int $reply_id Optional. Reply id - * and reply id + * * @return string Permanent link to reply */ function bbp_get_reply_permalink( $reply_id = 0 ) { @@ -465,7 +465,7 @@ function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) { // Get vars needed to support pending topics with unpretty links $has_slug = ! empty( $topic ) ? $topic->post_name : ''; $pretty = bbp_use_pretty_urls(); - $published = ! bbp_is_topic_pending( $topic_id ); + $published = bbp_is_topic_public( $topic_id ); // Don't include pagination if on first page if ( 1 >= $reply_page ) { @@ -799,7 +799,7 @@ function bbp_get_reply_raw_revision_log( $reply_id = 0 ) { * @since 2.0.0 bbPress (r2782) * * @param int $reply_id Optional. Reply id - * @return string reply revisions + * @return WP_Post[]|int[] reply revisions */ function bbp_get_reply_revisions( $reply_id = 0 ) { $reply_id = bbp_get_reply_id( $reply_id ); @@ -1457,7 +1457,7 @@ function bbp_reply_forum_id( $reply_id = 0 ) { * @since 2.0.0 bbPress (r2679) * * @param int $reply_id Optional. Reply id - * id and reply id + * * @return int The forum id of the reply */ function bbp_get_reply_forum_id( $reply_id = 0 ) { diff --git a/wp-content/plugins/bbpress/includes/search/template.php b/wp-content/plugins/bbpress/includes/search/template.php index a8eb22709b..acc1fa57a7 100644 --- a/wp-content/plugins/bbpress/includes/search/template.php +++ b/wp-content/plugins/bbpress/includes/search/template.php @@ -46,25 +46,22 @@ function bbp_has_search_results( $args = array() ) { $default['s'] = $default_search_terms; } - // What are the default allowed statuses (based on user caps) - if ( bbp_get_view_all() ) { + // Default public statuses (topics coincidentally cover all post types) + $post_statuses = array_keys( bbp_get_public_topic_statuses() ); - // Default view=all statuses - $post_statuses = array_keys( bbp_get_topic_statuses() ); - - // Add support for private status - if ( current_user_can( 'read_private_topics' ) ) { - $post_statuses[] = bbp_get_private_status_id(); - } - - // Join post statuses together - $default['post_status'] = $post_statuses; + // Add support for private status + if ( current_user_can( 'read_private_topics' ) ) { + $post_statuses[] = bbp_get_private_status_id(); + } - // Lean on the 'perm' query var value of 'readable' to provide statuses - } else { - $default['perm'] = 'readable'; + // Add support for hidden status + if ( current_user_can( 'read_hidden_topics' ) ) { + $post_statuses[] = bbp_get_hidden_status_id(); } + // Join post statuses together + $default['post_status'] = $post_statuses; + /** Setup *****************************************************************/ // Parse arguments against default values diff --git a/wp-content/plugins/bbpress/includes/topics/functions.php b/wp-content/plugins/bbpress/includes/topics/functions.php index 469579af14..b7fb9aba52 100644 --- a/wp-content/plugins/bbpress/includes/topics/functions.php +++ b/wp-content/plugins/bbpress/includes/topics/functions.php @@ -579,14 +579,14 @@ function bbp_edit_topic_handler( $action = '' ) { $topic_status = $topic->post_status; // Maybe force into pending - if ( bbp_is_topic_public( $topic->ID ) && ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) { + if ( bbp_is_topic_public( $topic_id ) && ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) { $topic_status = bbp_get_pending_status_id(); // Check for possible posted topic status } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( $topic_statuses ), true ) ) { // Allow capable users to explicitly override the status - if ( current_user_can( 'moderate', $forum_id ) ) { + if ( current_user_can( 'moderate', $topic_id ) ) { $topic_status = sanitize_key( $_POST['bbp_topic_status'] ); // Not capable diff --git a/wp-content/plugins/bbpress/includes/topics/template.php b/wp-content/plugins/bbpress/includes/topics/template.php index 3922110968..fdc78aabca 100644 --- a/wp-content/plugins/bbpress/includes/topics/template.php +++ b/wp-content/plugins/bbpress/includes/topics/template.php @@ -808,7 +808,7 @@ function bbp_get_topic_pagination( $args = array() ) { $has_slug = bbp_get_topic( $r['topic_id'] )->post_name; // If pretty permalinks are enabled, make our pagination pretty - $base = ! empty( $has_slug ) && bbp_use_pretty_urls() && ! bbp_is_topic_pending( $r['topic_id'] ) + $base = ! empty( $has_slug ) && bbp_use_pretty_urls() && bbp_is_topic_public( $r['topic_id'] ) ? trailingslashit( get_permalink( $r['topic_id'] ) ) . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' ) : add_query_arg( 'paged', '%#%', get_permalink( $r['topic_id'] ) ); @@ -963,7 +963,7 @@ function bbp_get_topic_raw_revision_log( $topic_id = 0 ) { * @since 2.0.0 bbPress (r2782) * * @param int $topic_id Optional. Topic id - * @return string Topic revisions + * @return WP_Post[]|int[] Topic revisions */ function bbp_get_topic_revisions( $topic_id = 0 ) { $topic_id = bbp_get_topic_id( $topic_id ); diff --git a/wp-content/plugins/bbpress/includes/users/functions.php b/wp-content/plugins/bbpress/includes/users/functions.php index 2adbbfc9d2..1ba1f57f59 100644 --- a/wp-content/plugins/bbpress/includes/users/functions.php +++ b/wp-content/plugins/bbpress/includes/users/functions.php @@ -954,35 +954,59 @@ function bbp_sanitize_displayed_user_field( $value = '', $field = '', $context = * Convert passwords from previous platform encryption to WordPress encryption. * * @since 2.1.0 bbPress (r3813) + * @since 2.6.10 bbPress (r7244) Switched from direct query to get_user_by() */ function bbp_user_maybe_convert_pass() { - // Sanitize username - $username = ! empty( $_POST['log'] ) - ? sanitize_user( $_POST['log'] ) + // Sanitize login + $login = ! empty( $_POST['log'] ) + ? sanitize_user( wp_unslash( $_POST['log'] ) ) : ''; - // Bail if no username - if ( empty( $username ) ) { + // Sanitize password + $pass = ! empty( $_POST['pwd'] ) + ? trim( $_POST['pwd'] ) + : ''; + + // Bail if no username or password + if ( empty( $login ) || empty( $pass ) ) { + return; + } + + // Get user by login... + $user = get_user_by( 'login', $login ); + + // ...or get user by email + if ( empty( $user ) && strpos( $login, '@' ) ) { + $user = get_user_by( 'email', $login ); + } + + // Bail if no user + if ( empty( $user ) ) { return; } - // Bail if no user password to convert - $bbp_db = bbp_db(); - $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 ); - $row = $bbp_db->get_row( $query ); - if ( empty( $row ) || is_wp_error( $row ) ) { + // Get converter class from usermeta + $class = get_user_meta( $user->ID, '_bbp_class', true ); + + // Bail if no converter class in meta + if ( empty( $class ) || ! is_string( $class ) ) { return; } // Setup the converter bbp_setup_converter(); - // Try to convert the old password for this user - $converter = bbp_new_converter( $row->meta_value ); + // Try to instantiate the converter class + $converter = bbp_new_converter( $class ); + + // Bail if no converter + if ( empty( $converter ) ) { + return; + } - // Try to call the conversion method + // Try to call the password conversion callback method if ( ( $converter instanceof BBP_Converter_Base ) && method_exists( $converter, 'callback_pass' ) ) { - $converter->callback_pass( $username, $_POST['pwd'] ); + $converter->callback_pass( $login, $pass ); } } diff --git a/wp-content/plugins/bbpress/readme.txt b/wp-content/plugins/bbpress/readme.txt index dc109e275a..e721359c31 100644 --- a/wp-content/plugins/bbpress/readme.txt +++ b/wp-content/plugins/bbpress/readme.txt @@ -1,12 +1,12 @@ === bbPress === -Contributors: matt, johnjamesjacoby, jmdodd, netweb, sergeybiryukov -Tags: forum, forums, discussion, support -Tested up to: 5.9 -Stable tag: 2.6.9 -License: GPLv2 or later -License URI: https://www.gnu.org/licenses/gpl-2.0.html -Requires PHP: 5.6.20 -Requires at least: 5.0 +Contributors: matt, johnjamesjacoby, jmdodd, netweb, sergeybiryukov +Tags: forum, forums, discussion, support +License: GNU General Public License v2 or later +License URI: https://www.gnu.org/licenses/gpl-2.0.html +Requires PHP: 5.6.20 +Requires at least: 6.0 +Tested up to: 6.5 +Stable tag: 2.6.11 bbPress is forum software for WordPress. diff --git a/wp-content/plugins/bbpress/templates/default/bbpress/content-archive-topic.php b/wp-content/plugins/bbpress/templates/default/bbpress/content-archive-topic.php index bb45f161b2..c6faa30291 100644 --- a/wp-content/plugins/bbpress/templates/default/bbpress/content-archive-topic.php +++ b/wp-content/plugins/bbpress/templates/default/bbpress/content-archive-topic.php @@ -14,15 +14,7 @@
- - -
- - - -
- - + diff --git a/wp-content/plugins/bbpress/templates/default/bbpress/content-search.php b/wp-content/plugins/bbpress/templates/default/bbpress/content-search.php index 917b27284d..6439f0cf54 100644 --- a/wp-content/plugins/bbpress/templates/default/bbpress/content-search.php +++ b/wp-content/plugins/bbpress/templates/default/bbpress/content-search.php @@ -14,6 +14,8 @@
+ + @@ -28,13 +30,9 @@ - - - - - + diff --git a/wp-content/plugins/bbpress/templates/default/bbpress/content-statistics.php b/wp-content/plugins/bbpress/templates/default/bbpress/content-statistics.php index c301d99092..84db6545b0 100644 --- a/wp-content/plugins/bbpress/templates/default/bbpress/content-statistics.php +++ b/wp-content/plugins/bbpress/templates/default/bbpress/content-statistics.php @@ -13,7 +13,7 @@ // Get the statistics $stats = bbp_get_statistics(); ?> -
+
diff --git a/wp-content/plugins/bbpress/templates/default/bbpress/feedback-no-search.php b/wp-content/plugins/bbpress/templates/default/bbpress/feedback-no-search.php index 82c1c16bcd..3fd8cf91a3 100644 --- a/wp-content/plugins/bbpress/templates/default/bbpress/feedback-no-search.php +++ b/wp-content/plugins/bbpress/templates/default/bbpress/feedback-no-search.php @@ -10,10 +10,20 @@ // Exit if accessed directly defined( 'ABSPATH' ) || exit; -?> +if ( bbp_get_search_terms() ) : ?>
+ + + +
+
    +
  • +
+
+ + + +

+
+ +

+ + - - -

-
- -

- - + diff --git a/wp-content/plugins/bbpress/templates/default/bbpress/form-reply.php b/wp-content/plugins/bbpress/templates/default/bbpress/form-reply.php index 9b1e6cbc7d..ca9e366270 100644 --- a/wp-content/plugins/bbpress/templates/default/bbpress/form-reply.php +++ b/wp-content/plugins/bbpress/templates/default/bbpress/form-reply.php @@ -73,14 +73,7 @@ - - -

-
- -

- - + diff --git a/wp-content/plugins/bbpress/templates/default/bbpress/form-topic.php b/wp-content/plugins/bbpress/templates/default/bbpress/form-topic.php index 695188f150..b14043fdb8 100644 --- a/wp-content/plugins/bbpress/templates/default/bbpress/form-topic.php +++ b/wp-content/plugins/bbpress/templates/default/bbpress/form-topic.php @@ -94,14 +94,7 @@ - - -

-
- -

- - + diff --git a/wp-content/plugins/bbpress/templates/default/bbpress/form-user-passwords.php b/wp-content/plugins/bbpress/templates/default/bbpress/form-user-passwords.php index 34dcfec258..6768d24712 100644 --- a/wp-content/plugins/bbpress/templates/default/bbpress/form-user-passwords.php +++ b/wp-content/plugins/bbpress/templates/default/bbpress/form-user-passwords.php @@ -13,10 +13,6 @@ // Filters the display of the password fields if ( apply_filters( 'show_password_fields', true, bbpress()->displayed_user ) ) : ?> - -
diff --git a/wp-content/plugins/bbpress/templates/default/css/bbpress.css b/wp-content/plugins/bbpress/templates/default/css/bbpress.css index e4b4a58c3f..ad278d36c2 100644 --- a/wp-content/plugins/bbpress/templates/default/css/bbpress.css +++ b/wp-content/plugins/bbpress/templates/default/css/bbpress.css @@ -8,13 +8,14 @@ /* =bbPress Style -------------------------------------------------------------- */ +/* Hide completely (including from screen readers) */ .hidden, -.no-js .hide-if-no-js, -.js .hide-if-js { +.bbp-no-js .hide-if-no-js, +.bbp-js .hide-if-js { display: none; } -/* Hide visually but not from screen readers */ +/* Hide visually (but not from screen readers) */ .screen-reader-text, .screen-reader-text span, .ui-helper-hidden-accessible {