Created
July 6, 2015 17:12
-
-
Save blainerobison/dca045adf1f0d76d519d to your computer and use it in GitHub Desktop.
WordPress Hide Editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Hide Editor | |
*/ | |
function prefix_hide_editor() { | |
// get post id | |
if ( isset( $_GET['post'] ) ) : | |
$post_id = $_GET['post']; | |
elseif ( isset( $_POST['post_ID'] ) ) : | |
$post_id = $_POST['post_ID']; | |
endif; | |
// bail since we have no post id | |
if ( ! isset( $post_id ) ) return; | |
// get page template | |
$template_file = get_post_meta( $post_id, '_wp_page_template', true ); | |
// exclude page templates | |
$exclude_templates = array( | |
'tpl-templatename.php' | |
); | |
// exclude ids | |
$exclude_ids = array( get_option( 'page_on_front' ) ); | |
// exclude custom post types | |
$current_screen = get_current_screen(); | |
$screen_id = $current_screen->post_type; | |
$post_types = array( | |
'post_type' | |
); | |
if ( in_array( $template_file, $exclude_templates ) || | |
in_array( $post_id, $exclude_ids ) || | |
in_array( $screen_id, $post_types ) ) : | |
?> | |
<style type="text/css"> | |
#postdivrich{ display: none; } | |
</style> | |
<?php | |
endif; | |
} | |
add_action( 'admin_head', 'prefix_hide_editor' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment