Inventory_Presser_Classic_Editor::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 Return

(string)


Top ↑

Source Source

File: includes/integrations/class-classic-editor.php

	protected function create_delete_all_post_attachments_button() {
		global $post;
		if ( ! is_object( $post ) || ! isset( $post->ID ) ) {
			return '';
		}
		// does this post have attachments?
		$the_post = get_post( $post->ID );
		if ( INVP::POST_TYPE !== $the_post->post_type ) {
			return '';
		}
		$attachments = get_children(
			array(
				'post_parent'    => $the_post->ID,
				'post_type'      => 'attachment',
				'posts_per_page' => -1,
			)
		);
		if ( 0 === count( $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' )
		);
	}