Skip to content

Instantly share code, notes, and snippets.

@gurasa
Last active June 16, 2016 03:46
Show Gist options
  • Save gurasa/169934c2469983c4e82a2bfe1b0342c1 to your computer and use it in GitHub Desktop.
Save gurasa/169934c2469983c4e82a2bfe1b0342c1 to your computer and use it in GitHub Desktop.
WordPress の特定のカスタムページテンプレートだけ、管理画面でビジュアルエディタ(リッチエディタ)を非表示にする方法
<?php
// 特定のカスタムページテンプレートだけ、管理画面でビジュアルエディタ(リッチエディタ)を非表示
function disable_visual_editor_in_page_template(){
global $typenow;
$template_name = basename( get_page_template_slug( $_GET['post'] ), '.php' );
if( $typenow == 'page' and $template_name == 'TEMPLATE_NAME' ){
add_filter('user_can_richedit', create_function('' , 'return false;') );
}
}
add_action( 'load-post.php', 'disable_visual_editor_in_page_template' );
add_action( 'load-post-new.php', 'disable_visual_editor_in_page_template' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment