ap_category_sorting()

Description #

Output category filter dropdown.

Source #

File: includes/taxo.php

function ap_category_sorting() {
	$filters  = ap_get_category_filter();
	$selected = (int) ap_sanitize_unslash( 'ap_cat_sort', 'g', 0 );
	if ( $filters ) {
		echo '<div class="ap-dropdown">';
		echo '<a id="ap-sort-anchor" class="ap-dropdown-toggle' . ( '' !== $selected ? ' active' : '' ) . '" href="#">' . esc_attr__( 'Category', 'anspress-question-answer' ) . '</a>';
		echo '<div class="ap-dropdown-menu">';

		foreach ( $filters as $category_id => $category_name ) {
			echo '<li ' . ( $selected === (int) $category_id ? 'class="active" ' : '' ) . '><a href="#" data-value="' . (int) $category_id . '">' . esc_html( $category_name ) . '</a></li>';
		}
		echo '<input name="ap_cat_sort" type="hidden" value="' . esc_attr( $selected ) . '" />';
		echo '</div>';
		echo '</div>';
	}
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment