BBP_Admin::suggest_topic()
Ajax action for facilitating the forum auto-suggest
Description Description
Source Source
File: includes/admin/classes/class-bbp-admin.php
public function suggest_topic() { // Bail early if no request if ( empty( $_REQUEST['q'] ) ) { wp_die( '0' ); } // Bail if user cannot moderate - only moderators can change hierarchy if ( ! current_user_can( 'moderate' ) ) { wp_die( '0' ); } // Check the ajax nonce check_ajax_referer( 'bbp_suggest_topic_nonce' ); // Try to get some topics $topics = get_posts( array( 's' => bbp_db()->esc_like( $_REQUEST['q'] ), 'post_type' => bbp_get_topic_post_type() ) ); // If we found some topics, loop through and display them if ( ! empty( $topics ) ) { foreach ( (array) $topics as $post ) { printf( esc_html__( '%s - %s', 'bbpress' ), bbp_get_topic_id( $post->ID ), bbp_get_topic_title( $post->ID ) . "\n" ); } } die(); }
Changelog Changelog
Version | Description |
---|---|
2.2.0 | Introduced. |