Remove "insert into button" in media uploader for custom post types
-
Looking for a way to remove the insert into post button in the media uploader for a specific custom post type. I can do it when the post type is in the url but when you edit a post, the post type isn’t in the url.
ex.
post.php?post=27&action=edit
I tried $post, $typenow and $current_screen but the only one that works anywhere so far is $_REQUEST[‘post_type’]. Not sure if part of it is using just
add_action('admin_head', 'remove_insert_button_13247')
In any case, how do I detect the post type when editing a post, custom or other?
function remove_insert_button_13247() { echo '<style type="text/css"> .media-frame a.button-primary {display:none;} </style>'; } function get_current_post_type_13247() { global $post, $typenow, $current_screen; if( $post && $post->post_type ) $post_type = $post->post_type; elseif( $typenow ) $post_type = $typenow; elseif( $current_screen && $current_screen->post_type ) $post_type = $current_screen->post_type; elseif( $_REQUEST['post_type'] ) $post_type = sanitize_key( $_REQUEST['post_type'] ); else $post_type = ''; return $post_type; } if ( get_current_post_type_13247() == 'listing') { add_action('admin_head', 'remove_insert_button_13247'); }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Remove "insert into button" in media uploader for custom post types’ is closed to new replies.