WC_Helper::_filter()private staticWC 1.0

Filter an array of subscriptions by $filter.

Метод класса: WC_Helper{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WC_Helper::_filter( $subscriptions, $filter );
$subscriptions(массив) (обязательный) (передается по ссылке — &)
The subscriptions array, passed by ref.
$filter(строка) (обязательный)
The filter.

Код WC_Helper::_filter() WC 9.4.2

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;
	}
}