true), 'names'); foreach ($post_types as $post_type) { add_meta_box( 'mxchat_visibility', __('MxChat Settings', 'mxchat'), array($this, 'render_meta_box'), $post_type, 'side', 'default' ); } } /** * Register meta field for Gutenberg */ public function register_meta_fields() { register_post_meta('', '_mxchat_hide_chatbot', array( 'show_in_rest' => true, 'single' => true, 'type' => 'string', 'default' => '', 'auth_callback' => function() { return current_user_can('edit_posts'); } )); } /** * Render the meta box content */ public function render_meta_box($post) { wp_nonce_field('mxchat_meta_box_nonce', 'mxchat_meta_box_nonce'); $hide_chatbot = get_post_meta($post->ID, '_mxchat_hide_chatbot', true); ?>