, pending: array} */ function forumax_admin_reply_stats( array $topic_ids ) { global $wpdb; $stats = [ 'total' => [], 'pending' => [], ]; $topic_ids = array_values( array_unique( array_filter( array_map( 'intval', $topic_ids ) ) ) ); foreach ( array_chunk( $topic_ids, 500 ) as $chunk ) { $placeholders = implode( ',', array_fill( 0, count( $chunk ), '%d' ) ); $args = array_merge( [ bbp_get_reply_post_type() ], $chunk ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $rows = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_parent, post_status FROM {$wpdb->posts} WHERE post_type = %s AND post_status IN ( 'publish', 'draft', 'pending' ) AND post_parent IN ( $placeholders ) ORDER BY post_date DESC", $args ) ); foreach ( $rows as $row ) { $parent = (int) $row->post_parent; $stats['total'][ $parent ] = ( $stats['total'][ $parent ] ?? 0 ) + 1; if ( 'pending' === $row->post_status ) { $stats['pending'][ $parent ][] = (int) $row->ID; } } } // Pending reply excerpts and each topic's freshness link are rendered, // so load those posts together instead of one query each. $prime_ids = empty( $stats['pending'] ) ? [] : array_merge( ...array_values( $stats['pending'] ) ); foreach ( $topic_ids as $topic_id ) { $prime_ids[] = (int) get_post_meta( $topic_id, '_bbp_last_active_id', true ); } $prime_ids = array_filter( $prime_ids ); if ( ! empty( $prime_ids ) ) { _prime_post_caches( $prime_ids, false, true ); } return $stats; } } $parent_forums = []; $fcount = wp_count_posts( bbp_get_forum_post_type() ); $forum_count = (int) ( $fcount->publish + $fcount->hidden + $fcount->spam ); ?>
0 ) : include __DIR__ . '/admin_ui/header.php'; ?>
bbp_get_forum_post_type(), 'posts_per_page' => -1, 'post_parent' => 0, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_status' => 'publish', ] ); $count = $forum_query->found_posts; // Left Sidebar Forums. include __DIR__ . '/admin_ui/forums.php'; ?>
$item, 'post_type' => bbp_get_topic_post_type(), 'orderby' => 'menu_order', 'order' => 'asc', 'posts_per_page' => -1, 'post_status' => [ 'any', 'spam' ], ] ); $count_open = 0; $count_closed = 0; $count_hidden = 0; $count_no_reply = 0; $count_solved = 0; $count_unsolved = 0; $count_trash = 0; $reply_stats = forumax_admin_reply_stats( wp_list_pluck( $children->posts, 'ID' ) ); while ( $children->have_posts() ) : $children->the_post(); $topic_id = get_the_ID(); // Count open/closed topics. if ( bbp_is_topic_closed( $topic_id ) ) { $count_closed++; } else { $count_open++; } // Count spam( hidden ) topics. if ( bbp_is_topic_spam( $topic_id ) || bbp_is_topic_pending( $topic_id ) ) { $count_hidden++; } // Replies count. if ( empty( $reply_stats['total'][ $topic_id ] ) ) { $count_no_reply++; } // Count solved. // Before using $GLOBALS['forumax_solve_topic'], check if it is set if (isset($GLOBALS['forumax_solve_topic']) && $GLOBALS['forumax_solve_topic']->is_solved($topic_id)) { $count_solved++; } else { $count_unsolved++; } endwhile; wp_reset_postdata(); // Count trashed topics without loading them. $trash_topic = new WP_Query( [ 'post_parent' => $item, 'post_type' => bbp_get_topic_post_type(), 'posts_per_page' => 1, 'post_status' => [ 'trash' ], 'fields' => 'ids', 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ] ); $count_trash = (int) $trash_topic->found_posts; ?>
post_count > 0 ) : ?>