__('Select media', 'ai-webmaster-studio'),
]);
}
public static function handle_save() {
if (!current_user_can('manage_options')) return;
if (!AIWEST_Security::is_post_request() || !AIWEST_Security::post_bool('aiwest_design_system_save')) return;
check_admin_referer('aiwest_design_system_save');
$keys = [
'primary', 'primary_dark', 'accent', 'ink', 'muted', 'border',
'surface', 'soft', 'soft_blue', 'radius', 'button_radius',
'max_width', 'layout_template', 'section_count', 'card_count',
'faq_policy', 'cta_policy', 'related_policy', 'media_source',
'media_position', 'media_size', 'media_id', 'media_url', 'video_url',
];
$data = [];
foreach ($keys as $key) {
$raw = AIWEST_Security::post_text('aiwest_ds_' . $key);
$value = class_exists('AIWEST_Design_System')
? AIWEST_Design_System::sanitize_value($key, $raw)
: sanitize_text_field($raw);
if ($value !== '') $data[$key] = $value;
}
update_option('aiwest_design_system', $data);
AIWEST_Site_Workspace::invalidate_presentation_cache();
set_transient('aiwest_ds_notice_' . get_current_user_id(), 1, 60);
wp_safe_redirect(add_query_arg(
['page' => 'aiwest-site-builder', 'tab' => 'style'],
admin_url('admin.php')
));
exit;
}
protected static function is_design_screen() {
return is_admin()
&& current_user_can('manage_options')
&& AIWEST_Security::get_key('page') === 'aiwest-site-builder'
&& AIWEST_Security::get_key('tab', 'home') === 'style';
}
public static function render_panel() {
if (!current_user_can('manage_options')) return;
AIWEST_Site_Workspace::appearance_panel();
$design = class_exists('AIWEST_Design_System') ? AIWEST_Design_System::get() : [];
if (!$design) return;
$notice_key = 'aiwest_ds_notice_' . get_current_user_id();
if (get_transient($notice_key)) {
delete_transient($notice_key);
echo '
'
. esc_html(__('AI Webmaster Studio Design System has been saved.', 'ai-webmaster-studio'))
. '
';
}
$fields = [
'primary' => [__('Primary color', 'ai-webmaster-studio'), true, 'HEX'],
'primary_dark' => [__('Primary dark color', 'ai-webmaster-studio'), true, 'HEX'],
'accent' => [__('Accent color', 'ai-webmaster-studio'), true, 'HEX'],
'ink' => [__('Main text color', 'ai-webmaster-studio'), true, 'HEX'],
'muted' => [__('Muted text color', 'ai-webmaster-studio'), true, 'HEX'],
'border' => [__('Border color', 'ai-webmaster-studio'), true, 'HEX'],
'surface' => [__('Card background', 'ai-webmaster-studio'), true, 'HEX'],
'soft' => [__('Soft background', 'ai-webmaster-studio'), true, 'HEX'],
'soft_blue' => [__('Soft blue background', 'ai-webmaster-studio'), true, 'HEX'],
'radius' => [__('Section radius', 'ai-webmaster-studio'), false, 'px/rem/em/%'],
'button_radius' => [__('Button radius', 'ai-webmaster-studio'), false, 'px/rem/em/%'],
'max_width' => [__('Maximum width', 'ai-webmaster-studio'), false, 'px/rem/em/%'],
];
$selects = [
'layout_template' => [__('Preferred page layout', 'ai-webmaster-studio'), [
'standard_landing' => __('Standard landing page', 'ai-webmaster-studio'),
'guide' => __('Step-by-step guide', 'ai-webmaster-studio'),
'comparison' => __('Comparison page', 'ai-webmaster-studio'),
'directory' => __('Directory/list page', 'ai-webmaster-studio'),
'product' => __('Product/service page', 'ai-webmaster-studio'),
'minimal' => __('Minimal editorial page', 'ai-webmaster-studio'),
]],
'faq_policy' => ['FAQ', [
'never' => __('Never', 'ai-webmaster-studio'),
'optional' => __('Optional', 'ai-webmaster-studio'),
'always' => __('Always', 'ai-webmaster-studio'),
]],
'cta_policy' => ['CTA', [
'never' => __('Never', 'ai-webmaster-studio'),
'optional' => __('Optional', 'ai-webmaster-studio'),
'always' => __('Always', 'ai-webmaster-studio'),
]],
'related_policy' => [__('Related content', 'ai-webmaster-studio'), [
'never' => __('Never', 'ai-webmaster-studio'),
'optional' => __('Optional', 'ai-webmaster-studio'),
'always' => __('Always', 'ai-webmaster-studio'),
]],
'media_source' => [__('Media source', 'ai-webmaster-studio'), [
'none' => __('No media', 'ai-webmaster-studio'),
'ai' => __('Generate AI image', 'ai-webmaster-studio'),
'library' => __('Use WordPress Media Library', 'ai-webmaster-studio'),
'ai_or_library' => __('AI or Media Library', 'ai-webmaster-studio'),
]],
'media_position' => [__('Media position', 'ai-webmaster-studio'), [
'above' => __('Above text', 'ai-webmaster-studio'),
'below' => __('Below text', 'ai-webmaster-studio'),
'left_column' => __('Left column', 'ai-webmaster-studio'),
'right_column' => __('Right column', 'ai-webmaster-studio'),
'section_background' => __('Section background', 'ai-webmaster-studio'),
]],
'media_size' => [__('Media size', 'ai-webmaster-studio'), [
'thumbnail' => __('Thumbnail', 'ai-webmaster-studio'),
'small' => __('Small', 'ai-webmaster-studio'),
'medium' => __('Medium', 'ai-webmaster-studio'),
'large' => __('Large', 'ai-webmaster-studio'),
'full_width' => __('Full width', 'ai-webmaster-studio'),
]],
];
?>