OSDN Git Service

税種別マスターから言語ID削除。
[magic3/magic3.git] / include / wp / wp-includes / script-loader.php
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
19 /** WordPress Dependency Class */
20 require( ABSPATH . WPINC . '/class-wp-dependency.php' );
21
22 /** WordPress Dependencies Class */
23 require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
24
25 /** WordPress Scripts Class */
26 require( ABSPATH . WPINC . '/class.wp-scripts.php' );
27
28 /** WordPress Scripts Functions */
29 require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
30
31 /** WordPress Styles Class */
32 require( ABSPATH . WPINC . '/class.wp-styles.php' );
33
34 /** WordPress Styles Functions */
35 require( ABSPATH . WPINC . '/functions.wp-styles.php' );
36
37 /**
38  * Register all WordPress scripts.
39  *
40  * Localizes some of them.
41  * args order: `$scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );`
42  * when last arg === 1 queues the script for the footer
43  *
44  * @since 2.6.0
45  *
46  * @param WP_Scripts $scripts WP_Scripts object.
47  */
48 function wp_default_scripts( &$scripts ) {
49 //      include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
50
51         $develop_src = false !== strpos( $wp_version, '-src' );
52
53         if ( ! defined( 'SCRIPT_DEBUG' ) ) {
54                 define( 'SCRIPT_DEBUG', $develop_src );
55         }
56
57         if ( ! $guessurl = site_url() ) {
58                 $guessed_url = true;
59                 $guessurl = wp_guess_url();
60         }
61
62         $scripts->base_url = $guessurl;
63         $scripts->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
64         $scripts->default_version = get_bloginfo( 'version' );
65         $scripts->default_dirs = array('/wp-admin/js/', '/scripts/wp/');
66
67         $suffix = SCRIPT_DEBUG ? '' : '.min';
68         $dev_suffix = $develop_src ? '' : '.min';
69
70         $scripts->add( 'utils', "/scripts/wp/utils$suffix.js" );
71         did_action( 'init' ) && $scripts->localize( 'utils', 'userSettings', array(
72                 'url' => (string) SITECOOKIEPATH,
73                 'uid' => (string) get_current_user_id(),
74                 'time' => (string) time(),
75                 'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ),
76         ) );
77
78         $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
79         did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
80                 'warnDelete'   => __( "You are about to permanently delete these items.\n  'Cancel' to stop, 'OK' to delete." ),
81                 'dismiss'      => __( 'Dismiss this notice.' ),
82                 'collapseMenu' => __( 'Collapse Main menu' ),
83                 'expandMenu'   => __( 'Expand Main menu' ),
84         ) );
85
86         $scripts->add( 'wp-a11y', "/scripts/wp/wp-a11y$suffix.js", array( 'jquery' ), false, 1 );
87
88         $scripts->add( 'sack', "/scripts/wp/tw-sack$suffix.js", array(), '1.6.1', 1 );
89
90         $scripts->add( 'quicktags', "/scripts/wp/quicktags$suffix.js", array(), false, 1 );
91         did_action( 'init' ) && $scripts->localize( 'quicktags', 'quicktagsL10n', array(
92                 'closeAllOpenTags'      => __( 'Close all open tags' ),
93                 'closeTags'             => __( 'close tags' ),
94                 'enterURL'              => __( 'Enter the URL' ),
95                 'enterImageURL'         => __( 'Enter the URL of the image' ),
96                 'enterImageDescription' => __( 'Enter a description of the image' ),
97                 'textdirection'         => __( 'text direction' ),
98                 'toggleTextdirection'   => __( 'Toggle Editor Text Direction' ),
99                 'dfw'                   => __( 'Distraction-free writing mode' ),
100                 'strong'          => __( 'Bold' ),
101                 'strongClose'     => __( 'Close bold tag' ),
102                 'em'              => __( 'Italic' ),
103                 'emClose'         => __( 'Close italic tag' ),
104                 'link'            => __( 'Insert link' ),
105                 'blockquote'      => __( 'Blockquote' ),
106                 'blockquoteClose' => __( 'Close blockquote tag' ),
107                 'del'             => __( 'Deleted text (strikethrough)' ),
108                 'delClose'        => __( 'Close deleted text tag' ),
109                 'ins'             => __( 'Inserted text' ),
110                 'insClose'        => __( 'Close inserted text tag' ),
111                 'image'           => __( 'Insert image' ),
112                 'ul'              => __( 'Bulleted list' ),
113                 'ulClose'         => __( 'Close bulleted list tag' ),
114                 'ol'              => __( 'Numbered list' ),
115                 'olClose'         => __( 'Close numbered list tag' ),
116                 'li'              => __( 'List item' ),
117                 'liClose'         => __( 'Close list item tag' ),
118                 'code'            => __( 'Code' ),
119                 'codeClose'       => __( 'Close code tag' ),
120                 'more'            => __( 'Insert Read More tag' ),
121         ) );
122
123         $scripts->add( 'colorpicker', "/scripts/wp/colorpicker$suffix.js", array('prototype'), '3517m' );
124
125         $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), false, 1 );
126
127         // Back-compat for old DFW. To-do: remove at the end of 2016.
128         $scripts->add( 'wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1 );
129
130         $scripts->add( 'wp-ajax-response', "/scripts/wp/wp-ajax-response$suffix.js", array('jquery'), false, 1 );
131         did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
132                 'noPerm' => __('Sorry, you are not allowed to do that.'),
133                 'broken' => __('An unidentified error has occurred.')
134         ) );
135
136         $scripts->add( 'wp-pointer', "/scripts/wp/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 );
137         did_action( 'init' ) && $scripts->localize( 'wp-pointer', 'wpPointerL10n', array(
138                 'dismiss' => __('Dismiss'),
139         ) );
140
141         $scripts->add( 'autosave', "/scripts/wp/autosave$suffix.js", array('heartbeat'), false, 1 );
142
143         $scripts->add( 'heartbeat', "/scripts/wp/heartbeat$suffix.js", array('jquery'), false, 1 );
144         did_action( 'init' ) && $scripts->localize( 'heartbeat', 'heartbeatSettings',
145                 /**
146                  * Filters the Heartbeat settings.
147                  *
148                  * @since 3.6.0
149                  *
150                  * @param array $settings Heartbeat settings array.
151                  */
152                 apply_filters( 'heartbeat_settings', array() )
153         );
154
155         $scripts->add( 'wp-auth-check', "/scripts/wp/wp-auth-check$suffix.js", array('heartbeat'), false, 1 );
156         did_action( 'init' ) && $scripts->localize( 'wp-auth-check', 'authcheckL10n', array(
157                 'beforeunload' => __('Your session has expired. You can log in again from this page or go to the login page.'),
158
159                 /**
160                  * Filters the authentication check interval.
161                  *
162                  * @since 3.6.0
163                  *
164                  * @param int $interval The interval in which to check a user's authentication.
165                  *                      Default 3 minutes in seconds, or 180.
166                  */
167                 'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ),
168         ) );
169
170         $scripts->add( 'wp-lists', "/scripts/wp/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 );
171
172         // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source.
173         $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1');
174         $scripts->add( 'scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0');
175         $scripts->add( 'scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0');
176         $scripts->add( 'scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0');
177         $scripts->add( 'scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0');
178         $scripts->add( 'scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0');
179         $scripts->add( 'scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' );
180         $scripts->add( 'scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0');
181         $scripts->add( 'scriptaculous', false, array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls') );
182
183         // not used in core, replaced by Jcrop.js
184         $scripts->add( 'cropper', '/scripts/wp/crop/cropper.js', array('scriptaculous-dragdrop') );
185
186         // jQuery
187 //      $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.12.4' );
188 //      $scripts->add( 'jquery-core', '/scripts/wp/jquery/jquery.js', array(), '1.12.4' );
189 //      $scripts->add( 'jquery-migrate', "/scripts/wp/jquery/jquery-migrate$suffix.js", array(), '1.4.1' );
190         $scripts->add( 'jquery', false, array(), '1.12.4' );
191         
192         // full jQuery UI
193         $scripts->add( 'jquery-ui-core', "/scripts/wp/jquery/ui/core$dev_suffix.js", array('jquery'), '1.11.4', 1 );
194         $scripts->add( 'jquery-effects-core', "/scripts/wp/jquery/ui/effect$dev_suffix.js", array('jquery'), '1.11.4', 1 );
195
196 /*      $scripts->add( 'jquery-effects-blind', "/scripts/wp/jquery/ui/effect-blind$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
197         $scripts->add( 'jquery-effects-bounce', "/scripts/wp/jquery/ui/effect-bounce$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
198         $scripts->add( 'jquery-effects-clip', "/scripts/wp/jquery/ui/effect-clip$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
199         $scripts->add( 'jquery-effects-drop', "/scripts/wp/jquery/ui/effect-drop$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
200         $scripts->add( 'jquery-effects-explode', "/scripts/wp/jquery/ui/effect-explode$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
201         $scripts->add( 'jquery-effects-fade', "/scripts/wp/jquery/ui/effect-fade$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
202         $scripts->add( 'jquery-effects-fold', "/scripts/wp/jquery/ui/effect-fold$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
203         $scripts->add( 'jquery-effects-highlight', "/scripts/wp/jquery/ui/effect-highlight$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
204         $scripts->add( 'jquery-effects-puff', "/scripts/wp/jquery/ui/effect-puff$dev_suffix.js", array('jquery-effects-core', 'jquery-effects-scale'), '1.11.4', 1 );
205         $scripts->add( 'jquery-effects-pulsate', "/scripts/wp/jquery/ui/effect-pulsate$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
206         $scripts->add( 'jquery-effects-scale', "/scripts/wp/jquery/ui/effect-scale$dev_suffix.js", array('jquery-effects-core', 'jquery-effects-size'), '1.11.4', 1 );
207         $scripts->add( 'jquery-effects-shake', "/scripts/wp/jquery/ui/effect-shake$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
208         $scripts->add( 'jquery-effects-size', "/scripts/wp/jquery/ui/effect-size$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );*/
209         $scripts->add( 'jquery-effects-slide', "/scripts/wp/jquery/ui/effect-slide$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
210 //      $scripts->add( 'jquery-effects-transfer', "/scripts/wp/jquery/ui/effect-transfer$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 );
211
212 /*      $scripts->add( 'jquery-ui-accordion', "/scripts/wp/jquery/ui/accordion$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 );
213         $scripts->add( 'jquery-ui-autocomplete', "/scripts/wp/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.11.4', 1 );
214         $scripts->add( 'jquery-ui-button', "/scripts/wp/jquery/ui/button$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 );
215         $scripts->add( 'jquery-ui-datepicker', "/scripts/wp/jquery/ui/datepicker$dev_suffix.js", array('jquery-ui-core'), '1.11.4', 1 );
216         $scripts->add( 'jquery-ui-dialog', "/scripts/wp/jquery/ui/dialog$dev_suffix.js", array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.11.4', 1 );
217         $scripts->add( 'jquery-ui-draggable', "/scripts/wp/jquery/ui/draggable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 );
218         $scripts->add( 'jquery-ui-droppable', "/scripts/wp/jquery/ui/droppable$dev_suffix.js", array('jquery-ui-draggable'), '1.11.4', 1 );
219         $scripts->add( 'jquery-ui-menu', "/scripts/wp/jquery/ui/menu$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 );
220         $scripts->add( 'jquery-ui-mouse', "/scripts/wp/jquery/ui/mouse$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
221         $scripts->add( 'jquery-ui-position', "/scripts/wp/jquery/ui/position$dev_suffix.js", array('jquery'), '1.11.4', 1 );
222         $scripts->add( 'jquery-ui-progressbar', "/scripts/wp/jquery/ui/progressbar$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 );
223         $scripts->add( 'jquery-ui-resizable', "/scripts/wp/jquery/ui/resizable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 );
224         $scripts->add( 'jquery-ui-selectable', "/scripts/wp/jquery/ui/selectable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 );
225         $scripts->add( 'jquery-ui-selectmenu', "/scripts/wp/jquery/ui/selectmenu$dev_suffix.js", array('jquery-ui-menu'), '1.11.4', 1 );
226         $scripts->add( 'jquery-ui-slider', "/scripts/wp/jquery/ui/slider$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 );
227         $scripts->add( 'jquery-ui-sortable', "/scripts/wp/jquery/ui/sortable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 );
228         $scripts->add( 'jquery-ui-spinner', "/scripts/wp/jquery/ui/spinner$dev_suffix.js", array( 'jquery-ui-button' ), '1.11.4', 1 );
229         $scripts->add( 'jquery-ui-tabs', "/scripts/wp/jquery/ui/tabs$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 );
230         $scripts->add( 'jquery-ui-tooltip', "/scripts/wp/jquery/ui/tooltip$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 );
231         $scripts->add( 'jquery-ui-widget', "/scripts/wp/jquery/ui/widget$dev_suffix.js", array('jquery'), '1.11.4', 1 );
232         */
233
234         // Strings for 'jquery-ui-autocomplete' live region messages
235         did_action( 'init' ) && $scripts->localize( 'jquery-ui-autocomplete', 'uiAutocompleteL10n', array(
236                 'noResults' => __( 'No results found.' ),
237                 /* translators: Number of results found when using jQuery UI Autocomplete */
238                 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ),
239                 /* translators: %d: Number of results found when using jQuery UI Autocomplete */
240                 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ),
241                 'itemSelected' => __( 'Item selected.' ),
242         ) );
243
244         // deprecated, not used in core, most functionality is included in jQuery 1.3
245         $scripts->add( 'jquery-form', "/scripts/wp/jquery/jquery.form$suffix.js", array('jquery'), '3.37.0', 1 );
246
247         // jQuery plugins
248         $scripts->add( 'jquery-color', "/scripts/wp/jquery/jquery.color.min.js", array('jquery'), '2.1.1', 1 );
249         $scripts->add( 'schedule', '/scripts/wp/jquery/jquery.schedule.js', array('jquery'), '20m', 1 );
250         $scripts->add( 'jquery-query', "/scripts/wp/jquery/jquery.query.js", array('jquery'), '2.1.7', 1 );
251         $scripts->add( 'jquery-serialize-object', "/scripts/wp/jquery/jquery.serialize-object.js", array('jquery'), '0.2', 1 );
252         $scripts->add( 'jquery-hotkeys', "/scripts/wp/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m', 1 );
253         $scripts->add( 'jquery-table-hotkeys', "/scripts/wp/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), false, 1 );
254         $scripts->add( 'jquery-touch-punch', "/scripts/wp/jquery/jquery.ui.touch-punch.js", array('jquery-ui-widget', 'jquery-ui-mouse'), '0.2.2', 1 );
255
256         // Not used any more, registered for backwards compatibility.
257         $scripts->add( 'suggest', "/scripts/wp/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113', 1 );
258
259         // Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv.
260         // It sets jQuery as a dependency, as the theme may have been implicitly loading it this way.
261         $scripts->add( 'imagesloaded', "/scripts/wp/imagesloaded.min.js", array(), '3.2.0', 1 );
262         $scripts->add( 'masonry', "/scripts/wp/masonry.min.js", array( 'imagesloaded' ), '3.3.2', 1 );
263         $scripts->add( 'jquery-masonry', "/scripts/wp/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2b', 1 );
264
265         $scripts->add( 'thickbox', "/scripts/wp/thickbox/thickbox.js", array('jquery'), '3.1-20121105', 1 );
266         did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array(
267                 'next' => __('Next &gt;'),
268                 'prev' => __('&lt; Prev'),
269                 'image' => __('Image'),
270                 'of' => __('of'),
271                 'close' => __('Close'),
272                 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
273                 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
274         ) );
275
276         $scripts->add( 'jcrop', "/scripts/wp/jcrop/jquery.Jcrop.min.js", array('jquery'), '0.9.12');
277
278         $scripts->add( 'swfobject', "/scripts/wp/swfobject.js", array(), '2.2-20120417');
279
280         // error message for both plupload and swfupload
281 /*      $uploader_l10n = array(
282                 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
283                 'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
284                 'zero_byte_file' => __('This file is empty. Please try another.'),
285                 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
286                 'not_an_image' => __('This file is not an image. Please try another.'),
287                 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
288                 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
289                 'default_error' => __('An error occurred in the upload. Please try again later.'),
290                 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
291                 'upload_limit_exceeded' => __('You may only upload 1 file.'),
292                 'http_error' => __('HTTP error.'),
293                 'upload_failed' => __('Upload failed.'),*/
294                 /* translators: 1: Opening link tag, 2: Closing link tag */
295 /*              'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
296                 'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
297                 'io_error' => __('IO error.'),
298                 'security_error' => __('Security error.'),
299                 'file_cancelled' => __('File canceled.'),
300                 'upload_stopped' => __('Upload stopped.'),
301                 'dismiss' => __('Dismiss'),
302                 'crunching' => __('Crunching&hellip;'),
303                 'deleted' => __('moved to the trash.'),
304                 'error_uploading' => __('&#8220;%s&#8221; has failed to upload.')
305         );*/
306 /*
307         $scripts->add( 'plupload', '/scripts/wp/plupload/plupload.full.min.js', array(), '2.1.8' );
308         // Back compat handles:
309         foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) {
310                 $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' );
311         }
312
313         $scripts->add( 'plupload-handlers', "/scripts/wp/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) );
314         did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
315
316         $scripts->add( 'wp-plupload', "/scripts/wp/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 );
317         did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );
318 */
319         // keep 'swfupload' for back-compat.
320 /*      $scripts->add( 'swfupload', '/scripts/wp/swfupload/swfupload.js', array(), '2201-20110113');
321         $scripts->add( 'swfupload-swfobject', '/scripts/wp/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201a');
322         $scripts->add( 'swfupload-queue', '/scripts/wp/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201');
323         $scripts->add( 'swfupload-speed', '/scripts/wp/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201');
324         $scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201');
325         $scripts->add( 'swfupload-handlers', "/scripts/wp/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20110524');
326         did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n );
327         */
328
329         $scripts->add( 'comment-reply', "/scripts/wp/comment-reply$suffix.js", array(), false, 1 );
330
331         $scripts->add( 'json2', "/scripts/wp/json2$suffix.js", array(), '2015-05-03' );
332         did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
333
334         $scripts->add( 'underscore', "/scripts/wp/underscore$dev_suffix.js", array(), '1.8.3', 1 );
335         $scripts->add( 'backbone', "/scripts/wp/backbone$dev_suffix.js", array( 'underscore','jquery' ), '1.2.3', 1 );
336
337         $scripts->add( 'wp-util', "/scripts/wp/wp-util$suffix.js", array('underscore', 'jquery'), false, 1 );
338         did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array(
339                 'ajax' => array(
340                         'url' => admin_url( 'admin-ajax.php', 'relative' ),
341                 ),
342         ) );
343
344         $scripts->add( 'wp-backbone', "/scripts/wp/wp-backbone$suffix.js", array('backbone', 'wp-util'), false, 1 );
345
346         $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 );
347
348         $scripts->add( 'imgareaselect', "/scripts/wp/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), false, 1 );
349
350         $scripts->add( 'mediaelement', "/scripts/wp/mediaelement/mediaelement-and-player.min.js", array('jquery'), '2.22.0', 1 );
351         did_action( 'init' ) && $scripts->localize( 'mediaelement', 'mejsL10n', array(
352                 'language' => get_bloginfo( 'language' ),
353                 'strings'  => array(
354                         'Close'                   => __( 'Close' ),
355                         'Fullscreen'              => __( 'Fullscreen' ),
356                         'Turn off Fullscreen'     => __( 'Turn off Fullscreen' ),
357                         'Go Fullscreen'           => __( 'Go Fullscreen' ),
358                         'Download File'           => __( 'Download File' ),
359                         'Download Video'          => __( 'Download Video' ),
360                         'Play'                    => __( 'Play' ),
361                         'Pause'                   => __( 'Pause' ),
362                         'Captions/Subtitles'      => __( 'Captions/Subtitles' ),
363                         'None'                    => __( 'None', 'no captions/subtitles' ),
364                         'Time Slider'             => __( 'Time Slider' ),
365                         /* translators: %1: number of seconds (30 by default) */
366                         'Skip back %1 seconds'    => __( 'Skip back %1 seconds' ),
367                         'Video Player'            => __( 'Video Player' ),
368                         'Audio Player'            => __( 'Audio Player' ),
369                         'Volume Slider'           => __( 'Volume Slider' ),
370                         'Mute Toggle'             => __( 'Mute Toggle' ),
371                         'Unmute'                  => __( 'Unmute' ),
372                         'Mute'                    => __( 'Mute' ),
373                         'Use Up/Down Arrow keys to increase or decrease volume.' => __( 'Use Up/Down Arrow keys to increase or decrease volume.' ),
374                         'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.' => __( 'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.' ),
375                 ),
376         ) );
377
378
379         $scripts->add( 'wp-mediaelement', "/scripts/wp/mediaelement/wp-mediaelement$suffix.js", array('mediaelement'), false, 1 );
380         $mejs_settings = array(
381                 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ),
382         );
383         did_action( 'init' ) && $scripts->localize( 'mediaelement', '_wpmejsSettings',
384                 /**
385                  * Filters the MediaElement configuration settings.
386                  *
387                  * @since 4.4.0
388                  *
389                  * @param array $mejs_settings MediaElement settings array.
390                  */
391                 apply_filters( 'mejs_settings', $mejs_settings )
392         );
393
394         $scripts->add( 'froogaloop',  "/scripts/wp/mediaelement/froogaloop.min.js", array(), '2.0' );
395         $scripts->add( 'wp-playlist', "/scripts/wp/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 );
396
397         $scripts->add( 'zxcvbn-async', "/scripts/wp/zxcvbn-async$suffix.js", array(), '1.0' );
398         did_action( 'init' ) && $scripts->localize( 'zxcvbn-async', '_zxcvbnSettings', array(
399                 'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/scripts/wp/zxcvbn.min.js',
400         ) );
401
402         $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 );
403         did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
404                 'unknown'  => _x( 'Password strength unknown', 'password strength' ),
405                 'short'    => _x( 'Very weak', 'password strength' ),
406                 'bad'      => _x( 'Weak', 'password strength' ),
407                 'good'     => _x( 'Medium', 'password strength' ),
408                 'strong'   => _x( 'Strong', 'password strength' ),
409                 'mismatch' => _x( 'Mismatch', 'password mismatch' ),
410         ) );
411
412         $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 );
413         did_action( 'init' ) && $scripts->localize( 'user-profile', 'userProfileL10n', array(
414                 'warn'     => __( 'Your new password has not been saved.' ),
415                 'warnWeak' => __( 'Confirm use of weak password' ),
416                 'show'     => __( 'Show' ),
417                 'hide'     => __( 'Hide' ),
418                 'cancel'   => __( 'Cancel' ),
419                 'ariaShow' => esc_attr__( 'Show password' ),
420                 'ariaHide' => esc_attr__( 'Hide password' ),
421         ) );
422
423         $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 );
424
425         $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
426
427         $scripts->add( 'admin-bar', "/scripts/wp/admin-bar$suffix.js", array(), false, 1 );
428
429         $scripts->add( 'wplink', "/scripts/wp/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
430         did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array(
431                 'title' => __('Insert/edit link'),
432                 'update' => __('Update'),
433                 'save' => __('Add Link'),
434                 'noTitle' => __('(no title)'),
435                 'noMatchesFound' => __('No results found.'),
436                 'linkSelected' => __( 'Link selected.' ),
437                 'linkInserted' => __( 'Link inserted.' ),
438         ) );
439
440         $scripts->add( 'wpdialogs', "/scripts/wp/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 );
441
442         $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
443         did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array(
444                 /*
445                  * translators: If your word count is based on single characters (e.g. East Asian characters),
446                  * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
447                  * Do not translate into your own language.
448                  */
449                 'type' => _x( 'words', 'Word count type. Do not translate!' ),
450                 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
451         ) );
452
453         $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
454
455         $scripts->add( 'hoverIntent', "/scripts/wp/hoverIntent$suffix.js", array('jquery'), '1.8.1', 1 );
456
457         $scripts->add( 'customize-base',     "/scripts/wp/customize-base$suffix.js",     array( 'jquery', 'json2', 'underscore' ), false, 1 );
458         $scripts->add( 'customize-loader',   "/scripts/wp/customize-loader$suffix.js",   array( 'customize-base' ), false, 1 );
459         $scripts->add( 'customize-preview',  "/scripts/wp/customize-preview$suffix.js",  array( 'wp-a11y', 'customize-base' ), false, 1 );
460         $scripts->add( 'customize-models',   "/scripts/wp/customize-models.js", array( 'underscore', 'backbone' ), false, 1 );
461         $scripts->add( 'customize-views',    "/scripts/wp/customize-views.js",  array( 'jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views' ), false, 1 );
462         $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y', 'wp-util' ), false, 1 );
463         did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array(
464                 'activate'           => __( 'Save &amp; Activate' ),
465                 'save'               => __( 'Save &amp; Publish' ),
466                 'saveAlert'          => __( 'The changes you made will be lost if you navigate away from this page.' ),
467                 'saved'              => __( 'Saved' ),
468                 'cancel'             => __( 'Cancel' ),
469                 'close'              => __( 'Close' ),
470                 'cheatin'            => __( 'Cheatin&#8217; uh?' ),
471                 'notAllowed'         => __( 'Sorry, you are not allowed to customize this site.' ),
472                 'previewIframeTitle' => __( 'Site Preview' ),
473                 'loginIframeTitle'   => __( 'Session expired' ),
474                 'collapseSidebar'    => _x( 'Hide Controls', 'label for hide controls button without length constraints' ),
475                 'expandSidebar'      => _x( 'Show Controls', 'label for hide controls button without length constraints' ),
476                 'untitledBlogName'   => __( '(Untitled)' ),
477                 // Used for overriding the file types allowed in plupload.
478                 'allowedFiles'       => __( 'Allowed Files' ),
479         ) );
480         $scripts->add( 'customize-selective-refresh', "/scripts/wp/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 );
481
482         $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 );
483         $scripts->add( 'customize-preview-widgets', "/scripts/wp/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );
484
485         $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu' ), false, 1 );
486         $scripts->add( 'customize-preview-nav-menus', "/scripts/wp/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );
487
488         $scripts->add( 'wp-custom-header', "/scripts/wp/wp-custom-header$suffix.js", array( 'wp-a11y' ), false, 1 );
489
490         $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 );
491
492         $scripts->add( 'shortcode', "/scripts/wp/shortcode$suffix.js", array( 'underscore' ), false, 1 );
493         $scripts->add( 'media-models', "/scripts/wp/media-models$suffix.js", array( 'wp-backbone' ), false, 1 );
494         did_action( 'init' ) && $scripts->localize( 'media-models', '_wpMediaModelsL10n', array(
495                 'settings' => array(
496                         'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
497                         'post' => array( 'id' => 0 ),
498                 ),
499         ) );
500
501         $scripts->add( 'wp-embed', "/scripts/wp/wp-embed$suffix.js" );
502
503         // To enqueue media-views or media-editor, call wp_enqueue_media().
504         // Both rely on numerous settings, styles, and templates to operate correctly.
505         $scripts->add( 'media-views',  "/scripts/wp/media-views$suffix.js",  array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement' ), false, 1 );
506         $scripts->add( 'media-editor', "/scripts/wp/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
507         $scripts->add( 'media-audiovideo', "/scripts/wp/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
508         $scripts->add( 'mce-view', "/scripts/wp/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
509
510 /*
511         $scripts->add( 'wp-api', "/scripts/wp/wp-api$suffix.js", array( 'jquery', 'backbone', 'underscore' ), false, 1 );
512         did_action( 'init' ) && $scripts->localize( 'wp-api', 'wpApiSettings', array(
513                 'root'          => esc_url_raw( get_rest_url() ),
514                 'nonce'         => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ),
515                 'versionString' => 'wp/v2/',
516         ) );
517 */
518         if ( is_admin() ) {
519                 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 );
520                 did_action( 'init' ) && $scripts->localize( 'admin-tags', 'tagsl10n', array(
521                         'noPerm' => __('Sorry, you are not allowed to do that.'),
522                         'broken' => __('An unidentified error has occurred.')
523                 ));
524
525                 $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'quicktags', 'jquery-query'), false, 1 );
526                 did_action( 'init' ) && $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
527                         'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
528                         'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
529                         'replyApprove' => __( 'Approve and Reply' ),
530                         'reply' => __( 'Reply' ),
531                         'warnQuickEdit' => __( "Are you sure you want to edit this comment?\nThe changes you made will be lost." ),
532                         'warnCommentChanges' => __( "Are you sure you want to do this?\nThe comment changes you made will be lost." ),
533                         'docTitleComments' => __( 'Comments' ),
534                         /* translators: %s: comments count */
535                         'docTitleCommentsCount' => __( 'Comments (%s)' ),
536                 ) );
537
538                 $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1 );
539
540                 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 );
541                 did_action( 'init' ) && $scripts->localize( 'postbox', 'postBoxL10n', array(
542                         'postBoxEmptyString' => __( 'Drag boxes here' ),
543                 ) );
544
545                 $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'tags-suggest' ), false, 1 );
546
547                 $scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'jquery-ui-autocomplete', 'wp-a11y' ), false, 1 );
548                 did_action( 'init' ) && $scripts->localize( 'tags-suggest', 'tagsSuggestL10n', array(
549                         'tagDelimiter' => _x( ',', 'tag delimiter' ),
550                         'removeTerm'   => __( 'Remove term:' ),
551                         'termSelected' => __( 'Term selected.' ),
552                         'termAdded'    => __( 'Term added.' ),
553                         'termRemoved'  => __( 'Term removed.' ),
554                 ) );
555
556                 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y' ), false, 1 );
557                 did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array(
558                         'ok' => __('OK'),
559                         'cancel' => __('Cancel'),
560                         'publishOn' => __('Publish on:'),
561                         'publishOnFuture' =>  __('Schedule for:'),
562                         'publishOnPast' => __('Published on:'),
563                         /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
564                         'dateFormat' => __('%1$s %2$s, %3$s @ %4$s:%5$s'),
565                         'showcomm' => __('Show more comments'),
566                         'endcomm' => __('No more comments found.'),
567                         'publish' => __('Publish'),
568                         'schedule' => __('Schedule'),
569                         'update' => __('Update'),
570                         'savePending' => __('Save as Pending'),
571                         'saveDraft' => __('Save Draft'),
572                         'private' => __('Private'),
573                         'public' => __('Public'),
574                         'publicSticky' => __('Public, Sticky'),
575                         'password' => __('Password Protected'),
576                         'privatelyPublished' => __('Privately Published'),
577                         'published' => __('Published'),
578                         'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
579                         'savingText' => __('Saving Draft&#8230;'),
580                         'permalinkSaved' => __( 'Permalink saved' ),
581                 ) );
582
583                 $scripts->add( 'press-this', "/wp-admin/js/press-this$suffix.js", array( 'jquery', 'tags-box' ), false, 1 );
584                 did_action( 'init' ) && $scripts->localize( 'press-this', 'pressThisL10n', array(
585                         'newPost' => __( 'Title' ),
586                         'serverError' => __( 'Connection lost or the server is busy. Please try again later.' ),
587                         'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
588                         /* translators: %d: nth embed found in a post */
589                         'suggestedEmbedAlt' => __( 'Suggested embed #%d' ),
590                         /* translators: %d: nth image found in a post */
591                         'suggestedImgAlt' => __( 'Suggested image #%d' ),
592                 ) );
593
594                 $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
595
596                 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
597
598                 $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) );
599                 $scripts->add_data( 'comment', 'group', 1 );
600                 did_action( 'init' ) && $scripts->localize( 'comment', 'commentL10n', array(
601                         'submittedOn' => __( 'Submitted on:' ),
602                         /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
603                         'dateFormat' => __( '%1$s %2$s, %3$s @ %4$s:%5$s' )
604                 ) );
605
606                 $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
607
608                 $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
609
610                 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y' ), false, 1 );
611
612                 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 );
613                 did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
614                         'error'      => __( 'Error while saving the changes.' ),
615                         'ntdeltitle' => __( 'Remove From Bulk Edit' ),
616                         'notitle'    => __( '(no title)' ),
617                         'comma'      => trim( _x( ',', 'tag delimiter' ) ),
618                         'saved'      => __( 'Changes saved.' ),
619                 ) );
620
621                 $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
622                 did_action( 'init' ) && $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
623                         'error' => __( 'Error while saving the changes.' ),
624                         'saved' => __( 'Changes saved.' ),
625                 ) );
626
627                 $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
628                 did_action( 'init' ) && $scripts->localize( 'plugin-install', 'plugininstallL10n', array(
629                         'plugin_information' => __( 'Plugin:' ),
630                         'plugin_modal_label' => __( 'Plugin details' ),
631                         'ays' => __('Are you sure you want to install this plugin?')
632                 ) );
633
634                 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
635                 did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array(
636                         'ajax_nonce' => wp_create_nonce( 'updates' ),
637                         'l10n'       => array(
638                                 /* translators: %s: Search string */
639                                 'searchResults'              => __( 'Search results for &#8220;%s&#8221;' ),
640                                 'searchResultsLabel'         => __( 'Search Results' ),
641                                 'noPlugins'                  => __( 'You do not appear to have any plugins available at this time.' ),
642                                 'noItemsSelected'            => __( 'Please select at least one item to perform this action on.' ),
643                                 'updating'                   => __( 'Updating...' ), // No ellipsis.
644                                 'updated'                    => __( 'Updated!' ),
645                                 'update'                     => __( 'Update' ),
646                                 'updateNow'                  => __( 'Update Now' ),
647                                 /* translators: %s: Plugin name and version */
648                                 'updateNowLabel'             => __( 'Update %s now' ),
649                                 'updateFailedShort'          => __( 'Update Failed!' ),
650                                 /* translators: %s: Error string for a failed update */
651                                 'updateFailed'               => __( 'Update Failed: %s' ),
652                                 /* translators: %s: Plugin name and version */
653                                 'updatingLabel'              => __( 'Updating %s...' ), // No ellipsis.
654                                 /* translators: %s: Plugin name and version */
655                                 'updatedLabel'               => __( '%s updated!' ),
656                                 /* translators: %s: Plugin name and version */
657                                 'updateFailedLabel'          => __( '%s update failed' ),
658                                 /* translators: JavaScript accessible string */
659                                 'updatingMsg'                => __( 'Updating... please wait.' ), // No ellipsis.
660                                 /* translators: JavaScript accessible string */
661                                 'updatedMsg'                 => __( 'Update completed successfully.' ),
662                                 /* translators: JavaScript accessible string */
663                                 'updateCancel'               => __( 'Update canceled.' ),
664                                 'beforeunload'               => __( 'Updates may not complete if you navigate away from this page.' ),
665                                 'installNow'                 => __( 'Install Now' ),
666                                 /* translators: %s: Plugin name */
667                                 'installNowLabel'            => __( 'Install %s now' ),
668                                 'installing'                 => __( 'Installing...' ),
669                                 'installed'                  => __( 'Installed!' ),
670                                 'installFailedShort'         => __( 'Install Failed!' ),
671                                 /* translators: %s: Error string for a failed installation */
672                                 'installFailed'              => __( 'Installation failed: %s' ),
673                                 /* translators: %s: Plugin name and version */
674                                 'pluginInstallingLabel'      => _x( 'Installing %s...', 'plugin' ), // no ellipsis
675                                 /* translators: %s: Theme name and version */
676                                 'themeInstallingLabel'       => _x( 'Installing %s...', 'theme' ), // no ellipsis
677                                 /* translators: %s: Plugin name and version */
678                                 'pluginInstalledLabel'       => _x( '%s installed!', 'plugin' ),
679                                 /* translators: %s: Theme name and version */
680                                 'themeInstalledLabel'        => _x( '%s installed!', 'theme' ),
681                                 /* translators: %s: Plugin name and version */
682                                 'pluginInstallFailedLabel'   => _x( '%s installation failed', 'plugin' ),
683                                 /* translators: %s: Theme name and version */
684                                 'themeInstallFailedLabel'    => _x( '%s installation failed', 'theme' ),
685                                 'installingMsg'              => __( 'Installing... please wait.' ),
686                                 'installedMsg'               => __( 'Installation completed successfully.' ),
687                                 /* translators: %s: Activation URL */
688                                 'importerInstalledMsg'       => __( 'Importer installed successfully. <a href="%s">Run importer</a>' ),
689                                 /* translators: %s: Theme name */
690                                 'aysDelete'                  => __( 'Are you sure you want to delete %s?' ),
691                                 /* translators: %s: Plugin name */
692                                 'aysDeleteUninstall'         => __( 'Are you sure you want to delete %s and its data?' ),
693                                 'aysBulkDelete'              => __( 'Are you sure you want to delete the selected plugins and their data?' ),
694                                 'aysBulkDeleteThemes'        => __( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' ),
695                                 'deleting'                   => __( 'Deleting...' ),
696                                 /* translators: %s: Error string for a failed deletion */
697                                 'deleteFailed'               => __( 'Deletion failed: %s' ),
698                                 'deleted'                    => __( 'Deleted!' ),
699                                 'livePreview'                => __( 'Live Preview' ),
700                                 'activatePlugin'             => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
701                                 'activateTheme'              => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
702                                 /* translators: %s: Plugin name */
703                                 'activatePluginLabel'        => is_network_admin() ? _x( 'Network Activate %s', 'plugin' ) : _x( 'Activate %s', 'plugin' ),
704                                 /* translators: %s: Theme name */
705                                 'activateThemeLabel'         => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ),
706                                 'activateImporter'           => __( 'Run Importer' ),
707                                 /* translators: %s: Importer name */
708                                 'activateImporterLabel'      => __( 'Run %s' ),
709                                 'unknownError'               => __( 'An unknown error occurred' ),
710                                 'connectionError'            => __( 'Connection lost or the server is busy. Please try again later.' ),
711                                 'nonceError'                 => __( 'An error has occurred. Please reload the page and try again.' ),
712                                 'pluginsFound'               => __( 'Number of plugins found: %d' ),
713                                 'noPluginsFound'             => __( 'No plugins found. Try a different search.' ),
714                         ),
715                 ) );
716
717                 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
718
719                 $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 );
720                 $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 );
721                 did_action( 'init' ) && $scripts->localize( 'wp-color-picker', 'wpColorPickerL10n', array(
722                         'clear' => __( 'Clear' ),
723                         'defaultString' => __( 'Default' ),
724                         'pick' => __( 'Select Color' ),
725                         'current' => __( 'Current Color' ),
726                 ) );
727
728                 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 );
729
730                 $scripts->add( 'list-revisions', "/scripts/wp/wp-list-revisions$suffix.js" );
731
732                 $scripts->add( 'media-grid', "/scripts/wp/media-grid$suffix.js", array( 'media-editor' ), false, 1 );
733                 $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
734                 did_action( 'init' ) && $scripts->localize( 'media', 'attachMediaBoxL10n', array(
735                         'error' => __( 'An error has occurred. Please reload the page and try again.' ),
736                 ));
737
738                 $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), false, 1 );
739                 did_action( 'init' ) && $scripts->localize( 'image-edit', 'imageEditL10n', array(
740                         'error' => __( 'Could not load the preview image. Please reload the page and try again.' )
741                 ));
742
743                 $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
744                 did_action( 'init' ) && $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
745                         'setThumbnail' => __( 'Use as featured image' ),
746                         'saving' => __( 'Saving...' ), // no ellipsis
747                         'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
748                         'done' => __( 'Done' )
749                 ) );
750
751                 // Navigation Menus
752                 $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' ) );
753                 did_action( 'init' ) && $scripts->localize( 'nav-menu', 'navMenuL10n', array(
754                         'noResultsFound' => __( 'No results found.' ),
755                         'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
756                         'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
757                         'untitled' => _x( '(no label)', 'missing menu item navigation label' )
758                 ) );
759
760                 $scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 );
761                 $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 );
762                 $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 );
763
764                 $scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 );
765         }
766 }
767
768 /**
769  * Assign default styles to $styles object.
770  *
771  * Nothing is returned, because the $styles parameter is passed by reference.
772  * Meaning that whatever object is passed will be updated without having to
773  * reassign the variable that was passed back to the same value. This saves
774  * memory.
775  *
776  * Adding default styles is not the only task, it also assigns the base_url
777  * property, the default version, and text direction for the object.
778  *
779  * @since 2.6.0
780  *
781  * @param WP_Styles $styles
782  */
783 function wp_default_styles( &$styles ) {
784 //      include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
785
786         if ( ! defined( 'SCRIPT_DEBUG' ) )
787                 define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) );
788
789         if ( ! $guessurl = site_url() )
790                 $guessurl = wp_guess_url();
791
792         $styles->base_url = $guessurl;
793         $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
794         $styles->default_version = get_bloginfo( 'version' );
795         $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
796         $styles->default_dirs = array('/wp-admin/', '/wp-includes/css/');
797
798         // Open Sans is no longer used by core, but may be relied upon by themes and plugins.
799         $open_sans_font_url = '';
800
801         /* translators: If there are characters in your language that are not supported
802          * by Open Sans, translate this to 'off'. Do not translate into your own language.
803          */
804         if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) {
805                 $subsets = 'latin,latin-ext';
806
807                 /* translators: To add an additional Open Sans character subset specific to your language,
808                  * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language.
809                  */
810                 $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' );
811
812                 if ( 'cyrillic' == $subset ) {
813                         $subsets .= ',cyrillic,cyrillic-ext';
814                 } elseif ( 'greek' == $subset ) {
815                         $subsets .= ',greek,greek-ext';
816                 } elseif ( 'vietnamese' == $subset ) {
817                         $subsets .= ',vietnamese';
818                 }
819
820                 // Hotlink Open Sans, for now
821                 $open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";
822         }
823
824         // Register a stylesheet for the selected admin color scheme.
825         $styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) );
826
827         $suffix = SCRIPT_DEBUG ? '' : '.min';
828
829         // Admin CSS
830         $styles->add( 'common',              "/wp-admin/css/common$suffix.css" );
831         $styles->add( 'forms',               "/wp-admin/css/forms$suffix.css" );
832         $styles->add( 'admin-menu',          "/wp-admin/css/admin-menu$suffix.css" );
833         $styles->add( 'dashboard',           "/wp-admin/css/dashboard$suffix.css" );
834         $styles->add( 'list-tables',         "/wp-admin/css/list-tables$suffix.css" );
835         $styles->add( 'edit',                "/wp-admin/css/edit$suffix.css" );
836         $styles->add( 'revisions',           "/wp-admin/css/revisions$suffix.css" );
837         $styles->add( 'media',               "/wp-admin/css/media$suffix.css" );
838         $styles->add( 'themes',              "/wp-admin/css/themes$suffix.css" );
839         $styles->add( 'about',               "/wp-admin/css/about$suffix.css" );
840         $styles->add( 'nav-menus',           "/wp-admin/css/nav-menus$suffix.css" );
841         $styles->add( 'widgets',             "/wp-admin/css/widgets$suffix.css" );
842         $styles->add( 'site-icon',           "/wp-admin/css/site-icon$suffix.css" );
843         $styles->add( 'l10n',                "/wp-admin/css/l10n$suffix.css" );
844
845         $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' ) );
846
847         $styles->add( 'login',               "/wp-admin/css/login$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) );
848         $styles->add( 'install',             "/wp-admin/css/install$suffix.css", array( 'buttons' ) );
849         $styles->add( 'wp-color-picker',     "/wp-admin/css/color-picker$suffix.css" );
850         $styles->add( 'customize-controls',  "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) );
851         $styles->add( 'customize-widgets',   "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) );
852         $styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) );
853         $styles->add( 'press-this',          "/wp-admin/css/press-this$suffix.css", array( 'buttons' ) );
854
855         $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" );
856         $styles->add_data( 'ie', 'conditional', 'lte IE 7' );
857
858         // Common dependencies
859         $styles->add( 'buttons',   "/wp-includes/css/buttons$suffix.css" );
860         $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" );
861
862         // Includes CSS
863         $styles->add( 'admin-bar',            "/wp-includes/css/admin-bar$suffix.css", array( 'dashicons' ) );
864         $styles->add( 'wp-auth-check',        "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) );
865         $styles->add( 'editor-buttons',       "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) );
866         $styles->add( 'media-views',          "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) );
867         $styles->add( 'wp-pointer',           "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) );
868         $styles->add( 'customize-preview',    "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) );
869         $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" );
870         $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );
871
872         // External libraries and friends
873         $styles->add( 'imgareaselect',       '/scripts/wp/imgareaselect/imgareaselect.css', array(), '0.9.8' );
874         $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) );
875         $styles->add( 'mediaelement',        "/scripts/wp/mediaelement/mediaelementplayer.min.css", array(), '2.22.0' );
876         $styles->add( 'wp-mediaelement',     "/scripts/wp/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) );
877         $styles->add( 'thickbox',            '/scripts/wp/thickbox/thickbox.css', array( 'dashicons' ) );
878
879         // Deprecated CSS
880         $styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" );
881         $styles->add( 'farbtastic',       "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' );
882         $styles->add( 'jcrop',            "/scripts/wp/jcrop/jquery.Jcrop.min.css", array(), '0.9.12' );
883         $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
884         $styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6
885
886         // RTL CSS
887         $rtl_styles = array(
888                 // wp-admin
889                 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus',
890                 'widgets', 'site-icon', 'l10n', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', 'customize-preview',
891                 'ie', 'login', 'press-this',
892                 // wp-includes
893                 'buttons', 'admin-bar', 'wp-auth-check', 'editor-buttons', 'media-views', 'wp-pointer',
894                 'wp-jquery-ui-dialog',
895                 // deprecated
896                 'deprecated-media', 'farbtastic',
897         );
898
899         foreach ( $rtl_styles as $rtl_style ) {
900                 $styles->add_data( $rtl_style, 'rtl', 'replace' );
901                 if ( $suffix ) {
902                         $styles->add_data( $rtl_style, 'suffix', $suffix );
903                 }
904         }
905 }
906
907 /**
908  * Reorder JavaScript scripts array to place prototype before jQuery.
909  *
910  * @since 2.3.1
911  *
912  * @param array $js_array JavaScript scripts array
913  * @return array Reordered array, if needed.
914  */
915 function wp_prototype_before_jquery( $js_array ) {
916         if ( false === $prototype = array_search( 'prototype', $js_array, true ) )
917                 return $js_array;
918
919         if ( false === $jquery = array_search( 'jquery', $js_array, true ) )
920                 return $js_array;
921
922         if ( $prototype < $jquery )
923                 return $js_array;
924
925         unset($js_array[$prototype]);
926
927         array_splice( $js_array, $jquery, 0, 'prototype' );
928
929         return $js_array;
930 }
931
932 /**
933  * Load localized data on print rather than initialization.
934  *
935  * These localizations require information that may not be loaded even by init.
936  *
937  * @since 2.5.0
938  */
939 function wp_just_in_time_script_localization() {
940         wp_localize_script( 'autosave', 'autosaveL10n', array(
941                 'autosaveInterval' => AUTOSAVE_INTERVAL,
942                 'blog_id' => get_current_blog_id(),
943         ) );
944 }
945
946 /**
947  * Localizes the jQuery UI datepicker.
948  *
949  * @since 4.6.0
950  *
951  * @link http://api.jqueryui.com/datepicker/#options
952  *
953  * @global WP_Locale $wp_locale The WordPress date and time locale object.
954  */
955 function wp_localize_jquery_ui_datepicker() {
956         global $wp_locale;
957
958         if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) {
959                 return;
960         }
961
962         // Convert the PHP date format into jQuery UI's format.
963         $datepicker_date_format = str_replace(
964                 array(
965                         'd', 'j', 'l', 'z', // Day.
966                         'F', 'M', 'n', 'm', // Month.
967                         'Y', 'y'            // Year.
968                 ),
969                 array(
970                         'dd', 'd', 'DD', 'o',
971                         'MM', 'M', 'm', 'mm',
972                         'yy', 'y'
973                 ),
974                 get_option( 'date_format' )
975         );
976
977         $datepicker_defaults = wp_json_encode( array(
978                 'closeText'       => __( 'Close' ),
979                 'currentText'     => __( 'Today' ),
980                 'monthNames'      => array_values( $wp_locale->month ),
981                 'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
982                 'nextText'        => __( 'Next' ),
983                 'prevText'        => __( 'Previous' ),
984                 'dayNames'        => array_values( $wp_locale->weekday ),
985                 'dayNamesShort'   => array_values( $wp_locale->weekday_abbrev ),
986                 'dayNamesMin'     => array_values( $wp_locale->weekday_initial ),
987                 'dateFormat'      => $datepicker_date_format,
988                 'firstDay'        => absint( get_option( 'start_of_week' ) ),
989                 'isRTL'           => $wp_locale->is_rtl(),
990         ) );
991
992         wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" );
993 }
994
995 /**
996  * Administration Screen CSS for changing the styles.
997  *
998  * If installing the 'wp-admin/' directory will be replaced with './'.
999  *
1000  * The $_wp_admin_css_colors global manages the Administration Screens CSS
1001  * stylesheet that is loaded. The option that is set is 'admin_color' and is the
1002  * color and key for the array. The value for the color key is an object with
1003  * a 'url' parameter that has the URL path to the CSS file.
1004  *
1005  * The query from $src parameter will be appended to the URL that is given from
1006  * the $_wp_admin_css_colors array value URL.
1007  *
1008  * @since 2.6.0
1009  * @global array $_wp_admin_css_colors
1010  *
1011  * @param string $src    Source URL.
1012  * @param string $handle Either 'colors' or 'colors-rtl'.
1013  * @return string|false URL path to CSS stylesheet for Administration Screens.
1014  */
1015 function wp_style_loader_src( $src, $handle ) {
1016         global $_wp_admin_css_colors;
1017
1018         if ( wp_installing() )
1019                 return preg_replace( '#^wp-admin/#', './', $src );
1020
1021         if ( 'colors' == $handle ) {
1022                 $color = get_user_option('admin_color');
1023
1024                 if ( empty($color) || !isset($_wp_admin_css_colors[$color]) )
1025                         $color = 'fresh';
1026
1027                 $color = $_wp_admin_css_colors[$color];
1028                 $url = $color->url;
1029
1030                 if ( ! $url ) {
1031                         return false;
1032                 }
1033
1034                 $parsed = parse_url( $src );
1035                 if ( isset($parsed['query']) && $parsed['query'] ) {
1036                         wp_parse_str( $parsed['query'], $qv );
1037                         $url = add_query_arg( $qv, $url );
1038                 }
1039
1040                 return $url;
1041         }
1042
1043         return $src;
1044 }
1045
1046 /**
1047  * Prints the script queue in the HTML head on admin pages.
1048  *
1049  * Postpones the scripts that were queued for the footer.
1050  * print_footer_scripts() is called in the footer to print these scripts.
1051  *
1052  * @since 2.8.0
1053  *
1054  * @see wp_print_scripts()
1055  *
1056  * @global bool $concatenate_scripts
1057  *
1058  * @return array
1059  */
1060 function print_head_scripts() {
1061         global $concatenate_scripts;
1062
1063         if ( ! did_action('wp_print_scripts') ) {
1064                 /** This action is documented in wp-includes/functions.wp-scripts.php */
1065                 do_action( 'wp_print_scripts' );
1066         }
1067
1068         $wp_scripts = wp_scripts();
1069
1070         script_concat_settings();
1071         $wp_scripts->do_concat = $concatenate_scripts;
1072         $wp_scripts->do_head_items();
1073
1074         /**
1075          * Filters whether to print the head scripts.
1076          *
1077          * @since 2.8.0
1078          *
1079          * @param bool $print Whether to print the head scripts. Default true.
1080          */
1081         if ( apply_filters( 'print_head_scripts', true ) ) {
1082                 _print_scripts();
1083         }
1084                 
1085         $wp_scripts->reset();
1086         return $wp_scripts->done;
1087 }
1088
1089 /**
1090  * Prints the scripts that were queued for the footer or too late for the HTML head.
1091  *
1092  * @since 2.8.0
1093  *
1094  * @global WP_Scripts $wp_scripts
1095  * @global bool       $concatenate_scripts
1096  *
1097  * @return array
1098  */
1099 function print_footer_scripts() {
1100         global $wp_scripts, $concatenate_scripts;
1101
1102         if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
1103                 return array(); // No need to run if not instantiated.
1104         }
1105         script_concat_settings();
1106         $wp_scripts->do_concat = $concatenate_scripts;
1107         $wp_scripts->do_footer_items();
1108
1109         /**
1110          * Filters whether to print the footer scripts.
1111          *
1112          * @since 2.8.0
1113          *
1114          * @param bool $print Whether to print the footer scripts. Default true.
1115          */
1116         if ( apply_filters( 'print_footer_scripts', true ) ) {
1117                 _print_scripts();
1118         }
1119
1120         $wp_scripts->reset();
1121         return $wp_scripts->done;
1122 }
1123
1124 /**
1125  * Print scripts (internal use only)
1126  *
1127  * @ignore
1128  *
1129  * @global WP_Scripts $wp_scripts
1130  * @global bool       $compress_scripts
1131  */
1132 function _print_scripts() {
1133         global $wp_scripts, $compress_scripts;
1134
1135         $zip = $compress_scripts ? 1 : 0;
1136         if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
1137                 $zip = 'gzip';
1138
1139         if ( $concat = trim( $wp_scripts->concat, ', ' ) ) {
1140
1141                 if ( !empty($wp_scripts->print_code) ) {
1142                         echo "\n<script type='text/javascript'>\n";
1143                         echo "/* <![CDATA[ */\n"; // not needed in HTML 5
1144                         echo $wp_scripts->print_code;
1145                         echo "/* ]]> */\n";
1146                         echo "</script>\n";
1147                 }
1148
1149                 $concat = str_split( $concat, 128 );
1150                 $concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat );
1151
1152                 $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&" . $concat . '&ver=' . $wp_scripts->default_version;
1153                 echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n";
1154         }
1155
1156         if ( !empty($wp_scripts->print_html) )
1157                 echo $wp_scripts->print_html;
1158 }
1159
1160 /**
1161  * Prints the script queue in the HTML head on the front end.
1162  *
1163  * Postpones the scripts that were queued for the footer.
1164  * wp_print_footer_scripts() is called in the footer to print these scripts.
1165  *
1166  * @since 2.8.0
1167  *
1168  * @global WP_Scripts $wp_scripts
1169  *
1170  * @return array
1171  */
1172 function wp_print_head_scripts() {
1173         if ( ! did_action('wp_print_scripts') ) {
1174                 /** This action is documented in wp-includes/functions.wp-scripts.php */
1175                 do_action( 'wp_print_scripts' );
1176         }
1177
1178         global $wp_scripts;
1179
1180         if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
1181                 return array(); // no need to run if nothing is queued
1182         }
1183         
1184         // ##### Javascript呼び出しのヘッダ部出力はMagic3側で出力するために出力を抑止する #####
1185         global $gEnvManager;
1186         
1187         ob_start();
1188         $ret = print_head_scripts();
1189         $contents = ob_get_contents();
1190         ob_end_clean();
1191         
1192         $gEnvManager->setWpHeadScriptsData($contents);
1193
1194         return $ret;
1195 }
1196
1197 /**
1198  * Private, for use in *_footer_scripts hooks
1199  *
1200  * @since 3.3.0
1201  */
1202 function _wp_footer_scripts() {
1203         print_late_styles();
1204         print_footer_scripts();
1205 }
1206
1207 /**
1208  * Hooks to print the scripts and styles in the footer.
1209  *
1210  * @since 2.8.0
1211  */
1212 function wp_print_footer_scripts() {
1213         /**
1214          * Fires when footer scripts are printed.
1215          *
1216          * @since 2.8.0
1217          */
1218         do_action( 'wp_print_footer_scripts' );
1219 }
1220
1221 /**
1222  * Wrapper for do_action('wp_enqueue_scripts')
1223  *
1224  * Allows plugins to queue scripts for the front end using wp_enqueue_script().
1225  * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
1226  *
1227  * @since 2.8.0
1228  */
1229 function wp_enqueue_scripts() {
1230         /**
1231          * Fires when scripts and styles are enqueued.
1232          *
1233          * @since 2.8.0
1234          */
1235         do_action( 'wp_enqueue_scripts' );
1236 }
1237
1238 /**
1239  * Prints the styles queue in the HTML head on admin pages.
1240  *
1241  * @since 2.8.0
1242  *
1243  * @global bool $concatenate_scripts
1244  *
1245  * @return array
1246  */
1247 function print_admin_styles() {
1248         global $concatenate_scripts;
1249
1250         $wp_styles = wp_styles();
1251
1252         script_concat_settings();
1253         $wp_styles->do_concat = $concatenate_scripts;
1254         $wp_styles->do_items(false);
1255
1256         /**
1257          * Filters whether to print the admin styles.
1258          *
1259          * @since 2.8.0
1260          *
1261          * @param bool $print Whether to print the admin styles. Default true.
1262          */
1263         if ( apply_filters( 'print_admin_styles', true ) ) {
1264                 _print_styles();
1265         }
1266
1267         $wp_styles->reset();
1268         return $wp_styles->done;
1269 }
1270
1271 /**
1272  * Prints the styles that were queued too late for the HTML head.
1273  *
1274  * @since 3.3.0
1275  *
1276  * @global WP_Styles $wp_styles
1277  * @global bool      $concatenate_scripts
1278  *
1279  * @return array|void
1280  */
1281 function print_late_styles() {
1282         global $wp_styles, $concatenate_scripts;
1283
1284         if ( ! ( $wp_styles instanceof WP_Styles ) ) {
1285                 return;
1286         }
1287
1288         script_concat_settings();
1289         $wp_styles->do_concat = $concatenate_scripts;
1290         $wp_styles->do_footer_items();
1291
1292         /**
1293          * Filters whether to print the styles queued too late for the HTML head.
1294          *
1295          * @since 3.3.0
1296          *
1297          * @param bool $print Whether to print the 'late' styles. Default true.
1298          */
1299         if ( apply_filters( 'print_late_styles', true ) ) {
1300                 _print_styles();
1301         }
1302
1303         $wp_styles->reset();
1304         return $wp_styles->done;
1305 }
1306
1307 /**
1308  * Print styles (internal use only)
1309  *
1310  * @ignore
1311  * @since 3.3.0
1312  *
1313  * @global bool $compress_css
1314  */
1315 function _print_styles() {
1316         global $compress_css;
1317
1318         $wp_styles = wp_styles();
1319
1320         $zip = $compress_css ? 1 : 0;
1321         if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
1322                 $zip = 'gzip';
1323
1324         if ( $concat = trim( $wp_styles->concat, ', ' ) ) {
1325                 $dir = $wp_styles->text_direction;
1326                 $ver = $wp_styles->default_version;
1327
1328                 $concat = str_split( $concat, 128 );
1329                 $concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat );
1330
1331                 $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&" . $concat . '&ver=' . $ver;
1332                 echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
1333
1334                 if ( !empty($wp_styles->print_code) ) {
1335                         echo "<style type='text/css'>\n";
1336                         echo $wp_styles->print_code;
1337                         echo "\n</style>\n";
1338                 }
1339         }
1340
1341         if ( !empty($wp_styles->print_html) )
1342                 echo $wp_styles->print_html;
1343 }
1344
1345 /**
1346  * Determine the concatenation and compression settings for scripts and styles.
1347  *
1348  * @since 2.8.0
1349  *
1350  * @global bool $concatenate_scripts
1351  * @global bool $compress_scripts
1352  * @global bool $compress_css
1353  */
1354 function script_concat_settings() {
1355         global $concatenate_scripts, $compress_scripts, $compress_css;
1356
1357         $compressed_output = ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') );
1358
1359         if ( ! isset($concatenate_scripts) ) {
1360                 $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true;
1361                 if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) )
1362                         $concatenate_scripts = false;
1363         }
1364
1365         if ( ! isset($compress_scripts) ) {
1366                 $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true;
1367                 if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
1368                         $compress_scripts = false;
1369         }
1370
1371         if ( ! isset($compress_css) ) {
1372                 $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true;
1373                 if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
1374                         $compress_css = false;
1375         }
1376 }