author | ymh <ymh.work@gmail.com> |
Tue, 15 Dec 2020 13:49:49 +0100 | |
changeset 16 | a86126ab1dd4 |
parent 13 | d255fe9cd479 |
child 18 | be944660c56a |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* WordPress scripts and styles default loader. |
|
4 |
* |
|
5 |
* Several constants are used to manage the loading, concatenating and compression of scripts and CSS: |
|
6 |
* define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation, |
|
7 |
* define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS, |
|
8 |
* define('COMPRESS_SCRIPTS', false); disables compression of scripts, |
|
9 |
* define('COMPRESS_CSS', false); disables compression of CSS, |
|
10 |
* define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate). |
|
11 |
* |
|
12 |
* The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins |
|
13 |
* to temporarily override the above settings. Also a compression test is run once and the result is saved |
|
14 |
* as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted. |
|
15 |
* |
|
16 |
* @package WordPress |
|
17 |
*/ |
|
18 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
/** WordPress Dependency Class */ |
16 | 20 |
require ABSPATH . WPINC . '/class-wp-dependency.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
/** WordPress Dependencies Class */ |
16 | 23 |
require ABSPATH . WPINC . '/class.wp-dependencies.php'; |
0 | 24 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
/** WordPress Scripts Class */ |
16 | 26 |
require ABSPATH . WPINC . '/class.wp-scripts.php'; |
0 | 27 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
/** WordPress Scripts Functions */ |
16 | 29 |
require ABSPATH . WPINC . '/functions.wp-scripts.php'; |
0 | 30 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
/** WordPress Styles Class */ |
16 | 32 |
require ABSPATH . WPINC . '/class.wp-styles.php'; |
0 | 33 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
/** WordPress Styles Functions */ |
16 | 35 |
require ABSPATH . WPINC . '/functions.wp-styles.php'; |
0 | 36 |
|
37 |
/** |
|
9 | 38 |
* Registers TinyMCE scripts. |
39 |
* |
|
40 |
* @since 5.0.0 |
|
41 |
* |
|
16 | 42 |
* @param WP_Scripts $scripts WP_Scripts object. |
43 |
* @param bool $force_uncompressed Whether to forcibly prevent gzip compression. Default false. |
|
9 | 44 |
*/ |
16 | 45 |
function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) { |
9 | 46 |
global $tinymce_version, $concatenate_scripts, $compress_scripts; |
47 |
$suffix = wp_scripts_get_suffix(); |
|
48 |
$dev_suffix = wp_scripts_get_suffix( 'dev' ); |
|
49 |
||
50 |
script_concat_settings(); |
|
51 |
||
52 |
$compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) |
|
16 | 53 |
&& false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed; |
9 | 54 |
|
16 | 55 |
// Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production) |
56 |
// or tinymce.min.js (when SCRIPT_DEBUG is true). |
|
9 | 57 |
if ( $compressed ) { |
58 |
$scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version ); |
|
59 |
} else { |
|
60 |
$scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version ); |
|
61 |
$scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version ); |
|
62 |
} |
|
63 |
||
64 |
$scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version ); |
|
65 |
} |
|
66 |
||
67 |
/** |
|
68 |
* Registers all the WordPress vendor scripts that are in the standardized |
|
69 |
* `js/dist/vendor/` location. |
|
70 |
* |
|
71 |
* For the order of `$scripts->add` see `wp_default_scripts`. |
|
72 |
* |
|
73 |
* @since 5.0.0 |
|
74 |
* |
|
75 |
* @param WP_Scripts $scripts WP_Scripts object. |
|
76 |
*/ |
|
16 | 77 |
function wp_default_packages_vendor( $scripts ) { |
9 | 78 |
global $wp_locale; |
79 |
||
80 |
$suffix = wp_scripts_get_suffix(); |
|
81 |
||
82 |
$vendor_scripts = array( |
|
83 |
'react' => array( 'wp-polyfill' ), |
|
84 |
'react-dom' => array( 'react' ), |
|
85 |
'moment', |
|
86 |
'lodash', |
|
87 |
'wp-polyfill-fetch', |
|
88 |
'wp-polyfill-formdata', |
|
89 |
'wp-polyfill-node-contains', |
|
16 | 90 |
'wp-polyfill-url', |
91 |
'wp-polyfill-dom-rect', |
|
9 | 92 |
'wp-polyfill-element-closest', |
93 |
'wp-polyfill', |
|
94 |
); |
|
95 |
||
96 |
$vendor_scripts_versions = array( |
|
16 | 97 |
'react' => '16.9.0', |
98 |
'react-dom' => '16.9.0', |
|
99 |
'moment' => '2.26.0', |
|
100 |
'lodash' => '4.17.15', |
|
9 | 101 |
'wp-polyfill-fetch' => '3.0.0', |
102 |
'wp-polyfill-formdata' => '3.0.12', |
|
16 | 103 |
'wp-polyfill-node-contains' => '3.42.0', |
104 |
'wp-polyfill-url' => '3.6.4', |
|
105 |
'wp-polyfill-dom-rect' => '3.42.0', |
|
9 | 106 |
'wp-polyfill-element-closest' => '2.0.2', |
16 | 107 |
'wp-polyfill' => '7.4.4', |
9 | 108 |
); |
109 |
||
110 |
foreach ( $vendor_scripts as $handle => $dependencies ) { |
|
111 |
if ( is_string( $dependencies ) ) { |
|
112 |
$handle = $dependencies; |
|
113 |
$dependencies = array(); |
|
114 |
} |
|
115 |
||
116 |
$path = "/wp-includes/js/dist/vendor/$handle$suffix.js"; |
|
117 |
$version = $vendor_scripts_versions[ $handle ]; |
|
118 |
||
119 |
$scripts->add( $handle, $path, $dependencies, $version, 1 ); |
|
120 |
} |
|
121 |
||
122 |
$scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) ); |
|
123 |
did_action( 'init' ) && $scripts->add_inline_script( |
|
124 |
'wp-polyfill', |
|
125 |
wp_get_script_polyfill( |
|
126 |
$scripts, |
|
127 |
array( |
|
128 |
'\'fetch\' in window' => 'wp-polyfill-fetch', |
|
129 |
'document.contains' => 'wp-polyfill-node-contains', |
|
16 | 130 |
'window.DOMRect' => 'wp-polyfill-dom-rect', |
131 |
'window.URL && window.URL.prototype && window.URLSearchParams' => 'wp-polyfill-url', |
|
9 | 132 |
'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata', |
133 |
'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest', |
|
134 |
) |
|
135 |
) |
|
136 |
); |
|
137 |
||
138 |
did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' ); |
|
139 |
||
140 |
did_action( 'init' ) && $scripts->add_inline_script( |
|
141 |
'moment', |
|
142 |
sprintf( |
|
16 | 143 |
"moment.updateLocale( '%s', %s );", |
9 | 144 |
get_user_locale(), |
145 |
wp_json_encode( |
|
146 |
array( |
|
147 |
'months' => array_values( $wp_locale->month ), |
|
148 |
'monthsShort' => array_values( $wp_locale->month_abbrev ), |
|
149 |
'weekdays' => array_values( $wp_locale->weekday ), |
|
150 |
'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ), |
|
151 |
'week' => array( |
|
152 |
'dow' => (int) get_option( 'start_of_week', 0 ), |
|
153 |
), |
|
154 |
'longDateFormat' => array( |
|
155 |
'LT' => get_option( 'time_format', __( 'g:i a', 'default' ) ), |
|
156 |
'LTS' => null, |
|
157 |
'L' => null, |
|
158 |
'LL' => get_option( 'date_format', __( 'F j, Y', 'default' ) ), |
|
159 |
'LLL' => __( 'F j, Y g:i a', 'default' ), |
|
160 |
'LLLL' => null, |
|
161 |
), |
|
162 |
) |
|
163 |
) |
|
164 |
), |
|
165 |
'after' |
|
166 |
); |
|
167 |
} |
|
168 |
||
169 |
/** |
|
170 |
* Returns contents of an inline script used in appending polyfill scripts for |
|
171 |
* browsers which fail the provided tests. The provided array is a mapping from |
|
172 |
* a condition to verify feature support to its polyfill script handle. |
|
173 |
* |
|
174 |
* @since 5.0.0 |
|
175 |
* |
|
176 |
* @param WP_Scripts $scripts WP_Scripts object. |
|
177 |
* @param array $tests Features to detect. |
|
178 |
* @return string Conditional polyfill inline script. |
|
179 |
*/ |
|
16 | 180 |
function wp_get_script_polyfill( $scripts, $tests ) { |
9 | 181 |
$polyfill = ''; |
182 |
foreach ( $tests as $test => $handle ) { |
|
183 |
if ( ! array_key_exists( $handle, $scripts->registered ) ) { |
|
184 |
continue; |
|
185 |
} |
|
186 |
||
187 |
$src = $scripts->registered[ $handle ]->src; |
|
188 |
$ver = $scripts->registered[ $handle ]->ver; |
|
189 |
||
190 |
if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) { |
|
191 |
$src = $scripts->base_url . $src; |
|
192 |
} |
|
193 |
||
194 |
if ( ! empty( $ver ) ) { |
|
195 |
$src = add_query_arg( 'ver', $ver, $src ); |
|
196 |
} |
|
197 |
||
198 |
/** This filter is documented in wp-includes/class.wp-scripts.php */ |
|
199 |
$src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) ); |
|
200 |
||
201 |
if ( ! $src ) { |
|
202 |
continue; |
|
203 |
} |
|
204 |
||
205 |
$polyfill .= ( |
|
206 |
// Test presence of feature... |
|
207 |
'( ' . $test . ' ) || ' . |
|
16 | 208 |
/* |
209 |
* ...appending polyfill on any failures. Cautious viewers may balk |
|
210 |
* at the `document.write`. Its caveat of synchronous mid-stream |
|
211 |
* blocking write is exactly the behavior we need though. |
|
212 |
*/ |
|
9 | 213 |
'document.write( \'<script src="' . |
214 |
$src . |
|
215 |
'"></scr\' + \'ipt>\' );' |
|
216 |
); |
|
217 |
} |
|
218 |
||
219 |
return $polyfill; |
|
220 |
} |
|
221 |
||
222 |
/** |
|
223 |
* Registers all the WordPress packages scripts that are in the standardized |
|
224 |
* `js/dist/` location. |
|
225 |
* |
|
226 |
* For the order of `$scripts->add` see `wp_default_scripts`. |
|
227 |
* |
|
228 |
* @since 5.0.0 |
|
229 |
* |
|
230 |
* @param WP_Scripts $scripts WP_Scripts object. |
|
231 |
*/ |
|
16 | 232 |
function wp_default_packages_scripts( $scripts ) { |
9 | 233 |
$suffix = wp_scripts_get_suffix(); |
234 |
||
16 | 235 |
// Expects multidimensional array like: |
236 |
// 'a11y.js' => array('dependencies' => array(...), 'version' => '...'), |
|
237 |
// 'annotations.js' => array('dependencies' => array(...), 'version' => '...'), |
|
238 |
// 'api-fetch.js' => array(... |
|
239 |
$assets = include ABSPATH . WPINC . '/assets/script-loader-packages.php'; |
|
240 |
||
241 |
foreach ( $assets as $package_name => $package_data ) { |
|
242 |
$basename = basename( $package_name, '.js' ); |
|
243 |
$handle = 'wp-' . $basename; |
|
244 |
$path = "/wp-includes/js/dist/{$basename}{$suffix}.js"; |
|
9 | 245 |
|
16 | 246 |
if ( ! empty( $package_data['dependencies'] ) ) { |
247 |
$dependencies = $package_data['dependencies']; |
|
248 |
} else { |
|
249 |
$dependencies = array(); |
|
250 |
} |
|
9 | 251 |
|
16 | 252 |
// Add dependencies that cannot be detected and generated by build tools. |
253 |
switch ( $handle ) { |
|
254 |
case 'wp-block-library': |
|
255 |
array_push( $dependencies, 'editor' ); |
|
256 |
break; |
|
257 |
case 'wp-edit-post': |
|
258 |
array_push( $dependencies, 'media-models', 'media-views', 'postbox', 'wp-dom-ready' ); |
|
259 |
break; |
|
260 |
} |
|
9 | 261 |
|
16 | 262 |
$scripts->add( $handle, $path, $dependencies, $package_data['version'], 1 ); |
9 | 263 |
|
16 | 264 |
if ( in_array( 'wp-i18n', $dependencies, true ) ) { |
9 | 265 |
$scripts->set_translations( $handle ); |
266 |
} |
|
267 |
} |
|
268 |
} |
|
269 |
||
270 |
/** |
|
271 |
* Adds inline scripts required for the WordPress JavaScript packages. |
|
272 |
* |
|
273 |
* @since 5.0.0 |
|
274 |
* |
|
275 |
* @param WP_Scripts $scripts WP_Scripts object. |
|
276 |
*/ |
|
16 | 277 |
function wp_default_packages_inline_scripts( $scripts ) { |
9 | 278 |
global $wp_locale; |
279 |
||
280 |
if ( isset( $scripts->registered['wp-api-fetch'] ) ) { |
|
281 |
$scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks'; |
|
282 |
} |
|
283 |
$scripts->add_inline_script( |
|
284 |
'wp-api-fetch', |
|
285 |
sprintf( |
|
16 | 286 |
'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );', |
287 |
esc_url_raw( get_rest_url() ) |
|
9 | 288 |
), |
289 |
'after' |
|
290 |
); |
|
291 |
$scripts->add_inline_script( |
|
292 |
'wp-api-fetch', |
|
16 | 293 |
implode( |
294 |
"\n", |
|
295 |
array( |
|
296 |
sprintf( |
|
297 |
'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );', |
|
298 |
( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ) |
|
299 |
), |
|
300 |
'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );', |
|
301 |
'wp.apiFetch.use( wp.apiFetch.mediaUploadMiddleware );', |
|
302 |
sprintf( |
|
303 |
'wp.apiFetch.nonceEndpoint = "%s";', |
|
304 |
admin_url( 'admin-ajax.php?action=rest-nonce' ) |
|
305 |
), |
|
306 |
) |
|
9 | 307 |
), |
308 |
'after' |
|
309 |
); |
|
310 |
$scripts->add_inline_script( |
|
311 |
'wp-data', |
|
312 |
implode( |
|
313 |
"\n", |
|
314 |
array( |
|
315 |
'( function() {', |
|
316 |
' var userId = ' . get_current_user_ID() . ';', |
|
317 |
' var storageKey = "WP_DATA_USER_" + userId;', |
|
318 |
' wp.data', |
|
16 | 319 |
' .use( wp.data.plugins.persistence, { storageKey: storageKey } );', |
9 | 320 |
' wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );', |
321 |
'} )();', |
|
322 |
) |
|
323 |
) |
|
324 |
); |
|
325 |
||
326 |
$scripts->add_inline_script( |
|
327 |
'wp-date', |
|
328 |
sprintf( |
|
329 |
'wp.date.setSettings( %s );', |
|
330 |
wp_json_encode( |
|
331 |
array( |
|
332 |
'l10n' => array( |
|
333 |
'locale' => get_user_locale(), |
|
334 |
'months' => array_values( $wp_locale->month ), |
|
335 |
'monthsShort' => array_values( $wp_locale->month_abbrev ), |
|
336 |
'weekdays' => array_values( $wp_locale->weekday ), |
|
337 |
'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ), |
|
338 |
'meridiem' => (object) $wp_locale->meridiem, |
|
339 |
'relative' => array( |
|
16 | 340 |
/* translators: %s: Duration. */ |
9 | 341 |
'future' => __( '%s from now' ), |
16 | 342 |
/* translators: %s: Duration. */ |
9 | 343 |
'past' => __( '%s ago' ), |
344 |
), |
|
345 |
), |
|
346 |
'formats' => array( |
|
16 | 347 |
/* translators: Time format, see https://www.php.net/date */ |
9 | 348 |
'time' => get_option( 'time_format', __( 'g:i a' ) ), |
16 | 349 |
/* translators: Date format, see https://www.php.net/date */ |
9 | 350 |
'date' => get_option( 'date_format', __( 'F j, Y' ) ), |
16 | 351 |
/* translators: Date/Time format, see https://www.php.net/date */ |
9 | 352 |
'datetime' => __( 'F j, Y g:i a' ), |
16 | 353 |
/* translators: Abbreviated date/time format, see https://www.php.net/date */ |
9 | 354 |
'datetimeAbbreviated' => __( 'M j, Y g:i a' ), |
355 |
), |
|
356 |
'timezone' => array( |
|
357 |
'offset' => get_option( 'gmt_offset', 0 ), |
|
358 |
'string' => get_option( 'timezone_string', 'UTC' ), |
|
359 |
), |
|
360 |
) |
|
361 |
) |
|
362 |
), |
|
363 |
'after' |
|
364 |
); |
|
365 |
||
366 |
// Loading the old editor and its config to ensure the classic block works as expected. |
|
367 |
$scripts->add_inline_script( |
|
368 |
'editor', |
|
369 |
'window.wp.oldEditor = window.wp.editor;', |
|
370 |
'after' |
|
371 |
); |
|
372 |
} |
|
373 |
||
374 |
/** |
|
375 |
* Adds inline scripts required for the TinyMCE in the block editor. |
|
376 |
* |
|
377 |
* These TinyMCE init settings are used to extend and override the default settings |
|
378 |
* from `_WP_Editors::default_settings()` for the Classic block. |
|
379 |
* |
|
380 |
* @since 5.0.0 |
|
381 |
* |
|
382 |
* @global WP_Scripts $wp_scripts |
|
383 |
*/ |
|
384 |
function wp_tinymce_inline_scripts() { |
|
385 |
global $wp_scripts; |
|
386 |
||
387 |
/** This filter is documented in wp-includes/class-wp-editor.php */ |
|
388 |
$editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' ); |
|
389 |
||
390 |
$tinymce_plugins = array( |
|
391 |
'charmap', |
|
392 |
'colorpicker', |
|
393 |
'hr', |
|
394 |
'lists', |
|
395 |
'media', |
|
396 |
'paste', |
|
397 |
'tabfocus', |
|
398 |
'textcolor', |
|
399 |
'fullscreen', |
|
400 |
'wordpress', |
|
401 |
'wpautoresize', |
|
402 |
'wpeditimage', |
|
403 |
'wpemoji', |
|
404 |
'wpgallery', |
|
405 |
'wplink', |
|
406 |
'wpdialogs', |
|
407 |
'wptextpattern', |
|
408 |
'wpview', |
|
409 |
); |
|
410 |
||
16 | 411 |
/** This filter is documented in wp-includes/class-wp-editor.php */ |
9 | 412 |
$tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' ); |
413 |
$tinymce_plugins = array_unique( $tinymce_plugins ); |
|
414 |
||
415 |
$disable_captions = false; |
|
416 |
// Runs after `tiny_mce_plugins` but before `mce_buttons`. |
|
417 |
/** This filter is documented in wp-admin/includes/media.php */ |
|
418 |
if ( apply_filters( 'disable_captions', '' ) ) { |
|
419 |
$disable_captions = true; |
|
420 |
} |
|
421 |
||
422 |
$toolbar1 = array( |
|
423 |
'formatselect', |
|
424 |
'bold', |
|
425 |
'italic', |
|
426 |
'bullist', |
|
427 |
'numlist', |
|
428 |
'blockquote', |
|
429 |
'alignleft', |
|
430 |
'aligncenter', |
|
431 |
'alignright', |
|
432 |
'link', |
|
433 |
'unlink', |
|
434 |
'wp_more', |
|
435 |
'spellchecker', |
|
436 |
'wp_add_media', |
|
437 |
'wp_adv', |
|
438 |
); |
|
439 |
||
16 | 440 |
/** This filter is documented in wp-includes/class-wp-editor.php */ |
9 | 441 |
$toolbar1 = apply_filters( 'mce_buttons', $toolbar1, 'classic-block' ); |
442 |
||
443 |
$toolbar2 = array( |
|
444 |
'strikethrough', |
|
445 |
'hr', |
|
446 |
'forecolor', |
|
447 |
'pastetext', |
|
448 |
'removeformat', |
|
449 |
'charmap', |
|
450 |
'outdent', |
|
451 |
'indent', |
|
452 |
'undo', |
|
453 |
'redo', |
|
454 |
'wp_help', |
|
455 |
); |
|
456 |
||
16 | 457 |
/** This filter is documented in wp-includes/class-wp-editor.php */ |
9 | 458 |
$toolbar2 = apply_filters( 'mce_buttons_2', $toolbar2, 'classic-block' ); |
16 | 459 |
/** This filter is documented in wp-includes/class-wp-editor.php */ |
9 | 460 |
$toolbar3 = apply_filters( 'mce_buttons_3', array(), 'classic-block' ); |
16 | 461 |
/** This filter is documented in wp-includes/class-wp-editor.php */ |
9 | 462 |
$toolbar4 = apply_filters( 'mce_buttons_4', array(), 'classic-block' ); |
16 | 463 |
/** This filter is documented in wp-includes/class-wp-editor.php */ |
9 | 464 |
$external_plugins = apply_filters( 'mce_external_plugins', array(), 'classic-block' ); |
465 |
||
466 |
$tinymce_settings = array( |
|
467 |
'plugins' => implode( ',', $tinymce_plugins ), |
|
468 |
'toolbar1' => implode( ',', $toolbar1 ), |
|
469 |
'toolbar2' => implode( ',', $toolbar2 ), |
|
470 |
'toolbar3' => implode( ',', $toolbar3 ), |
|
471 |
'toolbar4' => implode( ',', $toolbar4 ), |
|
472 |
'external_plugins' => wp_json_encode( $external_plugins ), |
|
473 |
'classic_block_editor' => true, |
|
474 |
); |
|
475 |
||
476 |
if ( $disable_captions ) { |
|
477 |
$tinymce_settings['wpeditimage_disable_captions'] = true; |
|
478 |
} |
|
479 |
||
480 |
if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) { |
|
481 |
array_merge( $tinymce_settings, $editor_settings['tinymce'] ); |
|
482 |
} |
|
483 |
||
16 | 484 |
/** This filter is documented in wp-includes/class-wp-editor.php */ |
9 | 485 |
$tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' ); |
486 |
||
487 |
// Do "by hand" translation from PHP array to js object. |
|
488 |
// Prevents breakage in some custom settings. |
|
489 |
$init_obj = ''; |
|
490 |
foreach ( $tinymce_settings as $key => $value ) { |
|
491 |
if ( is_bool( $value ) ) { |
|
492 |
$val = $value ? 'true' : 'false'; |
|
493 |
$init_obj .= $key . ':' . $val . ','; |
|
494 |
continue; |
|
495 |
} elseif ( ! empty( $value ) && is_string( $value ) && ( |
|
16 | 496 |
( '{' === $value[0] && '}' === $value[ strlen( $value ) - 1 ] ) || |
497 |
( '[' === $value[0] && ']' === $value[ strlen( $value ) - 1 ] ) || |
|
9 | 498 |
preg_match( '/^\(?function ?\(/', $value ) ) ) { |
499 |
$init_obj .= $key . ':' . $value . ','; |
|
500 |
continue; |
|
501 |
} |
|
502 |
$init_obj .= $key . ':"' . $value . '",'; |
|
503 |
} |
|
504 |
||
505 |
$init_obj = '{' . trim( $init_obj, ' ,' ) . '}'; |
|
506 |
||
507 |
$script = 'window.wpEditorL10n = { |
|
508 |
tinymce: { |
|
509 |
baseURL: ' . wp_json_encode( includes_url( 'js/tinymce' ) ) . ', |
|
510 |
suffix: ' . ( SCRIPT_DEBUG ? '""' : '".min"' ) . ', |
|
511 |
settings: ' . $init_obj . ', |
|
512 |
} |
|
513 |
}'; |
|
514 |
||
515 |
$wp_scripts->add_inline_script( 'wp-block-library', $script, 'before' ); |
|
516 |
} |
|
517 |
||
518 |
/** |
|
519 |
* Registers all the WordPress packages scripts. |
|
520 |
* |
|
521 |
* @since 5.0.0 |
|
522 |
* |
|
523 |
* @param WP_Scripts $scripts WP_Scripts object. |
|
524 |
*/ |
|
16 | 525 |
function wp_default_packages( $scripts ) { |
9 | 526 |
wp_default_packages_vendor( $scripts ); |
527 |
wp_register_tinymce_scripts( $scripts ); |
|
528 |
wp_default_packages_scripts( $scripts ); |
|
529 |
||
530 |
if ( did_action( 'init' ) ) { |
|
531 |
wp_default_packages_inline_scripts( $scripts ); |
|
532 |
} |
|
533 |
} |
|
534 |
||
535 |
/** |
|
536 |
* Returns the suffix that can be used for the scripts. |
|
537 |
* |
|
538 |
* There are two suffix types, the normal one and the dev suffix. |
|
539 |
* |
|
540 |
* @since 5.0.0 |
|
541 |
* |
|
542 |
* @param string $type The type of suffix to retrieve. |
|
543 |
* @return string The script suffix. |
|
544 |
*/ |
|
545 |
function wp_scripts_get_suffix( $type = '' ) { |
|
546 |
static $suffixes; |
|
547 |
||
16 | 548 |
if ( null === $suffixes ) { |
549 |
// Include an unmodified $wp_version. |
|
550 |
require ABSPATH . WPINC . '/version.php'; |
|
9 | 551 |
|
552 |
$develop_src = false !== strpos( $wp_version, '-src' ); |
|
553 |
||
554 |
if ( ! defined( 'SCRIPT_DEBUG' ) ) { |
|
555 |
define( 'SCRIPT_DEBUG', $develop_src ); |
|
556 |
} |
|
557 |
$suffix = SCRIPT_DEBUG ? '' : '.min'; |
|
558 |
$dev_suffix = $develop_src ? '' : '.min'; |
|
559 |
||
560 |
$suffixes = array( |
|
561 |
'suffix' => $suffix, |
|
562 |
'dev_suffix' => $dev_suffix, |
|
563 |
); |
|
564 |
} |
|
565 |
||
16 | 566 |
if ( 'dev' === $type ) { |
9 | 567 |
return $suffixes['dev_suffix']; |
568 |
} |
|
569 |
||
570 |
return $suffixes['suffix']; |
|
571 |
} |
|
572 |
||
573 |
/** |
|
0 | 574 |
* Register all WordPress scripts. |
575 |
* |
|
576 |
* Localizes some of them. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
577 |
* args order: `$scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );` |
0 | 578 |
* when last arg === 1 queues the script for the footer |
579 |
* |
|
580 |
* @since 2.6.0 |
|
581 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
* @param WP_Scripts $scripts WP_Scripts object. |
0 | 583 |
*/ |
16 | 584 |
function wp_default_scripts( $scripts ) { |
9 | 585 |
$suffix = wp_scripts_get_suffix(); |
586 |
$dev_suffix = wp_scripts_get_suffix( 'dev' ); |
|
16 | 587 |
$guessurl = site_url(); |
0 | 588 |
|
16 | 589 |
if ( ! $guessurl ) { |
0 | 590 |
$guessed_url = true; |
9 | 591 |
$guessurl = wp_guess_url(); |
0 | 592 |
} |
593 |
||
9 | 594 |
$scripts->base_url = $guessurl; |
595 |
$scripts->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : ''; |
|
0 | 596 |
$scripts->default_version = get_bloginfo( 'version' ); |
9 | 597 |
$scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); |
0 | 598 |
|
599 |
$scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" ); |
|
9 | 600 |
did_action( 'init' ) && $scripts->localize( |
601 |
'utils', |
|
602 |
'userSettings', |
|
603 |
array( |
|
604 |
'url' => (string) SITECOOKIEPATH, |
|
605 |
'uid' => (string) get_current_user_id(), |
|
606 |
'time' => (string) time(), |
|
607 |
'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ), |
|
608 |
) |
|
609 |
); |
|
0 | 610 |
|
9 | 611 |
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils' ), false, 1 ); |
16 | 612 |
$scripts->set_translations( 'common' ); |
0 | 613 |
|
9 | 614 |
$scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 ); |
615 |
||
0 | 616 |
$scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 ); |
617 |
||
618 |
$scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 ); |
|
9 | 619 |
did_action( 'init' ) && $scripts->localize( |
620 |
'quicktags', |
|
621 |
'quicktagsL10n', |
|
622 |
array( |
|
623 |
'closeAllOpenTags' => __( 'Close all open tags' ), |
|
624 |
'closeTags' => __( 'close tags' ), |
|
625 |
'enterURL' => __( 'Enter the URL' ), |
|
626 |
'enterImageURL' => __( 'Enter the URL of the image' ), |
|
627 |
'enterImageDescription' => __( 'Enter a description of the image' ), |
|
628 |
'textdirection' => __( 'text direction' ), |
|
629 |
'toggleTextdirection' => __( 'Toggle Editor Text Direction' ), |
|
630 |
'dfw' => __( 'Distraction-free writing mode' ), |
|
631 |
'strong' => __( 'Bold' ), |
|
632 |
'strongClose' => __( 'Close bold tag' ), |
|
633 |
'em' => __( 'Italic' ), |
|
634 |
'emClose' => __( 'Close italic tag' ), |
|
635 |
'link' => __( 'Insert link' ), |
|
636 |
'blockquote' => __( 'Blockquote' ), |
|
637 |
'blockquoteClose' => __( 'Close blockquote tag' ), |
|
638 |
'del' => __( 'Deleted text (strikethrough)' ), |
|
639 |
'delClose' => __( 'Close deleted text tag' ), |
|
640 |
'ins' => __( 'Inserted text' ), |
|
641 |
'insClose' => __( 'Close inserted text tag' ), |
|
642 |
'image' => __( 'Insert image' ), |
|
643 |
'ul' => __( 'Bulleted list' ), |
|
644 |
'ulClose' => __( 'Close bulleted list tag' ), |
|
645 |
'ol' => __( 'Numbered list' ), |
|
646 |
'olClose' => __( 'Close numbered list tag' ), |
|
647 |
'li' => __( 'List item' ), |
|
648 |
'liClose' => __( 'Close list item tag' ), |
|
649 |
'code' => __( 'Code' ), |
|
650 |
'codeClose' => __( 'Close code tag' ), |
|
651 |
'more' => __( 'Insert Read More tag' ), |
|
652 |
) |
|
653 |
); |
|
0 | 654 |
|
9 | 655 |
$scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array( 'prototype' ), '3517m' ); |
0 | 656 |
|
9 | 657 |
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 ); |
658 |
||
659 |
$scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), false, 1 ); |
|
0 | 660 |
|
9 | 661 |
$scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery' ), false, 1 ); |
662 |
did_action( 'init' ) && $scripts->localize( |
|
663 |
'wp-ajax-response', |
|
664 |
'wpAjax', |
|
665 |
array( |
|
666 |
'noPerm' => __( 'Sorry, you are not allowed to do that.' ), |
|
667 |
'broken' => __( 'Something went wrong.' ), |
|
668 |
) |
|
669 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
$scripts->add( 'wp-api-request', "/wp-includes/js/api-request$suffix.js", array( 'jquery' ), false, 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
// `wpApiSettings` is also used by `wp-api`, which depends on this script. |
9 | 673 |
did_action( 'init' ) && $scripts->localize( |
674 |
'wp-api-request', |
|
675 |
'wpApiSettings', |
|
676 |
array( |
|
677 |
'root' => esc_url_raw( get_rest_url() ), |
|
678 |
'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ), |
|
679 |
'versionString' => 'wp/v2/', |
|
680 |
) |
|
681 |
); |
|
0 | 682 |
|
16 | 683 |
$scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), false, 1 ); |
684 |
$scripts->set_translations( 'wp-pointer' ); |
|
0 | 685 |
|
9 | 686 |
$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array( 'heartbeat' ), false, 1 ); |
0 | 687 |
|
9 | 688 |
$scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array( 'jquery', 'wp-hooks' ), false, 1 ); |
689 |
did_action( 'init' ) && $scripts->localize( |
|
690 |
'heartbeat', |
|
691 |
'heartbeatSettings', |
|
5 | 692 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
* Filters the Heartbeat settings. |
5 | 694 |
* |
695 |
* @since 3.6.0 |
|
696 |
* |
|
697 |
* @param array $settings Heartbeat settings array. |
|
698 |
*/ |
|
0 | 699 |
apply_filters( 'heartbeat_settings', array() ) |
700 |
); |
|
701 |
||
9 | 702 |
$scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array( 'heartbeat' ), false, 1 ); |
16 | 703 |
$scripts->set_translations( 'wp-auth-check' ); |
0 | 704 |
|
705 |
$scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 ); |
|
706 |
||
707 |
// WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source. |
|
9 | 708 |
$scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' ); |
709 |
$scripts->add( 'scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array( 'prototype' ), '1.9.0' ); |
|
710 |
$scripts->add( 'scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array( 'scriptaculous-root' ), '1.9.0' ); |
|
711 |
$scripts->add( 'scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array( 'scriptaculous-builder', 'scriptaculous-effects' ), '1.9.0' ); |
|
712 |
$scripts->add( 'scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array( 'scriptaculous-root' ), '1.9.0' ); |
|
713 |
$scripts->add( 'scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array( 'scriptaculous-effects' ), '1.9.0' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
$scripts->add( 'scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' ); |
9 | 715 |
$scripts->add( 'scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array( 'scriptaculous-root' ), '1.9.0' ); |
716 |
$scripts->add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) ); |
|
0 | 717 |
|
16 | 718 |
// Not used in core, replaced by Jcrop.js. |
9 | 719 |
$scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array( 'scriptaculous-dragdrop' ) ); |
0 | 720 |
|
16 | 721 |
// jQuery. |
722 |
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4-wp' ); |
|
9 | 723 |
$scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.12.4-wp' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
724 |
$scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.4.1' ); |
0 | 725 |
|
16 | 726 |
// Full jQuery UI. |
9 | 727 |
$scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 ); |
728 |
$scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 ); |
|
0 | 729 |
|
9 | 730 |
$scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
731 |
$scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
732 |
$scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
733 |
$scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
734 |
$scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
735 |
$scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
736 |
$scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
737 |
$scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
738 |
$scripts->add( 'jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff$dev_suffix.js", array( 'jquery-effects-core', 'jquery-effects-scale' ), '1.11.4', 1 ); |
|
739 |
$scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
740 |
$scripts->add( 'jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale$dev_suffix.js", array( 'jquery-effects-core', 'jquery-effects-size' ), '1.11.4', 1 ); |
|
741 |
$scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
742 |
$scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
743 |
$scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
744 |
$scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 ); |
|
0 | 745 |
|
9 | 746 |
$scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
$scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.11.4', 1 ); |
9 | 748 |
$scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 ); |
749 |
$scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array( 'jquery-ui-core' ), '1.11.4', 1 ); |
|
750 |
$scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$dev_suffix.js", array( 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position' ), '1.11.4', 1 ); |
|
751 |
$scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 ); |
|
752 |
$scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$dev_suffix.js", array( 'jquery-ui-draggable' ), '1.11.4', 1 ); |
|
5 | 753 |
$scripts->add( 'jquery-ui-menu', "/wp-includes/js/jquery/ui/menu$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 ); |
754 |
$scripts->add( 'jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 ); |
|
9 | 755 |
$scripts->add( 'jquery-ui-position', "/wp-includes/js/jquery/ui/position$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 ); |
756 |
$scripts->add( 'jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 ); |
|
757 |
$scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 ); |
|
758 |
$scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 ); |
|
759 |
$scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$dev_suffix.js", array( 'jquery-ui-menu' ), '1.11.4', 1 ); |
|
760 |
$scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 ); |
|
761 |
$scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 ); |
|
5 | 762 |
$scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$dev_suffix.js", array( 'jquery-ui-button' ), '1.11.4', 1 ); |
9 | 763 |
$scripts->add( 'jquery-ui-tabs', "/wp-includes/js/jquery/ui/tabs$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 ); |
5 | 764 |
$scripts->add( 'jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 ); |
9 | 765 |
$scripts->add( 'jquery-ui-widget', "/wp-includes/js/jquery/ui/widget$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 ); |
0 | 766 |
|
16 | 767 |
// Strings for 'jquery-ui-autocomplete' live region messages. |
9 | 768 |
did_action( 'init' ) && $scripts->localize( |
769 |
'jquery-ui-autocomplete', |
|
770 |
'uiAutocompleteL10n', |
|
771 |
array( |
|
772 |
'noResults' => __( 'No results found.' ), |
|
16 | 773 |
/* translators: Number of results found when using jQuery UI Autocomplete. */ |
9 | 774 |
'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ), |
16 | 775 |
/* translators: %d: Number of results found when using jQuery UI Autocomplete. */ |
9 | 776 |
'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ), |
777 |
'itemSelected' => __( 'Item selected.' ), |
|
778 |
) |
|
779 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
780 |
|
16 | 781 |
// Deprecated, not used in core, most functionality is included in jQuery 1.3. |
9 | 782 |
$scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.2.1', 1 ); |
0 | 783 |
|
16 | 784 |
// jQuery plugins. |
785 |
$scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.min.js', array( 'jquery' ), '2.1.2', 1 ); |
|
9 | 786 |
$scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array( 'jquery' ), '20m', 1 ); |
787 |
$scripts->add( 'jquery-query', '/wp-includes/js/jquery/jquery.query.js', array( 'jquery' ), '2.1.7', 1 ); |
|
788 |
$scripts->add( 'jquery-serialize-object', '/wp-includes/js/jquery/jquery.serialize-object.js', array( 'jquery' ), '0.2', 1 ); |
|
789 |
$scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array( 'jquery' ), '0.0.2m', 1 ); |
|
790 |
$scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array( 'jquery', 'jquery-hotkeys' ), false, 1 ); |
|
791 |
$scripts->add( 'jquery-touch-punch', '/wp-includes/js/jquery/jquery.ui.touch-punch.js', array( 'jquery-ui-widget', 'jquery-ui-mouse' ), '0.2.2', 1 ); |
|
5 | 792 |
|
9 | 793 |
// Not used any more, registered for backward compatibility. |
794 |
$scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array( 'jquery' ), '1.1-20110113', 1 ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
|
5 | 796 |
// Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv. |
797 |
// It sets jQuery as a dependency, as the theme may have been implicitly loading it this way. |
|
16 | 798 |
$scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '4.1.4', 1 ); |
799 |
$scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '4.2.2', 1 ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
$scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2b', 1 ); |
0 | 801 |
|
9 | 802 |
$scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array( 'jquery' ), '3.1-20121105', 1 ); |
803 |
did_action( 'init' ) && $scripts->localize( |
|
804 |
'thickbox', |
|
805 |
'thickboxL10n', |
|
806 |
array( |
|
807 |
'next' => __( 'Next >' ), |
|
808 |
'prev' => __( '< Prev' ), |
|
809 |
'image' => __( 'Image' ), |
|
810 |
'of' => __( 'of' ), |
|
811 |
'close' => __( 'Close' ), |
|
812 |
'noiframes' => __( 'This feature requires inline frames. You have iframes disabled or your browser does not support them.' ), |
|
813 |
'loadingAnimation' => includes_url( 'js/thickbox/loadingAnimation.gif' ), |
|
814 |
) |
|
815 |
); |
|
0 | 816 |
|
9 | 817 |
$scripts->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.js', array( 'jquery' ), '0.9.12' ); |
0 | 818 |
|
9 | 819 |
$scripts->add( 'swfobject', '/wp-includes/js/swfobject.js', array(), '2.2-20120417' ); |
0 | 820 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
821 |
// Error messages for Plupload. |
0 | 822 |
$uploader_l10n = array( |
9 | 823 |
'queue_limit_exceeded' => __( 'You have attempted to queue too many files.' ), |
16 | 824 |
/* translators: %s: File name. */ |
9 | 825 |
'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.' ), |
826 |
'zero_byte_file' => __( 'This file is empty. Please try another.' ), |
|
827 |
'invalid_filetype' => __( 'Sorry, this file type is not permitted for security reasons.' ), |
|
828 |
'not_an_image' => __( 'This file is not an image. Please try another.' ), |
|
829 |
'image_memory_exceeded' => __( 'Memory exceeded. Please try another smaller file.' ), |
|
830 |
'image_dimensions_exceeded' => __( 'This is larger than the maximum size. Please try another.' ), |
|
831 |
'default_error' => __( 'An error occurred in the upload. Please try again later.' ), |
|
832 |
'missing_upload_url' => __( 'There was a configuration error. Please contact the server administrator.' ), |
|
833 |
'upload_limit_exceeded' => __( 'You may only upload 1 file.' ), |
|
16 | 834 |
'http_error' => __( 'Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.' ), |
835 |
'http_error_image' => __( 'Post-processing of the image failed likely because the server is busy or does not have enough resources. Uploading a smaller image may help. Suggested maximum size is 2500 pixels.' ), |
|
9 | 836 |
'upload_failed' => __( 'Upload failed.' ), |
16 | 837 |
/* translators: 1: Opening link tag, 2: Closing link tag. */ |
9 | 838 |
'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.' ), |
16 | 839 |
/* translators: %s: File name. */ |
9 | 840 |
'big_upload_queued' => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.' ), |
841 |
'io_error' => __( 'IO error.' ), |
|
842 |
'security_error' => __( 'Security error.' ), |
|
843 |
'file_cancelled' => __( 'File canceled.' ), |
|
844 |
'upload_stopped' => __( 'Upload stopped.' ), |
|
845 |
'dismiss' => __( 'Dismiss' ), |
|
846 |
'crunching' => __( 'Crunching…' ), |
|
16 | 847 |
'deleted' => __( 'moved to the Trash.' ), |
848 |
/* translators: %s: File name. */ |
|
9 | 849 |
'error_uploading' => __( '“%s” has failed to upload.' ), |
16 | 850 |
'unsupported_image' => __( 'This image cannot be displayed in a web browser. For best results convert it to JPEG before uploading.' ), |
0 | 851 |
); |
852 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
853 |
$scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
854 |
$scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.1.9' ); |
5 | 855 |
// Back compat handles: |
856 |
foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) { |
|
857 |
$scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' ); |
|
858 |
} |
|
0 | 859 |
|
5 | 860 |
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) ); |
0 | 861 |
did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n ); |
862 |
||
5 | 863 |
$scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 ); |
0 | 864 |
did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n ); |
865 |
||
16 | 866 |
// Keep 'swfupload' for back-compat. |
9 | 867 |
$scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
868 |
$scripts->add( 'swfupload-all', false, array( 'swfupload' ), '2201' ); |
9 | 869 |
$scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array( 'swfupload-all', 'jquery' ), '2201-20110524' ); |
0 | 870 |
did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n ); |
871 |
||
5 | 872 |
$scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 ); |
0 | 873 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
874 |
$scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' ); |
5 | 875 |
did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' ); |
0 | 876 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
877 |
$scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.8.3', 1 ); |
16 | 878 |
$scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.4.0', 1 ); |
0 | 879 |
|
9 | 880 |
$scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array( 'underscore', 'jquery' ), false, 1 ); |
881 |
did_action( 'init' ) && $scripts->localize( |
|
882 |
'wp-util', |
|
883 |
'_wpUtilSettings', |
|
884 |
array( |
|
885 |
'ajax' => array( |
|
886 |
'url' => admin_url( 'admin-ajax.php', 'relative' ), |
|
887 |
), |
|
888 |
) |
|
889 |
); |
|
0 | 890 |
|
9 | 891 |
$scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array( 'backbone', 'wp-util' ), false, 1 ); |
0 | 892 |
|
893 |
$scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 ); |
|
894 |
||
9 | 895 |
$scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array( 'jquery' ), false, 1 ); |
0 | 896 |
|
16 | 897 |
$scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.13-9993131', 1 ); |
898 |
$scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.13-9993131', 1 ); |
|
9 | 899 |
$scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
900 |
|
9 | 901 |
did_action( 'init' ) && $scripts->add_inline_script( |
902 |
'mediaelement-core', |
|
903 |
sprintf( |
|
904 |
'var mejsL10n = %s;', |
|
905 |
wp_json_encode( |
|
906 |
array( |
|
907 |
'language' => strtolower( strtok( determine_locale(), '_-' ) ), |
|
908 |
'strings' => array( |
|
16 | 909 |
'mejs.download-file' => __( 'Download File' ), |
9 | 910 |
'mejs.install-flash' => __( 'You are using a browser that does not have Flash player enabled or installed. Please turn on your Flash player plugin or download the latest version from https://get.adobe.com/flashplayer/' ), |
911 |
'mejs.fullscreen' => __( 'Fullscreen' ), |
|
912 |
'mejs.play' => __( 'Play' ), |
|
913 |
'mejs.pause' => __( 'Pause' ), |
|
914 |
'mejs.time-slider' => __( 'Time Slider' ), |
|
915 |
'mejs.time-help-text' => __( 'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.' ), |
|
16 | 916 |
'mejs.live-broadcast' => __( 'Live Broadcast' ), |
9 | 917 |
'mejs.volume-help-text' => __( 'Use Up/Down Arrow keys to increase or decrease volume.' ), |
918 |
'mejs.unmute' => __( 'Unmute' ), |
|
919 |
'mejs.mute' => __( 'Mute' ), |
|
920 |
'mejs.volume-slider' => __( 'Volume Slider' ), |
|
921 |
'mejs.video-player' => __( 'Video Player' ), |
|
922 |
'mejs.audio-player' => __( 'Audio Player' ), |
|
16 | 923 |
'mejs.captions-subtitles' => __( 'Captions/Subtitles' ), |
924 |
'mejs.captions-chapters' => __( 'Chapters' ), |
|
925 |
'mejs.none' => __( 'None' ), |
|
9 | 926 |
'mejs.afrikaans' => __( 'Afrikaans' ), |
927 |
'mejs.albanian' => __( 'Albanian' ), |
|
928 |
'mejs.arabic' => __( 'Arabic' ), |
|
929 |
'mejs.belarusian' => __( 'Belarusian' ), |
|
930 |
'mejs.bulgarian' => __( 'Bulgarian' ), |
|
931 |
'mejs.catalan' => __( 'Catalan' ), |
|
932 |
'mejs.chinese' => __( 'Chinese' ), |
|
933 |
'mejs.chinese-simplified' => __( 'Chinese (Simplified)' ), |
|
934 |
'mejs.chinese-traditional' => __( 'Chinese (Traditional)' ), |
|
935 |
'mejs.croatian' => __( 'Croatian' ), |
|
936 |
'mejs.czech' => __( 'Czech' ), |
|
937 |
'mejs.danish' => __( 'Danish' ), |
|
938 |
'mejs.dutch' => __( 'Dutch' ), |
|
939 |
'mejs.english' => __( 'English' ), |
|
940 |
'mejs.estonian' => __( 'Estonian' ), |
|
941 |
'mejs.filipino' => __( 'Filipino' ), |
|
942 |
'mejs.finnish' => __( 'Finnish' ), |
|
943 |
'mejs.french' => __( 'French' ), |
|
944 |
'mejs.galician' => __( 'Galician' ), |
|
945 |
'mejs.german' => __( 'German' ), |
|
946 |
'mejs.greek' => __( 'Greek' ), |
|
947 |
'mejs.haitian-creole' => __( 'Haitian Creole' ), |
|
948 |
'mejs.hebrew' => __( 'Hebrew' ), |
|
949 |
'mejs.hindi' => __( 'Hindi' ), |
|
950 |
'mejs.hungarian' => __( 'Hungarian' ), |
|
951 |
'mejs.icelandic' => __( 'Icelandic' ), |
|
952 |
'mejs.indonesian' => __( 'Indonesian' ), |
|
953 |
'mejs.irish' => __( 'Irish' ), |
|
954 |
'mejs.italian' => __( 'Italian' ), |
|
955 |
'mejs.japanese' => __( 'Japanese' ), |
|
956 |
'mejs.korean' => __( 'Korean' ), |
|
957 |
'mejs.latvian' => __( 'Latvian' ), |
|
958 |
'mejs.lithuanian' => __( 'Lithuanian' ), |
|
959 |
'mejs.macedonian' => __( 'Macedonian' ), |
|
960 |
'mejs.malay' => __( 'Malay' ), |
|
961 |
'mejs.maltese' => __( 'Maltese' ), |
|
962 |
'mejs.norwegian' => __( 'Norwegian' ), |
|
963 |
'mejs.persian' => __( 'Persian' ), |
|
964 |
'mejs.polish' => __( 'Polish' ), |
|
965 |
'mejs.portuguese' => __( 'Portuguese' ), |
|
966 |
'mejs.romanian' => __( 'Romanian' ), |
|
967 |
'mejs.russian' => __( 'Russian' ), |
|
968 |
'mejs.serbian' => __( 'Serbian' ), |
|
969 |
'mejs.slovak' => __( 'Slovak' ), |
|
970 |
'mejs.slovenian' => __( 'Slovenian' ), |
|
971 |
'mejs.spanish' => __( 'Spanish' ), |
|
972 |
'mejs.swahili' => __( 'Swahili' ), |
|
973 |
'mejs.swedish' => __( 'Swedish' ), |
|
974 |
'mejs.tagalog' => __( 'Tagalog' ), |
|
975 |
'mejs.thai' => __( 'Thai' ), |
|
976 |
'mejs.turkish' => __( 'Turkish' ), |
|
977 |
'mejs.ukrainian' => __( 'Ukrainian' ), |
|
978 |
'mejs.vietnamese' => __( 'Vietnamese' ), |
|
979 |
'mejs.welsh' => __( 'Welsh' ), |
|
980 |
'mejs.yiddish' => __( 'Yiddish' ), |
|
981 |
), |
|
982 |
) |
|
983 |
) |
|
984 |
), |
|
985 |
'before' |
|
986 |
); |
|
0 | 987 |
|
16 | 988 |
$scripts->add( 'mediaelement-vimeo', '/wp-includes/js/mediaelement/renderers/vimeo.min.js', array( 'mediaelement' ), '4.2.13-9993131', 1 ); |
9 | 989 |
$scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array( 'mediaelement' ), false, 1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
$mejs_settings = array( |
9 | 991 |
'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ), |
992 |
'classPrefix' => 'mejs-', |
|
993 |
'stretching' => 'responsive', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
994 |
); |
9 | 995 |
did_action( 'init' ) && $scripts->localize( |
996 |
'mediaelement', |
|
997 |
'_wpmejsSettings', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
998 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
999 |
* Filters the MediaElement configuration settings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1000 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
* @param array $mejs_settings MediaElement settings array. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1004 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1005 |
apply_filters( 'mejs_settings', $mejs_settings ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1006 |
); |
0 | 1007 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
$scripts->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.js', array(), '5.29.1-alpha-ee20357' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1009 |
$scripts->add( 'csslint', '/wp-includes/js/codemirror/csslint.js', array(), '1.0.5' ); |
9 | 1010 |
$scripts->add( 'esprima', '/wp-includes/js/codemirror/esprima.js', array(), '4.0.0' ); |
1011 |
$scripts->add( 'jshint', '/wp-includes/js/codemirror/fakejshint.js', array( 'esprima' ), '2.9.5' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1012 |
$scripts->add( 'jsonlint', '/wp-includes/js/codemirror/jsonlint.js', array(), '1.6.2' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1013 |
$scripts->add( 'htmlhint', '/wp-includes/js/codemirror/htmlhint.js', array(), '0.9.14-xwp' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1014 |
$scripts->add( 'htmlhint-kses', '/wp-includes/js/codemirror/htmlhint-kses.js', array( 'htmlhint' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
$scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror', 'underscore' ) ); |
16 | 1016 |
$scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'common', 'wp-util', 'wp-sanitize', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) ); |
1017 |
$scripts->set_translations( 'wp-theme-plugin-editor' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1019 |
$scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 ); |
5 | 1020 |
|
0 | 1021 |
$scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' ); |
9 | 1022 |
did_action( 'init' ) && $scripts->localize( |
1023 |
'zxcvbn-async', |
|
1024 |
'_zxcvbnSettings', |
|
1025 |
array( |
|
1026 |
'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js', |
|
1027 |
) |
|
1028 |
); |
|
0 | 1029 |
|
1030 |
$scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 ); |
|
9 | 1031 |
did_action( 'init' ) && $scripts->localize( |
1032 |
'password-strength-meter', |
|
1033 |
'pwsL10n', |
|
1034 |
array( |
|
1035 |
'unknown' => _x( 'Password strength unknown', 'password strength' ), |
|
1036 |
'short' => _x( 'Very weak', 'password strength' ), |
|
1037 |
'bad' => _x( 'Weak', 'password strength' ), |
|
1038 |
'good' => _x( 'Medium', 'password strength' ), |
|
1039 |
'strong' => _x( 'Strong', 'password strength' ), |
|
1040 |
'mismatch' => _x( 'Mismatch', 'password mismatch' ), |
|
1041 |
) |
|
1042 |
); |
|
16 | 1043 |
$scripts->set_translations( 'password-strength-meter' ); |
0 | 1044 |
|
5 | 1045 |
$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 ); |
16 | 1046 |
$scripts->set_translations( 'user-profile' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1047 |
|
5 | 1048 |
$scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 ); |
0 | 1049 |
|
1050 |
$scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 ); |
|
1051 |
||
16 | 1052 |
$scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array( 'hoverintent-js' ), false, 1 ); |
0 | 1053 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1054 |
$scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); |
9 | 1055 |
did_action( 'init' ) && $scripts->localize( |
1056 |
'wplink', |
|
1057 |
'wpLinkL10n', |
|
1058 |
array( |
|
1059 |
'title' => __( 'Insert/edit link' ), |
|
1060 |
'update' => __( 'Update' ), |
|
1061 |
'save' => __( 'Add Link' ), |
|
1062 |
'noTitle' => __( '(no title)' ), |
|
1063 |
'noMatchesFound' => __( 'No results found.' ), |
|
1064 |
'linkSelected' => __( 'Link selected.' ), |
|
1065 |
'linkInserted' => __( 'Link inserted.' ), |
|
16 | 1066 |
/* translators: Minimum input length in characters to start searching posts in the "Insert/edit link" modal. */ |
1067 |
'minInputLength' => (int) _x( '3', 'minimum input length for searching post links' ), |
|
9 | 1068 |
) |
1069 |
); |
|
0 | 1070 |
|
5 | 1071 |
$scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 ); |
0 | 1072 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1073 |
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 ); |
0 | 1074 |
|
1075 |
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 ); |
|
1076 |
||
9 | 1077 |
$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array( 'jquery' ), '1.8.1', 1 ); |
0 | 1078 |
|
16 | 1079 |
// JS-only version of hoverintent (no dependencies). |
1080 |
$scripts->add( 'hoverintent-js', '/wp-includes/js/hoverintent-js.min.js', array(), '2.2.1', 1 ); |
|
1081 |
||
9 | 1082 |
$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 ); |
1083 |
$scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 ); |
|
1084 |
$scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 ); |
|
1085 |
$scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 ); |
|
1086 |
$scripts->add( 'customize-views', '/wp-includes/js/customize-views.js', array( 'jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views' ), false, 1 ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1087 |
$scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y', 'wp-util', 'jquery-ui-core' ), false, 1 ); |
9 | 1088 |
did_action( 'init' ) && $scripts->localize( |
1089 |
'customize-controls', |
|
1090 |
'_wpCustomizeControlsL10n', |
|
1091 |
array( |
|
1092 |
'activate' => __( 'Activate & Publish' ), |
|
1093 |
'save' => __( 'Save & Publish' ), // @todo Remove as not required. |
|
1094 |
'publish' => __( 'Publish' ), |
|
1095 |
'published' => __( 'Published' ), |
|
1096 |
'saveDraft' => __( 'Save Draft' ), |
|
1097 |
'draftSaved' => __( 'Draft Saved' ), |
|
1098 |
'updating' => __( 'Updating' ), |
|
1099 |
'schedule' => _x( 'Schedule', 'customizer changeset action/button label' ), |
|
1100 |
'scheduled' => _x( 'Scheduled', 'customizer changeset status' ), |
|
1101 |
'invalid' => __( 'Invalid' ), |
|
1102 |
'saveBeforeShare' => __( 'Please save your changes in order to share the preview.' ), |
|
1103 |
'futureDateError' => __( 'You must supply a future date to schedule.' ), |
|
1104 |
'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), |
|
1105 |
'saved' => __( 'Saved' ), |
|
1106 |
'cancel' => __( 'Cancel' ), |
|
1107 |
'close' => __( 'Close' ), |
|
1108 |
'action' => __( 'Action' ), |
|
1109 |
'discardChanges' => __( 'Discard changes' ), |
|
1110 |
'cheatin' => __( 'Something went wrong.' ), |
|
1111 |
'notAllowedHeading' => __( 'You need a higher level of permission.' ), |
|
1112 |
'notAllowed' => __( 'Sorry, you are not allowed to customize this site.' ), |
|
1113 |
'previewIframeTitle' => __( 'Site Preview' ), |
|
1114 |
'loginIframeTitle' => __( 'Session expired' ), |
|
1115 |
'collapseSidebar' => _x( 'Hide Controls', 'label for hide controls button without length constraints' ), |
|
1116 |
'expandSidebar' => _x( 'Show Controls', 'label for hide controls button without length constraints' ), |
|
1117 |
'untitledBlogName' => __( '(Untitled)' ), |
|
1118 |
'unknownRequestFail' => __( 'Looks like something’s gone wrong. Wait a couple seconds, and then try again.' ), |
|
1119 |
'themeDownloading' => __( 'Downloading your new theme…' ), |
|
1120 |
'themePreviewWait' => __( 'Setting up your live preview. This may take a bit.' ), |
|
1121 |
'revertingChanges' => __( 'Reverting unpublished changes…' ), |
|
16 | 1122 |
'trashConfirm' => __( 'Are you sure you want to discard your unpublished changes?' ), |
9 | 1123 |
/* translators: %s: Display name of the user who has taken over the changeset in customizer. */ |
1124 |
'takenOverMessage' => __( '%s has taken over and is currently customizing.' ), |
|
16 | 1125 |
/* translators: %s: URL to the Customizer to load the autosaved version. */ |
9 | 1126 |
'autosaveNotice' => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ), |
1127 |
'videoHeaderNotice' => __( 'This theme doesn’t support video headers on this page. Navigate to the front page or another page that supports video headers.' ), |
|
16 | 1128 |
// Used for overriding the file types allowed in Plupload. |
9 | 1129 |
'allowedFiles' => __( 'Allowed Files' ), |
1130 |
'customCssError' => array( |
|
16 | 1131 |
/* translators: %d: Error count. */ |
9 | 1132 |
'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ), |
16 | 1133 |
/* translators: %d: Error count. */ |
1134 |
'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), |
|
1135 |
// @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. |
|
9 | 1136 |
), |
1137 |
'pageOnFrontError' => __( 'Homepage and posts page must be different.' ), |
|
1138 |
'saveBlockedError' => array( |
|
16 | 1139 |
/* translators: %s: Number of invalid settings. */ |
9 | 1140 |
'singular' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 1 ), |
16 | 1141 |
/* translators: %s: Number of invalid settings. */ |
1142 |
'plural' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 2 ), |
|
1143 |
// @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. |
|
9 | 1144 |
), |
1145 |
'scheduleDescription' => __( 'Schedule your customization changes to publish ("go live") at a future date.' ), |
|
1146 |
'themePreviewUnavailable' => __( 'Sorry, you can’t preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ), |
|
1147 |
'themeInstallUnavailable' => sprintf( |
|
16 | 1148 |
/* translators: %s: URL to Add Themes admin screen. */ |
1149 |
__( 'You won’t be able to install new themes from here yet since your install requires SFTP credentials. For now, please <a href="%s">add themes in the admin</a>.' ), |
|
9 | 1150 |
esc_url( admin_url( 'theme-install.php' ) ) |
1151 |
), |
|
1152 |
'publishSettings' => __( 'Publish Settings' ), |
|
1153 |
'invalidDate' => __( 'Invalid date.' ), |
|
1154 |
'invalidValue' => __( 'Invalid value.' ), |
|
1155 |
) |
|
1156 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1157 |
$scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 ); |
0 | 1158 |
|
5 | 1159 |
$scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
$scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
|
9 | 1162 |
$scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu', 'wp-sanitize' ), false, 1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1163 |
$scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1164 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1165 |
$scripts->add( 'wp-custom-header', "/wp-includes/js/wp-custom-header$suffix.js", array( 'wp-a11y' ), false, 1 ); |
5 | 1166 |
|
0 | 1167 |
$scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 ); |
1168 |
||
1169 |
$scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 ); |
|
1170 |
$scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 ); |
|
9 | 1171 |
did_action( 'init' ) && $scripts->localize( |
1172 |
'media-models', |
|
1173 |
'_wpMediaModelsL10n', |
|
1174 |
array( |
|
1175 |
'settings' => array( |
|
1176 |
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), |
|
1177 |
'post' => array( 'id' => 0 ), |
|
1178 |
), |
|
1179 |
) |
|
1180 |
); |
|
0 | 1181 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1182 |
$scripts->add( 'wp-embed', "/wp-includes/js/wp-embed$suffix.js" ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1183 |
|
0 | 1184 |
// To enqueue media-views or media-editor, call wp_enqueue_media(). |
1185 |
// Both rely on numerous settings, styles, and templates to operate correctly. |
|
16 | 1186 |
$scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'clipboard' ), false, 1 ); |
1187 |
$scripts->set_translations( 'media-views' ); |
|
1188 |
||
0 | 1189 |
$scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); |
16 | 1190 |
$scripts->set_translations( 'media-editor' ); |
5 | 1191 |
$scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1192 |
$scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1193 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1194 |
$scripts->add( 'wp-api', "/wp-includes/js/wp-api$suffix.js", array( 'jquery', 'backbone', 'underscore', 'wp-api-request' ), false, 1 ); |
0 | 1195 |
|
1196 |
if ( is_admin() ) { |
|
5 | 1197 |
$scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 ); |
16 | 1198 |
$scripts->set_translations( 'admin-tags' ); |
0 | 1199 |
|
9 | 1200 |
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array( 'wp-lists', 'quicktags', 'jquery-query' ), false, 1 ); |
16 | 1201 |
$scripts->set_translations( 'admin-comments' ); |
9 | 1202 |
did_action( 'init' ) && $scripts->localize( |
1203 |
'admin-comments', |
|
16 | 1204 |
'adminCommentsSettings', |
9 | 1205 |
array( |
1206 |
'hotkeys_highlight_first' => isset( $_GET['hotkeys_highlight_first'] ), |
|
1207 |
'hotkeys_highlight_last' => isset( $_GET['hotkeys_highlight_last'] ), |
|
1208 |
) |
|
1209 |
); |
|
0 | 1210 |
|
9 | 1211 |
$scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array( 'jquery' ), false, 1 ); |
0 | 1212 |
|
16 | 1213 |
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array( 'jquery-ui-sortable', 'wp-a11y' ), false, 1 ); |
1214 |
$scripts->set_translations( 'postbox' ); |
|
5 | 1215 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1216 |
$scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'tags-suggest' ), false, 1 ); |
16 | 1217 |
$scripts->set_translations( 'tags-box' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1218 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
$scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'jquery-ui-autocomplete', 'wp-a11y' ), false, 1 ); |
16 | 1220 |
$scripts->set_translations( 'tags-suggest' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1221 |
|
16 | 1222 |
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize', 'clipboard' ), false, 1 ); |
1223 |
$scripts->set_translations( 'post' ); |
|
0 | 1224 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
$scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 ); |
5 | 1226 |
|
0 | 1227 |
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 ); |
1228 |
||
16 | 1229 |
$scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ), false, 1 ); |
1230 |
$scripts->set_translations( 'comment' ); |
|
0 | 1231 |
|
1232 |
$scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) ); |
|
1233 |
||
16 | 1234 |
$scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-a11y' ), false, 1 ); |
1235 |
$scripts->set_translations( 'admin-widgets' ); |
|
0 | 1236 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
$scripts->add( 'media-widgets', "/wp-admin/js/widgets/media-widgets$suffix.js", array( 'jquery', 'media-models', 'media-views', 'wp-api-request' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1238 |
$scripts->add_inline_script( 'media-widgets', 'wp.mediaWidgets.init();', 'after' ); |
0 | 1239 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1240 |
$scripts->add( 'media-audio-widget', "/wp-admin/js/widgets/media-audio-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1241 |
$scripts->add( 'media-image-widget', "/wp-admin/js/widgets/media-image-widget$suffix.js", array( 'media-widgets' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
$scripts->add( 'media-gallery-widget', "/wp-admin/js/widgets/media-gallery-widget$suffix.js", array( 'media-widgets' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1243 |
$scripts->add( 'media-video-widget', "/wp-admin/js/widgets/media-video-widget$suffix.js", array( 'media-widgets', 'media-audiovideo', 'wp-api-request' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
$scripts->add( 'text-widgets', "/wp-admin/js/widgets/text-widgets$suffix.js", array( 'jquery', 'backbone', 'editor', 'wp-util', 'wp-a11y' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
$scripts->add( 'custom-html-widgets', "/wp-admin/js/widgets/custom-html-widgets$suffix.js", array( 'jquery', 'backbone', 'wp-util', 'jquery-ui-core', 'wp-a11y' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1246 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1247 |
$scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y', 'customize-base' ), false, 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1248 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1249 |
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 ); |
16 | 1250 |
$scripts->set_translations( 'inline-edit-post' ); |
0 | 1251 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1252 |
$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); |
16 | 1253 |
$scripts->set_translations( 'inline-edit-tax' ); |
0 | 1254 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 ); |
16 | 1256 |
$scripts->set_translations( 'plugin-install' ); |
9 | 1257 |
|
16 | 1258 |
$scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y' ), false, 1 ); |
9 | 1259 |
$scripts->set_translations( 'site-health' ); |
0 | 1260 |
|
16 | 1261 |
$scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); |
1262 |
$scripts->set_translations( 'privacy-tools' ); |
|
1263 |
||
1264 |
$scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'common', 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 ); |
|
1265 |
$scripts->set_translations( 'updates' ); |
|
9 | 1266 |
did_action( 'init' ) && $scripts->localize( |
1267 |
'updates', |
|
1268 |
'_wpUpdatesSettings', |
|
1269 |
array( |
|
1270 |
'ajax_nonce' => wp_create_nonce( 'updates' ), |
|
1271 |
) |
|
1272 |
); |
|
5 | 1273 |
|
9 | 1274 |
$scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array( 'jquery' ), '1.2' ); |
0 | 1275 |
|
5 | 1276 |
$scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 ); |
0 | 1277 |
$scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 ); |
16 | 1278 |
$scripts->set_translations( 'wp-color-picker' ); |
0 | 1279 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
$scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 ); |
0 | 1281 |
|
1282 |
$scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); |
|
1283 |
||
5 | 1284 |
$scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 ); |
1285 |
$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 ); |
|
16 | 1286 |
$scripts->set_translations( 'media' ); |
0 | 1287 |
|
16 | 1288 |
$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 ); |
1289 |
$scripts->set_translations( 'image-edit' ); |
|
0 | 1290 |
|
1291 |
$scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 ); |
|
16 | 1292 |
$scripts->set_translations( 'set-post-thumbnail' ); |
0 | 1293 |
|
9 | 1294 |
/* |
1295 |
* Navigation Menus: Adding underscore as a dependency to utilize _.debounce |
|
1296 |
* see https://core.trac.wordpress.org/ticket/42321 |
|
1297 |
*/ |
|
1298 |
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2', 'underscore' ) ); |
|
16 | 1299 |
$scripts->set_translations( 'nav-menu' ); |
0 | 1300 |
|
9 | 1301 |
$scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 ); |
0 | 1302 |
$scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 ); |
9 | 1303 |
$scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array( 'jquery' ), false, 1 ); |
5 | 1304 |
|
1305 |
$scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 ); |
|
0 | 1306 |
} |
1307 |
} |
|
1308 |
||
1309 |
/** |
|
1310 |
* Assign default styles to $styles object. |
|
1311 |
* |
|
1312 |
* Nothing is returned, because the $styles parameter is passed by reference. |
|
1313 |
* Meaning that whatever object is passed will be updated without having to |
|
1314 |
* reassign the variable that was passed back to the same value. This saves |
|
1315 |
* memory. |
|
1316 |
* |
|
1317 |
* Adding default styles is not the only task, it also assigns the base_url |
|
1318 |
* property, the default version, and text direction for the object. |
|
1319 |
* |
|
1320 |
* @since 2.6.0 |
|
1321 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1322 |
* @param WP_Styles $styles |
0 | 1323 |
*/ |
16 | 1324 |
function wp_default_styles( $styles ) { |
1325 |
// Include an unmodified $wp_version. |
|
1326 |
require ABSPATH . WPINC . '/version.php'; |
|
0 | 1327 |
|
9 | 1328 |
if ( ! defined( 'SCRIPT_DEBUG' ) ) { |
0 | 1329 |
define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); |
9 | 1330 |
} |
0 | 1331 |
|
16 | 1332 |
$guessurl = site_url(); |
1333 |
||
1334 |
if ( ! $guessurl ) { |
|
9 | 1335 |
$guessurl = wp_guess_url(); |
1336 |
} |
|
1337 |
||
1338 |
$styles->base_url = $guessurl; |
|
1339 |
$styles->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : ''; |
|
0 | 1340 |
$styles->default_version = get_bloginfo( 'version' ); |
9 | 1341 |
$styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr'; |
1342 |
$styles->default_dirs = array( '/wp-admin/', '/wp-includes/css/' ); |
|
0 | 1343 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1344 |
// Open Sans is no longer used by core, but may be relied upon by themes and plugins. |
5 | 1345 |
$open_sans_font_url = ''; |
1346 |
||
16 | 1347 |
/* |
1348 |
* translators: If there are characters in your language that are not supported |
|
5 | 1349 |
* by Open Sans, translate this to 'off'. Do not translate into your own language. |
1350 |
*/ |
|
1351 |
if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) { |
|
1352 |
$subsets = 'latin,latin-ext'; |
|
1353 |
||
16 | 1354 |
/* |
1355 |
* translators: To add an additional Open Sans character subset specific to your language, |
|
5 | 1356 |
* translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. |
1357 |
*/ |
|
1358 |
$subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' ); |
|
1359 |
||
16 | 1360 |
if ( 'cyrillic' === $subset ) { |
5 | 1361 |
$subsets .= ',cyrillic,cyrillic-ext'; |
16 | 1362 |
} elseif ( 'greek' === $subset ) { |
5 | 1363 |
$subsets .= ',greek,greek-ext'; |
16 | 1364 |
} elseif ( 'vietnamese' === $subset ) { |
5 | 1365 |
$subsets .= ',vietnamese'; |
1366 |
} |
|
1367 |
||
16 | 1368 |
// Hotlink Open Sans, for now. |
1369 |
$open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets&display=fallback"; |
|
5 | 1370 |
} |
1371 |
||
1372 |
// Register a stylesheet for the selected admin color scheme. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1373 |
$styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) ); |
5 | 1374 |
|
0 | 1375 |
$suffix = SCRIPT_DEBUG ? '' : '.min'; |
1376 |
||
16 | 1377 |
// Admin CSS. |
9 | 1378 |
$styles->add( 'common', "/wp-admin/css/common$suffix.css" ); |
1379 |
$styles->add( 'forms', "/wp-admin/css/forms$suffix.css" ); |
|
1380 |
$styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" ); |
|
1381 |
$styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css" ); |
|
1382 |
$styles->add( 'list-tables', "/wp-admin/css/list-tables$suffix.css" ); |
|
1383 |
$styles->add( 'edit', "/wp-admin/css/edit$suffix.css" ); |
|
1384 |
$styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" ); |
|
1385 |
$styles->add( 'media', "/wp-admin/css/media$suffix.css" ); |
|
1386 |
$styles->add( 'themes', "/wp-admin/css/themes$suffix.css" ); |
|
1387 |
$styles->add( 'about', "/wp-admin/css/about$suffix.css" ); |
|
1388 |
$styles->add( 'nav-menus', "/wp-admin/css/nav-menus$suffix.css" ); |
|
1389 |
$styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array( 'wp-pointer' ) ); |
|
1390 |
$styles->add( 'site-icon', "/wp-admin/css/site-icon$suffix.css" ); |
|
1391 |
$styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" ); |
|
1392 |
$styles->add( 'code-editor', "/wp-admin/css/code-editor$suffix.css", array( 'wp-codemirror' ) ); |
|
1393 |
$styles->add( 'site-health', "/wp-admin/css/site-health$suffix.css" ); |
|
0 | 1394 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1395 |
$styles->add( 'wp-admin', false, array( 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
|
9 | 1397 |
$styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) ); |
1398 |
$styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) ); |
|
1399 |
$styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" ); |
|
16 | 1400 |
$styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'imgareaselect' ) ); |
9 | 1401 |
$styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1402 |
$styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1403 |
|
16 | 1404 |
// Common dependencies. |
9 | 1405 |
$styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); |
5 | 1406 |
$styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" ); |
0 | 1407 |
|
16 | 1408 |
// Includes CSS. |
9 | 1409 |
$styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'dashicons' ) ); |
1410 |
$styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) ); |
|
1411 |
$styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) ); |
|
1412 |
$styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) ); |
|
1413 |
$styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) ); |
|
1414 |
$styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1415 |
$styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1416 |
$styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' ); |
0 | 1417 |
|
16 | 1418 |
// External libraries and friends. |
9 | 1419 |
$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); |
5 | 1420 |
$styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) ); |
16 | 1421 |
$styles->add( 'mediaelement', '/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css', array(), '4.2.13-9993131' ); |
9 | 1422 |
$styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) ); |
1423 |
$styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) ); |
|
1424 |
$styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' ); |
|
5 | 1425 |
|
16 | 1426 |
// Deprecated CSS. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1427 |
$styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" ); |
9 | 1428 |
$styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' ); |
1429 |
$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.12' ); |
|
5 | 1430 |
$styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle. |
16 | 1431 |
$styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6. |
0 | 1432 |
|
16 | 1433 |
// Packages styles. |
9 | 1434 |
$fonts_url = ''; |
1435 |
||
1436 |
/* |
|
16 | 1437 |
* translators: Use this to specify the proper Google Font name and variants |
9 | 1438 |
* to load that is supported by your language. Do not translate. |
1439 |
* Set to 'off' to disable loading. |
|
1440 |
*/ |
|
1441 |
$font_family = _x( 'Noto Serif:400,400i,700,700i', 'Google Font Name and Variants' ); |
|
1442 |
if ( 'off' !== $font_family ) { |
|
1443 |
$fonts_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $font_family ); |
|
1444 |
} |
|
1445 |
$styles->add( 'wp-editor-font', $fonts_url ); |
|
1446 |
||
1447 |
$styles->add( 'wp-block-library-theme', "/wp-includes/css/dist/block-library/theme$suffix.css" ); |
|
1448 |
||
1449 |
$styles->add( |
|
1450 |
'wp-edit-blocks', |
|
1451 |
"/wp-includes/css/dist/block-library/editor$suffix.css", |
|
1452 |
array( |
|
1453 |
'wp-components', |
|
1454 |
'wp-editor', |
|
1455 |
'wp-block-library', |
|
1456 |
// Always include visual styles so the editor never appears broken. |
|
1457 |
'wp-block-library-theme', |
|
1458 |
) |
|
1459 |
); |
|
1460 |
||
1461 |
$package_styles = array( |
|
1462 |
'block-editor' => array( |
|
1463 |
'wp-components', |
|
1464 |
'wp-editor-font', |
|
1465 |
), |
|
1466 |
'block-library' => array(), |
|
16 | 1467 |
'block-directory' => array(), |
9 | 1468 |
'components' => array(), |
1469 |
'edit-post' => array( |
|
1470 |
'wp-components', |
|
1471 |
'wp-block-editor', |
|
1472 |
'wp-editor', |
|
1473 |
'wp-edit-blocks', |
|
1474 |
'wp-block-library', |
|
1475 |
'wp-nux', |
|
1476 |
), |
|
1477 |
'editor' => array( |
|
1478 |
'wp-components', |
|
1479 |
'wp-block-editor', |
|
1480 |
'wp-nux', |
|
1481 |
), |
|
1482 |
'format-library' => array(), |
|
1483 |
'list-reusable-blocks' => array( 'wp-components' ), |
|
1484 |
'nux' => array( 'wp-components' ), |
|
1485 |
); |
|
1486 |
||
1487 |
foreach ( $package_styles as $package => $dependencies ) { |
|
1488 |
$handle = 'wp-' . $package; |
|
1489 |
$path = "/wp-includes/css/dist/$package/style$suffix.css"; |
|
1490 |
||
1491 |
$styles->add( $handle, $path, $dependencies ); |
|
1492 |
} |
|
1493 |
||
16 | 1494 |
// RTL CSS. |
5 | 1495 |
$rtl_styles = array( |
16 | 1496 |
// Admin CSS. |
9 | 1497 |
'common', |
1498 |
'forms', |
|
1499 |
'admin-menu', |
|
1500 |
'dashboard', |
|
1501 |
'list-tables', |
|
1502 |
'edit', |
|
1503 |
'revisions', |
|
1504 |
'media', |
|
1505 |
'themes', |
|
1506 |
'about', |
|
1507 |
'nav-menus', |
|
1508 |
'widgets', |
|
1509 |
'site-icon', |
|
1510 |
'l10n', |
|
1511 |
'install', |
|
1512 |
'wp-color-picker', |
|
1513 |
'customize-controls', |
|
1514 |
'customize-widgets', |
|
1515 |
'customize-nav-menus', |
|
1516 |
'customize-preview', |
|
1517 |
'login', |
|
1518 |
'site-health', |
|
16 | 1519 |
// Includes CSS. |
9 | 1520 |
'buttons', |
1521 |
'admin-bar', |
|
1522 |
'wp-auth-check', |
|
1523 |
'editor-buttons', |
|
1524 |
'media-views', |
|
1525 |
'wp-pointer', |
|
5 | 1526 |
'wp-jquery-ui-dialog', |
16 | 1527 |
// Package styles. |
9 | 1528 |
'wp-block-library-theme', |
1529 |
'wp-edit-blocks', |
|
1530 |
'wp-block-editor', |
|
1531 |
'wp-block-library', |
|
16 | 1532 |
'wp-block-directory', |
9 | 1533 |
'wp-components', |
1534 |
'wp-edit-post', |
|
1535 |
'wp-editor', |
|
1536 |
'wp-format-library', |
|
1537 |
'wp-list-reusable-blocks', |
|
1538 |
'wp-nux', |
|
16 | 1539 |
// Deprecated CSS. |
9 | 1540 |
'deprecated-media', |
1541 |
'farbtastic', |
|
5 | 1542 |
); |
0 | 1543 |
|
1544 |
foreach ( $rtl_styles as $rtl_style ) { |
|
5 | 1545 |
$styles->add_data( $rtl_style, 'rtl', 'replace' ); |
1546 |
if ( $suffix ) { |
|
0 | 1547 |
$styles->add_data( $rtl_style, 'suffix', $suffix ); |
5 | 1548 |
} |
0 | 1549 |
} |
1550 |
} |
|
1551 |
||
1552 |
/** |
|
1553 |
* Reorder JavaScript scripts array to place prototype before jQuery. |
|
1554 |
* |
|
1555 |
* @since 2.3.1 |
|
1556 |
* |
|
1557 |
* @param array $js_array JavaScript scripts array |
|
1558 |
* @return array Reordered array, if needed. |
|
1559 |
*/ |
|
1560 |
function wp_prototype_before_jquery( $js_array ) { |
|
16 | 1561 |
$prototype = array_search( 'prototype', $js_array, true ); |
1562 |
||
1563 |
if ( false === $prototype ) { |
|
0 | 1564 |
return $js_array; |
9 | 1565 |
} |
0 | 1566 |
|
16 | 1567 |
$jquery = array_search( 'jquery', $js_array, true ); |
1568 |
||
1569 |
if ( false === $jquery ) { |
|
0 | 1570 |
return $js_array; |
9 | 1571 |
} |
0 | 1572 |
|
9 | 1573 |
if ( $prototype < $jquery ) { |
0 | 1574 |
return $js_array; |
9 | 1575 |
} |
0 | 1576 |
|
9 | 1577 |
unset( $js_array[ $prototype ] ); |
0 | 1578 |
|
1579 |
array_splice( $js_array, $jquery, 0, 'prototype' ); |
|
1580 |
||
1581 |
return $js_array; |
|
1582 |
} |
|
1583 |
||
1584 |
/** |
|
1585 |
* Load localized data on print rather than initialization. |
|
1586 |
* |
|
1587 |
* These localizations require information that may not be loaded even by init. |
|
1588 |
* |
|
1589 |
* @since 2.5.0 |
|
1590 |
*/ |
|
1591 |
function wp_just_in_time_script_localization() { |
|
1592 |
||
9 | 1593 |
wp_localize_script( |
1594 |
'autosave', |
|
1595 |
'autosaveL10n', |
|
1596 |
array( |
|
1597 |
'autosaveInterval' => AUTOSAVE_INTERVAL, |
|
1598 |
'blog_id' => get_current_blog_id(), |
|
1599 |
) |
|
1600 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1601 |
|
9 | 1602 |
wp_localize_script( |
1603 |
'mce-view', |
|
1604 |
'mceViewL10n', |
|
1605 |
array( |
|
1606 |
'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(), |
|
1607 |
) |
|
1608 |
); |
|
1609 |
||
1610 |
wp_localize_script( |
|
1611 |
'word-count', |
|
1612 |
'wordCountL10n', |
|
1613 |
array( |
|
1614 |
/* |
|
1615 |
* translators: If your word count is based on single characters (e.g. East Asian characters), |
|
1616 |
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. |
|
1617 |
* Do not translate into your own language. |
|
1618 |
*/ |
|
1619 |
'type' => _x( 'words', 'Word count type. Do not translate!' ), |
|
1620 |
'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(), |
|
1621 |
) |
|
1622 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1623 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1624 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1625 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1626 |
* Localizes the jQuery UI datepicker. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1627 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1628 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1629 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1630 |
* @link https://api.jqueryui.com/datepicker/#options |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1631 |
* |
16 | 1632 |
* @global WP_Locale $wp_locale WordPress date and time locale object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1633 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1634 |
function wp_localize_jquery_ui_datepicker() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1635 |
global $wp_locale; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1636 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1637 |
if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1638 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1639 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1640 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1641 |
// Convert the PHP date format into jQuery UI's format. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1642 |
$datepicker_date_format = str_replace( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1643 |
array( |
9 | 1644 |
'd', |
1645 |
'j', |
|
1646 |
'l', |
|
1647 |
'z', // Day. |
|
1648 |
'F', |
|
1649 |
'M', |
|
1650 |
'n', |
|
1651 |
'm', // Month. |
|
1652 |
'Y', |
|
16 | 1653 |
'y', // Year. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1654 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1655 |
array( |
9 | 1656 |
'dd', |
1657 |
'd', |
|
1658 |
'DD', |
|
1659 |
'o', |
|
1660 |
'MM', |
|
1661 |
'M', |
|
1662 |
'm', |
|
1663 |
'mm', |
|
1664 |
'yy', |
|
1665 |
'y', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1666 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1667 |
get_option( 'date_format' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1668 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1669 |
|
9 | 1670 |
$datepicker_defaults = wp_json_encode( |
1671 |
array( |
|
1672 |
'closeText' => __( 'Close' ), |
|
1673 |
'currentText' => __( 'Today' ), |
|
1674 |
'monthNames' => array_values( $wp_locale->month ), |
|
1675 |
'monthNamesShort' => array_values( $wp_locale->month_abbrev ), |
|
1676 |
'nextText' => __( 'Next' ), |
|
1677 |
'prevText' => __( 'Previous' ), |
|
1678 |
'dayNames' => array_values( $wp_locale->weekday ), |
|
1679 |
'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), |
|
1680 |
'dayNamesMin' => array_values( $wp_locale->weekday_initial ), |
|
1681 |
'dateFormat' => $datepicker_date_format, |
|
1682 |
'firstDay' => absint( get_option( 'start_of_week' ) ), |
|
1683 |
'isRTL' => $wp_locale->is_rtl(), |
|
1684 |
) |
|
1685 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1686 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1687 |
wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1688 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1689 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1690 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1691 |
* Localizes community events data that needs to be passed to dashboard.js. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1692 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1693 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1694 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1695 |
function wp_localize_community_events() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1696 |
if ( ! wp_script_is( 'dashboard' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1697 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1698 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1699 |
|
16 | 1700 |
require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1701 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1702 |
$user_id = get_current_user_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1703 |
$saved_location = get_user_option( 'community-events-location', $user_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1704 |
$saved_ip_address = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1705 |
$current_ip_address = WP_Community_Events::get_unsafe_client_ip(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1706 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1707 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1708 |
* If the user's location is based on their IP address, then update their |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1709 |
* location when their IP address changes. This allows them to see events |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1710 |
* in their current city when travelling. Otherwise, they would always be |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1711 |
* shown events in the city where they were when they first loaded the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1712 |
* Dashboard, which could have been months or years ago. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1713 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1714 |
if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1715 |
$saved_location['ip'] = $current_ip_address; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1716 |
update_user_option( $user_id, 'community-events-location', $saved_location, true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1717 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1718 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1719 |
$events_client = new WP_Community_Events( $user_id, $saved_location ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1720 |
|
9 | 1721 |
wp_localize_script( |
1722 |
'dashboard', |
|
1723 |
'communityEventsData', |
|
1724 |
array( |
|
1725 |
'nonce' => wp_create_nonce( 'community_events' ), |
|
1726 |
'cache' => $events_client->get_cached_events(), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1727 |
|
9 | 1728 |
'l10n' => array( |
1729 |
'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ), |
|
1730 |
'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ), |
|
1731 |
'attend_event_near_generic' => __( 'Attend an upcoming event near you.' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1732 |
|
9 | 1733 |
/* |
1734 |
* These specific examples were chosen to highlight the fact that a |
|
1735 |
* state is not needed, even for cities whose name is not unique. |
|
1736 |
* It would be too cumbersome to include that in the instructions |
|
1737 |
* to the user, so it's left as an implication. |
|
1738 |
*/ |
|
16 | 1739 |
/* |
1740 |
* translators: %s is the name of the city we couldn't locate. |
|
9 | 1741 |
* Replace the examples with cities related to your locale. Test that |
1742 |
* they match the expected location and have upcoming events before |
|
1743 |
* including them. If no cities related to your locale have events, |
|
1744 |
* then use cities related to your locale that would be recognizable |
|
1745 |
* to most users. Use only the city name itself, without any region |
|
1746 |
* or country. Use the endonym (native locale name) instead of the |
|
1747 |
* English name if possible. |
|
1748 |
*/ |
|
1749 |
'could_not_locate_city' => __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1750 |
|
9 | 1751 |
// This one is only used with wp.a11y.speak(), so it can/should be more brief. |
16 | 1752 |
/* translators: %s: The name of a city. */ |
9 | 1753 |
'city_updated' => __( 'City updated. Listing events near %s.' ), |
1754 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1755 |
) |
9 | 1756 |
); |
0 | 1757 |
} |
1758 |
||
1759 |
/** |
|
1760 |
* Administration Screen CSS for changing the styles. |
|
1761 |
* |
|
1762 |
* If installing the 'wp-admin/' directory will be replaced with './'. |
|
1763 |
* |
|
1764 |
* The $_wp_admin_css_colors global manages the Administration Screens CSS |
|
1765 |
* stylesheet that is loaded. The option that is set is 'admin_color' and is the |
|
1766 |
* color and key for the array. The value for the color key is an object with |
|
1767 |
* a 'url' parameter that has the URL path to the CSS file. |
|
1768 |
* |
|
1769 |
* The query from $src parameter will be appended to the URL that is given from |
|
1770 |
* the $_wp_admin_css_colors array value URL. |
|
1771 |
* |
|
1772 |
* @since 2.6.0 |
|
16 | 1773 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1774 |
* @global array $_wp_admin_css_colors |
0 | 1775 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1776 |
* @param string $src Source URL. |
0 | 1777 |
* @param string $handle Either 'colors' or 'colors-rtl'. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1778 |
* @return string|false URL path to CSS stylesheet for Administration Screens. |
0 | 1779 |
*/ |
1780 |
function wp_style_loader_src( $src, $handle ) { |
|
5 | 1781 |
global $_wp_admin_css_colors; |
1782 |
||
9 | 1783 |
if ( wp_installing() ) { |
0 | 1784 |
return preg_replace( '#^wp-admin/#', './', $src ); |
9 | 1785 |
} |
0 | 1786 |
|
16 | 1787 |
if ( 'colors' === $handle ) { |
9 | 1788 |
$color = get_user_option( 'admin_color' ); |
0 | 1789 |
|
9 | 1790 |
if ( empty( $color ) || ! isset( $_wp_admin_css_colors[ $color ] ) ) { |
0 | 1791 |
$color = 'fresh'; |
9 | 1792 |
} |
0 | 1793 |
|
9 | 1794 |
$color = $_wp_admin_css_colors[ $color ]; |
1795 |
$url = $color->url; |
|
0 | 1796 |
|
5 | 1797 |
if ( ! $url ) { |
1798 |
return false; |
|
1799 |
} |
|
0 | 1800 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1801 |
$parsed = parse_url( $src ); |
9 | 1802 |
if ( isset( $parsed['query'] ) && $parsed['query'] ) { |
0 | 1803 |
wp_parse_str( $parsed['query'], $qv ); |
1804 |
$url = add_query_arg( $qv, $url ); |
|
1805 |
} |
|
1806 |
||
1807 |
return $url; |
|
1808 |
} |
|
1809 |
||
1810 |
return $src; |
|
1811 |
} |
|
1812 |
||
1813 |
/** |
|
1814 |
* Prints the script queue in the HTML head on admin pages. |
|
1815 |
* |
|
1816 |
* Postpones the scripts that were queued for the footer. |
|
1817 |
* print_footer_scripts() is called in the footer to print these scripts. |
|
1818 |
* |
|
5 | 1819 |
* @since 2.8.0 |
1820 |
* |
|
0 | 1821 |
* @see wp_print_scripts() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1822 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1823 |
* @global bool $concatenate_scripts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1824 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1825 |
* @return array |
0 | 1826 |
*/ |
1827 |
function print_head_scripts() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1828 |
global $concatenate_scripts; |
0 | 1829 |
|
9 | 1830 |
if ( ! did_action( 'wp_print_scripts' ) ) { |
5 | 1831 |
/** This action is documented in wp-includes/functions.wp-scripts.php */ |
1832 |
do_action( 'wp_print_scripts' ); |
|
1833 |
} |
|
0 | 1834 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1835 |
$wp_scripts = wp_scripts(); |
0 | 1836 |
|
1837 |
script_concat_settings(); |
|
1838 |
$wp_scripts->do_concat = $concatenate_scripts; |
|
1839 |
$wp_scripts->do_head_items(); |
|
1840 |
||
5 | 1841 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1842 |
* Filters whether to print the head scripts. |
5 | 1843 |
* |
1844 |
* @since 2.8.0 |
|
1845 |
* |
|
1846 |
* @param bool $print Whether to print the head scripts. Default true. |
|
1847 |
*/ |
|
1848 |
if ( apply_filters( 'print_head_scripts', true ) ) { |
|
0 | 1849 |
_print_scripts(); |
5 | 1850 |
} |
0 | 1851 |
|
1852 |
$wp_scripts->reset(); |
|
1853 |
return $wp_scripts->done; |
|
1854 |
} |
|
1855 |
||
1856 |
/** |
|
1857 |
* Prints the scripts that were queued for the footer or too late for the HTML head. |
|
1858 |
* |
|
5 | 1859 |
* @since 2.8.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1860 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1861 |
* @global WP_Scripts $wp_scripts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1862 |
* @global bool $concatenate_scripts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1863 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1864 |
* @return array |
0 | 1865 |
*/ |
1866 |
function print_footer_scripts() { |
|
1867 |
global $wp_scripts, $concatenate_scripts; |
|
1868 |
||
5 | 1869 |
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { |
0 | 1870 |
return array(); // No need to run if not instantiated. |
5 | 1871 |
} |
0 | 1872 |
script_concat_settings(); |
1873 |
$wp_scripts->do_concat = $concatenate_scripts; |
|
1874 |
$wp_scripts->do_footer_items(); |
|
1875 |
||
5 | 1876 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1877 |
* Filters whether to print the footer scripts. |
5 | 1878 |
* |
1879 |
* @since 2.8.0 |
|
1880 |
* |
|
1881 |
* @param bool $print Whether to print the footer scripts. Default true. |
|
1882 |
*/ |
|
1883 |
if ( apply_filters( 'print_footer_scripts', true ) ) { |
|
0 | 1884 |
_print_scripts(); |
5 | 1885 |
} |
0 | 1886 |
|
1887 |
$wp_scripts->reset(); |
|
1888 |
return $wp_scripts->done; |
|
1889 |
} |
|
1890 |
||
1891 |
/** |
|
5 | 1892 |
* Print scripts (internal use only) |
1893 |
* |
|
1894 |
* @ignore |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1895 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1896 |
* @global WP_Scripts $wp_scripts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1897 |
* @global bool $compress_scripts |
0 | 1898 |
*/ |
1899 |
function _print_scripts() { |
|
1900 |
global $wp_scripts, $compress_scripts; |
|
1901 |
||
1902 |
$zip = $compress_scripts ? 1 : 0; |
|
9 | 1903 |
if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) { |
0 | 1904 |
$zip = 'gzip'; |
9 | 1905 |
} |
0 | 1906 |
|
16 | 1907 |
$concat = trim( $wp_scripts->concat, ', ' ); |
1908 |
$type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'"; |
|
0 | 1909 |
|
16 | 1910 |
if ( $concat ) { |
9 | 1911 |
if ( ! empty( $wp_scripts->print_code ) ) { |
16 | 1912 |
echo "\n<script{$type_attr}>\n"; |
1913 |
echo "/* <![CDATA[ */\n"; // Not needed in HTML 5. |
|
0 | 1914 |
echo $wp_scripts->print_code; |
1915 |
echo "/* ]]> */\n"; |
|
1916 |
echo "</script>\n"; |
|
1917 |
} |
|
1918 |
||
16 | 1919 |
$concat = str_split( $concat, 128 ); |
1920 |
$concatenated = ''; |
|
0 | 1921 |
|
16 | 1922 |
foreach ( $concat as $key => $chunk ) { |
1923 |
$concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}"; |
|
1924 |
} |
|
1925 |
||
1926 |
$src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version; |
|
1927 |
echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n"; |
|
0 | 1928 |
} |
1929 |
||
9 | 1930 |
if ( ! empty( $wp_scripts->print_html ) ) { |
0 | 1931 |
echo $wp_scripts->print_html; |
9 | 1932 |
} |
0 | 1933 |
} |
1934 |
||
1935 |
/** |
|
1936 |
* Prints the script queue in the HTML head on the front end. |
|
1937 |
* |
|
1938 |
* Postpones the scripts that were queued for the footer. |
|
1939 |
* wp_print_footer_scripts() is called in the footer to print these scripts. |
|
1940 |
* |
|
5 | 1941 |
* @since 2.8.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1942 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1943 |
* @global WP_Scripts $wp_scripts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1944 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1945 |
* @return array |
0 | 1946 |
*/ |
1947 |
function wp_print_head_scripts() { |
|
9 | 1948 |
if ( ! did_action( 'wp_print_scripts' ) ) { |
5 | 1949 |
/** This action is documented in wp-includes/functions.wp-scripts.php */ |
1950 |
do_action( 'wp_print_scripts' ); |
|
1951 |
} |
|
0 | 1952 |
|
1953 |
global $wp_scripts; |
|
1954 |
||
5 | 1955 |
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { |
16 | 1956 |
return array(); // No need to run if nothing is queued. |
5 | 1957 |
} |
0 | 1958 |
return print_head_scripts(); |
1959 |
} |
|
1960 |
||
1961 |
/** |
|
1962 |
* Private, for use in *_footer_scripts hooks |
|
1963 |
* |
|
1964 |
* @since 3.3.0 |
|
1965 |
*/ |
|
1966 |
function _wp_footer_scripts() { |
|
1967 |
print_late_styles(); |
|
1968 |
print_footer_scripts(); |
|
1969 |
} |
|
1970 |
||
1971 |
/** |
|
1972 |
* Hooks to print the scripts and styles in the footer. |
|
1973 |
* |
|
5 | 1974 |
* @since 2.8.0 |
0 | 1975 |
*/ |
1976 |
function wp_print_footer_scripts() { |
|
5 | 1977 |
/** |
1978 |
* Fires when footer scripts are printed. |
|
1979 |
* |
|
1980 |
* @since 2.8.0 |
|
1981 |
*/ |
|
1982 |
do_action( 'wp_print_footer_scripts' ); |
|
0 | 1983 |
} |
1984 |
||
1985 |
/** |
|
16 | 1986 |
* Wrapper for do_action( 'wp_enqueue_scripts' ). |
0 | 1987 |
* |
1988 |
* Allows plugins to queue scripts for the front end using wp_enqueue_script(). |
|
1989 |
* Runs first in wp_head() where all is_home(), is_page(), etc. functions are available. |
|
1990 |
* |
|
5 | 1991 |
* @since 2.8.0 |
0 | 1992 |
*/ |
1993 |
function wp_enqueue_scripts() { |
|
5 | 1994 |
/** |
1995 |
* Fires when scripts and styles are enqueued. |
|
1996 |
* |
|
1997 |
* @since 2.8.0 |
|
1998 |
*/ |
|
1999 |
do_action( 'wp_enqueue_scripts' ); |
|
0 | 2000 |
} |
2001 |
||
2002 |
/** |
|
2003 |
* Prints the styles queue in the HTML head on admin pages. |
|
2004 |
* |
|
5 | 2005 |
* @since 2.8.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2006 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2007 |
* @global bool $concatenate_scripts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2008 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2009 |
* @return array |
0 | 2010 |
*/ |
2011 |
function print_admin_styles() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2012 |
global $concatenate_scripts; |
0 | 2013 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2014 |
$wp_styles = wp_styles(); |
0 | 2015 |
|
2016 |
script_concat_settings(); |
|
2017 |
$wp_styles->do_concat = $concatenate_scripts; |
|
9 | 2018 |
$wp_styles->do_items( false ); |
0 | 2019 |
|
5 | 2020 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2021 |
* Filters whether to print the admin styles. |
5 | 2022 |
* |
2023 |
* @since 2.8.0 |
|
2024 |
* |
|
2025 |
* @param bool $print Whether to print the admin styles. Default true. |
|
2026 |
*/ |
|
2027 |
if ( apply_filters( 'print_admin_styles', true ) ) { |
|
0 | 2028 |
_print_styles(); |
5 | 2029 |
} |
0 | 2030 |
|
2031 |
$wp_styles->reset(); |
|
2032 |
return $wp_styles->done; |
|
2033 |
} |
|
2034 |
||
2035 |
/** |
|
2036 |
* Prints the styles that were queued too late for the HTML head. |
|
2037 |
* |
|
2038 |
* @since 3.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2039 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2040 |
* @global WP_Styles $wp_styles |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2041 |
* @global bool $concatenate_scripts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2042 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2043 |
* @return array|void |
0 | 2044 |
*/ |
2045 |
function print_late_styles() { |
|
2046 |
global $wp_styles, $concatenate_scripts; |
|
2047 |
||
5 | 2048 |
if ( ! ( $wp_styles instanceof WP_Styles ) ) { |
0 | 2049 |
return; |
5 | 2050 |
} |
0 | 2051 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2052 |
script_concat_settings(); |
0 | 2053 |
$wp_styles->do_concat = $concatenate_scripts; |
2054 |
$wp_styles->do_footer_items(); |
|
2055 |
||
5 | 2056 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2057 |
* Filters whether to print the styles queued too late for the HTML head. |
5 | 2058 |
* |
2059 |
* @since 3.3.0 |
|
2060 |
* |
|
2061 |
* @param bool $print Whether to print the 'late' styles. Default true. |
|
2062 |
*/ |
|
2063 |
if ( apply_filters( 'print_late_styles', true ) ) { |
|
0 | 2064 |
_print_styles(); |
5 | 2065 |
} |
0 | 2066 |
|
2067 |
$wp_styles->reset(); |
|
2068 |
return $wp_styles->done; |
|
2069 |
} |
|
2070 |
||
2071 |
/** |
|
5 | 2072 |
* Print styles (internal use only) |
2073 |
* |
|
2074 |
* @ignore |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2075 |
* @since 3.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2076 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2077 |
* @global bool $compress_css |
0 | 2078 |
*/ |
2079 |
function _print_styles() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2080 |
global $compress_css; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2081 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2082 |
$wp_styles = wp_styles(); |
0 | 2083 |
|
2084 |
$zip = $compress_css ? 1 : 0; |
|
9 | 2085 |
if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) { |
0 | 2086 |
$zip = 'gzip'; |
9 | 2087 |
} |
0 | 2088 |
|
16 | 2089 |
$concat = trim( $wp_styles->concat, ', ' ); |
2090 |
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; |
|
2091 |
||
2092 |
if ( $concat ) { |
|
0 | 2093 |
$dir = $wp_styles->text_direction; |
2094 |
$ver = $wp_styles->default_version; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2095 |
|
16 | 2096 |
$concat = str_split( $concat, 128 ); |
2097 |
$concatenated = ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2098 |
|
16 | 2099 |
foreach ( $concat as $key => $chunk ) { |
2100 |
$concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}"; |
|
2101 |
} |
|
2102 |
||
2103 |
$href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver; |
|
2104 |
echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n"; |
|
0 | 2105 |
|
9 | 2106 |
if ( ! empty( $wp_styles->print_code ) ) { |
16 | 2107 |
echo "<style{$type_attr}>\n"; |
0 | 2108 |
echo $wp_styles->print_code; |
2109 |
echo "\n</style>\n"; |
|
2110 |
} |
|
2111 |
} |
|
2112 |
||
9 | 2113 |
if ( ! empty( $wp_styles->print_html ) ) { |
0 | 2114 |
echo $wp_styles->print_html; |
9 | 2115 |
} |
0 | 2116 |
} |
2117 |
||
2118 |
/** |
|
2119 |
* Determine the concatenation and compression settings for scripts and styles. |
|
2120 |
* |
|
5 | 2121 |
* @since 2.8.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2122 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2123 |
* @global bool $concatenate_scripts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2124 |
* @global bool $compress_scripts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2125 |
* @global bool $compress_css |
0 | 2126 |
*/ |
2127 |
function script_concat_settings() { |
|
2128 |
global $concatenate_scripts, $compress_scripts, $compress_css; |
|
2129 |
||
16 | 2130 |
$compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ); |
9 | 2131 |
|
2132 |
if ( ! isset( $concatenate_scripts ) ) { |
|
2133 |
$concatenate_scripts = defined( 'CONCATENATE_SCRIPTS' ) ? CONCATENATE_SCRIPTS : true; |
|
2134 |
if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) { |
|
2135 |
$concatenate_scripts = false; |
|
2136 |
} |
|
2137 |
} |
|
2138 |
||
2139 |
if ( ! isset( $compress_scripts ) ) { |
|
2140 |
$compress_scripts = defined( 'COMPRESS_SCRIPTS' ) ? COMPRESS_SCRIPTS : true; |
|
2141 |
if ( $compress_scripts && ( ! get_site_option( 'can_compress_scripts' ) || $compressed_output ) ) { |
|
2142 |
$compress_scripts = false; |
|
2143 |
} |
|
2144 |
} |
|
0 | 2145 |
|
9 | 2146 |
if ( ! isset( $compress_css ) ) { |
2147 |
$compress_css = defined( 'COMPRESS_CSS' ) ? COMPRESS_CSS : true; |
|
2148 |
if ( $compress_css && ( ! get_site_option( 'can_compress_scripts' ) || $compressed_output ) ) { |
|
2149 |
$compress_css = false; |
|
2150 |
} |
|
2151 |
} |
|
2152 |
} |
|
2153 |
||
2154 |
/** |
|
2155 |
* Handles the enqueueing of block scripts and styles that are common to both |
|
2156 |
* the editor and the front-end. |
|
2157 |
* |
|
2158 |
* @since 5.0.0 |
|
2159 |
* |
|
16 | 2160 |
* @global WP_Screen $current_screen WordPress current screen object. |
9 | 2161 |
*/ |
2162 |
function wp_common_block_scripts_and_styles() { |
|
2163 |
global $current_screen; |
|
2164 |
||
2165 |
if ( is_admin() && ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor() ) { |
|
2166 |
return; |
|
2167 |
} |
|
2168 |
||
2169 |
wp_enqueue_style( 'wp-block-library' ); |
|
2170 |
||
2171 |
if ( current_theme_supports( 'wp-block-styles' ) ) { |
|
2172 |
wp_enqueue_style( 'wp-block-library-theme' ); |
|
0 | 2173 |
} |
2174 |
||
9 | 2175 |
/** |
2176 |
* Fires after enqueuing block assets for both editor and front-end. |
|
2177 |
* |
|
2178 |
* Call `add_action` on any hook before 'wp_enqueue_scripts'. |
|
2179 |
* |
|
2180 |
* In the function call you supply, simply use `wp_enqueue_script` and |
|
2181 |
* `wp_enqueue_style` to add your functionality to the Gutenberg editor. |
|
2182 |
* |
|
2183 |
* @since 5.0.0 |
|
2184 |
*/ |
|
16 | 2185 |
do_action( 'enqueue_block_assets' ); |
9 | 2186 |
} |
2187 |
||
2188 |
/** |
|
2189 |
* Enqueues registered block scripts and styles, depending on current rendered |
|
2190 |
* context (only enqueuing editor scripts while in context of the editor). |
|
2191 |
* |
|
2192 |
* @since 5.0.0 |
|
2193 |
* |
|
16 | 2194 |
* @global WP_Screen $current_screen WordPress current screen object. |
9 | 2195 |
*/ |
2196 |
function wp_enqueue_registered_block_scripts_and_styles() { |
|
2197 |
global $current_screen; |
|
0 | 2198 |
|
9 | 2199 |
$is_editor = ( ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor() ); |
2200 |
||
2201 |
$block_registry = WP_Block_Type_Registry::get_instance(); |
|
2202 |
foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) { |
|
2203 |
// Front-end styles. |
|
2204 |
if ( ! empty( $block_type->style ) ) { |
|
2205 |
wp_enqueue_style( $block_type->style ); |
|
2206 |
} |
|
2207 |
||
2208 |
// Front-end script. |
|
2209 |
if ( ! empty( $block_type->script ) ) { |
|
2210 |
wp_enqueue_script( $block_type->script ); |
|
2211 |
} |
|
2212 |
||
2213 |
// Editor styles. |
|
2214 |
if ( $is_editor && ! empty( $block_type->editor_style ) ) { |
|
2215 |
wp_enqueue_style( $block_type->editor_style ); |
|
2216 |
} |
|
2217 |
||
2218 |
// Editor script. |
|
2219 |
if ( $is_editor && ! empty( $block_type->editor_script ) ) { |
|
2220 |
wp_enqueue_script( $block_type->editor_script ); |
|
2221 |
} |
|
0 | 2222 |
} |
2223 |
} |
|
16 | 2224 |
|
2225 |
/** |
|
2226 |
* Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend. |
|
2227 |
* |
|
2228 |
* @since 5.3.0 |
|
2229 |
*/ |
|
2230 |
function enqueue_block_styles_assets() { |
|
2231 |
$block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); |
|
2232 |
||
2233 |
foreach ( $block_styles as $styles ) { |
|
2234 |
foreach ( $styles as $style_properties ) { |
|
2235 |
if ( isset( $style_properties['style_handle'] ) ) { |
|
2236 |
wp_enqueue_style( $style_properties['style_handle'] ); |
|
2237 |
} |
|
2238 |
if ( isset( $style_properties['inline_style'] ) ) { |
|
2239 |
wp_add_inline_style( 'wp-block-library', $style_properties['inline_style'] ); |
|
2240 |
} |
|
2241 |
} |
|
2242 |
} |
|
2243 |
} |
|
2244 |
||
2245 |
/** |
|
2246 |
* Function responsible for enqueuing the assets required for block styles functionality on the editor. |
|
2247 |
* |
|
2248 |
* @since 5.3.0 |
|
2249 |
*/ |
|
2250 |
function enqueue_editor_block_styles_assets() { |
|
2251 |
$block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); |
|
2252 |
||
2253 |
$register_script_lines = array( '( function() {' ); |
|
2254 |
foreach ( $block_styles as $block_name => $styles ) { |
|
2255 |
foreach ( $styles as $style_properties ) { |
|
2256 |
$register_script_lines[] = sprintf( |
|
2257 |
' wp.blocks.registerBlockStyle( \'%s\', %s );', |
|
2258 |
$block_name, |
|
2259 |
wp_json_encode( |
|
2260 |
array( |
|
2261 |
'name' => $style_properties['name'], |
|
2262 |
'label' => $style_properties['label'], |
|
2263 |
) |
|
2264 |
) |
|
2265 |
); |
|
2266 |
} |
|
2267 |
} |
|
2268 |
$register_script_lines[] = '} )();'; |
|
2269 |
$inline_script = implode( "\n", $register_script_lines ); |
|
2270 |
||
2271 |
wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true ); |
|
2272 |
wp_add_inline_script( 'wp-block-styles', $inline_script ); |
|
2273 |
wp_enqueue_script( 'wp-block-styles' ); |
|
2274 |
} |
|
2275 |
||
2276 |
/** |
|
2277 |
* Enqueues the assets required for the block directory within the block editor. |
|
2278 |
* |
|
2279 |
* @since 5.5.0 |
|
2280 |
*/ |
|
2281 |
function wp_enqueue_editor_block_directory_assets() { |
|
2282 |
wp_enqueue_script( 'wp-block-directory' ); |
|
2283 |
wp_enqueue_style( 'wp-block-directory' ); |
|
2284 |
} |