Inventory_Presser_Taxonomies::delete_unused_terms()

delete_unused_terms


Description Description

The nature of inserting and deleting vehicles means terms in a few of our taxonomies will be left behind and unused. This method deletes some of them. Runs once daily in a WordPress cron job.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-taxonomies.php

	function delete_unused_terms()
	{
		$terms = get_terms( array(
			'taxonomy'   => array( 'model_year', 'make', 'model', 'style' ),
			'childless'  => true,
			'count'      => true,
			'hide_empty' => false,
		) );

		foreach( $terms as $term )
		{
			if( 0 == $term->count )
			{
				wp_delete_term( $term->term_id, $term->taxonomy );
			}
		}
	}