*/ 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 ); wp_add_inline_script(self::SCRIPT_HANDLE, 'window.tdabV2MetadataEditor=' . wp_json_encode([ 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('thedotdev_agentic_bridge_metadata_editor'), ]) . ';', 'before'); } 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 render_plans(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 = 'plans'; $thedotdev_agentic_bridge_v2_assets_section = 'artifacts'; if (!isset($thedotdev_agentic_bridge_is_s2)) { $thedotdev_agentic_bridge_is_s2 = is_array(TheDotDevAgenticBridge_Readiness_Store::latest()); } include THEDOTDEV_AGENTIC_BRIDGE_PLUGIN_DIR . 'views/v2/app.php'; } /** * @param array $context */ public static function render_review(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 = 'review'; $thedotdev_agentic_bridge_v2_assets_section = 'artifacts'; if (!isset($thedotdev_agentic_bridge_is_s2)) { $thedotdev_agentic_bridge_is_s2 = is_array(TheDotDevAgenticBridge_Readiness_Store::latest()); } 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(); $setup_complete = TheDotDevAgenticBridge_Onboarding_Wizard::is_setup_confirmed(); $setup_item = [ 'key' => 'setup', 'label' => $setup_complete ? __('Setup guide', 'agentic-bridge') : __('Quick Start', 'agentic-bridge'), 'href' => TheDotDevAgenticBridge_Admin::setup_url(), 'primary' => !$setup_complete, ]; $items = [ ['key' => 'dashboard', 'label' => __('Dashboard', 'agentic-bridge'), 'href' => $admin, 'primary' => $setup_complete], ['key' => 'findings', 'label' => __('Site checks', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'findings'], $admin)], ['key' => 'history', 'label' => __('Progress', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'history'], $admin)], ['key' => 'ai-preview', 'label' => __('How AI may read your site', 'agentic-bridge'), 'href' => TheDotDevAgenticBridge_Admin::ai_preview_url()], ['key' => 'content', 'label' => __('Pages & answers', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'content'], $admin)], ['key' => 'review', 'label' => __('Review changes', 'agentic-bridge'), 'href' => TheDotDevAgenticBridge_Admin::review_changes_url()], ['key' => 'assets-safety', 'label' => __('AI files & controls', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'artifacts'], $admin)], ['key' => 'plans', 'label' => __('Plans & AI usage', 'agentic-bridge'), 'href' => TheDotDevAgenticBridge_Admin::plans_url()], ['key' => 'settings', 'label' => __('Settings', 'agentic-bridge'), 'href' => add_query_arg(['thedotdev_agentic_bridge_view' => 'settings'], $admin)], ]; if (!$has_scan) { $items = array_values(array_filter( $items, static fn (array $item): bool => !in_array($item['key'], ['findings'], true) )); } // Incomplete setup: Quick Start is first/default. Complete: Dashboard primary, Setup guide remains reachable. if (!$setup_complete) { array_unshift($items, $setup_item); } else { $items[] = $setup_item; } return $items; } }