ord', 'range', ), 'select' => array( 'select', 'checkbox', 'radio', ), 'date' => array( 'date_picker', 'date_time_picker', ), 'boolean' => array( 'true_false', ), 'post' => array( 'post_object', 'relationship', ), 'taxonomy' => array( 'taxonomy', ), ); } /** * Get search acf field by label. * * @param array $field_type Field types. * * @return false|void * @since 1.35.1 */ public function get_acf_field_check_label( $field_type ) { if ( ! function_exists( 'acf_get_field_type' ) ) { return; } $field_type_object = acf_get_field_type( $field_type ); if ( $field_type_object ) { return $field_type_object->label; } return false; } /** * Load function to get value titles depending on ajax query * * @param mixed $request Ajax request. * @since 1.35.1 * @return array */ public function uael_get_control_value_titles( $request ) { $results = call_user_func( array( $this, 'get_value_titles_for_' . $request['query_type'] ), $request ); return $results; } /** * Get values for 'ACF' query * * @param mixed $request Ajax request. * @since 1.35.1 */ protected function get_value_titles_for_acf( $request ) { $keys = (array) $request['id']; $results = array(); $options = $request['query_options']; $query = new \WP_Query( array( 'post_type' => 'acf-field', 'post_name__in' => $keys, 'posts_per_page' => -1, ) ); foreach ( $query->posts as $post ) { $field_settings = unserialize( $post->post_content ); // phpcs:ignore $field_type = $field_settings['type']; $display = $post->post_title; $display_type = ( $options['show_type'] ) ? $this->get_title() : ''; $display_field_type = ( $options['show_field_type'] ) ? $this->get_acf_field_check_label( $field_type ) : ''; $display = ( $options['show_type'] || $options['show_field_type'] ) ? ': ' . $display : $display; $results[ $post->post_name ] = sprintf( '%1$s %2$s %3$s', $display_type, $display_field_type, $display ); } return $results; } /** * Register Elementor Ajax Actions * * @param mixed $ajax_manager Elementor ajax manager. * @since 1.35.1 */ public function register_ajax_actions( $ajax_manager ) { $ajax_manager->register_ajax_action( 'uael_query_control_value_titles', array( $this, 'uael_get_control_value_titles' ) ); $ajax_manager->register_ajax_action( 'uael_query_control_filter_autocomplete', array( $this, 'uael_get_filter_autocomplete' ) ); } /** * Add initial actions. * * @since 1.35.1 */ protected function add_actions() { add_action( 'elementor/ajax/register_actions', array( $this, 'register_ajax_actions' ) ); } /** * Register the control query. * * @since 1.35.1 */ public function register_controls() { $controls_manager = \Elementor\Plugin::$instance->controls_manager; $controls_manager->register( new Uae_Control_Query() ); } }