Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FutureMedia/aa5d7d844dbf79f0c100c903425f6b4c to your computer and use it in GitHub Desktop.
Save FutureMedia/aa5d7d844dbf79f0c100c903425f6b4c to your computer and use it in GitHub Desktop.
Remove 'Add Media' (and toolbar) button from above WP editor, per post-type.
// Removes the Post Editor Toolbar
// found here http://stackoverflow.com/questions/36865699/wordpress-how-to-hide-toolbar-in-post-editor
if( get_post_type() == 'product' && is_admin() ) {
add_filter( 'admin_footer', 'custom_edit_page_js', 99);
}
function custom_edit_page_js(){
echo '<style type="text/css"> a#content-tmce, a#content-tmce:hover, #qt_content_fullscreen{ display:none; } </style>';
echo '<script type="text/javascript"> jQuery(document).ready(function(){ jQuery("#content-tmce").attr("onclick", null); }); </script>';
}
// Removes Post Editor "Add Media" button
function check_post_type_and_remove_media_buttons() {
global $current_screen;
// use 'post', 'page' or 'custom-post-type-name'
if( 'post' == $current_screen->post_type ) add_action( 'media_buttons_context' , create_function('', 'return;') );
}
add_action('admin_head','check_post_type_and_remove_media_buttons');
// Removes Post Editor "Add Media" button
// found here http://stackoverflow.com/questions/36865699/wordpress-how-to-hide-toolbar-in-post-editor
function z_remove_media_controls() {
remove_action( 'media_buttons', 'media_buttons' );
}
add_action('admin_head','z_remove_media_controls');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment