Last active
March 15, 2018 23:26
-
-
Save certainlyakey/a75bc4cc172fd59eec95913fb96bdd85 to your computer and use it in GitHub Desktop.
Hide visual editor on edit screens of specific pages in admin (Wordpress)
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 support for certain admin "features" (metaboxes) for some pages | |
function hide_features() { | |
if ( isset($_GET['action']) && $_GET['action'] === 'edit' ) { | |
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID']; | |
if( !isset( $post_id ) ) return; | |
$templated_pages_names = array( | |
// 'template-contact.php', | |
); | |
$templated_pages_ids = array(); | |
foreach ($templated_pages_names as $page_name) { | |
$templated_page_id = get_page_by_custom_template($page_name, 'id'); | |
if ($templated_page_id) { | |
$templated_pages_ids[] = $templated_page_id; | |
} | |
} | |
$optioned_pages_ids = array( | |
get_option('page_for_posts'), | |
get_option('page_on_front') | |
); | |
$pages_no_content_editor = array_merge($optioned_pages_ids, $templated_pages_ids); | |
$features_to_remove = array('editor'); | |
// for some reason we're unable to remove thumbnail and page-attributes support with this... | |
if(in_array($post_id, $pages_no_content_editor)){ | |
foreach ($features_to_remove as $feature) { | |
remove_post_type_support('page', $feature); | |
} | |
} | |
} | |
} | |
add_action( 'do_meta_boxes', 'hide_features' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment