esc_html__( 'None - choose filter sets below', 'ace-content-filters' ), ) + acewpcf_get_filter_panel_choices(); $this->start_controls_section( 'acewpcf_content_section', array( 'label' => esc_html__( 'Content', 'ace-content-filters' ), ) ); $this->add_control( 'filter_panel_id', array( 'label' => esc_html__( 'Filter panel (optional)', 'ace-content-filters' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $panel_choices, 'default' => '', 'description' => esc_html__( 'Leave this empty when you want to place one simple filter set or a manual combination of sets instead of a saved panel.', 'ace-content-filters' ), ) ); $this->add_control( 'filter_ids', array( 'label' => esc_html__( 'Filter sets', 'ace-content-filters' ), 'type' => \Elementor\Controls_Manager::SELECT2, 'multiple' => true, 'options' => $filter_choices, 'default' => array(), 'label_block' => true, ) ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $filter_panel_id = isset( $settings['filter_panel_id'] ) ? sanitize_key( $settings['filter_panel_id'] ) : ''; $filter_ids = acewpcf_parse_filter_id_list( isset( $settings['filter_ids'] ) ? $settings['filter_ids'] : array() ); $output = acewpcf_render_filter_shortcode( array( 'ids' => $filter_ids, 'panel_id' => $filter_panel_id, ) ); if ( '' === $output ) { return; } echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } } $widgets_manager->register( new ACEWPCF_Ace_Content_Filter_Widget() ); if ( ! class_exists( 'ACEWPCF_Ace_Content_Search_Widget' ) ) { class ACEWPCF_Ace_Content_Search_Widget extends \Elementor\Widget_Base { public function get_name() { return 'ace-content-filters-content-search'; } public function get_title() { return esc_html__( 'ACE Content Search', 'ace-content-filters' ); } public function get_icon() { return 'cpcf-elementor-widget-icon'; } public function get_keywords() { return array( 'search', 'content', 'posts', 'pages', 'ajax', 'ace' ); } public function get_categories() { return array( 'general' ); } public function get_style_depends() { return array( 'acewpcf-filter-style' ); } public function get_script_depends() { return array( 'acewpcf-content-search-script' ); } protected function register_controls() { $search_choices = acewpcf_get_content_search_choices(); $this->start_controls_section( 'acewpcf_content_section', array( 'label' => esc_html__( 'Content', 'ace-content-filters' ), ) ); if ( empty( $search_choices ) ) { $this->add_control( 'acewpcf_search_notice', array( 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => esc_html__( 'Create a content search in ACE Content Filters first, then choose it here.', 'ace-content-filters' ), ) ); } else { $this->add_control( 'search_id', array( 'label' => esc_html__( 'Content search', 'ace-content-filters' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $search_choices, 'default' => array_key_first( $search_choices ), ) ); } $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $search_id = isset( $settings['search_id'] ) ? sanitize_key( $settings['search_id'] ) : ''; $output = acewpcf_render_content_search_shortcode( array( 'id' => $search_id, ) ); if ( '' === $output ) { return; } echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } } $widgets_manager->register( new ACEWPCF_Ace_Content_Search_Widget() ); } add_action( 'elementor/widgets/register', 'acewpcf_register_elementor_widget' ); function acewpcf_register_elementor_assets() { acewpcf_register_assets(); } add_action( 'elementor/frontend/after_register_scripts', 'acewpcf_register_elementor_assets' ); add_action( 'elementor/editor/before_enqueue_scripts', 'acewpcf_register_elementor_assets' ); function acewpcf_enqueue_elementor_preview_assets() { acewpcf_enqueue_assets(); acewpcf_enqueue_content_search_assets(); } add_action( 'elementor/preview/enqueue_styles', 'acewpcf_enqueue_elementor_preview_assets' ); add_action( 'elementor/preview/enqueue_scripts', 'acewpcf_enqueue_elementor_preview_assets' ); function acewpcf_enqueue_elementor_editor_icon_styles() { acewpcf_register_assets(); acewpcf_enqueue_assets(); wp_enqueue_style( 'acewpcf-elementor-editor-style', ACEWPCF_PLUGIN_URL . 'assets/css/elementor-editor.css', array( 'acewpcf-filter-style' ), acewpcf_get_asset_version( 'assets/css/elementor-editor.css' ) ); } add_action( 'elementor/editor/after_enqueue_styles', 'acewpcf_enqueue_elementor_editor_icon_styles' );