'
. '#adminmenu #toplevel_page_wpwand .wp-menu-image img{width:20px;height:20px;padding-top:7px;}'
. '#wpadminbar #wp-admin-bar-wpwand-trigger .ab-item img{width:18px;height:18px;vertical-align:middle;margin-right:4px;}'
. '';
}
public function add_menu(): void
{
$brand = \WPWand\Data\Brand::resolve();
$label = $brand['name'];
$icon = $brand['icon'] ?: 'dashicons-edit';
add_menu_page($label, $label, 'edit_posts', self::PAGE_SLUG, [$this, 'render'], $icon);
// Rename the auto-created first submenu (which defaults to the brand name) to "Settings".
add_submenu_page(
self::PAGE_SLUG,
__('Settings', 'wp-wand'),
__('Settings', 'wp-wand'),
'edit_posts',
self::PAGE_SLUG,
[$this, 'render']
);
}
/**
* The container carries a static, JS-free loading skeleton so the page paints the REAL settings
* layout the moment WordPress prints it — before settings.js has even downloaded. It reuses the
* app's actual markup/classes (wpwand-app header, wpws-card/tabs/panel/rows), which are styled by
* style-settings.css (enqueued in
, independent of JS), blurred under a spinner overlay.
* React's createRoot() clears these children on first mount, so the skeleton is replaced by the
* live UI with no teardown code. Skeleton-only CSS is scoped under #wpwand-settings-root.
*/
public function render(): void
{
echo '
';
}
private function skeleton(): string
{
$brand = \WPWand\Data\Brand::resolve();
$name = $brand['name'] !== '' ? $brand['name'] : 'WP Wand';
// Mirrors the General tab: the four provider key rows exactly as the app renders them.
$labels = [
__('OpenAI API Key', 'wp-wand'),
__('Claude API Key', 'wp-wand'),
__('DeepSeek API Key', 'wp-wand'),
__('OpenRouter API Key', 'wp-wand'),
];
$desc = esc_html__('Add your API key to activate.', 'wp-wand');
$rows = '';
foreach ($labels as $label) {
$rows .= '
'
. '
'
. '' . $desc . '
'
. '
'
. '
';
}
// Only the form panel blurs behind the spinner; the brand header + tab rail + Pro button
// stay crisp so the page reads as "loaded, fetching your settings" — not a blurred mess.
return ''
. '