menuItem = $menuItem; } /** * Registra el menú en WordPress */ public function register(): void { add_action('admin_menu', [$this, 'addMenuPage']); } /** * Callback para agregar la página al menú de WordPress */ public function addMenuPage(): void { add_menu_page( $this->menuItem->getPageTitle(), $this->menuItem->getMenuTitle(), $this->menuItem->getCapability(), $this->menuItem->getMenuSlug(), [$this, 'renderPage'], $this->menuItem->getIcon(), $this->menuItem->getPosition() ); } /** * Callback para renderizar la página */ public function renderPage(): void { try { echo $this->renderUseCase->execute('dashboard'); } catch (\Exception $e) { echo '

Error rendering dashboard: ' . esc_html($e->getMessage()) . '

'; } } public function getCapability(): string { return $this->menuItem->getCapability(); } public function getSlug(): string { return $this->menuItem->getMenuSlug(); } }