WC_Admin_Log_Table_List::level_dropdown()publicWC 1.0

Display level dropdown

Method of the class: WC_Admin_Log_Table_List{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Admin_Log_Table_List = new WC_Admin_Log_Table_List();
$WC_Admin_Log_Table_List->level_dropdown();

Notes

  • Global. wpdb. $wpdb

WC_Admin_Log_Table_List::level_dropdown() code WC 8.9.0

<?php
public function level_dropdown() {
	$labels = WC_Log_Levels::get_all_level_labels();

	$levels = array_reduce(
		array_keys( $labels ),
		function( $carry, $item ) use ( $labels ) {
			$carry[] = array(
				'value' => $item,
				'label' => $labels[ $item ],
			);

			return $carry;
		},
		array()
	);

	$selected_level = isset( $_REQUEST['level'] ) ? $_REQUEST['level'] : '';
	?>
		<label for="filter-by-level" class="screen-reader-text"><?php esc_html_e( 'Filter by level', 'woocommerce' ); ?></label>
		<select name="level" id="filter-by-level">
			<option<?php selected( $selected_level, '' ); ?> value=""><?php esc_html_e( 'All levels', 'woocommerce' ); ?></option>
			<?php
			foreach ( $levels as $l ) {
				printf(
					'<option%1$s value="%2$s">%3$s</option>',
					selected( $selected_level, $l['value'], false ),
					esc_attr( $l['value'] ),
					esc_html( $l['label'] )
				);
			}
			?>
		</select>
	<?php
}