无法从帖子和页面类型中删除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);
Monarch代码用于添加元框:
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