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 fields 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'); } )); register_post_meta('', '_mxchat_selected_bot', array( 'show_in_rest' => true, 'single' => true, 'type' => 'string', 'default' => '', 'auth_callback' => function() { return current_user_can('edit_posts'); } )); } /** * Get available bots */ private function get_available_bots() { $bots = array(); // Check if multi-bot addon is active if (class_exists('MxChat_Multi_Bot_Manager')) { $multi_bot_manager = MxChat_Multi_Bot_Core_Manager::get_instance(); $available_bots = $multi_bot_manager->get_available_bots(); // Add the available bots foreach ($available_bots as $bot_id => $bot_name) { $bots[$bot_id] = $bot_name; } } else { // Only default bot available $bots['default'] = __('Default Bot', 'mxchat'); } return $bots; } /** * Check if global auto-show is enabled */ private function is_global_autoshow_enabled() { $options = get_option('mxchat_options', array()); return isset($options['append_to_body']) && $options['append_to_body'] === 'on'; } /** * Updated render_meta_box method with clarified copy */ 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); $selected_bot = get_post_meta($post->ID, '_mxchat_selected_bot', true); $available_bots = $this->get_available_bots(); $global_autoshow = $this->is_global_autoshow_enabled(); $has_multibot = class_exists('MxChat_Multi_Bot_Manager'); ?>