Inventory_Presser_Taxonomies::populate_default_terms()

populate_default_terms


Description Description

Populate our taxonomies with terms if they do not already exist


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-taxonomies.php

	static function populate_default_terms()
	{
		//create the taxonomies or else our wp_insert_term calls will fail
		self::register_taxonomies();

		$taxonomy_data = self::taxonomy_data();
		for( $i=0; $i<sizeof( $taxonomy_data ); $i++ )
		{
			if( ! isset( $taxonomy_data[$i]['term_data'] ) ) { continue; }

			foreach( $taxonomy_data[$i]['term_data'] as $abbr => $desc )
			{
				$taxonomy_name = str_replace( '-', '_', $taxonomy_data[$i]['args']['query_var'] );
				if ( ! is_array( term_exists( $desc, $taxonomy_name ) ) )
				{
					$term_exists = wp_insert_term(
						$desc,
						$taxonomy_name,
						array (
							'description' => $desc,
							'slug'        => $abbr,
						)
					);
				}
			}
		}
	}