Inventory_Presser_Customize_Dashboard::create_delete_all_post_attachments_button()

create_delete_all_post_attachments_button


Description Description

Creates HTML that renders a button that says "Delete All Media" that will be placed near the Add Media button.


Top ↑

Return Return

(string)


Top ↑

Source Source

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

	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 ) )
		{
			return '';
		}
		return sprintf( 
			'<button type="button" id="delete-media-button" class="button" onclick="delete_all_post_attachments();">'
			. '<span class="wp-media-buttons-icon"></span> %s</button>',
			__( 'Delete All Media', 'inventory-presser' )
		);
	}