Удалить плагин Monarch meta box из поста и страницы - PullRequest
0 голосов
/ 22 ноября 2018

Возникли проблемы при удалении мета-блоков плагинов Monarch из типов записей и страниц.

Я пробовал:

function remove_monarch_metabox() {
  $screen = get_current_screen();
remove_meta_box( 'et_monarch_settings', $screen->post_type, 'normal' );
}
add_action( 'admin_head', 'remove_monarch_metabox', 99, 1 );

... а также с помощью ловушки do_meta_boxes

add_action( 'do_meta_boxes', 'remove_monarch_metabox', 99, 1 );

&

function remove_monarch_metabox() {
remove_meta_box( 'et_monarch_settings' , 'post' , 'normal' );
}
add_action( 'admin_menu' , 'remove_monarch_metabox' );

&

function remove_monarch_metabox($post_type){
  $post_types_to_remove = array('post', 'page');
  if(in_array($post_type, $post_types_to_remove)){
remove_meta_box('et_monarch_settings', $post_type, 'normal');
  }
}
add_action('add_meta_boxes', 'remove_monarch_metabox', 99, 1);

Код, который Монарх использует для добавления мета-блоков:

    function add_meta_box() {
    $monarch_options = $this->monarch_options;

    if ( isset( $monarch_options['sharing_locations_manage_locations'] ) && '' != $monarch_options['sharing_locations_manage_locations'] ) {
        $selected_locations_array = $monarch_options['sharing_locations_manage_locations'];

        $all_post_types = ! empty( $selected_locations_array ) ? $this->monarch_post_types : array();

        foreach ( $all_post_types as $post_type ) {
            $post_type = sanitize_text_field( $post_type );

            add_meta_box( 'et_monarch_settings', esc_html__( 'Monarch Settings', 'Monarch' ), array( $this, 'display_meta_box' ), $post_type );
            add_meta_box( 'et_monarch_sharing_stats', esc_html__( 'Monarch Sharing Stats', 'Monarch' ), array( $this, 'display_meta_box_stats' ), $post_type );
        }
    }
}

Любое понимание будеточень ценю, я уверен, что это что-то простое, что мне не хватает!

thx

...