is_block_editor() ) { return true; } return false; } private function posttype_supports_gutenberg() { return post_type_supports( monsterinsights_get_current_post_type(), 'custom-fields' ); } private function get_current_post_type() { global $post; if ( $post && $post->post_type ) { return $post->post_type; } global $typenow; if ( $typenow ) { return $typenow; } global $current_screen; if ( $current_screen && $current_screen->post_type ) { return $current_screen->post_type; } if ( isset( $_REQUEST['post_type'] ) ) { return sanitize_key( $_REQUEST['post_type'] ); } return null; } public function meta_box_init() { $post_type = $this->get_current_post_type(); if ( ! is_post_type_viewable( $post_type ) ) { return; } add_action( 'admin_enqueue_scripts', array( $this, 'load_metabox_styles' ) ); if ( $this->is_gutenberg_editor() && $this->posttype_supports_gutenberg() ) { return; } add_action( 'add_meta_boxes', [ $this, 'create_meta_box' ] ); } public function register_meta() { if ( ! function_exists( 'register_post_meta' ) ) { return; } register_post_meta( '', '_monsterinsights_skip_tracking', [ 'auth_callback' => '__return_true', 'default' => false, 'show_in_rest' => true, 'single' => true, 'type' => 'boolean', ] ); } public function create_meta_box() { add_meta_box( 'monsterinsights-metabox', 'MonsterInsights', [ $this, 'print_metabox_html' ], null, 'side', 'high' ); } public function print_metabox_html( $post ) { $skipped = (bool) get_post_meta( $post->ID, '_monsterinsights_skip_tracking', true ); wp_nonce_field( 'monsterinsights_metabox', 'monsterinsights_metabox_nonce' ); ?>
" target="_blank" rel="noopener">