Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

INVP::delete_all_inventory_on_blog()


Source Source

File: includes/class-invp.php

		}
	}

	private static function delete_all_inventory_on_blog()
	{
		$args = array(
			'post_status'    => get_post_stati(),
			'post_type'      => self::POST_TYPE,
			'posts_per_page' => -1,
		);
		$posts = get_posts( $args );
		$deleted_count = 0;
		$settings = self::settings();

		if ( $posts )
		{
			foreach( $posts as $post )
			{
				//delete the parent post or vehicle
				if( $settings['skip_trash'] )
				{
					wp_delete_post( $post->ID, $settings['skip_trash'] );
				}
				else
				{
					wp_trash_post( $post->ID );
				}
				$deleted_count++;
			}
		}

		do_action( 'invp_delete_all_inventory', $deleted_count );

		return $deleted_count;
	}

	private static function delete_all_terms_on_blog()
	{	
		if( ! class_exists( 'Inventory_Presser_Taxonomies' ) )
		{
			require_once( 'class-taxonomies.php' );
		}
		$taxonomies = new Inventory_Presser_Taxonomies();
		global $wpdb;
		foreach( $taxonomies->query_vars_array() as $taxonomy )
		{
			$taxonomy_name = str_replace( '-', '_', $taxonomy );
			$terms = $wpdb->get_results( $wpdb->prepare( 
				"SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", 
				$taxonomy_name
			) );
		
			//delete terms
			if ( $terms )
			{
				foreach ( $terms as $term )
				{
					$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) );
					$wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) );
				}
			}
			
			//delete taxonomy
			$wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy_name ), array( '%s' ) );
		}
	}
	
	/**
	 * delete_attachments