Skip to content

How to remove “Insert into post” button from media panel

add_action( 'admin_footer-post-new.php', 'firmasite_mediapanel_edit' );
add_action( 'admin_footer-post.php', 'firmasite_mediapanel_edit' );
function firmasite_mediapanel_edit() { ?>
  <script type="text/javascript">
jQuery(document).on("DOMNodeInserted", function(){
		// Removing "Insert into post" button from media panel
		jQuery('a.media-button-insert').filter(function(index) { return jQuery(this).text() === "<?php echo __( 'Insert into post' ); ?>" }).remove();
	});
  </script>
<?php }

This will remove “Insert into post” button from wordpress 3.5 media panel from post post types. It wont remove from page post types. For removing both:

add_action( 'admin_footer-post-new.php', 'firmasite_mediapanel_edit' );
add_action( 'admin_footer-post.php', 'firmasite_mediapanel_edit' );
function firmasite_mediapanel_edit() { ?>
  <script type="text/javascript">
jQuery(document).on("DOMNodeInserted", function(){
		// Removing "Insert into post" button from media panel
		jQuery('a.media-button-insert').filter(function(index) { return jQuery(this).text() === "<?php echo __( 'Insert into post' ); ?>" }).remove();
		// Removing "Insert into page" button from media panel
		jQuery('a.media-button-insert').filter(function(index) { return jQuery(this).text() === "<?php echo __( 'Insert into page' ); ?>" }).remove();
	});
  </script>
<?php }

Leave a Reply

Your email address will not be published. Required fields are marked *