]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/script-loader.php
0616afca04f2e93404a096d6e029cd707157cd68
[autoinstalls/wordpress.git] / wp-includes / script-loader.php
1 <?php
2 /**
3  * WordPress scripts and styles default loader.
4  *
5  * Most of the functionality that existed here was moved to
6  * {@link http://backpress.automattic.com/ BackPress}. WordPress themes and
7  * plugins will only be concerned about the filters and actions set in this
8  * file.
9  *
10  * Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
11  * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,
12  * define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,
13  * define('COMPRESS_SCRIPTS', false); disables compression of scripts,
14  * define('COMPRESS_CSS', false); disables compression of CSS,
15  * define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).
16  *
17  * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
18  * to temporarily override the above settings. Also a compression test is run once and the result is saved
19  * as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted.
20  *
21  * @package WordPress
22  */
23
24 /** BackPress: WordPress Dependencies Class */
25 require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
26
27 /** BackPress: WordPress Scripts Class */
28 require( ABSPATH . WPINC . '/class.wp-scripts.php' );
29
30 /** BackPress: WordPress Scripts Functions */
31 require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
32
33 /** BackPress: WordPress Styles Class */
34 require( ABSPATH . WPINC . '/class.wp-styles.php' );
35
36 /** BackPress: WordPress Styles Functions */
37 require( ABSPATH . WPINC . '/functions.wp-styles.php' );
38
39 /**
40  * Set up WordPress scripts to load by default for Administration Screen.
41  *
42  * Localizes a few of the scripts.
43  * $scripts->add_data( 'script-handle', 'group', 1 ); queues the script for the footer
44  *
45  * @since 2.6.0
46  *
47  * @param object $scripts WP_Scripts object.
48  */
49 function wp_default_scripts( &$scripts ) {
50
51         if ( !$guessurl = site_url() )
52                 $guessurl = wp_guess_url();
53
54         $scripts->base_url = $guessurl;
55         $scripts->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
56         $scripts->default_version = get_bloginfo( 'version' );
57         $scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/');
58
59         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
60
61         // Always ensure that we have the convertEntities function
62         $scripts->add( 'l10n', "/wp-includes/js/l10n$suffix.js", false, '20101110' );
63         $scripts->enqueue( 'l10n' );
64
65         $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
66
67         $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20110610' );
68         $scripts->add_data( 'common', 'group', 1 );
69         $scripts->localize( 'common', 'commonL10n', array(
70                 'warnDelete' => __("You are about to permanently delete the selected items.\n  'Cancel' to stop, 'OK' to delete."),
71                 'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};'
72         ) );
73
74         $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1' );
75         $scripts->add_data( 'sack', 'group', 1 );
76
77         $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20110502' );
78         $scripts->add_data( 'quicktags', 'group', 1 );
79         $scripts->localize( 'quicktags', 'quicktagsL10n', array(
80                 'quickLinks' => __('(Quick Links)'),
81                 'wordLookup' => __('Enter a word to look up:'),
82                 'dictionaryLookup' => esc_attr(__('Dictionary lookup')),
83                 'lookup' => esc_attr(__('lookup')),
84                 'closeAllOpenTags' => esc_attr(__('Close all open tags')),
85                 'closeTags' => esc_attr(__('close tags')),
86                 'enterURL' => __('Enter the URL'),
87                 'enterImageURL' => __('Enter the URL of the image'),
88                 'enterImageDescription' => __('Enter a description of the image'),
89                 'fullscreen' => __('fullscreen'),
90                 'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
91                 'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};'
92         ) );
93
94         $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );
95
96         $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110411' );
97         $scripts->add_data( 'editor', 'group', 1 );
98
99         $scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110610' );
100         $scripts->add_data( 'wp-fullscreen', 'group', 1 );
101
102         $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6.1');
103
104         $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), '20091119' );
105         $scripts->add_data( 'wp-ajax-response', 'group', 1 );
106         $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
107                 'noPerm' => __('You do not have permission to do that.'),
108                 'broken' => __('An unidentified error has occurred.'),
109                 'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'
110         ) );
111
112         $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110524' );
113         $scripts->add_data( 'autosave', 'group', 1 );
114
115         $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20110521' );
116         $scripts->add_data( 'wp-lists', 'group', 1 );
117
118         $scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.8.3');
119         $scripts->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.8.3');
120         $scripts->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.8.3');
121         $scripts->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.8.3');
122         $scripts->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.8.3');
123         $scripts->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.8.3' );
124         $scripts->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.8.3');
125         $scripts->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.8.3');
126
127         // not used in core, replaced by Jcrop.js
128         $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118');
129
130         $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.6.1');
131
132         $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.8.12' );
133         $scripts->add_data( 'jquery-ui-core', 'group', 1 );
134
135         $scripts->add( 'jquery-ui-position', '/wp-includes/js/jquery/ui.position.js', array('jquery-ui-core'), '1.8.12' );
136         $scripts->add_data( 'jquery-ui-position', 'group', 1 );
137
138         $scripts->add( 'jquery-ui-widget', '/wp-includes/js/jquery/ui.widget.js', array('jquery-ui-core'), '1.8.12' );
139         $scripts->add_data( 'jquery-ui-widget', 'group', 1 );
140
141         $scripts->add( 'jquery-ui-mouse', '/wp-includes/js/jquery/ui.mouse.js', array('jquery-ui-widget'), '1.8.12' );
142         $scripts->add_data( 'jquery-ui-mouse', 'group', 1 );
143
144         $scripts->add( 'jquery-ui-button', '/wp-includes/js/jquery/ui.button.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.12' );
145         $scripts->add_data( 'jquery-ui-button', 'group', 1 );
146
147         $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.12' );
148         $scripts->add_data( 'jquery-ui-tabs', 'group', 1 );
149
150         $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.12' );
151         $scripts->add_data( 'jquery-ui-sortable', 'group', 1 );
152
153         $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui.draggable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.12' );
154         $scripts->add_data( 'jquery-ui-draggable', 'group', 1 );
155
156         $scripts->add( 'jquery-ui-droppable', '/wp-includes/js/jquery/ui.droppable.js', array('jquery-ui-core', 'jquery-ui-mouse', 'jquery-ui-draggable'), '1.8.12' );
157         $scripts->add_data( 'jquery-ui-droppable', 'group', 1 );
158
159         $scripts->add( 'jquery-ui-selectable', '/wp-includes/js/jquery/ui.selectable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.12' );
160         $scripts->add_data( 'jquery-ui-selectable', 'group', 1 );
161
162         $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.12' );
163         $scripts->add_data( 'jquery-ui-resizable', 'group', 1 );
164
165         $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.8.12' );
166         $scripts->add_data( 'jquery-ui-dialog', 'group', 1 );
167
168         // deprecated, not used in core, most functionality is included in jQuery 1.3
169         $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '2.73');
170         $scripts->add_data( 'jquery-form', 'group', 1 );
171
172         $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color$suffix.js", array('jquery'), '2.0-4561m');
173         $scripts->add_data( 'jquery-color', 'group', 1 );
174
175         $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113');
176         $scripts->add_data( 'suggest', 'group', 1 );
177
178         $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m');
179         $scripts->add_data( 'schedule', 'group', 1 );
180
181         $scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7' );
182         $scripts->add_data( 'jquery-query', 'group', 1 );
183
184         $scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2' );
185         $scripts->add_data( 'jquery-serialize-object', 'group', 1 );
186
187         $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m' );
188         $scripts->add_data( 'jquery-hotkeys', 'group', 1 );
189
190         $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), '20090102' );
191         $scripts->add_data( 'jquery-table-hotkeys', 'group', 1 );
192
193         $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20110528');
194         $scripts->add_data( 'thickbox', 'group', 1 );
195         $scripts->localize( 'thickbox', 'thickboxL10n', array(
196                         'next' => __('Next &gt;'),
197                         'prev' => __('&lt; Prev'),
198                         'image' => __('Image'),
199                         'of' => __('of'),
200                         'close' => __('Close'),
201                         'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
202                         'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
203                         'closeImage' => includes_url('js/thickbox/tb-close.png'),
204                         'l10n_print_after' => 'try{convertEntities(thickboxL10n);}catch(e){};'
205         ) );
206
207         $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop$suffix.js", array('jquery'), '0.9.8-20110113');
208
209         $scripts->add( 'swfobject', "/wp-includes/js/swfobject.js", false, '2.2');
210
211         $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2201-20110113');
212         $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201a');
213         $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201');
214         $scripts->add( 'swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201');
215
216         if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) {
217                 // queue all SWFUpload scripts that are used by default
218                 $scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201');
219         } else {
220                 $scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201a');
221         }
222
223         $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20110524');
224         $max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
225         if ( empty($max_upload_size) )
226                 $max_upload_size = __('not configured');
227         // these error messages came from the sample swfupload js, they might need changing.
228         $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array(
229                         'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
230                         'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'),
231                         'zero_byte_file' => __('This file is empty. Please try another.'),
232                         'invalid_filetype' => __('This file type is not allowed. Please try another.'),
233                         'default_error' => __('An error occurred in the upload. Please try again later.'),
234                         'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
235                         'upload_limit_exceeded' => __('You may only upload 1 file.'),
236                         'http_error' => __('HTTP error.'),
237                         'upload_failed' => __('Upload failed.'),
238                         'io_error' => __('IO error.'),
239                         'security_error' => __('Security error.'),
240                         'file_cancelled' => __('File canceled.'),
241                         'upload_stopped' => __('Upload stopped.'),
242                         'dismiss' => __('Dismiss'),
243                         'crunching' => __('Crunching&hellip;'),
244                         'deleted' => __('moved to the trash.'),
245                         'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error'),
246                         'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};',
247         ) );
248
249         $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102');
250
251         $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", false, '2011-02-23');
252
253         $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.6-20110515' );
254         $scripts->add_data( 'imgareaselect', 'group', 1 );
255
256         $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20101027' );
257         $scripts->add_data( 'password-strength-meter', 'group', 1 );
258         $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
259                 'empty' => __('Strength indicator'),
260                 'short' => __('Very weak'),
261                 'bad' => __('Weak'),
262                 /* translators: password strength */
263                 'good' => _x('Medium', 'password strength'),
264                 'strong' => __('Strong'),
265                 'mismatch' => __('Mismatch'),
266                 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
267         ) );
268
269         $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110628' );
270         $scripts->add_data( 'user-profile', 'group', 1 );
271
272         $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20110131' );
273         $scripts->add_data( 'admin-bar', 'group', 1 );
274
275         $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), '20110528' );
276         $scripts->add_data( 'wplink', 'group', 1 );
277         $scripts->localize( 'wplink', 'wpLinkL10n', array(
278                 'title' => __('Insert/edit link'),
279                 'update' => __('Update'),
280                 'save' => __('Add Link'),
281                 'noTitle' => __('(no title)'),
282                 'noMatchesFound' => __('No matches found.'),
283                 'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};',
284         ) );
285
286         $scripts->add( 'wpdialogs', "/wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), '20110528' );
287         $scripts->add_data( 'wpdialogs', 'group', 1 );
288
289         $scripts->add( 'wpdialogs-popup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", array( 'wpdialogs' ), '20110421' );
290         $scripts->add_data( 'wpdialogs-popup', 'group', 1 );
291
292         if ( is_admin() ) {
293                 $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );
294                 $scripts->add_data( 'ajaxcat', 'group', 1 );
295                 $scripts->localize( 'ajaxcat', 'catL10n', array(
296                         'add' => esc_attr(__('Add')),
297                         'how' => __('Separate multiple categories with commas.'),
298                         'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};'
299                 ) );
300
301                 $scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), '20091201' );
302                 $scripts->add_data( 'admin-categories', 'group', 1 );
303
304                 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), '20110429' );
305                 $scripts->add_data( 'admin-tags', 'group', 1 );
306                 $scripts->localize( 'admin-tags', 'tagsl10n', array(
307                         'noPerm' => __('You do not have permission to do that.'),
308                         'broken' => __('An unidentified error has occurred.'),
309                         'l10n_print_after' => 'try{convertEntities(tagsl10n);}catch(e){};'
310                 ));
311
312                 $scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20110429' );
313                 $scripts->add_data( 'admin-custom-fields', 'group', 1 );
314
315                 $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'jquery-query'), '20110602' );
316                 $scripts->add_data( 'admin-comments', 'group', 1 );
317                 $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
318                         'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
319                         'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
320                         'replyApprove' => __( 'Approve and Reply' ),
321                         'reply' => __( 'Reply' )
322                 ) );
323
324                 $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20110524' );
325                 $scripts->add_data( 'xfn', 'group', 1 );
326
327                 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20110612' );
328                 $scripts->add_data( 'postbox', 'group', 1 );
329
330                 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110524' );
331                 $scripts->add_data( 'post', 'group', 1 );
332                 $scripts->localize( 'post', 'postL10n', array(
333                         'tagsUsed' =>  __('Tags used on this post:'),
334                         'add' => esc_attr(__('Add')),
335                         'addTag' => esc_attr(__('Add new Tag')),
336                         'separate' => __('Separate tags with commas'),
337                         'ok' => __('OK'),
338                         'cancel' => __('Cancel'),
339                         'edit' => __('Edit'),
340                         'publishOn' => __('Publish on:'),
341                         'publishOnFuture' =>  __('Schedule for:'),
342                         'publishOnPast' => __('Published on:'),
343                         'showcomm' => __('Show more comments'),
344                         'endcomm' => __('No more comments found.'),
345                         'publish' => __('Publish'),
346                         'schedule' => __('Schedule'),
347                         'update' => __('Update'),
348                         'savePending' => __('Save as Pending'),
349                         'saveDraft' => __('Save Draft'),
350                         'private' => __('Private'),
351                         'public' => __('Public'),
352                         'publicSticky' => __('Public, Sticky'),
353                         'password' => __('Password Protected'),
354                         'privatelyPublished' => __('Privately Published'),
355                         'published' => __('Published'),
356                         'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
357                 ) );
358
359                 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), '20110524' );
360                 $scripts->add_data( 'link', 'group', 1 );
361
362                 $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery'), '20110429' );
363                 $scripts->add_data( 'comment', 'group', 1 );
364                 $scripts->localize( 'comment', 'commentL10n', array(
365                         'cancel' => __('Cancel'),
366                         'edit' => __('Edit'),
367                         'submittedOn' => __('Submitted on:'),
368                         'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'
369                 ) );
370
371                 $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20110414' );
372
373                 $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110425' );
374                 $scripts->add_data( 'media-upload', 'group', 1 );
375
376                 $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), '20110601' );
377                 $scripts->add_data( 'admin-widgets', 'group', 1 );
378
379                 $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20110515' );
380                 $scripts->add_data( 'word-count', 'group', 1 );
381
382                 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'thickbox' ), '20110118' );
383                 $scripts->add_data( 'theme', 'group', 1 );
384
385                 $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407' );
386                 $scripts->add_data( 'theme-preview', 'group', 1 );
387
388                 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20110609' );
389                 $scripts->add_data( 'inline-edit-post', 'group', 1 );
390                 $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
391                         'error' => __('Error while saving the changes.'),
392                         'ntdeltitle' => __('Remove From Bulk Edit'),
393                         'notitle' => __('(no title)'),
394                         'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
395                 ) );
396
397                 $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), '20110609' );
398                 $scripts->add_data( 'inline-edit-tax', 'group', 1 );
399                 $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
400                         'error' => __('Error while saving the changes.'),
401                         'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
402                 ) );
403
404                 $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), '20110113' );
405                 $scripts->add_data( 'plugin-install', 'group', 1 );
406                 $scripts->localize( 'plugin-install', 'plugininstallL10n', array(
407                         'plugin_information' => __('Plugin Information:'),
408                         'ays' => __('Are you sure you want to install this plugin?'),
409                         'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};'
410                 ) );
411
412                 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
413
414                 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20110524' );
415                 $scripts->add_data( 'dashboard', 'group', 1 );
416
417                 $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '20090102' );
418                 $scripts->add_data( 'hoverIntent', 'group', 1 );
419
420                 $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js", null, '20091223' );
421
422                 $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery-ui-draggable' ), '20101022' );
423                 $scripts->add_data( 'media', 'group', 1 );
424
425                 $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), '20110524' );
426                 $scripts->add_data( 'image-edit', 'group', 1 );
427
428                 $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), '20100518' );
429                 $scripts->add_data( 'set-post-thumbnail', 'group', 1 );
430                 $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
431                         'setThumbnail' => __( 'Use as featured image' ),
432                         'saving' => __( 'Saving...' ),
433                         'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
434                         'done' => __( 'Done' ),
435                         'l10n_print_after' => 'try{convertEntities(setPostThumbnailL10n);}catch(e){};'
436                 ) );
437
438                 // Navigation Menus
439                 $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array('jquery-ui-sortable'), '20110524' );
440                 $scripts->localize( 'nav-menu', 'navMenuL10n', array(
441                         'noResultsFound' => _x('No results found.', 'search results'),
442                         'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
443                         'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
444                         'l10n_print_after' => 'try{convertEntities(navMenuL10n);}catch(e){};'
445                 ) );
446
447                 $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20110511' );
448                 $scripts->add_data( 'custom-background', 'group', 1 );
449         }
450 }
451
452 /**
453  * Assign default styles to $styles object.
454  *
455  * Nothing is returned, because the $styles parameter is passed by reference.
456  * Meaning that whatever object is passed will be updated without having to
457  * reassign the variable that was passed back to the same value. This saves
458  * memory.
459  *
460  * Adding default styles is not the only task, it also assigns the base_url
461  * property, the default version, and text direction for the object.
462  *
463  * @since 2.6.0
464  *
465  * @param object $styles
466  */
467 function wp_default_styles( &$styles ) {
468         // This checks to see if site_url() returns something and if it does not
469         // then it assigns $guess_url to wp_guess_url(). Strange format, but it works.
470         if ( ! $guessurl = site_url() )
471                 $guessurl = wp_guess_url();
472
473         $styles->base_url = $guessurl;
474         $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
475         $styles->default_version = get_bloginfo( 'version' );
476         $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
477         $styles->default_dirs = array('/wp-admin/');
478
479         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
480
481         $rtl_styles = array( 'wp-admin', 'global', 'colors', 'colors-fresh', 'colors-classic', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'nav-menu', 'farbtastic', 'admin-bar', 'wplink', 'theme-install' );
482         // Any rtl stylesheets that don't have a .dev version for ltr
483         $no_suffix = array( 'farbtastic' );
484
485         $styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110627' );
486
487         $styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20110627' );
488         $styles->add_data( 'ie', 'conditional', 'lte IE 7' );
489
490         // all colors stylesheets need to have the same query strings (cache manifest compat)
491         $colors_version = '20110703';
492
493         // Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string.
494         $styles->add( 'colors', true, array(), $colors_version );
495
496         // do not refer to these directly, the right one is queued by the above "meta" colors handle
497         $styles->add( 'colors-fresh', "/wp-admin/css/colors-fresh$suffix.css", array(), $colors_version );
498         $styles->add( 'colors-classic', "/wp-admin/css/colors-classic$suffix.css", array(), $colors_version );
499
500         $styles->add( 'ms', "/wp-admin/css/ms$suffix.css", array(), '20110623' );
501         $styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20110627' );
502         $styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20110614' );
503         $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20110606' );
504         $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20110627' );
505         $styles->add( 'install', "/wp-admin/css/install$suffix.css", array(), '20110602' ); // Readme as well
506         $styles->add( 'theme-editor', "/wp-admin/css/theme-editor$suffix.css", array(), '20110602' );
507         $styles->add( 'press-this', "/wp-admin/css/press-this$suffix.css", array(), '20110611a' );
508         $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20090514' );
509         $styles->add( 'login', "/wp-admin/css/login$suffix.css", array(), '20110610' );
510         $styles->add( 'plugin-install', "/wp-admin/css/plugin-install$suffix.css", array(), '20110628' );
511         $styles->add( 'theme-install', "/wp-admin/css/theme-install$suffix.css", array(), '20110506' );
512         $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u' );
513         $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
514         $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' );
515         $styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20110611' );
516         $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20110622' );
517         $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array(), '20101224' );
518         $styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101224' );
519
520         foreach ( $rtl_styles as $rtl_style ) {
521                 $styles->add_data( $rtl_style, 'rtl', true );
522                 if ( $suffix && ! in_array( $rtl_style, $no_suffix ) )
523                         $styles->add_data( $rtl_style, 'suffix', $suffix );
524         }
525 }
526
527 /**
528  * Reorder JavaScript scripts array to place prototype before jQuery.
529  *
530  * @since 2.3.1
531  *
532  * @param array $js_array JavaScript scripst array
533  * @return array Reordered array, if needed.
534  */
535 function wp_prototype_before_jquery( $js_array ) {
536         if ( false === $jquery = array_search( 'jquery', $js_array, true ) )
537                 return $js_array;
538
539         if ( false === $prototype = array_search( 'prototype', $js_array, true ) )
540                 return $js_array;
541
542         if ( $prototype < $jquery )
543                 return $js_array;
544
545         unset($js_array[$prototype]);
546
547         array_splice( $js_array, $jquery, 0, 'prototype' );
548
549         return $js_array;
550 }
551
552 /**
553  * Load localized data on print rather than initialization.
554  *
555  * These localizations require information that may not be loaded even by init.
556  *
557  * @since 2.5.0
558  */
559 function wp_just_in_time_script_localization() {
560
561         wp_localize_script( 'autosave', 'autosaveL10n', array(
562                 'autosaveInterval' => AUTOSAVE_INTERVAL,
563                 'savingText' => __('Saving Draft&#8230;'),
564                 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
565                 'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};'
566         ) );
567
568 }
569
570 /**
571  * Administration Screen CSS for changing the styles.
572  *
573  * If installing the 'wp-admin/' directory will be replaced with './'.
574  *
575  * The $_wp_admin_css_colors global manages the Administration Screens CSS
576  * stylesheet that is loaded. The option that is set is 'admin_color' and is the
577  * color and key for the array. The value for the color key is an object with
578  * a 'url' parameter that has the URL path to the CSS file.
579  *
580  * The query from $src parameter will be appended to the URL that is given from
581  * the $_wp_admin_css_colors array value URL.
582  *
583  * @since 2.6.0
584  * @uses $_wp_admin_css_colors
585  *
586  * @param string $src Source URL.
587  * @param string $handle Either 'colors' or 'colors-rtl'.
588  * @return string URL path to CSS stylesheet for Administration Screens.
589  */
590 function wp_style_loader_src( $src, $handle ) {
591         if ( defined('WP_INSTALLING') )
592                 return preg_replace( '#^wp-admin/#', './', $src );
593
594         if ( 'colors' == $handle || 'colors-rtl' == $handle ) {
595                 global $_wp_admin_css_colors;
596                 $color = get_user_option('admin_color');
597
598                 if ( empty($color) || !isset($_wp_admin_css_colors[$color]) )
599                         $color = 'fresh';
600
601                 $color = $_wp_admin_css_colors[$color];
602                 $parsed = parse_url( $src );
603                 $url = $color->url;
604
605                 if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG )
606                         $url = preg_replace('/.css$|.css(?=\?)/', '.dev.css', $url);
607
608                 if ( isset($parsed['query']) && $parsed['query'] ) {
609                         wp_parse_str( $parsed['query'], $qv );
610                         $url = add_query_arg( $qv, $url );
611                 }
612
613                 return $url;
614         }
615
616         return $src;
617 }
618
619 /**
620  * Prints the script queue in the HTML head on admin pages.
621  *
622  * Postpones the scripts that were queued for the footer.
623  * print_footer_scripts() is called in the footer to print these scripts.
624  *
625  * @since 2.8
626  * @see wp_print_scripts()
627  */
628 function print_head_scripts() {
629         global $wp_scripts, $concatenate_scripts;
630
631         if ( ! did_action('wp_print_scripts') )
632                 do_action('wp_print_scripts');
633
634         if ( !is_a($wp_scripts, 'WP_Scripts') )
635                 $wp_scripts = new WP_Scripts();
636
637         script_concat_settings();
638         $wp_scripts->do_items( 'l10n' );
639         $wp_scripts->do_concat = $concatenate_scripts;
640         $wp_scripts->do_head_items();
641
642         if ( apply_filters('print_head_scripts', true) )
643                 _print_scripts();
644
645         $wp_scripts->reset();
646         return $wp_scripts->done;
647 }
648
649 /**
650  * Prints the scripts that were queued for the footer on admin pages.
651  *
652  * @since 2.8
653  */
654 function print_footer_scripts() {
655         global $wp_scripts, $concatenate_scripts;
656
657         if ( ! did_action('wp_print_footer_scripts') )
658                 do_action('wp_print_footer_scripts');
659
660         if ( !is_a($wp_scripts, 'WP_Scripts') )
661                 return array(); // No need to run if not instantiated.
662
663         script_concat_settings();
664         $wp_scripts->do_concat = $concatenate_scripts;
665         $wp_scripts->do_footer_items();
666
667         if ( apply_filters('print_footer_scripts', true) )
668                 _print_scripts();
669
670         $wp_scripts->reset();
671         return $wp_scripts->done;
672 }
673
674 function _print_scripts() {
675         global $wp_scripts, $compress_scripts;
676
677         $zip = $compress_scripts ? 1 : 0;
678         if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
679                 $zip = 'gzip';
680
681         if ( !empty($wp_scripts->concat) ) {
682
683                 if ( !empty($wp_scripts->print_code) ) {
684                         echo "<script type='text/javascript'>\n";
685                         echo "/* <![CDATA[ */\n";
686                         echo $wp_scripts->print_code;
687                         echo "/* ]]> */\n";
688                         echo "</script>\n";
689                 }
690
691                 $ver = md5("$wp_scripts->concat_version");
692                 $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . trim($wp_scripts->concat, ', ') . "&ver=$ver";
693                 echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n";
694         }
695
696         if ( !empty($wp_scripts->print_html) )
697                 echo $wp_scripts->print_html;
698 }
699
700 /**
701  * Prints the script queue in the HTML head on the front end.
702  *
703  * Postpones the scripts that were queued for the footer.
704  * wp_print_footer_scripts() is called in the footer to print these scripts.
705  *
706  * @since 2.8
707  */
708 function wp_print_head_scripts() {
709         if ( ! did_action('wp_print_scripts') )
710                 do_action('wp_print_scripts');
711
712         global $wp_scripts;
713
714         if ( !is_a($wp_scripts, 'WP_Scripts') )
715                 return array(); // no need to run if nothing is queued
716
717         return print_head_scripts();
718 }
719
720 /**
721  * Prints the scripts that were queued for the footer on the front end.
722  *
723  * @since 2.8
724  */
725 function wp_print_footer_scripts() {
726         return print_footer_scripts();
727 }
728
729 /**
730  * Wrapper for do_action('wp_enqueue_scripts')
731  *
732  * Allows plugins to queue scripts for the front end using wp_enqueue_script().
733  * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
734  *
735  * @since 2.8
736  */
737 function wp_enqueue_scripts() {
738         do_action('wp_enqueue_scripts');
739 }
740
741 function print_admin_styles() {
742         global $wp_styles, $concatenate_scripts, $compress_css;
743
744         if ( !is_a($wp_styles, 'WP_Styles') )
745                 $wp_styles = new WP_Styles();
746
747         script_concat_settings();
748         $wp_styles->do_concat = $concatenate_scripts;
749         $zip = $compress_css ? 1 : 0;
750         if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
751                 $zip = 'gzip';
752
753         $wp_styles->do_items(false);
754
755         if ( apply_filters('print_admin_styles', true) ) {
756                 if ( !empty($wp_styles->concat) ) {
757                         $dir = $wp_styles->text_direction;
758                         $ver = md5("$wp_styles->concat_version{$dir}");
759                         $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . "&ver=$ver";
760                         echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
761                 }
762
763                 if ( !empty($wp_styles->print_html) )
764                         echo $wp_styles->print_html;
765         }
766
767         $wp_styles->do_concat = false;
768         $wp_styles->concat = $wp_styles->concat_version = $wp_styles->print_html = '';
769         return $wp_styles->done;
770 }
771
772 function script_concat_settings() {
773         global $concatenate_scripts, $compress_scripts, $compress_css;
774
775         $compressed_output = ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') );
776
777         if ( ! isset($concatenate_scripts) ) {
778                 $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true;
779                 if ( ! is_admin() || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) )
780                         $concatenate_scripts = false;
781         }
782
783         if ( ! isset($compress_scripts) ) {
784                 $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true;
785                 if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
786                         $compress_scripts = false;
787         }
788
789         if ( ! isset($compress_css) ) {
790                 $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true;
791                 if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
792                         $compress_css = false;
793         }
794 }
795
796 add_action( 'wp_default_scripts', 'wp_default_scripts' );
797 add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
798 add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
799
800 add_action( 'wp_default_styles', 'wp_default_styles' );
801 add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );