Inventory_Presser_Taxonomies::add_hooks()

Adds hooks to register and manage our taxonomies

On This Page


Return Return

(void)


Top ↑

Source Source

File: includes/class-taxonomies.php

	public function add_hooks() {
		// Create custom taxonomies for vehicles.
		add_action( 'init', array( $this, 'register_taxonomies' ) );
		add_action( 'init', array( $this, 'unregister_taxonomies' ), 11 );
		// Remove meta boxes from editors if taxonomies are not active.
		add_action( 'admin_head', array( $this, 'editor_remove_meta_boxes' ) );

		add_action( 'init', array( $this, 'register_meta' ) );

		add_action( 'invp_delete_all_data', array( $this, 'delete_term_data' ) );

		// Sort some taxonomy terms as numbers.
		add_filter( 'get_terms_orderby', array( $this, 'sort_terms_as_numbers' ), 10, 3 );

		// Do not include sold vehicles in listings unless an option is checked.
		add_action( 'pre_get_posts', array( $this, 'maybe_exclude_sold_vehicles' ) );

		// Run a cron job to delete empty terms.
		add_action( self::CRON_HOOK_DELETE_TERMS, array( $this, 'delete_unused_terms' ) );

		// Put terms into our taxonomies when the plugin is activated.
		register_activation_hook( INVP_PLUGIN_FILE_PATH, array( 'Inventory_Presser_Taxonomies', 'populate_default_terms' ) );
		// Schedule a weekly wp-cron job to delete empty terms in our taxonomies.
		register_activation_hook( INVP_PLUGIN_FILE_PATH, array( 'Inventory_Presser_Taxonomies', 'schedule_terms_cron_job' ) );
		// Remove the wp-cron job during deactivation.
		register_deactivation_hook( INVP_PLUGIN_FILE_PATH, array( 'Inventory_Presser_Taxonomies', 'remove_terms_cron_job' ) );

		// Change which taxonomies appear in the dashboard menu.
		add_filter( 'invp_taxonomy_data', array( $this, 'change_taxonomy_show_in_menu_attribute' ) );

		// Add a noindex meta tag to vehicle archive pages that have a lot of filters.
		add_filter( 'wp_robots', array( $this, 'maybe_add_noindex' ) );
	}