WC_Helper::_filter()private staticWC 1.0

Filter an array of subscriptions by $filter.

{} It's a method of the class: WC_Helper{}

No Hooks.

Return

null. Nothing.

Usage

$result = WC_Helper::_filter( $subscriptions, $filter );
$subscriptions(array) (required) (passed by reference — &)
The subscriptions array, passed by ref.
$filter(string) (required)
The filter.

Code of WC_Helper::_filter() WC 6.7.0

private static function _filter( &$subscriptions, $filter ) {
	switch ( $filter ) {
		case 'active':
			$subscriptions = wp_list_filter( $subscriptions, array( 'active' => true ) );
			break;

		case 'inactive':
			$subscriptions = wp_list_filter( $subscriptions, array( 'active' => false ) );
			break;

		case 'installed':
			foreach ( $subscriptions as $key => $subscription ) {
				if ( empty( $subscription['local']['installed'] ) ) {
					unset( $subscriptions[ $key ] );
				}
			}
			break;

		case 'update-available':
			$subscriptions = wp_list_filter( $subscriptions, array( 'has_update' => true ) );
			break;

		case 'expiring':
			$subscriptions = wp_list_filter( $subscriptions, array( 'expiring' => true ) );
			break;

		case 'expired':
			$subscriptions = wp_list_filter( $subscriptions, array( 'expired' => true ) );
			break;

		case 'download':
			foreach ( $subscriptions as $key => $subscription ) {
				if ( $subscription['local']['installed'] || $subscription['expired'] ) {
					unset( $subscriptions[ $key ] );
				}
			}
			break;
	}
}