<?php
declare( strict_types=1 );

namespace FiboFilters\Integrations\Plugins;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class HideCategoriesProductsWooCommerce
 *
 *  Plugin Name: Hide Categories and Products for Woocommerce
 *  Plugin URI: https://wordpress.org/plugins/hide-categories-products-woocommerce/
 *  Version: 1.2.9
 */
class HideCategoriesProductsWooCommerce extends AbstractPlugin {
	public function init(): void {
		/** @see \FiboFilters\Indexer\SourceQuery::get_selection_sql() */
		add_filter( 'fibofilters/indexer/filters_source_query/term_ids/excluded/product_cat', [ $this, 'exclude_categories' ], 5 );
	}

	public function exclude_categories( $term_ids ): array {
		$hidden_categories = Hide_Categories_Products_WC()->get_hidden_cats();
		if ( ! empty( $hidden_categories ) ) {
			$term_ids = $hidden_categories;
		}

		return $term_ids;
	}
}
