is_private() || ( ! $show_protected && $category->is_protected() ) ) { $hidden_categories[] = $category->term_id; } } if ( $hidden_categories && ! empty( $hidden_categories ) ) { $this->data['exclude_categories'] = $hidden_categories; $args = array( 'posts_per_page' => -1, 'fields' => 'ids', 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'suppress_filters' => true, 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $hidden_categories ) ) ); $exclude_products = get_posts( $args ); if ( $exclude_products && count( $exclude_products ) > 0 ) { $this->data['exclude_products'] = $exclude_products; } } } if ( isset( $this->data['exclude_categories'] ) ) { add_filter( 'aws_terms_exclude_product_cat', array( $this, 'filter_protected_cats_term_exclude' ) ); } if ( isset( $this->data['exclude_products'] ) ) { add_filter( 'aws_exclude_products', array( $this, 'filter_products_exclude' ) ); } } /* * Exclude product categories */ public function filter_protected_cats_term_exclude( $exclude ) { foreach( $this->data['exclude_categories'] as $to_exclude ) { $exclude[] = $to_exclude; } return $exclude; } /* * Exclude products */ public function filter_products_exclude( $exclude ) { foreach( $this->data['exclude_products'] as $to_exclude ) { $exclude[] = $to_exclude; } return $exclude; } } endif; add_action( 'init', 'AWS_Integrations::instance' );