esc_html__( 'A search form for comments.', 'elasticpress' ) ); parent::__construct( 'ep-comments', esc_html__( 'ElasticPress - Comments', 'elasticpress' ), $options ); } /** * Display widget * * @param array $args Widget arguments * @param array $instance Widget instance variables * @since 3.6.0 */ public function widget( $args, $instance ) { echo wp_kses_post( $args['before_widget'] ); ob_start(); if ( ! empty( $instance['title'] ) ) { echo wp_kses_post( $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'] ); } ?>
esc_html__( 'We could not find any results', 'elasticpress' ), 'minimumLengthToSearch' => 2, 'restApiEndpoint' => get_rest_url( null, 'elasticpress/v1/comments' ), ]; /** * Filter the l10n data attached to the Widget Search Comments script * * @since 3.6.0 * @hook ep_comment_search_widget_l10n_data_script * @param {array} $default_script_data Default data attached to the script * @return {array} New l10n data to be attached */ $script_data = apply_filters( 'ep_comment_search_widget_l10n_data_script', $default_script_data ); wp_localize_script( 'elasticpress-comments', 'epc', $script_data ); // phpcs:disable /** * Filter comment search widget HTML * * @hook ep_widget_search_comments * @since 3.6.0 * @param {string} $search_comments_html Widget HTML * @param {string} $title Widget title * @return {string} New HTML */ echo apply_filters( 'ep_widget_search_comments', $search_comments_html, $instance['title'] ); // phpcs:enable echo wp_kses_post( $args['after_widget'] ); } /** * Display widget settings form * * @param array $instance Widget instance variables * @since 3.6.0 */ public function form( $instance ) { $title = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; $post_type = ( isset( $instance['post_type'] ) ) ? $instance['post_type'] : []; $post_types_options = array_map( 'get_post_type_object', array_filter( Features::factory()->get_registered_feature( 'search' )->get_searchable_post_types(), function ( $post_type ) { return post_type_supports( $post_type, 'comments' ); } ) ); ?>
name, $post_type, true ) ); ?> />