Skip to content

Instantly share code, notes, and snippets.

@Avakulenko
Created March 29, 2016 15:39
Show Gist options
  • Save Avakulenko/2523bd1832bcbd236baa to your computer and use it in GitHub Desktop.
Save Avakulenko/2523bd1832bcbd236baa to your computer and use it in GitHub Desktop.
add_action('init', 'crb_remove_editor_init');
function crb_remove_editor_init() {
if (!is_admin()) {
return;
}
$current_post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );
$update_post_id = filter_input( INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT );
if ( isset( $current_post_id ) ) {
$post_id = absint( $current_post_id );
} else if ( isset( $update_post_id ) ) {
$post_id = absint( $update_post_id );
} else {
return;
}
if ( isset( $post_id ) ) {
$template_file = get_post_meta( $post_id, '_wp_page_template', true );
if (('templates/home.php' === $template_file || 'templates/landing.php' === $template_file)) {
remove_post_type_support( 'page', 'editor' );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment