ap_get_current_list_filters( string|null $filter = null )

Description #

Get active list filter by filter key.

Parameters #

  • $filter
    string | null (Optional) Filter key. Default value: null

Source #

File: includes/functions.php

function ap_get_current_list_filters( $filter = null ) {
	$get_filters = array();
	$filters     = array_keys( ap_get_list_filters() );

	if ( in_array( 'order_by', $filters, true ) ) {
		$get_filters['order_by'] = ap_opt( 'question_order_by' );
	}

	if ( empty( $filters ) || ! is_array( $filters ) ) {
		$filters = array();
	}

	foreach ( (array) $filters as $k ) {
		$val = ap_isset_post_value( $k );

		if ( ! empty( $val ) ) {
			$get_filters[ $k ] = $val;
		}
	}

	if ( null !== $filter ) {
		return ! isset( $get_filters[ $filter ] ) ? null : $get_filters[ $filter ];
	}

	return $get_filters;
}

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