PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 1.1.0
Translate and Go multilingual – Automatic AI translation – wpLingua v1.1.0
2.16.7 2.16.6 2.16.5 2.16.4 2.16.3 2.16.2 2.16.1 2.16.0 2.15.2 2.15.1 2.15.0 2.14.3 2.14.2 2.14.1 2.14.0 2.13.1 2.13.0 2.12.3 2.12.2 2.12.1 trunk 1.0.3 1.0.4 1.0.5 1.1.0 All 112 releases
wplingua / inc / admin / assets.php

assets.php in Translate and Go multilingual – Automatic AI translation – wpLingua 1.1.0, at inc/admin/assets.php

381 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If this file is called directly, abort.
4 if ( ! defined( 'WPINC' ) ) {
5 die;
6 }
7
8
9 /**
10 * Register wpLingua assets for option page : Settings
11 *
12 * @param string $hook
13 * @return void
14 */
15 function wplng_option_page_settings_assets( $hook ) {
16
17 if ( ! is_admin()
18 || $hook !== 'toplevel_page_wplingua-settings'
19 || empty( wplng_get_api_key() )
20 ) {
21 return;
22 }
23
24 /**
25 * Enqueue jQuery
26 */
27
28 wp_enqueue_script( 'jquery' );
29
30 /**
31 * Enqueue wpLingua JS scripts
32 */
33
34 wp_enqueue_script(
35 'wplingua-option-settings',
36 plugins_url() . '/wplingua/assets/js/admin/option-page-settings.js',
37 array( 'jquery' ),
38 WPLNG_API_VERSION
39 );
40
41 /**
42 * Enqueue wpLingua CSS styles
43 */
44
45 wp_enqueue_style(
46 'wplingua-option-settings',
47 plugins_url() . '/wplingua/assets/css/admin/option-page-settings.css',
48 array(),
49 WPLNG_API_VERSION
50 );
51
52 wp_enqueue_style(
53 'wplingua-option-pages',
54 plugins_url() . '/wplingua/assets/css/admin/option-page.css',
55 array(),
56 WPLNG_API_VERSION
57 );
58 }
59
60
61 /**
62 * Register wpLingua assets for option page : Register
63 *
64 * @param string $hook
65 * @return void
66 */
67 function wplng_option_page_register_assets( $hook ) {
68
69 if ( ! is_admin()
70 || $hook !== 'toplevel_page_wplingua-settings'
71 ) {
72 return;
73 }
74
75 /**
76 * Enqueue jQuery
77 */
78
79 wp_enqueue_script( 'jquery' );
80
81 /**
82 * Enqueue wpLingua JS scripts
83 */
84
85 wp_enqueue_script(
86 'wplingua-option-register',
87 plugins_url() . '/wplingua/assets/js/admin/option-page-register.js',
88 array( 'jquery' ),
89 WPLNG_API_VERSION
90 );
91
92 /**
93 * Enqueue wpLingua CSS styles
94 */
95
96 wp_enqueue_style(
97 'wplingua-option-register',
98 plugins_url() . '/wplingua/assets/css/admin/option-page-register.css',
99 array(),
100 WPLNG_API_VERSION
101 );
102
103 wp_enqueue_style(
104 'wplingua-option-pages',
105 plugins_url() . '/wplingua/assets/css/admin/option-page.css',
106 array(),
107 WPLNG_API_VERSION
108 );
109 }
110
111
112 /**
113 * Register wpLingua assets for option page : Switcher
114 *
115 * @param string $hook
116 * @return void
117 */
118 function wplng_option_page_switcher_assets( $hook ) {
119
120 if ( ! is_admin()
121 || $hook !== 'wplingua_page_wplingua-switcher'
122 ) {
123 return;
124 }
125
126 /**
127 * Enqueue jQuery
128 */
129
130 wp_enqueue_script( 'jquery' );
131
132 /**
133 * Enqueue wpLingua JS scripts
134 */
135
136 wp_enqueue_script(
137 'wplingua-option-switcher',
138 plugins_url() . '/wplingua/assets/js/admin/option-page-switcher.js',
139 array( 'jquery' ),
140 WPLNG_API_VERSION
141 );
142
143 wp_enqueue_script(
144 'wplingua-script',
145 plugins_url() . '/wplingua/assets/js/script.js',
146 array( 'jquery' ),
147 WPLNG_API_VERSION
148 );
149
150 /**
151 * Enqueue wpLingua CSS styles
152 */
153
154 wp_enqueue_style(
155 'wplingua-option-switcher',
156 plugins_url() . '/wplingua/assets/css/admin/option-page-switcher.css',
157 array(),
158 WPLNG_API_VERSION
159 );
160
161 wp_enqueue_style(
162 'wplingua-option-pages',
163 plugins_url() . '/wplingua/assets/css/admin/option-page.css',
164 array(),
165 WPLNG_API_VERSION
166 );
167
168 wp_enqueue_style(
169 'wplingua',
170 plugins_url() . '/wplingua/assets/css/front.css',
171 array(),
172 WPLNG_API_VERSION
173 );
174
175 /**
176 * Enqueue CSS and JS for the code editor
177 */
178
179 if ( function_exists( 'wp_enqueue_code_editor' ) ) {
180 $cm_settings = array();
181 $cm_settings['codeEditor'] = wp_enqueue_code_editor(
182 array( 'type' => 'text/css' )
183 );
184
185 wp_localize_script( 'jquery', 'cm_settings', $cm_settings );
186 wp_enqueue_script( 'wp-theme-plugin-editor' );
187 wp_enqueue_style( 'wp-codemirror' );
188 }
189
190 /**
191 * Add inline style for wpLingua custom CSS
192 */
193
194 $custom_css = get_option( 'wplng_custom_css' );
195
196 if ( ! empty( $custom_css )
197 && is_string( $custom_css )
198 ) {
199 $custom_css = wp_strip_all_tags( $custom_css );
200 wp_add_inline_style( 'wplingua', $custom_css );
201 }
202 }
203
204
205 /**
206 * Register wpLingua assets for option page : Exclusions
207 *
208 * @param string $hook
209 * @return void
210 */
211 function wplng_option_page_exclusions_assets( $hook ) {
212
213 if ( ! is_admin()
214 || $hook !== 'wplingua_page_wplingua-exclusions'
215 ) {
216 return;
217 }
218
219 /**
220 * Enqueue jQuery
221 */
222
223 wp_enqueue_script( 'jquery' );
224
225 /**
226 * Enqueue wpLingua CSS styles
227 */
228
229 wp_enqueue_style(
230 'wplingua-option-exclusions',
231 plugins_url() . '/wplingua/assets/css/admin/option-page-exclusions.css',
232 array(),
233 WPLNG_API_VERSION
234 );
235
236 wp_enqueue_style(
237 'wplingua-option-pages',
238 plugins_url() . '/wplingua/assets/css/admin/option-page.css',
239 array(),
240 WPLNG_API_VERSION
241 );
242
243 }
244
245
246 /**
247 * Register wpLingua assets for option page : Dictionary
248 *
249 * @param string $hook
250 * @return void
251 */
252 function wplng_option_page_dictionary_assets( $hook ) {
253
254 if ( ! is_admin()
255 || $hook !== 'wplingua_page_wplingua-dictionary'
256 ) {
257 return;
258 }
259
260 /**
261 * Enqueue jQuery
262 */
263
264 wp_enqueue_script( 'jquery' );
265
266 /**
267 * Enqueue wpLingua JS scripts
268 */
269
270 wp_enqueue_script(
271 'wplingua-option-dictionary',
272 plugins_url() . '/wplingua/assets/js/admin/option-page-dictionary.js',
273 array( 'jquery' ),
274 WPLNG_API_VERSION
275 );
276
277 /**
278 * Enqueue wpLingua CSS styles
279 */
280
281 wp_enqueue_style(
282 'wplingua-option-dictionary',
283 plugins_url() . '/wplingua/assets/css/admin/option-page-dictionary.css',
284 array(),
285 WPLNG_API_VERSION
286 );
287
288 wp_enqueue_style(
289 'wplingua-option-pages',
290 plugins_url() . '/wplingua/assets/css/admin/option-page.css',
291 array(),
292 WPLNG_API_VERSION
293 );
294
295 }
296
297
298 /**
299 * Register wpLingua assets on translations edit pages
300 *
301 * @return void
302 */
303 function wplng_translation_assets() {
304
305 global $post_type;
306
307 if ( 'wplng_translation' === $post_type ) {
308
309 /**
310 * Enqueue jQuery
311 */
312
313 wp_enqueue_script( 'jquery' );
314
315 /**
316 * Enqueue wpLingua JS scripts
317 */
318
319 wp_enqueue_script(
320 'wplingua-translation',
321 plugins_url() . '/wplingua/assets/js/admin/translation.js',
322 array( 'jquery' ),
323 WPLNG_API_VERSION
324 );
325
326 /**
327 * Localize script for AJAX
328 */
329
330 wp_localize_script(
331 'wplingua-translation',
332 'adminAjax',
333 array(
334 'ajaxurl' => admin_url( 'admin-ajax.php' ),
335 )
336 );
337
338 /**
339 * Enqueue wpLingua CSS styles
340 */
341
342 wp_enqueue_style(
343 'wplingua-translation',
344 plugins_url() . '/wplingua/assets/css/admin/translation.css',
345 array(),
346 WPLNG_API_VERSION
347 );
348
349 }
350
351 }
352
353
354 /**
355 * Print wpLingua head script (JSON with all languages informations)
356 *
357 * @return void
358 */
359 function wplng_inline_script_languages() {
360
361 $languages = array();
362 $languages_allow = wplng_get_languages_allow();
363
364 if ( ! empty( $languages_allow ) && is_array( $languages_allow ) ) {
365
366 $language_website = wplng_get_language_website();
367
368 if ( ! in_array( $language_website, $languages_allow, true ) ) {
369 $languages_allow[] = $language_website;
370 }
371
372 $languages = $languages_allow;
373
374 } else {
375 $languages = wplng_get_languages_all();
376 }
377
378 ?><script>var wplngAllLanguages = <?php echo wp_json_encode( $languages ); ?>;</script>
379 <?php
380 }
381