PluginProbe
AI Builder – Generate pages, blocks, images & translate with AI / trunk
AI Builder – Generate pages, blocks, images & translate with AI vtrunk
2.7.10 2.7.9 2.7.8 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.10 All 122 releases
ai-builder / admin / pages / translation-settings.php

translation-settings.php in AI Builder – Generate pages, blocks, images & translate with AI trunk, at admin/pages/translation-settings.php

135 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH'))
3 exit;
4
5 $translation_settings = AIBUI_Translation_Settings::get_settings();
6 $supported_languages = AIBUI_Translation_Handler::get_supported_languages();
7
8 $header_link = admin_url('site-editor.php?p=%2Fpattern&postType=wp_template_part&categoryId=header');
9 $footer_link = admin_url('site-editor.php?p=%2Fpattern&postType=wp_template_part&categoryId=footer');
10 ?>
11 <div class="wrap ai-builder-settings">
12 <h1><?php esc_html_e('AI Builder – Translation Settings', 'ai-builder'); ?></h1>
13
14 <?php if (isset($_GET['translation_saved'])) : ?>
15 <div class="notice notice-success is-dismissible">
16 <p><?php esc_html_e('Translation settings saved.', 'ai-builder'); ?></p>
17 </div>
18 <?php endif; ?>
19
20 <p><?php esc_html_e('Configure the global behavior of language switching and learn how to translate your headers and footers.', 'ai-builder'); ?></p>
21
22 <div class="aibui-settings-grid">
23 <div class="aibui-card aibui-card--highlight">
24 <h2><?php esc_html_e('Translate your headers & footers', 'ai-builder'); ?></h2>
25 <p><?php esc_html_e('Template parts follow the same language as your pages. Follow these steps to translate them:', 'ai-builder'); ?></p>
26 <ol>
27 <li><?php esc_html_e('Open the Site Editor and select the template part (header or footer).', 'ai-builder'); ?></li>
28 <li><?php esc_html_e('In the editing canvas, click the floating “Translate with AI” button located in the bottom-right corner.', 'ai-builder'); ?></li>
29 <li><?php esc_html_e('Publish the translated template part. AI Builder will automatically serve it when visitors switch languages.', 'ai-builder'); ?></li>
30 </ol>
31 <p>
32 <a href="<?php echo esc_url($header_link); ?>" class="button button-primary"><?php esc_html_e('Open header in Site Editor', 'ai-builder'); ?></a>
33 <a href="<?php echo esc_url($footer_link); ?>" class="button"><?php esc_html_e('Open footer in Site Editor', 'ai-builder'); ?></a>
34 </p>
35 <p><?php esc_html_e('Once translations exist, insert the “Language Switcher” block in your templates to let visitors change the language.', 'ai-builder'); ?></p>
36 </div>
37
38 <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" class="aibui-card aibui-translation-settings-form">
39 <input type="hidden" name="action" value="aibui_save_translation_settings">
40 <?php wp_nonce_field('aibui_save_translation_settings'); ?>
41
42 <table class="form-table" role="presentation">
43 <tbody>
44 <tr>
45 <th scope="row"><?php esc_html_e('Language switcher', 'ai-builder'); ?></th>
46 <td>
47 <label>
48 <input type="checkbox" name="enable_switcher" <?php checked($translation_settings['enable_switcher']); ?> />
49 <?php esc_html_e('Enable the Language Switcher block for visitors', 'ai-builder'); ?>
50 </label>
51 <p class="description">
52 <?php esc_html_e('When enabled, you can insert the “Language Switcher” block into your site header or anywhere else on your pages and patterns. Visitors can then pick a language and only translated content will be shown.', 'ai-builder'); ?>
53 </p>
54 </td>
55 </tr>
56 <tr>
57 <th scope="row"><label for="aibui-default-lang"><?php esc_html_e('Default site language', 'ai-builder'); ?></label></th>
58 <td>
59 <select name="default_lang" id="aibui-default-lang">
60 <?php foreach ($supported_languages as $code => $label) : ?>
61 <option value="<?php echo esc_attr($code); ?>" <?php selected($translation_settings['default_lang'], $code); ?>>
62 <?php echo esc_html($label); ?>
63 </option>
64 <?php endforeach; ?>
65 </select>
66 <p class="description">
67 <?php esc_html_e('Pages and template parts created without translation will belong to this language.', 'ai-builder'); ?>
68 </p>
69 </td>
70 </tr>
71 <tr>
72 <th scope="row"><?php esc_html_e('Available languages', 'ai-builder'); ?></th>
73 <td>
74 <fieldset class="aibui-available-langs-grid">
75 <?php foreach ($supported_languages as $code => $label) : ?>
76 <label>
77 <input type="checkbox" name="available_langs[]" value="<?php echo esc_attr($code); ?>" <?php checked(in_array($code, $translation_settings['available_langs'], true)); ?> />
78 <?php echo esc_html($label); ?>
79 </label>
80 <?php endforeach; ?>
81 </fieldset>
82 <p class="description">
83 <?php esc_html_e('Choose the languages exposed to visitors via the selector. The default language is always enforced.', 'ai-builder'); ?>
84 </p>
85 </td>
86 </tr>
87 </tbody>
88 </table>
89
90 <p class="submit">
91 <button type="submit" class="button button-primary"><?php esc_html_e('Save Translation Settings', 'ai-builder'); ?></button>
92 </p>
93 </form>
94 </div>
95 </div>
96
97 <style>
98 .aibui-settings-grid {
99 display: grid;
100 grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
101 gap: 24px;
102 margin-top: 24px;
103 }
104 .aibui-card {
105 background: #fff;
106 border: 1px solid #e5e7eb;
107 border-radius: 14px;
108 padding: 24px;
109 box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
110 }
111 .aibui-card--highlight {
112 background: linear-gradient(135deg, #f6f8ff, #eef2ff);
113 }
114 .aibui-card ol {
115 margin-left: 20px;
116 }
117 .aibui-card .button {
118 margin-right: 8px;
119 margin-top: 8px;
120 }
121 .aibui-available-langs-grid {
122 display: grid;
123 grid-template-columns: repeat(2, minmax(0, 1fr));
124 gap: 4px 16px;
125 max-width: 480px;
126 }
127 .aibui-available-langs-grid label {
128 display: flex;
129 align-items: center;
130 gap: 6px;
131 margin: 0;
132 }
133 </style>
134
135