post_content; if (has_shortcode($content, 'aiwest_menu')) { self::enqueue_assets(); return; } if (!has_shortcode($content, 'aiwest_header')) return; $header = get_post((int) get_option('aiwest_active_header_page_id', 0)); if ($header && has_shortcode((string) $header->post_content, 'aiwest_menu')) { self::enqueue_assets(); } } public static function shortcode($atts=[]) { return self::render_menu(); } public static function default_structure() { return [ ['title'=>__('Product', 'ai-webmaster-studio'),'url'=>self::url_for_title('AI Webmaster Studio', true),'columns'=>[ ['heading'=>__('Overview', 'ai-webmaster-studio'),'items'=>[__('What is AI Webmaster Studio', 'ai-webmaster-studio'),__('Who We Are', 'ai-webmaster-studio'),__('Project Roadmap', 'ai-webmaster-studio')]], ['heading'=>__('Start', 'ai-webmaster-studio'),'items'=>[__('Download AI Webmaster Studio', 'ai-webmaster-studio'),__('Getting Started', 'ai-webmaster-studio'),__('Documentation Hub', 'ai-webmaster-studio')]], ]], ['title'=>__('Features', 'ai-webmaster-studio'),'url'=>self::url_for_title(__('Features', 'ai-webmaster-studio'), true),'columns'=>[ ['heading'=>__('Website tools', 'ai-webmaster-studio'),'items'=>[__('Site Builder', 'ai-webmaster-studio'),__('Content Development', 'ai-webmaster-studio'),__('AI Webmaster Studio Operator', 'ai-webmaster-studio')]], ['heading'=>__('Content tools', 'ai-webmaster-studio'),'items'=>[__('Graphics and Media', 'ai-webmaster-studio'),__('AI Policies', 'ai-webmaster-studio'),__('Directory Map', 'ai-webmaster-studio')]], ]], ['title'=>__('Documentation', 'ai-webmaster-studio'),'url'=>self::url_for_title(__('Documentation Hub', 'ai-webmaster-studio'), true),'columns'=>[ ['heading'=>__('Setup', 'ai-webmaster-studio'),'items'=>[__('OpenAI API', 'ai-webmaster-studio'),__('API Keys', 'ai-webmaster-studio'),__('External Services', 'ai-webmaster-studio')]], ['heading'=>__('Guides', 'ai-webmaster-studio'),'items'=>[__('Getting Started', 'ai-webmaster-studio'),__('Administrator-Controlled AI for WordPress', 'ai-webmaster-studio'),__('Artificial Intelligence (AI) in AI Webmaster Studio', 'ai-webmaster-studio')]], ]], ['title'=>__('Support', 'ai-webmaster-studio'),'url'=>self::url_for_title(__('Support Center', 'ai-webmaster-studio'), true),'columns'=>[ ['heading'=>__('Help', 'ai-webmaster-studio'),'items'=>[__('Contact Support', 'ai-webmaster-studio'),__('Get Support', 'ai-webmaster-studio'),__('Contact – Get in Touch with AI Webmaster Studio', 'ai-webmaster-studio')]], ]], ['title'=>__('Download', 'ai-webmaster-studio'),'url'=>self::url_for_title(__('Download AI Webmaster Studio', 'ai-webmaster-studio'), true),'columns'=>[]], ]; } public static function get_structure() { $saved = get_option('aiwest_dropdown_menu_structure', []); if (is_array($saved) && $saved) { return $saved; } return self::default_structure(); } public static function save_default_structure($create_drafts=true) { $structure = self::default_structure(); if ($create_drafts) foreach ($structure as &$main) { $main['url'] = self::url_for_title($main['title'], true); if (!empty($main['columns'])) foreach ($main['columns'] as &$col) if (!empty($col['items'])) { $items = []; foreach ($col['items'] as $item) $items[] = ['title'=>$item, 'url'=>self::url_for_title($item, true)]; $col['items'] = $items; } } update_option('aiwest_dropdown_menu_structure', $structure, false); return $structure; } public static function render_menu() { $structure = self::get_structure(); if (!$structure) return ''; self::enqueue_assets(); ob_start(); ?> true, 'aria-label' => true]; return wp_kses($html, $allowed); } public static function inject_into_active_header($create_drafts=true, $reset_to_default=true) { $post_id=intval(get_option('aiwest_active_header_page_id',0)); if(!$post_id) return new WP_Error('aiwest_no_header', __('No active AI Header.', 'ai-webmaster-studio')); $post=get_post($post_id); if(!$post||$post->post_type!=='page') return new WP_Error('aiwest_no_header_post', __('The active AI Header project page was not found.', 'ai-webmaster-studio')); if ($reset_to_default) { self::save_default_structure($create_drafts); } $content=$post->post_content; // Remove all previous menu shortcode occurrences so the action can repair placement. $content=preg_replace('/\[aiwest_menu\s*\/?\]/i','',$content); // Remove old generated static span menu blocks. $content=preg_replace('/
' . esc_html(__('This page was prepared as a placeholder for the AI Webmaster Studio directory/map module.', 'ai-webmaster-studio')) . '
[aiwest_directory_map]'; } if (stripos($title, 'support') !== false || stripos($title, 'contact') !== false) { return '' . esc_html(__('This is a draft support page created by AI Webmaster Studio. Expand it with clear support instructions, contact options and next steps.', 'ai-webmaster-studio')) . '
'; } return '' . esc_html(__('This page was created as an AI Webmaster Studio menu draft. Expand it in Content Development before publishing.', 'ai-webmaster-studio')) . '
'; } } AIWEST_AI_Menu::init();