plugin_name = $plugin_name; $this->version = $version; // Initialize delegates. $this->assets = new Peptide_News_Admin_Assets( $plugin_name, $version ); $this->settings = new Peptide_News_Admin_Settings(); $this->settings_page = new Peptide_News_Admin_Settings_Page( $this->settings ); $this->dashboard_pages = new Peptide_News_Admin_Dashboard_Pages(); // Menu callbacks are closures pointing to dashboard pages instance methods. $this->menu = new Peptide_News_Admin_Menu( fn() => $this->dashboard_pages->render_dashboard_page(), fn() => $this->settings_page->render_settings_page(), fn() => $this->dashboard_pages->render_articles_page(), fn() => $this->dashboard_pages->render_cost_dashboard_page() ); } /** * Enqueue admin CSS. * * @param string $hook Current admin page hook. * @return void */ public function enqueue_styles( string $hook ): void { $this->assets->enqueue_styles( $hook ); } /** * Enqueue admin JavaScript. * * @param string $hook Current admin page hook. * @return void */ public function enqueue_scripts( string $hook ): void { $this->assets->enqueue_scripts( $hook ); } /** * Register all admin menu pages. * * @return void */ public function add_admin_menu(): void { $this->menu->add_admin_menu(); } /** * Register all WordPress settings. * * @return void */ public function register_settings(): void { $this->settings->register_settings(); } /** * Render the settings page. * * @return void */ public function render_settings_page(): void { $this->settings_page->render_settings_page(); } /** * Render the analytics dashboard page. * * @return void */ public function render_dashboard_page(): void { $this->dashboard_pages->render_dashboard_page(); } /** * Render the articles management page. * * @return void */ public function render_articles_page(): void { $this->dashboard_pages->render_articles_page(); } /** * Render the LLM cost tracking dashboard page. * * @return void */ public function render_cost_dashboard_page(): void { $this->dashboard_pages->render_cost_dashboard_page(); } /** * Sanitize and validate an OpenRouter model ID. * * Delegates to the settings class. Kept on the orchestrator because * WordPress register_setting() callbacks may reference $this. * * @param string $value Raw model ID from form input. * @return string Sanitized model ID or empty string on failure. */ public function sanitize_model_id( string $value ): string { return $this->settings->sanitize_model_id( $value ); } /** * Sanitize an API key value — encrypt if new, preserve if masked. * * Delegates to the settings class. Kept on the orchestrator because * WordPress register_setting() callbacks may reference $this. * * @param string $value Raw API key from form input. * @param string $option_name The WP option being saved. * @return string Encrypted key or previous value if input was masked. */ public function sanitize_api_key( string $value, string $option_name = '' ): string { return $this->settings->sanitize_api_key( $value, $option_name ); } }