esc_html__( 'Add a facet to an archive or search results page.', 'elasticpress' ) ); parent::__construct( 'ep-facet', esc_html__( 'ElasticPress - Facet', 'elasticpress' ), $options ); $this->renderer = new Renderer(); } /** * Output widget * * @param array $args Widget args * @param array $instance Instance settings * @since 2.5, 4.2.0 made a wrapper for the renderer call. */ public function widget( $args, $instance ) { $this->renderer->render( $args, $instance ); } /** * Get the markup for an individual facet item. * * @param WP_Term $term Term object. * @param string $url Filter URL. * @param boolean $selected Whether the term is currently selected. * @since 3.6.3, 4.2.0 deprecated in favor of a method in the renderer. * @return string HTML for an individual facet term. */ protected function get_facet_term_html( $term, $url, $selected = false ) { _deprecated_function( __FUNCTION__, '4.2.0', '$this->renderer->get_facet_term_html()' ); return $this->renderer->get_facet_term_html( $term, $url, $selected ); } /** * Output widget form * * @param array $instance Instance settings * @since 2.5 */ public function form( $instance ) { $dashboard_url = admin_url( 'admin.php?page=elasticpress' ); if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { $dashboard_url = network_admin_url( 'admin.php?page=elasticpress' ); } $feature = Features::factory()->get_registered_feature( 'facets' ); $settings = []; if ( $feature ) { $settings = $feature->get_settings(); } $settings = wp_parse_args( $settings, array( 'match_type' => 'all', ) ); $set = esc_html__( 'all', 'elasticpress' ); $not_set = esc_html__( 'any', 'elasticpress' ); if ( 'any' === $settings['match_type'] ) { $set = esc_html__( 'any', 'elasticpress' ); $not_set = esc_html__( 'all', 'elasticpress' ); } $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : ''; $facet = ( ! empty( $instance['facet'] ) ) ? $instance['facet'] : ''; $orderby = ( ! empty( $instance['orderby'] ) ) ? $instance['orderby'] : ''; $order = ( ! empty( $instance['order'] ) ) ? $instance['order'] : ''; $taxonomies = $feature->get_facetable_taxonomies(); $orderby_options = [ 'count' => __( 'Count', 'elasticpress' ), 'name' => __( 'Term Name', 'elasticpress' ), ]; $order_options = [ 'desc' => __( 'Descending', 'elasticpress' ), 'asc' => __( 'Ascending', 'elasticpress' ), ]; ?>




%1$s content tagged to %2$s selected term in ElasticPress settings.', 'elasticpress' ), $set, $not_set, esc_url( $dashboard_url ) ) ); ?>