WC_Admin_Log_Table_List::source_dropdown()protectedWC 1.0

Display source dropdown

Method of the class: WC_Admin_Log_Table_List{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->source_dropdown();

Notes

  • Global. wpdb. $wpdb

WC_Admin_Log_Table_List::source_dropdown() code WC 8.6.1

<?php
protected function source_dropdown() {
	global $wpdb;

	$sources = $wpdb->get_col(
		"SELECT DISTINCT source
		FROM {$wpdb->prefix}woocommerce_log
		WHERE source != ''
		ORDER BY source ASC"
	);

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