Buddypress_Helpers::select_topic_fields_func()
Return all the specific topics of a forum in ajax call
Source Source
File: src/integrations/buddypress/helpers/buddypress-helpers.php
public function select_topic_fields_func() { Automator()->utilities->ajax_auth_check( $_POST ); $fields = array(); if ( isset( $_POST ) ) { $fields[] = [ 'value' => - 1, 'text' => __( 'Any topic', 'uncanny-automator' ), ]; $forum_id = (int) $_POST['value']; if ( $forum_id > 0 ) { $args = [ 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $forum_id, 'post_status' => array_keys( get_post_stati() ), 'posts_per_page' => 9999, ]; $topics = Automator()->helpers->recipe->wp_query( $args ); if ( ! empty( $topics ) ) { foreach ( $topics as $input_id => $input_title ) { $fields[] = [ 'value' => $input_id, 'text' => $input_title, ]; } } } } echo wp_json_encode( $fields ); die(); }
Expand full source code Collapse full source code View on Github