*/ public const LEGACY_STYLE_HANDLES = [ 'thedotdev-agentic-bridge-admin', 'thedotdev-agentic-bridge-overview-v2', 'thedotdev-agentic-bridge-admin-editor', ]; /** @var list */ public const LEGACY_SCRIPT_HANDLES = [ 'thedotdev-agentic-bridge-admin', 'thedotdev-agentic-bridge-admin-editor', ]; /** @var list */ public const LEGACY_MARKUP_CLASSES = [ 'tdab-admin', 'tdab-app', 'tdab-s1-header', 'tdab-s2-hero', 'tdab-card', 'tdab-shell-nav', 'tdab-b2-connection', 'tdab-b3-metadata', 'tdab-readiness', ]; public static function register(): void { add_filter('thedotdev_agentic_bridge_v2_presentation', [self::class, 'filter_default_enabled']); } /** @param mixed $enabled */ public static function filter_default_enabled($enabled): bool { if (is_bool($enabled)) { return $enabled; } return true; } public static function is_enabled(): bool { if (defined('THEDOTDEV_AGENTIC_BRIDGE_V2_UI')) { return (bool) THEDOTDEV_AGENTIC_BRIDGE_V2_UI; } return (bool) apply_filters('thedotdev_agentic_bridge_v2_presentation', true); } public static function enqueue_admin_assets(string $hook): void { if (!self::is_enabled() || !TheDotDevAgenticBridge_Admin::should_enqueue_admin_app_assets($hook)) { return; } wp_enqueue_style( 'thedotdev-agentic-bridge-v2-fonts', THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_URL . 'assets/admin-fonts.css', [], THEDOTDEV_AGENTIC_BRIDGE_VERSION ); wp_enqueue_style( self::STYLE_HANDLE, THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_URL . 'assets/v2/shell.css', ['thedotdev-agentic-bridge-v2-fonts'], THEDOTDEV_AGENTIC_BRIDGE_VERSION ); wp_enqueue_script( self::SCRIPT_HANDLE, THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_URL . 'assets/v2/shell.js', [], THEDOTDEV_AGENTIC_BRIDGE_VERSION, true ); } public static function enqueue_editor_assets(): void { if (!self::is_enabled()) { return; } wp_enqueue_style( 'thedotdev-agentic-bridge-v2-fonts', THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_URL . 'assets/admin-fonts.css', [], THEDOTDEV_AGENTIC_BRIDGE_VERSION ); wp_enqueue_style( self::EDITOR_STYLE_HANDLE, THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_URL . 'assets/v2/editor.css', ['thedotdev-agentic-bridge-v2-fonts'], THEDOTDEV_AGENTIC_BRIDGE_VERSION ); wp_enqueue_script( self::EDITOR_SCRIPT_HANDLE, THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_URL . 'assets/v2/editor.js', ['wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'], THEDOTDEV_AGENTIC_BRIDGE_VERSION, true ); } /** * @param array $context */ public static function render_admin_app(array $context): void { foreach ($context as $key => $value) { if (is_string($key) && $key !== '' && !str_starts_with($key, "\0")) { ${$key} = $value; } } $thedotdev_agentic_bridge_v2_workspace = self::resolve_workspace($context); $thedotdev_agentic_bridge_v2_assets_section = self::resolve_assets_section($context); include THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_DIR . 'views/v2/app.php'; } /** * @param array $context */ public static function render_ai_preview(array $context): void { foreach ($context as $key => $value) { if (is_string($key) && $key !== '' && !str_starts_with($key, "\0")) { ${$key} = $value; } } $thedotdev_agentic_bridge_v2_workspace = 'ai-preview'; $thedotdev_agentic_bridge_v2_assets_section = 'artifacts'; include THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_DIR . 'views/v2/app.php'; } /** * @param array $context */ public static function render_setup(array $context): void { foreach ($context as $key => $value) { if (is_string($key) && $key !== '' && !str_starts_with($key, "\0")) { ${$key} = $value; } } $thedotdev_agentic_bridge_v2_workspace = 'setup'; $thedotdev_agentic_bridge_v2_assets_section = 'artifacts'; include THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_DIR . 'views/v2/app.php'; } /** * @param array $context */ public static function resolve_workspace(array $context): string { if (($context['thedotdev_agentic_bridge_view'] ?? '') === 'history') { return 'history'; } if (!empty($context['thedotdev_agentic_bridge_is_settings'])) { return 'settings'; } if (!empty($context['thedotdev_agentic_bridge_is_s3']) || (($context['thedotdev_agentic_bridge_view'] ?? '') === 'findings')) { return 'findings'; } if (!empty($context['thedotdev_agentic_bridge_is_s4'])) { return 'content'; } if (!empty($context['thedotdev_agentic_bridge_is_s5']) || !empty($context['thedotdev_agentic_bridge_is_s6']) || !empty($context['thedotdev_agentic_bridge_is_s7'])) { return 'assets-safety'; } if (!empty($context['thedotdev_agentic_bridge_is_s8'])) { return 'settings'; } return 'dashboard'; } /** * @param array $context */ public static function resolve_assets_section(array $context): string { if (!empty($context['thedotdev_agentic_bridge_is_s6'])) { return 'privacy'; } if (!empty($context['thedotdev_agentic_bridge_is_s7'])) { return 'safety'; } return 'artifacts'; } public static function connection_status_label(bool $connected): string { return $connected ? __('Optional service connected', 'agentic-bridge') : __('Local setup / Optional service', 'agentic-bridge'); } /** @return list */ public static function nav_items(bool $has_scan): array { $admin = TheDotDevAgenticBridge_Admin::admin_page_url(); $items = [ ['key' => 'dashboard', 'label' => __('Dashboard', 'agentic-bridge'), 'href' => $admin], ['key' => 'findings', 'label' => __('Findings Triage', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'findings'], $admin)], ['key' => 'history', 'label' => __('History & drift', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'history'], $admin)], ['key' => 'ai-preview', 'label' => __('AI Preview', 'agentic-bridge'), 'href' => TheDotDevAgenticBridge_Admin::ai_preview_url()], ['key' => 'content', 'label' => __('Content & Intent', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'content'], $admin)], ['key' => 'assets-safety', 'label' => __('Assets & Safety', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'artifacts'], $admin)], ['key' => 'settings', 'label' => __('Settings', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'settings'], $admin)], ['key' => 'setup', 'label' => __('Setup', 'agentic-bridge'), 'href' => TheDotDevAgenticBridge_Admin::setup_url()], ]; if (!$has_scan) { $items = array_values(array_filter( $items, static fn (array $item): bool => !in_array($item['key'], ['findings'], true) )); } return $items; } }