<?php
/**
 * Seed WooCommerce tag "norepetito" that will be used to identify products that should not be allowed for this plugin.
 */

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use const Repetito\NOREPETITO_TAG;

function repetito_seed_norepetito_tag() {
	// Check if WooCommerce is active.
	if ( ! class_exists( 'WooCommerce' ) ) {
		return;
	}
	$tag = get_term_by( 'name', NOREPETITO_TAG, 'product_tag' );
	if ( ! $tag ) {
		wp_insert_term( NOREPETITO_TAG, 'product_tag', array(
			'slug'        => NOREPETITO_TAG,
			'description' => __( 'Product tag to exclude from Repetito reusable returnable packaging.', 'repetito' ),
		) );
	}
}

add_action( 'init', 'repetito_seed_norepetito_tag' );