# bbp-core/2.4.3/includes/ajax_actions.php

Forumax – AI Powered Advanced Community Forum Plugin, version 2.4.3. 642 lines.

- Page: https://pluginprobe.com/plugins/bbp-core/2.4.3/code/includes/ajax_actions.php
- Raw: https://pluginprobe.com/plugins/bbp-core/2.4.3/raw/includes/ajax_actions.php
- Modified: 2026-07-10T07:02:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bbp-core/2.4.3/code/includes/ajax_actions.php#L10-L20`.

```php
<?php
/**
 * Ajax actions for Forumax
 *
 * @package Forumax
 */

defined( 'ABSPATH' ) || exit;

/**
 * All Search results
 */
add_action( 'wp_ajax_forumax_search_data_fetch', 'forumax_search_data_fetch' );
add_action( 'wp_ajax_nopriv_forumax_search_data_fetch', 'forumax_search_data_fetch' );

/**
 * Build the ancestor "breadcrumb" trail for a search result, mirroring the
 * EazyDocs search UI (e.g. Forum › Topic for a reply).
 *
 * @param int    $post_id Post ID.
 * @param string $type    Post type of the result.
 * @return array List of ancestor titles, ordered from top-most down.
 */
function forumax_search_result_breadcrumb( $post_id, $type ) {
	$crumbs = array();

	if ( 'reply' === $type && function_exists( 'bbp_get_reply_forum_id' ) ) {
		$forum_id = bbp_get_reply_forum_id( $post_id );
		$topic_id = bbp_get_reply_topic_id( $post_id );
		if ( $forum_id ) {
			$crumbs[] = get_the_title( $forum_id );
		}
		if ( $topic_id ) {
			$crumbs[] = get_the_title( $topic_id );
		}
	} elseif ( 'topic' === $type && function_exists( 'bbp_get_topic_forum_id' ) ) {
		$forum_id = bbp_get_topic_forum_id( $post_id );
		if ( $forum_id ) {
			$crumbs[] = get_the_title( $forum_id );
		}
	} else {
		// Generic hierarchy fallback (forums with parents, docs, pages, etc.).
		foreach ( array_reverse( get_post_ancestors( $post_id ) ) as $ancestor_id ) {
			$crumbs[] = get_the_title( $ancestor_id );
		}
	}

	return array_values( array_filter( $crumbs ) );
}

/**
 * Fetch search data.
 */
function forumax_search_data_fetch() {

	// Check nonce.
	check_ajax_referer( 'forumax-nonce', 'nonce' );

	// Sanitize keyword.
	$keyword   = isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : '';
	$post_type = isset( $_POST['post_type'] ) ? sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) : '';

	// Determine which post types to query. An explicit single post type narrows
	// the search; 'all' (or no value) searches the whole forum: forums, topics
	// and replies, so content matches from any of them are returned.
	if ( ! empty( $post_type ) && 'all' !== $post_type ) {
		$query_post_types = array( $post_type );
	} elseif ( class_exists( 'bbPress' ) ) {
		$query_post_types = array( 'forum', 'topic', 'reply' );
	} else {
		$query_post_types = array( 'post' );
	}

	// Determine which statuses to include. bbPress stores closed topics with the
	// 'closed' post status (and uses 'private'/'hidden' for restricted forums),
	// none of which are returned by WP_Query's default 'publish'-only behavior.
	// Include the publicly viewable bbPress statuses so closed topics still match.
	if ( class_exists( 'bbPress' ) ) {
		$query_post_status = array( 'publish', 'closed', 'private', 'hidden' );
	} else {
		$query_post_status = array( 'publish' );
	}

	// Force the search to match BOTH the title and the content. This overrides
	// any other plugin/theme `posts_search` filter that may otherwise restrict
	// matching to titles only, so content keywords return results too.
	$bbpc_search_clause = static function ( $search, $wp_query ) use ( $keyword ) {
		global $wpdb;

		if ( '' === $keyword || ! $wp_query->get( 'bbpc_ajax_search' ) ) {
			return $search;
		}

		$like = '%' . $wpdb->esc_like( $keyword ) . '%';

		return $wpdb->prepare(
			" AND ( {$wpdb->posts}.post_title LIKE %s OR {$wpdb->posts}.post_content LIKE %s ) ",
			$like,
			$like
		);
	};

	add_filter( 'posts_search', $bbpc_search_clause, 999, 2 );

	// Main results query.
	$results = new \WP_Query( array(
		'post_type'        => $query_post_types,
		'post_status'      => $query_post_status,
		's'                => $keyword,
		'posts_per_page'   => 10,
		'bbpc_ajax_search' => true,
	) );

	remove_filter( 'posts_search', $bbpc_search_clause, 999 );

	$results_count = $results->found_posts;

	if ( $results_count > 0 ) {
		$nsoresult = 'data-result=';
	} else {
		$nsoresult = 'data-noresult=';
	}

	?>
	<div class="tab-item active all-active" <?php echo esc_attr( $nsoresult . 'No-Results-Found' ); ?>></div>
	<?php

	echo '<div class="bbpc-search-results-wrapper">';
	echo '<div class="search-results-tab forum show" id="search-forum-results">';

	if ( $results->have_posts() ) :
		// Group results by post type.
		$grouped = array();
		while ( $results->have_posts() ) :
			$results->the_post();
			$type = get_post_type();
			if ( ! isset( $grouped[ $type ] ) ) {
				$grouped[ $type ] = array();
			}
			$grouped[ $type ][] = array(
				'id'         => get_the_ID(),
				'title'      => get_the_title(),
				'url'        => get_the_permalink(),
				'breadcrumb' => forumax_search_result_breadcrumb( get_the_ID(), $type ),
			);
		endwhile;
		wp_reset_postdata();

		// Render grouped results.
		$type_labels = array(
			'forum' => __( 'Forums', 'forumax' ),
			'topic' => __( 'Topics', 'forumax' ),
			'reply' => __( 'Replies', 'forumax' ),
			'docs'  => __( 'Documentation', 'forumax' ),
			'post'  => __( 'Posts', 'forumax' ),
		);

		// Document icon shared by every result row.
		$result_icon = '<svg class="bbpc-result-icon" width="16" height="16" viewBox="0 0 17 17" fill="currentColor" role="img" aria-hidden="true"><path d="M14.72,0H2.28A2.28,2.28,0,0,0,0,2.28V14.72A2.28,2.28,0,0,0,2.28,17H14.72A2.28,2.28,0,0,0,17,14.72V2.28A2.28,2.28,0,0,0,14.72,0ZM2.28,1H14.72A1.28,1.28,0,0,1,16,2.28V5.33H1V2.28A1.28,1.28,0,0,1,2.28,1ZM1,14.72V6.33H5.33V16H2.28A1.28,1.28,0,0,1,1,14.72ZM14.72,16H6.33V6.33H16v8.39A1.28,1.28,0,0,1,14.72,16Z"></path></svg>';

		// Result type tabs (All / Forums / Topics / Replies), mirroring EazyDocs.
		?>
		<div class="bbpc-result-tabs">
			<button type="button" class="bbpc-tab active" data-tab="all"><?php esc_html_e( 'All', 'forumax' ); ?></button>
			<?php foreach ( $grouped as $type => $posts ) :
				$tab_label = isset( $type_labels[ $type ] ) ? $type_labels[ $type ] : ucfirst( $type );
				?>
				<button type="button" class="bbpc-tab" data-tab="<?php echo esc_attr( $type ); ?>"><?php echo esc_html( $tab_label ); ?></button>
			<?php endforeach; ?>
		</div>
		<?php

		foreach ( $grouped as $type => $posts ) :
			$label = isset( $type_labels[ $type ] ) ? $type_labels[ $type ] : ucfirst( $type );
			?>
			<div class="bbpc-result-group" data-type="<?php echo esc_attr( $type ); ?>">
				<div class="bbpc-result-group-label"><?php echo esc_html( $label ); ?></div>
				<?php foreach ( $posts as $post_item ) : ?>
					<div class="search-result-item" data-url="<?php echo esc_url( $post_item['url'] ); ?>" onclick="document.location='<?php echo esc_url( $post_item['url'] ); ?>'">
						<a href="<?php echo esc_url( $post_item['url'] ); ?>" class="bbpc-result-link">
							<?php echo $result_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static markup. ?>
							<span class="bbpc-result-body">
								<span class="bbpc-result-title"><?php echo esc_html( $post_item['title'] ); ?></span>
								<span class="bbpc-result-type"><?php echo esc_html( $label ); ?></span>
							</span>
						</a>
						<?php if ( ! empty( $post_item['breadcrumb'] ) ) : ?>
							<ol class="bbpc-result-breadcrumb">
								<?php foreach ( $post_item['breadcrumb'] as $crumb ) : ?>
									<li class="bbpc-breadcrumb-item"><?php echo esc_html( $crumb ); ?></li>
								<?php endforeach; ?>
							</ol>
						<?php endif; ?>
					</div>
				<?php endforeach; ?>
			</div>
			<?php
		endforeach;
	endif;

	echo '</div>';
	echo '</div>';
	wp_die();
}

/**
 * AJAX handler to fetch forums for Gutenberg block editor
 * Used by the Single Forum block to populate the forum selector dropdown
 */
add_action( 'wp_ajax_bbpc_get_forums', 'forumax_get_forums_ajax' );

/**
 * Get forums ajax.
 */
function forumax_get_forums_ajax() {
	// Verify nonce for security
	check_ajax_referer( 'forumax-nonce', 'nonce' );

	if ( ! current_user_can( 'edit_posts' ) ) {
		wp_send_json_error( 'Unauthorized' );
	}

	// Get all forums
	$forums = new \WP_Query( [
		'post_type'      => 'forum',
		'posts_per_page' => -1,
		'orderby'        => 'title',
		'order'          => 'ASC',
	] );

	$forum_list = [];

	if ( $forums->have_posts() ) {
		while ( $forums->have_posts() ) {
			$forums->the_post();
			$forum_list[] = [
				'id'    => get_the_ID(),
				'title' => get_the_title(),
			];
		}
		wp_reset_postdata();
	}

	wp_send_json_success( $forum_list );
}


/**
 * Loading Post
 */
add_action( 'wp_ajax_forumax_loading_post', 'forumax_loading_post' );
add_action( 'wp_ajax_nopriv_forumax_loading_post', 'forumax_loading_post' );

/**
 * Loading forum posts
 *
 * @return void
 */
function forumax_loading_post() {
	// Check nonce
	if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'forumax-nonce' ) ) {
		wp_die( '-1' );
	}

	$type    = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
	$post_in = isset( $_POST['a_t_id'] ) ? sanitize_text_field( wp_unslash( $_POST['a_t_id'] ) ) : '';
	$count   = isset( $_POST['count'] ) ? sanitize_text_field( wp_unslash( $_POST['count'] ) ) : '';
	$parent  = isset( $_POST['parent'] ) ? sanitize_text_field( wp_unslash( $_POST['parent'] ) ) : '';

	$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
	$q     = [
		'post_type'           => 'topic',
		'post_parent'         => $parent,
		'order'               => 'DESC',
		'orderby'             => 'post_date',
		'post_status'         => 'publish',
		'posts_per_page'      => get_option( '_bbp_topics_per_page', 10 ),
		'ignore_sticky_posts' => 1,
	];

	if ( 'author' === $type ) {
		$auth_ids = [
			'author' => $post_in,
		];
		$q        = array_merge( $q, $auth_ids );
	} elseif ( 'tag' === $type ) {
		$tax_query[] = [
			'taxonomy' => 'topic-tag',
			'field'    => 'term_id',
			'terms'    => $post_in,
		];
	}

	$tax_query[] = [
		'taxonomy' => 'post_format',
		'field'    => 'slug',
		'terms'    => [ 'post-format-quote', 'post-format-link' ],
		'operator' => 'NOT IN',
	];

	if ( ! empty( $tax_query ) ) {
		$tax_query = array_merge( [ 'relation' => 'AND' ], $tax_query );
		$q         = array_merge( $q, [ 'tax_query' => $tax_query ] );
	}

	$query = new WP_Query( $q );

	if ( $query->have_posts() ) :
		echo '<div class="community-posts-wrapper bb-radius">';
		while ( $query->have_posts() ) : $query->the_post();
			global $post;
			$author_id      = $post->post_author;
			$parent_post_id = $parent;
			$favoriters     = get_post_meta( get_the_ID(), '_bbp_favorite', true );
			$favorite_count = ! empty( $favoriters ) ? $favoriters[0] : '0';
			$get_reply      = get_post_meta( get_the_ID(), '_bbp_reply_count', true );
			$_reply_count   = isset( $get_reply ) && ! empty( $get_reply ) ? $get_reply : 0;
			?>
            <div class="community-post style-two <?php the_author_meta( 'user_nicename', $author_id ); ?>">
                <div class="post-content">
                    <div class="author-avatar">
						<?php
						echo bbp_get_topic_author_link(
							[
								'post_id' => get_the_ID(),
								'type'    => 'avatar',
								'size'    => 40,
							]
						);
						?>
                    </div>
                    <div class="entry-content">
						<?php the_title( sprintf( '<a href="%s" rel="bookmark"> <h3 class="post-title">', esc_url( get_permalink() ) ), '</h3></a>' ); ?>
                        <ul class="meta">
                            <li>
								<?php echo get_the_post_thumbnail( bbp_get_topic_forum_id(), [ 40, 40 ] ); ?>
                                <a href="<?php echo get_permalink( bbp_get_topic_forum_id() ); ?>">
									<?php echo get_the_title( bbp_get_topic_forum_id() ); ?>
                                </a>
                            </li>
                            <li><i class="icon_clock_alt"></i> <?php bbp_topic_post_date( get_the_ID() ); ?> </li>
                        </ul>
                    </div>
                </div>
                <div class="post-meta-wrapper">
                    <ul class="post-meta-info">
                        <li><a href="#"><i class="icon_chat_alt"></i><?php echo esc_html( $_reply_count ); ?></a></li>
                        <li><a href="#"><i class="icon_star"></i><?php echo esc_html( $favorite_count ); ?></a></li>
                    </ul>
                </div>
            </div>
		<?php
		endwhile;
		wp_reset_postdata();

		echo '</div>';
	else :
		echo '<div class="community-post-error bug">';
		echo '<div class="error-content">';
		echo '<svg height="40" class="forumax-error error-icon" viewBox="0 0 24 24" version="1.1" width="40" aria-hidden="true"><path d="M12 7a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0112 7zm1 9a1 1 0 11-2 0 1 1 0 012 0z"></path><path fill-rule="evenodd" d="M12 1C5.925 1 1 5.925 1 12s4.925 11 11 11 11-4.925 11-11S18.075 1 12 1zM2.5 12a9.5 9.5 0 1119 0 9.5 9.5 0 01-19 0z"></path></svg>';
		echo '<h3 class="error">' . esc_html__( 'Oops! No results matched your search.', 'forumax' ) . '</h3>';
		echo '<p class="error">' . esc_html__( 'You could search again.', 'forumax' ) . '</p>';
		echo '</div>';
		echo '</div>';
	endif;

	wp_die();
}

/**
 * Filter posts by status (open/closed)
 *
 * @return void
 */
add_action( 'wp_ajax_forumax_open_post', 'forumax_open_post' );
add_action( 'wp_ajax_nopriv_forumax_open_post', 'forumax_open_post' );

/**
 * Open post.
 */
function forumax_open_post() {

	// Check nonce
	if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'forumax-nonce' ) ) {
		wp_die( '-1' );
	}

	$is_queried_obj = is_singular( 'forum' ) ? get_queried_object_id() : false;
	$type           = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
	$post_in        = isset( $_POST['a_t_id'] ) ? sanitize_text_field( wp_unslash( $_POST['a_t_id'] ) ) : '';
	$count          = isset( $_POST['count'] ) ? sanitize_text_field( wp_unslash( $_POST['count'] ) ) : '';
	$parent         = isset( $_POST['parent'] ) ? sanitize_text_field( wp_unslash( $_POST['parent'] ) ) : '';
	$userid         = isset( $_POST['userid'] ) ? sanitize_text_field( wp_unslash( $_POST['userid'] ) ) : '';

	$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
	$q     = [
		'post_type'           => 'topic',
		'post_parent'         => $parent,
		'order'               => 'DESC',
		'orderby'             => 'post_date',
		'posts_per_page'      => get_option( '_bbp_topics_per_page', 10 ),
		'ignore_sticky_posts' => 1,
		'author'              => $userid,
	];

	if ( 'open' === $type ) {
		$status = [
			'post_status' => 'publish',
		];
		$q      = array_merge( $q, $status );
	} elseif ( 'closed' === $type ) {
		$status = [
			'post_status' => 'closed',
		];
		$q      = array_merge( $q, $status );
	}

	$tax_query[] = [
		'taxonomy' => 'post_format',
		'field'    => 'slug',
		'terms'    => [ 'post-format-quote', 'post-format-link' ],
		'operator' => 'NOT IN',
	];

	if ( ! empty( $tax_query ) ) {
		$tax_query = array_merge( [ 'relation' => 'AND' ], $tax_query );
		$q         = array_merge( $q, [ 'tax_query' => $tax_query ] );
	}

	$query = new WP_Query( $q );
	if ( $query->have_posts() ) :
		echo '<div class="community-posts-wrapper bb-radius">';
		while ( $query->have_posts() ) : $query->the_post();
			global $post;
			$author_id = $post->post_author;
			//$parent_post_id = get_post_meta( get_the_ID(), '_bbp_topic_id', true );
			$parent_post_id = $parent;
			$favoriters     = get_post_meta( get_the_ID(), '_bbp_favorite', true );
			$favorite_count = ! empty( $favoriters ) ? $favoriters[0] : '0';
			$get_reply      = get_post_meta( get_the_ID(), '_bbp_reply_count', true );
			$_reply_count   = isset( $get_reply ) && ! empty( $get_reply ) ? $get_reply : 0;
			?>

            <div class="community-post style-two <?php the_author_meta( 'user_nicename', $author_id ); ?>">
                <div class="post-content">
                    <div class="author-avatar">
						<?php
						echo bbp_get_topic_author_link(
							[
								'post_id' => get_the_ID(),
								'type'    => 'avatar',
								'size'    => 40,
							]
						);
						?>
                    </div>
                    <div class="entry-content">
						<?php the_title( sprintf( '<a href="%s" rel="bookmark"> <h3 class="post-title">', get_permalink() ), '</h3></a>' ); ?>
                        <ul class="meta">
                            <li>
								<?php echo get_the_post_thumbnail( bbp_get_topic_forum_id(), [ 40, 40 ] ); ?>
                                <a href="<?php echo get_permalink( bbp_get_topic_forum_id() ); ?>">
									<?php echo get_the_title( bbp_get_topic_forum_id() ); ?>
                                </a>
                            </li>
                            <li><i class="icon_clock_alt"></i> <?php bbp_topic_post_date( get_the_ID() ); ?> </li>
                        </ul>
                    </div>
                </div>
                <div class="post-meta-wrapper">
                    <ul class="post-meta-info">
                        <li><a href="#"><i class="icon_chat_alt"></i><?php echo esc_html( $_reply_count ); ?></a></li>
                        <li><a href="#"><i class="icon_star"></i><?php echo esc_html( $favorite_count ); ?></a></li>
                    </ul>
                </div>
            </div>
		<?php
		endwhile;
		wp_reset_postdata();

		echo '</div>';
	else :
		echo '<div class="community-post-error bug">';
		echo '<div class="error-content">';
		echo '<svg height="40" class="forumax-error error-icon" viewBox="0 0 24 24" version="1.1" width="40" aria-hidden="true"><path d="M12 7a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0112 7zm1 9a1 1 0 11-2 0 1 1 0 012 0z"></path><path fill-rule="evenodd" d="M12 1C5.925 1 1 5.925 1 12s4.925 11 11 11 11-4.925 11-11S18.075 1 12 1zM2.5 12a9.5 9.5 0 1119 0 9.5 9.5 0 01-19 0z"></path></svg>';
		echo '<h3 class="error">' . esc_html__( 'Oops! No results matched your search.', 'forumax' ) . '</h3>';
		echo '<p class="error">' . esc_html__( 'You could search again.', 'forumax' ) . '</p>';
		echo '</div>';
		echo '</div>';
	endif;
	wp_die();
}

/**
 * Sort posts
 *
 * @return void
 */
add_action( 'wp_ajax_forumax_loading_sort_post', 'forumax_loading_sort_post' );
add_action( 'wp_ajax_nopriv_forumax_loading_sort_post', 'forumax_loading_sort_post' );

/**
 * Loading sort post.
 */
function forumax_loading_sort_post() {

	// Check nonce
	if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'forumax-nonce' ) ) {
		wp_die( '-1' );
	}

	$sort   = isset( $_POST['sort'] ) ? sanitize_text_field( wp_unslash( $_POST['sort'] ) ) : '';
	$parent = isset( $_POST['parent'] ) ? sanitize_text_field( wp_unslash( $_POST['parent'] ) ) : '';

	$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
	$q     = [
		'post_type'           => 'topic',
		'post_parent'         => $parent,
		'post_status'         => 'publish',
		'posts_per_page'      => get_option( '_bbp_topics_per_page', 10 ),
		'ignore_sticky_posts' => 1,
	];

	if ( 'newest_posts' === $sort ) {
		$newest_posts = [
			'order' => 'DESC',
		];
		$q            = array_merge( $q, $newest_posts );
	} elseif ( 'oldest_posts' === $sort ) {
		$oldest_posts = [
			'order' => 'ASC',
		];
		$q            = array_merge( $q, $oldest_posts );
	} elseif ( 'comment_count' === $sort ) {
		$comment_count = [
			'meta_key' => '_bbp_reply_count',
			'orderby'  => 'meta_value_num',
			'order'    => 'DESC',
		];
		$q             = array_merge( $q, $comment_count );
	} elseif ( 'comment_date' === $sort ) {
		$comment_count = [
			'meta_key'  => '_bbp_reply_count',
			'meta_type' => 'NUMERIC',
			'orderby'   => 'meta_value_num',
			'order'     => 'ASC',
		];
		$q             = array_merge( $q, $comment_count );
	} elseif ( 'recent_updated_post' === $sort ) {
		$post_date = [
			'orderby' => 'post_modified',
			'order'   => 'DESC',
		];
		$q         = array_merge( $q, $post_date );
	} elseif ( 'last_recent_updated_post' === $sort ) {
		$post_modified = [
			'orderby' => 'post_modified',
			'order'   => 'ASC',
		];
		$q             = array_merge( $q, $post_modified );
	}

	$tax_query[] = [
		'taxonomy' => 'post_format',
		'field'    => 'slug',
		'terms'    => [ 'post-format-quote', 'post-format-link' ],
		'operator' => 'NOT IN',
	];

	if ( ! empty( $tax_query ) ) {
		$tax_query = array_merge( [ 'relation' => 'AND' ], $tax_query );
		$q         = array_merge( $q, [ 'tax_query' => $tax_query ] );
	}

	$query = new WP_Query( $q );
	if ( $query->have_posts() ) :
		echo '<div class="community-posts-wrapper bb-radius">';
		while ( $query->have_posts() ) : $query->the_post();
			global $post;

			$author_id      = $post->post_author;
			$parent_post_id = $parent;
			$favoriters     = get_post_meta( get_the_ID(), '_bbp_favorite', true );
			$favorite_count = ! empty( $favoriters ) ? $favoriters[0] : '0';
			$get_reply      = get_post_meta( get_the_ID(), '_bbp_reply_count', true );
			$_reply_count   = isset( $get_reply ) && ! empty( $get_reply ) ? $get_reply : 0;
			?>
            <div class="community-post style-two <?php the_author_meta( 'user_nicename', $author_id ); ?>">
                <div class="post-content">
                    <div class="author-avatar">
						<?php
						echo bbp_get_topic_author_link(
							[
								'post_id' => get_the_ID(),
								'type'    => 'avatar',
								'size'    => 40,
							]
						);
						?>
                    </div>
                    <div class="entry-content">
						<?php the_title( sprintf( '<a href="%s" rel="bookmark"> <h3 class="post-title">', esc_url( get_permalink() ) ), '</h3></a>' ); ?>
                        <ul class="meta">
                            <li>
								<?php
								if ( get_the_post_thumbnail_url( $parent_post_id ) ) :
									?>
                                    <img src="<?php echo get_the_post_thumbnail_url( $parent_post_id ); ?>"
                                         alt="<?php echo get_the_title( $parent_post_id ); ?>">
								<?php
								endif;
								?>
                                <a href="<?php echo get_permalink( $parent_post_id ); ?>"> <?php echo get_the_title( $parent_post_id ); ?> </a>
                            </li>
                            <li><i class="icon_clock_alt"></i> <?php bbp_topic_post_date( get_the_ID() ); ?> </li>
                        </ul>
                    </div>
                </div>
                <div class="post-meta-wrapper">
                    <ul class="post-meta-info">
                        <li><a href="#"><i class="icon_chat_alt"></i><?php echo esc_html( $_reply_count ); ?></a></li>
                        <li><a href="#"><i class="icon_star"></i><?php echo esc_html( $favorite_count ); ?></a></li>
                    </ul>
                </div>
            </div>
		<?php endwhile;
		wp_reset_postdata();

		echo '</div>';
	else :
		echo '<div class="community-post-error bug">';
		echo '<div class="error-content">';
		echo '<svg height="40" class="forumax-error error-icon" viewBox="0 0 24 24" version="1.1" width="40" aria-hidden="true"><path d="M12 7a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0112 7zm1 9a1 1 0 11-2 0 1 1 0 012 0z"></path><path fill-rule="evenodd" d="M12 1C5.925 1 1 5.925 1 12s4.925 11 11 11 11-4.925 11-11S18.075 1 12 1zM2.5 12a9.5 9.5 0 1119 0 9.5 9.5 0 01-19 0z"></path></svg>';
		echo '<h3 class="error">' . esc_html__( 'Oops! No results matched your search.', 'forumax' ) . '</h3>';
		echo '<p class="error">' . esc_html__( 'You could search again.', 'forumax' ) . '</p>';
		echo '</div>';
		echo '</div>';
	endif;

	wp_die();
}

```
