Add a discard button to the edit post/page form

Mods and Stuff for WordPress
Post Reply
User avatar
syntax
Site Admin
Posts: 54
Joined: Tue Jan 06, 2009 9:25 pm

Add a discard button to the edit post/page form

Post by syntax » Wed Dec 17, 2014 5:37 pm

Relies on having fontawesome included for the icon

Code: Select all

//discard link
function asd_discard_button(){
	global $post;
	global $wp_version;

	if($post->post_type != 'acf') {
		if($post->post_status == 'publish') {
			echo '<div class="misc-pub-section" style="clear:both;" ><span class="fa-ban" style="font: 400 20px/1 FontAwesome; color: #888; padding: 0px 5px 0px 0px;"></span> <a style="vertical-align: top;" href="'.$_SERVER['REQUEST_URI'].'">Discard Changes</a></div>';
		}
	}
}
add_action( 'post_submitbox_misc_actions', 'asd_discard_button' );
edit: 2/4/2015 added style="clear:both;"

Post Reply