$item) { if (isset($item[2]) && $item[2] === 'astra' && is_numeric($position)) { return (float) $position + 0.1; } } return 30; } function aiwest_register_admin_menu() { add_menu_page( 'AI Webmaster Studio', 'AI Webmaster', 'manage_options', 'aiwest-dashboard', 'aiwest_dashboard_page', 'dashicons-superhero-alt', aiwest_admin_menu_position() ); // Primary work areas, ordered according to the administrator workflow. add_submenu_page('aiwest-dashboard', __('Dashboard', 'ai-webmaster-studio'), __('Dashboard', 'ai-webmaster-studio'), 'manage_options', 'aiwest-dashboard', 'aiwest_dashboard_page'); add_submenu_page('aiwest-dashboard', __('Getting Started', 'ai-webmaster-studio'), __('Getting Started', 'ai-webmaster-studio'), 'manage_options', 'aiwest-getting-started', 'aiwest_getting_started_page'); if (function_exists('aiwest_content_upgrader_page')) { add_submenu_page('aiwest-dashboard', __('Content Development', 'ai-webmaster-studio'), __('Content Development', 'ai-webmaster-studio'), 'manage_options', 'aiwest-content-upgrader', 'aiwest_content_upgrader_page'); } add_submenu_page('aiwest-dashboard', __('Content Generator', 'ai-webmaster-studio'), __('Content Generator', 'ai-webmaster-studio'), 'manage_options', 'aiwest-content', 'aiwest_content_page'); if (function_exists('aiwest_chat_page')) { add_submenu_page('aiwest-dashboard', __('AI Chat', 'ai-webmaster-studio'), __('AI Chat', 'ai-webmaster-studio'), 'manage_options', 'aiwest-chat', 'aiwest_chat_page'); } if (function_exists('aiwest_site_builder_page')) { add_submenu_page('aiwest-dashboard', __('Site Builder', 'ai-webmaster-studio'), __('Site Builder', 'ai-webmaster-studio'), 'manage_options', 'aiwest-site-builder', 'aiwest_site_builder_page'); } if (function_exists('aiwest_policies_page')) { add_submenu_page('aiwest-dashboard', __('AI Policies', 'ai-webmaster-studio'), __('AI Policies', 'ai-webmaster-studio'), 'manage_options', 'aiwest-policies', 'aiwest_policies_page'); } add_submenu_page('aiwest-dashboard', __('Prompts', 'ai-webmaster-studio'), __('Prompts', 'ai-webmaster-studio'), 'manage_options', 'aiwest-prompts', 'aiwest_prompts_page'); add_submenu_page('aiwest-dashboard', __('Settings', 'ai-webmaster-studio'), __('Settings', 'ai-webmaster-studio'), 'manage_options', 'aiwest-settings', 'aiwest_settings_page'); add_submenu_page('aiwest-dashboard', __('Help & Support', 'ai-webmaster-studio'), __('Help & Support', 'ai-webmaster-studio'), 'manage_options', 'aiwest-support', 'aiwest_support_page'); add_submenu_page('aiwest-dashboard', 'AIWOS Cloud', 'AIWOS Cloud', 'manage_options', 'aiwest-aiwos', 'aiwest_aiwos_page'); // Supporting screens stay out of the left menu but remain available through contextual links. // Registering them without a parent avoids adding and then removing visible submenu entries. add_submenu_page(null, __('Documentation', 'ai-webmaster-studio'), __('Documentation', 'ai-webmaster-studio'), 'manage_options', 'aiwest-documentation', 'aiwest_documentation_page'); add_submenu_page(null, __('Product', 'ai-webmaster-studio'), __('Product', 'ai-webmaster-studio'), 'manage_options', 'aiwest-product', 'aiwest_product_page'); add_submenu_page(null, __('Project Goals', 'ai-webmaster-studio'), __('Project Goals', 'ai-webmaster-studio'), 'manage_options', 'aiwest-goals', 'aiwest_goals_page'); if (function_exists('aiwest_directory_map_admin_page')) { add_submenu_page(null, __('Locations & Partners Map', 'ai-webmaster-studio'), __('Locations & Partners Map', 'ai-webmaster-studio'), 'manage_options', 'aiwest-directory-map', 'aiwest_directory_map_admin_page'); } if (function_exists('aiwest_lovable_importer_page')) { add_submenu_page(null, __('Design Reference Import', 'ai-webmaster-studio'), __('Design Reference Import', 'ai-webmaster-studio'), 'manage_options', 'aiwest-lovable-importer', 'aiwest_lovable_importer_page'); } if (function_exists('aiwest_site_cleanup_page')) { add_submenu_page(null, __('Site Cleanup', 'ai-webmaster-studio'), __('Site Cleanup', 'ai-webmaster-studio'), 'manage_options', 'aiwest-site-cleanup', 'aiwest_site_cleanup_page'); } add_submenu_page(null, __('AI Memory', 'ai-webmaster-studio'), __('AI Memory', 'ai-webmaster-studio'), 'manage_options', 'aiwest-memory', 'aiwest_memory_page'); add_submenu_page(null, __('Actions to approve', 'ai-webmaster-studio'), __('Actions to approve', 'ai-webmaster-studio'), 'manage_options', 'aiwest-actions', 'aiwest_actions_page'); } function aiwest_enqueue_admin_assets($hook) { if (strpos($hook, 'aiwest') === false) return; if (AIWEST_Security::get_key('page') === 'aiwest-content') { wp_enqueue_media(); } wp_enqueue_style('aiwest-admin', AIWEST_URL . 'assets/admin.css', [], AIWEST_VERSION); wp_enqueue_script('aiwest-admin', AIWEST_URL . 'assets/admin.js', ['jquery'], AIWEST_VERSION, true); wp_localize_script('aiwest-admin', 'AIWESTAdminI18n', [ 'processing' => __('Processing...', 'ai-webmaster-studio'), 'workingTitle' => __('AI Webmaster Studio is working', 'ai-webmaster-studio'), 'workingDefaultText' => __('AI Webmaster Studio is working. This may take a few minutes.', 'ai-webmaster-studio'), 'workingHint' => __('Do not close this page. When the task finishes, you will see the result and action history.', 'ai-webmaster-studio'), 'workingButton' => __('AI is working...', 'ai-webmaster-studio'), 'copied' => __('Copied', 'ai-webmaster-studio'), 'chooseImage' => __('Choose image for content', 'ai-webmaster-studio'), 'useImage' => __('Use this image', 'ai-webmaster-studio'), ]); } add_action('wp_enqueue_scripts', 'aiwest_frontend_media_css'); function aiwest_frontend_media_css() { wp_enqueue_style( 'aiwest-frontend-media', AIWEST_URL . 'assets/frontend-media.css', [], AIWEST_VERSION ); } add_filter('all_plugins', 'aiwest_localize_plugin_list_data'); function aiwest_localize_plugin_list_data($plugins) { $file = plugin_basename(__FILE__); if (isset($plugins[$file]) && is_array($plugins[$file])) { $plugins[$file]['Description'] = __('A free AI toolkit for creating, improving and managing WordPress websites under administrator control.', 'ai-webmaster-studio'); } return $plugins; } add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'aiwest_plugin_action_links'); function aiwest_plugin_action_links($links) { $custom = [ '' . esc_html(__('Details', 'ai-webmaster-studio')) . '', '' . esc_html(__('Getting Started', 'ai-webmaster-studio')) . '', '' . esc_html(__('Documentation', 'ai-webmaster-studio')) . '', '' . esc_html(__('Support', 'ai-webmaster-studio')) . '', '' . esc_html(__('Settings', 'ai-webmaster-studio')) . '', ]; return array_merge($custom, $links); } add_filter('plugin_row_meta', 'aiwest_plugin_row_meta', 10, 2); function aiwest_plugin_row_meta($links, $file) { if ($file !== plugin_basename(__FILE__)) { return $links; } $links[] = '' . esc_html(__('Overview and features', 'ai-webmaster-studio')) . ''; $links[] = '' . esc_html(__('Prompts', 'ai-webmaster-studio')) . ''; $links[] = '' . esc_html(__('Getting Started', 'ai-webmaster-studio')) . ''; return $links; } add_filter('plugin_row_meta', 'aiwest_plugin_row_meta_product_links', 20, 2); function aiwest_plugin_row_meta_product_links($links, $file) { if ($file !== plugin_basename(__FILE__)) { return $links; } $links[] = '' . esc_html(__('Product', 'ai-webmaster-studio')) . ''; $links[] = '' . esc_html(__('Support', 'ai-webmaster-studio')) . ''; $links[] = '' . esc_html(__('Donate', 'ai-webmaster-studio')) . ''; return $links; }