INVP::delete_all_inventory()

delete_all_inventory


Description Description

This function deletes all posts that exist of our custom post type and their associated meta data. Returns the number of vehicles deleted.


Top ↑

Return Return

(int) The number of vehicles that were deleted


Top ↑

Source Source

File: includes/class-invp.php

	 * 
	 * @return int The number of vehicles that were deleted
	 */
	public static function delete_all_inventory()
	{
		if( ! current_user_can( 'delete_posts' ) )
		{
			return 0;
		}

		set_time_limit( 0 );

		if( ! is_multisite() )
		{
			return self::delete_all_inventory_on_blog();
		}

		$sites = get_sites( array( 'network' => 1, 'limit' => 1000 ) );
		foreach( $sites as $site )
		{
			switch_to_blog( $site->blog_id );
			$count = self::delete_all_inventory_on_blog();
			restore_current_blog();