programing

워드프레스 편집 페이지 화면에서 주 편집기 제거

oldcodes 2023. 2. 23. 23:05
반응형

워드프레스 편집 페이지 화면에서 주 편집기 제거

페이지 편집 화면에서 메인 에디터를 삭제하는 방법을 아는 사람?css뿐만 아니라나는 작은 mice에 메타박스 몇 개를 추가했는데 그것들은 메인 박스와 충돌한다.

편집 화면에서 다른 메타박스를 삭제하는 클래스가 있는데, 이렇게 하면 메인 에디터를 제거할 수 없습니다.클래스의 어레이에 'divpostrich' 및 'divpost'를 추가하려고 했지만 실패했습니다.

class removeMetas{
    public function __construct(){
        add_action('do_meta_boxes', array($this, 'removeMetaBoxes'), 10, 3);
    }

    public function removeMetaBoxes($type, $context, $post){
        /**
         * usages
         * remove_meta_box($id, $page, $context)
         * add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default')
         */
        $boxes = array( 'slugdiv', 'postexcerpt', 'passworddiv', 'categorydiv',
                        'tagsdiv', 'trackbacksdiv', 'commentstatusdiv', 'commentsdiv',
                        'authordiv', 'postcustom');

        foreach ($boxes as $box){
            foreach (array('link', 'post', 'page') as $page){
                foreach (array('normal', 'advanced', 'side') as $context){
                    remove_meta_box($box, $type, $context);
                }
            }
        }
    }
}

$removeMetas = new removeMetas();

나는 또한 jquery로 'divpostrich'를 제거해 보았다.하지만 js를 어디에 넣어야 할지 모르겠어요.파이어버그로 브라우저의 'postdivrich'를 삭제하면 나머지 작은 필드도 완벽하게 작동합니다.

좋은 생각 있어요?

이것에 대한 WP 서포트가 내장되어 있기 때문에, 기능 처리 방법이 변경되어도, 글로벌을 직접 조작할 필요가 없고, 포워드의 호환성을 확보할 수 있습니다.WP Core 코드는 @user622018 answer와 거의 동일한 로직을 수행합니다.

function remove_editor() {
  remove_post_type_support('page', 'editor');
}
add_action('admin_init', 'remove_editor');

고객님이 찾고 있는 것은 글로벌$_wp_post_type_features어레이를 설정합니다.

다음은 사용 방법의 간단한 예입니다.

function reset_editor()
{
     global $_wp_post_type_features;

     $post_type="page";
     $feature = "editor";
     if ( !isset($_wp_post_type_features[$post_type]) )
     {

     }
     elseif ( isset($_wp_post_type_features[$post_type][$feature]) )
     unset($_wp_post_type_features[$post_type][$feature]);
}

add_action("init","reset_editor");

기능에 다음 코드를 추가합니다.

function remove_editor_init() {
if ( is_admin() ) {
    $post_id = 0;
    if(isset($_GET['post'])) $post_id = $_GET['post'];
    $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
    if ($template_file == 'page-home.php') {
        remove_post_type_support('page', 'editor');
    }
}
}
add_action( 'init', 'remove_editor_init' );

TinyMCE 에디터를 비활성화하고 HTML 에디터를 그대로 두면 안 될까요?메타박스가 충돌합니다. :)

에디터를 무효로 하려면 , 다음의 순서를 편집할 필요가 있습니다.wp-config.php파일을 작성하여 다음 행을 맨 위에 추가합니다.

define('DISALLOW_FILE_EDIT', true);

언급URL : https://stackoverflow.com/questions/2544870/remove-main-editor-from-wordpress-edit-page-screen

반응형