Inventory_Presser_Customize_Admin_Dashboard::delete_all_inventory()


Source

File: includes/class-customize-admin-dashboard.php

			switch( $attachment->post_mime_type )
			{
				case 'image/jpeg':
				case 'image/png':
				case 'image/gif':
					$counts['image']++;
					break;
				case 'video/mpeg':
				case 'video/mp4':
				case 'video/quicktime':
					$counts['video']++;
					break;
				case 'text/csv':
				case 'text/plain':
				case 'text/xml':
					$counts['text']++;
					break;
				case 'application/pdf':
					$counts['PDF']++;
					break;
				default:
					$counts['other']++;
					break;
			}
		}
		if( 0 < ( $counts['image'] + $counts['video'] + $counts['text'] + $counts['PDF'] + $counts['other'] ) )
		{
			$note = '';
			foreach( $counts as $key => $count )
			{
				if( 0 < $count )
				{
					if( '' != $note ) { $note .= ', '; }
					$note .= $count . ' ' . $key . ( 1 != $count ? 's' : '' );
				}
			}
			return $note;
		}
		return '0 photos';
	}
	
	/**
	 * create_delete_all_post_attachments_button
	 * 
	 * Creates HTML that renders a button that says "Delete All Media" that will
	 * be placed near the Add Media button.
	 *
	 * @return string
	 */
	function create_delete_all_post_attachments_button()
	{
		global $post;
		if( ! is_object( $post ) || ! isset( $post->ID ) )
		{
			return '';
		}
		//does this post have attachments?
		$post = get_post( $post->ID );
		if( INVP::POST_TYPE != $post->post_type )
		{
			return '';
		}
		$attachments = get_children( array(
			'post_parent'    => $post->ID,
			'post_type'      => 'attachment',
			'posts_per_page' => -1,
		) );
		if( 0 === sizeof( $attachments ) )
		{