カスタムフィールドプラグインの動作を妨げず本文入力欄を非表示
@kzxtreme 山カズ
処理の概要: プラグインが editor の画像追加ボタンをクリックしたことにしてアップロード用 Thickbox を表示してるから、editor が不要な投稿タイプでは support はしつつ css で非表示にしてる。
投稿タイプを1つ指定
//管理画面でpost.phpを開いてる時 admin_print_stylesアクションが呼ばれたらbc_post_page_style()実行
add_action( 'admin_print_styles-post.php', 'bc_post_page_style' );
//管理画面でpost-new.phpを開いてる時 admin_print_stylesアクションが呼ばれたらbc_post_page_style()実行
add_action( 'admin_print_styles-post-new.php', 'bc_post_page_style' );
//bc_post_page_style()実行して投稿タイプがsampleの時、<style>~</style>を実行する
function bc_post_page_style() {
if ( 'sample' == $GLOBALS['current_screen']->post_type ) :
?>
<style type="text/css">
#postdivrich{display:none;}
</style>
<?php
endif;
投稿タイプを複数指定
//管理画面でpost.phpを開いてる時 admin_print_stylesアクションが呼ばれたらbc_post_page_style()実行
add_action( 'admin_print_styles-post.php', 'bc_post_page_style' );
//管理画面でpost-new.phpを開いてる時 admin_print_stylesアクションが呼ばれたらbc_post_page_style()実行
add_action( 'admin_print_styles-post-new.php', 'bc_post_page_style' );
//bc_post_page_style()実行して投稿タイプがquestion、video、voice、dictionary、recruitの時、<style>~</style>を実行する
function bc_post_page_style() {
if ( in_array( $GLOBALS['current_screen']->post_type, array( 'question', 'video', 'voice', 'dictionary', 'recruit' ) ) ) :
?>
<style type="text/css">
#postdivrich{display:none;}
</style>
<?php
endif;
投稿タイプを指定しないでいい時
add_action( 'admin_print_styles-post.php', 'bc_post_page_style' );
add_action( 'admin_print_styles-post-new.php', 'bc_post_page_style' );
function bc_post_page_style() {
?>
<style type="text/css">
#postdivrich{display:none;}
</style>
<?php
補足
現在の画面の投稿タイプって何かなー、を調べる時
$GLOBALS['current_screen']->post_type
※current_screen→現在の画面
※in_array 特定の値が配列に含まれているかを判断する関数
※array() は配列生成
上記はkzさんのご協力によるものです。情報提供料金200万円也!ありがとうございますw