options(); // Log if (Options::get('chat_response_log')) { new Log\Post(); } // Load with plugin new Agents(); new Api\Htmx(); new Chat\Post(); } public function adminAddMenu() { add_menu_page( ALPACA_BOT_TITLE, ALPACA_BOT_TITLE, apply_filters(Options::appendPrefix('menu-capability'), 'edit_posts'), ALPACA_BOT, [$this, 'chatScreen'], ALPACA_BOT_DIR_URL . 'assets/img/icon-80.png', 4 ); // Add submenu page to replace the default menu page add_submenu_page( ALPACA_BOT, 'Chat', 'Chat', apply_filters(Options::appendPrefix('menu-capability'), 'edit_posts'), ALPACA_BOT, [$this, 'chatScreen'], 0 ); // add generate page add_submenu_page( ALPACA_BOT, 'Generate', 'Generate', apply_filters(Options::appendPrefix('menu-capability'), 'edit_posts'), Options::appendPrefix('generate', '-'), [$this, 'chatScreen'], 1 ); } public function adminCheckScreen() { $screen = get_current_screen(); // check page for alpaca-bot if (in_array($screen->id, Define::getAdminPages())) { return true; } return false; } public function adminEnqueueScripts() { if (!$this->adminCheckScreen()) { return; } wp_enqueue_script('htmx', ALPACA_BOT_DIR_URL . 'assets/js/htmx.min.js', [], '1.9.10', true); wp_enqueue_script('htmx-multi-swap', ALPACA_BOT_DIR_URL . 'assets/js/multi-swap.js', [], '1', true); wp_enqueue_script('prism', ALPACA_BOT_DIR_URL . 'assets/js/prism.min.js', [], '1.29.0', true); wp_enqueue_script(ALPACA_BOT, ALPACA_BOT_DIR_URL . 'assets/js/alpaca-bot.js', [], VERSION, true); } public function adminEnqueueStyles() { wp_enqueue_style(ALPACA_BOT, ALPACA_BOT_DIR_URL . 'assets/css/alpaca-bot.css', [], VERSION); if (!$this->adminCheckScreen()) { return; } wp_enqueue_style('hint', ALPACA_BOT_DIR_URL . 'assets/css/hint.min.css', [], VERSION); wp_enqueue_style('materialsymbolsoutlined', ALPACA_BOT_DIR_URL . 'assets/css/materialsymbolsoutlined.css', [], VERSION); wp_enqueue_style('prism', ALPACA_BOT_DIR_URL . 'assets/css/prism-default.min.css', [], '1.29.0'); } public function adminInit() { new Help(); } public function adminNotices() { $notices = [ [ 'message' => 'Alpaca Bot requires pretty permalinks to be enabled. Please enable them in Settings > Permalinks.', 'condition' => get_option('permalink_structure') === false or get_option('permalink_structure') === '' ], [ 'message' => 'Alpaca Bot requires an Ollama API URL to be set. Please set it in Settings > Alpaca Bot.', 'condition' => Options::get('api_url') === false ] ]; $default = [ 'message' => '', 'condition' => false, ]; foreach ($notices as $notice) { $notice = wp_parse_args($notice, $default); if ($notice['condition']) { echo '
' . wp_kses($notice['message'], Options::getAllowedTags('p')) . '