protected function build_filter( $name, array $values, $label, $args = array() ) {

		if ( empty( $values ) ) {
			return esc_html( $label ); // Return label text, without being marked up as a label element.
		}

		if ( ! is_array( $args ) ) {
			$args = array(
				'highlight' => $args,
			);
		}

		$args = array_merge( array(
			'highlight' => '',
			'prepend'   => array(),
			'append'    => array(),
		), $args );

		$core_val = __( 'Core', 'query-monitor' );
		$core_key = array_search( $core_val, $values, true );

		if ( 'component' === $name && count( $values ) > 1 && false !== $core_key ) {
			$args['append'][ $core_val ] = $core_val;
			$args['append']['non-core']  = __( 'Non-Core', 'query-monitor' );
			unset( $values[ $core_key ] );
		}

		$filter_id = 'qm-filter-' . $this->collector->id . '-' . $name;

		$out = '<div class="qm-filter-container">';
		$out .= '<label for="' . esc_attr( $filter_id ) . '">' . esc_html( $label ) . '</label>';
		$out .= '<select id="' . esc_attr( $filter_id ) . '" class="qm-filter" data-filter="' . esc_attr( $name ) . '" data-highlight="' . esc_attr( $args['highlight'] ) . '">';
		$out .= '<option value="">' . esc_html_x( 'All', '"All" option for filters', 'query-monitor' ) . '</option>';

		if ( ! empty( $args['prepend'] ) ) {
			foreach ( $args['prepend'] as $value => $label ) {
				$out .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $label ) . '</option>';
			}
		}

		foreach ( $values as $value ) {
			$out .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $value ) . '</option>';
		}

		if ( ! empty( $args['append'] ) ) {
			foreach ( $args['append'] as $value => $label ) {
				$out .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $label ) . '</option>';
			}
		}

		$out .= '</select>';
		$out .= '</div>';

		return $out;

	}
protected function build_filter( $name, array $values, $label, $args = array() ) {

		if ( empty( $values ) ) {
			return esc_html( $label ); // Return label text, without being marked up as a label element.
		}

		if ( ! is_array( $args ) ) {
			$args = array(
				'highlight' => $args,
			);
		}

		$args = array_merge( array(
			'highlight' => '',
			'prepend'   => array(),
			'append'    => array(),
		), $args );

		$core_val = __( 'Core', 'query-monitor' );
		$core_key = array_search( $core_val, $values, true );

		if ( 'component' === $name && count( $values ) > 1 && false !== $core_key ) {
			$args['append'][ $core_val ] = $core_val;
			$args['append']['non-core']  = __( 'Non-Core', 'query-monitor' );
			unset( $values[ $core_key ] );
		}

		$filter_id = 'qm-filter-' . $this->collector->id . '-' . $name;

		$out = '<div class="qm-filter-container">';
		$out .= '<label for="' . esc_attr( $filter_id ) . '">' . esc_html( $label ) . '</label>';
		$out .= '<select id="' . esc_attr( $filter_id ) . '" class="qm-filter" data-filter="' . esc_attr( $name ) . '" data-highlight="' . esc_attr( $args['highlight'] ) . '">';
		$out .= '<option value="">' . esc_html_x( 'All', '"All" option for filters', 'query-monitor' ) . '</option>';

		if ( ! empty( $args['prepend'] ) ) {
			foreach ( $args['prepend'] as $value => $label ) {
				$out .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $label ) . '</option>';
			}
		}

		foreach ( $values as $value ) {
			$out .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $value ) . '</option>';
		}

		if ( ! empty( $args['append'] ) ) {
			foreach ( $args['append'] as $value => $label ) {
				$out .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $label ) . '</option>';
			}
		}

		$out .= '</select>';
		$out .= '</div>';

		return $out;

	}
protected function build_filter ( $ name , array $ values , $ label , $ args = array ( ) ) { if ( empty ( $ values ) ) { return esc_html ( $ label ) ; // Return label text, without being marked up as a label element. } if ( ! is_array ( $ args ) ) { $ args = array ( 'highlight' => $ args , ) ; } $ args = array_merge ( array ( 'highlight' => '' , 'prepend' => array ( ) , 'append' => array ( ) , ) , $ args ) ; $ core_val = __ ( 'Core' , 'query-monitor' ) ; $ core_key = array_search ( $ core_val , $ values , true ) ; if ( 'component' === $ name && count ( $ values ) > 1 && false !== $ core_key ) { $ args [ 'append' ] [ $ core_val ] = $ core_val ; $ args [ 'append' ] [ 'non-core' ] = __ ( 'Non-Core' , 'query-monitor' ) ; unset ( $ values [ $ core_key ] ) ; } $ filter_id = 'qm-filter-' . $ this -> collector -> id . '-' . $ name ; $ out = '<div class="qm-filter-container">' ; $ out .= '<label for="' . esc_attr ( $ filter_id ) . '">' . esc_html ( $ label ) . '</label>' ; $ out .= '<select id="' . esc_attr ( $ filter_id ) . '" class="qm-filter" data-filter="' . esc_attr ( $ name ) . '" data-highlight="' . esc_attr ( $ args [ 'highlight' ] ) . '">' ; $ out .= '<option value="">' . esc_html_x ( 'All' , '"All" option for filters' , 'query-monitor' ) . '</option>' ; if ( ! empty ( $ args [ 'prepend' ] ) ) { foreach ( $ args [ 'prepend' ] as $ value => $ label ) { $ out .= '<option value="' . esc_attr ( $ value ) . '">' . esc_html ( $ label ) . '</option>' ; } } foreach ( $ values as $ value ) { $ out .= '<option value="' . esc_attr ( $ value ) . '">' . esc_html ( $ value ) . '</option>' ; } if ( ! empty ( $ args [ 'append' ] ) ) { foreach ( $ args [ 'append' ] as $ value => $ label ) { $ out .= '<option value="' . esc_attr ( $ value ) . '">' . esc_html ( $ label ) . '</option>' ; } } $ out .= '</select>' ; $ out .= '</div>' ; return $ out ; }
Returns the table filter controls. Safe for output.

@param  string   $name   The name for the `data-` attributes that get filtered by this control.
@param  string[] $values Option values for this control.
@param  string   $label  Label text for the filter control.
@param  array    $args {
@type string $highlight The name for the `data-` attributes that get highlighted by this control.
@type array  $prepend   Associative array of options to prepend to the list of values.
@type array  $append    Associative array of options to append to the list of values.
}
@return string Markup for the table filter controls.
Returns the table filter controls . Safe for output .