|
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 disables compression and concatenation |
|
12 * define('CONCATENATE_SCRIPTS', false); disables compression and concatenation, |
|
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 * Setup WordPress scripts to load by default for Administration Panels. |
|
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 $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' ); |
|
62 |
|
63 $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090609' ); |
|
64 $scripts->add_data( 'common', 'group', 1 ); |
|
65 $scripts->localize( 'common', 'commonL10n', array( |
|
66 'warnDelete' => __("You are about to delete the selected items.\n 'Cancel' to stop, 'OK' to delete."), |
|
67 'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};' |
|
68 ) ); |
|
69 |
|
70 $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1' ); |
|
71 $scripts->add_data( 'sack', 'group', 1 ); |
|
72 |
|
73 $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20090307' ); |
|
74 $scripts->localize( 'quicktags', 'quicktagsL10n', array( |
|
75 'quickLinks' => __('(Quick Links)'), |
|
76 'wordLookup' => __('Enter a word to look up:'), |
|
77 'dictionaryLookup' => esc_attr(__('Dictionary lookup')), |
|
78 'lookup' => esc_attr(__('lookup')), |
|
79 'closeAllOpenTags' => esc_attr(__('Close all open tags')), |
|
80 'closeTags' => esc_attr(__('close tags')), |
|
81 'enterURL' => __('Enter the URL'), |
|
82 'enterImageURL' => __('Enter the URL of the image'), |
|
83 'enterImageDescription' => __('Enter a description of the image'), |
|
84 'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};' |
|
85 ) ); |
|
86 |
|
87 $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' ); |
|
88 |
|
89 $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", false, '20090503' ); |
|
90 |
|
91 $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6'); |
|
92 |
|
93 $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), '20090128' ); |
|
94 $scripts->add_data( 'wp-ajax-response', 'group', 1 ); |
|
95 $scripts->localize( 'wp-ajax-response', 'wpAjax', array( |
|
96 'noPerm' => __('You do not have permission to do that.'), |
|
97 'broken' => __('An unidentified error has occurred.'), |
|
98 'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};' |
|
99 ) ); |
|
100 |
|
101 $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20090526' ); |
|
102 $scripts->add_data( 'autosave', 'group', 1 ); |
|
103 |
|
104 $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20090504' ); |
|
105 $scripts->add_data( 'wp-lists', 'group', 1 ); |
|
106 $scripts->localize( 'wp-lists', 'wpListL10n', array( |
|
107 'url' => admin_url('admin-ajax.php') |
|
108 ) ); |
|
109 |
|
110 $scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.8.0'); |
|
111 $scripts->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.8.0'); |
|
112 $scripts->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.8.0'); |
|
113 $scripts->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.8.0'); |
|
114 $scripts->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.8.0'); |
|
115 $scripts->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.8.0' ); |
|
116 $scripts->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.8.0'); |
|
117 $scripts->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.8.0'); |
|
118 |
|
119 $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118'); |
|
120 |
|
121 $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.3.2'); |
|
122 |
|
123 $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.7.1' ); |
|
124 $scripts->add_data( 'jquery-ui-core', 'group', 1 ); |
|
125 |
|
126 $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core'), '1.7.1' ); |
|
127 $scripts->add_data( 'jquery-ui-tabs', 'group', 1 ); |
|
128 |
|
129 $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core'), '1.7.1' ); |
|
130 $scripts->add_data( 'jquery-ui-sortable', 'group', 1 ); |
|
131 |
|
132 $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui.draggable.js', array('jquery-ui-core'), '1.7.1' ); |
|
133 $scripts->add_data( 'jquery-ui-draggable', 'group', 1 ); |
|
134 |
|
135 $scripts->add( 'jquery-ui-droppable', '/wp-includes/js/jquery/ui.droppable.js', array('jquery-ui-core'), '1.7.1' ); |
|
136 $scripts->add_data( 'jquery-ui-droppable', 'group', 1 ); |
|
137 |
|
138 $scripts->add( 'jquery-ui-selectable', '/wp-includes/js/jquery/ui.selectable.js', array('jquery-ui-core'), '1.7.1' ); |
|
139 $scripts->add_data( 'jquery-ui-selectable', 'group', 1 ); |
|
140 |
|
141 $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.7.1' ); |
|
142 $scripts->add_data( 'jquery-ui-resizable', 'group', 1 ); |
|
143 |
|
144 $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.7.1' ); |
|
145 $scripts->add_data( 'jquery-ui-dialog', 'group', 1 ); |
|
146 |
|
147 $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '2.02m'); |
|
148 $scripts->add_data( 'jquery-form', 'group', 1 ); |
|
149 |
|
150 $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color$suffix.js", array('jquery'), '2.0-4561m'); |
|
151 $scripts->add_data( 'jquery-color', 'group', 1 ); |
|
152 |
|
153 $scripts->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2' ); |
|
154 |
|
155 $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20090125'); |
|
156 $scripts->add_data( 'suggest', 'group', 1 ); |
|
157 |
|
158 $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m'); |
|
159 $scripts->add_data( 'schedule', 'group', 1 ); |
|
160 |
|
161 $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m' ); |
|
162 $scripts->add_data( 'jquery-hotkeys', 'group', 1 ); |
|
163 |
|
164 $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), '20090102' ); |
|
165 $scripts->add_data( 'jquery-table-hotkeys', 'group', 1 ); |
|
166 |
|
167 $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20090123'); |
|
168 $scripts->add_data( 'thickbox', 'group', 1 ); |
|
169 |
|
170 $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop$suffix.js", array('jquery'), '0.9.8'); |
|
171 |
|
172 $scripts->add( 'swfobject', "/wp-includes/js/swfobject.js", false, '2.1'); |
|
173 |
|
174 $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2201'); |
|
175 $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201'); |
|
176 $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201'); |
|
177 $scripts->add( 'swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201'); |
|
178 |
|
179 if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) { |
|
180 // queue all SWFUpload scripts that are used by default |
|
181 $scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201'); |
|
182 } else { |
|
183 $scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201'); |
|
184 } |
|
185 |
|
186 $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20090515'); |
|
187 // these error messages came from the sample swfupload js, they might need changing. |
|
188 $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array( |
|
189 'queue_limit_exceeded' => __('You have attempted to queue too many files.'), |
|
190 'file_exceeds_size_limit' => sprintf(__('This file is too big. Your php.ini upload_max_filesize is %s.'), @ini_get('upload_max_filesize')), |
|
191 'zero_byte_file' => __('This file is empty. Please try another.'), |
|
192 'invalid_filetype' => __('This file type is not allowed. Please try another.'), |
|
193 'default_error' => __('An error occurred in the upload. Please try again later.'), |
|
194 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'), |
|
195 'upload_limit_exceeded' => __('You may only upload 1 file.'), |
|
196 'http_error' => __('HTTP error.'), |
|
197 'upload_failed' => __('Upload failed.'), |
|
198 'io_error' => __('IO error.'), |
|
199 'security_error' => __('Security error.'), |
|
200 'file_cancelled' => __('File cancelled.'), |
|
201 'upload_stopped' => __('Upload stopped.'), |
|
202 'dismiss' => __('Dismiss'), |
|
203 'crunching' => __('Crunching…'), |
|
204 'deleted' => __('Deleted'), |
|
205 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' |
|
206 ) ); |
|
207 |
|
208 $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102'); |
|
209 |
|
210 if ( is_admin() ) { |
|
211 $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' ); |
|
212 $scripts->add_data( 'ajaxcat', 'group', 1 ); |
|
213 $scripts->localize( 'ajaxcat', 'catL10n', array( |
|
214 'add' => esc_attr(__('Add')), |
|
215 'how' => __('Separate multiple categories with commas.'), |
|
216 'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};' |
|
217 ) ); |
|
218 |
|
219 $scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), '20090207' ); |
|
220 $scripts->add_data( 'admin-categories', 'group', 1 ); |
|
221 |
|
222 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('wp-lists'), '20090211' ); |
|
223 $scripts->add_data( 'admin-tags', 'group', 1 ); |
|
224 |
|
225 $scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' ); |
|
226 $scripts->add_data( 'admin-custom-fields', 'group', 1 ); |
|
227 |
|
228 $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20090102' ); |
|
229 $scripts->add_data( 'password-strength-meter', 'group', 1 ); |
|
230 $scripts->localize( 'password-strength-meter', 'pwsL10n', array( |
|
231 'empty' => __('Strength indicator'), |
|
232 'short' => __('Very weak'), |
|
233 'bad' => __('Weak'), |
|
234 /* translators: password strength */ |
|
235 'good' => _x('Medium', 'password strength'), |
|
236 'strong' => __('Strong'), |
|
237 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};' |
|
238 ) ); |
|
239 |
|
240 $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20090514' ); |
|
241 $scripts->add_data( 'user-profile', 'group', 1 ); |
|
242 |
|
243 $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090627' ); |
|
244 $scripts->add_data( 'admin-comments', 'group', 1 ); |
|
245 $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( |
|
246 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), |
|
247 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']) |
|
248 ) ); |
|
249 |
|
250 $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", false, '3517m' ); |
|
251 |
|
252 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20090618' ); |
|
253 $scripts->add_data( 'postbox', 'group', 1 ); |
|
254 $scripts->localize( 'postbox', 'postboxL10n', array( |
|
255 'requestFile' => admin_url('admin-ajax.php') |
|
256 ) ); |
|
257 |
|
258 $scripts->add( 'slug', "/wp-admin/js/slug$suffix.js", array('jquery'), '20090207' ); |
|
259 $scripts->add_data( 'slug', 'group', 1 ); |
|
260 $scripts->localize( 'slug', 'slugL10n', array( |
|
261 'requestFile' => admin_url('admin-ajax.php'), |
|
262 'save' => __('Save'), |
|
263 'cancel' => __('Cancel'), |
|
264 'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};' |
|
265 ) ); |
|
266 |
|
267 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox', 'slug'), '20090624' ); |
|
268 $scripts->add_data( 'post', 'group', 1 ); |
|
269 $scripts->localize( 'post', 'postL10n', array( |
|
270 'tagsUsed' => __('Tags used on this post:'), |
|
271 'add' => esc_attr(__('Add')), |
|
272 'addTag' => esc_attr(__('Add new tag')), |
|
273 'separate' => __('Separate tags with commas'), |
|
274 'cancel' => __('Cancel'), |
|
275 'edit' => __('Edit'), |
|
276 'publishOn' => __('Publish on:'), |
|
277 'publishOnFuture' => __('Schedule for:'), |
|
278 'publishOnPast' => __('Published on:'), |
|
279 'showcomm' => __('Show more comments'), |
|
280 'endcomm' => __('No more comments found.'), |
|
281 'publish' => __('Publish'), |
|
282 'schedule' => __('Schedule'), |
|
283 'update' => __('Update Post'), |
|
284 'savePending' => __('Save as Pending'), |
|
285 'saveDraft' => __('Save Draft'), |
|
286 'private' => __('Private'), |
|
287 'public' => __('Public'), |
|
288 'publicSticky' => __('Public, Sticky'), |
|
289 'password' => __('Password Protected'), |
|
290 'privatelyPublished' => __('Privately Published'), |
|
291 'published' => __('Published'), |
|
292 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' |
|
293 ) ); |
|
294 |
|
295 $scripts->add( 'page', "/wp-admin/js/page$suffix.js", array('jquery', 'slug', 'wp-lists', 'postbox'), '20090526' ); |
|
296 $scripts->add_data( 'page', 'group', 1 ); |
|
297 $scripts->localize( 'page', 'postL10n', array( |
|
298 'cancel' => __('Cancel'), |
|
299 'edit' => __('Edit'), |
|
300 'publishOn' => __('Publish on:'), |
|
301 'publishOnFuture' => __('Schedule for:'), |
|
302 'publishOnPast' => __('Published on:'), |
|
303 'showcomm' => __('Show more comments'), |
|
304 'endcomm' => __('No more comments found.'), |
|
305 'publish' => __('Publish'), |
|
306 'schedule' => __('Schedule'), |
|
307 'update' => __('Update Page'), |
|
308 'savePending' => __('Save as Pending'), |
|
309 'saveDraft' => __('Save Draft'), |
|
310 'private' => __('Private'), |
|
311 'public' => __('Public'), |
|
312 'password' => __('Password Protected'), |
|
313 'privatelyPublished' => __('Privately Published'), |
|
314 'published' => __('Published'), |
|
315 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' |
|
316 ) ); |
|
317 |
|
318 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), '20090506' ); |
|
319 $scripts->add_data( 'link', 'group', 1 ); |
|
320 |
|
321 $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery'), '20090102' ); |
|
322 $scripts->add_data( 'comment', 'group', 1 ); |
|
323 $scripts->localize( 'comment', 'commentL10n', array( |
|
324 'cancel' => __('Cancel'), |
|
325 'edit' => __('Edit'), |
|
326 'submittedOn' => __('Submitted on:'), |
|
327 'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};' |
|
328 ) ); |
|
329 |
|
330 $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090516' ); |
|
331 |
|
332 $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20090114' ); |
|
333 $scripts->add_data( 'media-upload', 'group', 1 ); |
|
334 |
|
335 $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), '20090601' ); |
|
336 $scripts->add_data( 'admin-widgets', 'group', 1 ); |
|
337 |
|
338 $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20090422' ); |
|
339 $scripts->add_data( 'word-count', 'group', 1 ); |
|
340 $scripts->localize( 'word-count', 'wordCountL10n', array( |
|
341 'count' => __('Word count: %d'), |
|
342 'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};' |
|
343 )); |
|
344 |
|
345 $scripts->add( 'wp-gears', "/wp-admin/js/wp-gears$suffix.js", false, '20090102' ); |
|
346 $scripts->localize( 'wp-gears', 'wpGearsL10n', array( |
|
347 'updateCompleted' => __('Update completed.'), |
|
348 'error' => __('Error:'), |
|
349 'l10n_print_after' => 'try{convertEntities(wpGearsL10n);}catch(e){};' |
|
350 )); |
|
351 |
|
352 $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20090319' ); |
|
353 $scripts->add_data( 'theme-preview', 'group', 1 ); |
|
354 |
|
355 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery-form', 'suggest' ), '20090125' ); |
|
356 $scripts->add_data( 'inline-edit-post', 'group', 1 ); |
|
357 $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( |
|
358 'error' => __('Error while saving the changes.'), |
|
359 'ntdeltitle' => __('Remove From Bulk Edit'), |
|
360 'notitle' => __('(no title)'), |
|
361 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' |
|
362 ) ); |
|
363 |
|
364 $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery-form' ), '20090211' ); |
|
365 $scripts->add_data( 'inline-edit-tax', 'group', 1 ); |
|
366 $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( |
|
367 'error' => __('Error while saving the changes.'), |
|
368 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' |
|
369 ) ); |
|
370 |
|
371 $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery' ), '20090520' ); |
|
372 $scripts->add_data( 'plugin-install', 'group', 1 ); |
|
373 $scripts->localize( 'plugin-install', 'plugininstallL10n', array( |
|
374 'plugin_information' => __('Plugin Information:'), |
|
375 'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};' |
|
376 ) ); |
|
377 |
|
378 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); |
|
379 |
|
380 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20090618' ); |
|
381 $scripts->add_data( 'dashboard', 'group', 1 ); |
|
382 |
|
383 $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '20090102' ); |
|
384 $scripts->add_data( 'hoverIntent', 'group', 1 ); |
|
385 |
|
386 $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery-ui-draggable' ), '20090415' ); |
|
387 $scripts->add_data( 'media', 'group', 1 ); |
|
388 |
|
389 $scripts->add( 'codepress', '/wp-includes/js/codepress/codepress.js', false, '0.9.6' ); |
|
390 $scripts->add_data( 'codepress', 'group', 1 ); |
|
391 } |
|
392 } |
|
393 |
|
394 /** |
|
395 * Assign default styles to $styles object. |
|
396 * |
|
397 * Nothing is returned, because the $styles parameter is passed by reference. |
|
398 * Meaning that whatever object is passed will be updated without having to |
|
399 * reassign the variable that was passed back to the same value. This saves |
|
400 * memory. |
|
401 * |
|
402 * Adding default styles is not the only task, it also assigns the base_url |
|
403 * property, the default version, and text direction for the object. |
|
404 * |
|
405 * @since 2.6.0 |
|
406 * |
|
407 * @param object $styles |
|
408 */ |
|
409 function wp_default_styles( &$styles ) { |
|
410 // This checks to see if site_url() returns something and if it does not |
|
411 // then it assigns $guess_url to wp_guess_url(). Strange format, but it works. |
|
412 if ( ! $guessurl = site_url() ) |
|
413 $guessurl = wp_guess_url(); |
|
414 |
|
415 $styles->base_url = $guessurl; |
|
416 $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : ''; |
|
417 $styles->default_version = get_bloginfo( 'version' ); |
|
418 $styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr'; |
|
419 $styles->default_dirs = array('/wp-admin/'); |
|
420 |
|
421 $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' ); |
|
422 |
|
423 // all colors stylesheets need to have the same query strings (cache manifest compat) |
|
424 $colors_version = '20090625'; |
|
425 |
|
426 $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20090625' ); |
|
427 $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' ); |
|
428 |
|
429 $styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20090630' ); |
|
430 $styles->add_data( 'ie', 'conditional', 'lte IE 7' ); |
|
431 |
|
432 // Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string. |
|
433 $styles->add( 'colors', true, array(), $colors_version ); |
|
434 |
|
435 // do not refer to these directly, the right one is queued by the above "meta" colors handle |
|
436 $styles->add( 'colors-fresh', '/wp-admin/css/colors-fresh.css', array(), $colors_version); |
|
437 $styles->add_data( 'colors-fresh', 'rtl', true ); |
|
438 $styles->add( 'colors-classic', '/wp-admin/css/colors-classic.css', array(), $colors_version); |
|
439 $styles->add_data( 'colors-classic', 'rtl', true ); |
|
440 |
|
441 $styles->add( 'global', '/wp-admin/css/global.css', array(), '20090630' ); |
|
442 $styles->add( 'media', '/wp-admin/css/media.css', array(), '20090516' ); |
|
443 $styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20090603' ); |
|
444 $styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20090514' ); |
|
445 $styles->add( 'install', '/wp-admin/css/install.css', array(), '20090514' ); |
|
446 $styles->add( 'theme-editor', '/wp-admin/css/theme-editor.css', array(), '20090625' ); |
|
447 $styles->add( 'press-this', '/wp-admin/css/press-this.css', array(), '20090514' ); |
|
448 $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20090514' ); |
|
449 $styles->add( 'login', '/wp-admin/css/login.css', array(), '20090514' ); |
|
450 $styles->add( 'plugin-install', '/wp-admin/css/plugin-install.css', array(), '20090514' ); |
|
451 $styles->add( 'theme-install', '/wp-admin/css/theme-install.css', array(), '20090610' ); |
|
452 $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' ); |
|
453 $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' ); |
|
454 |
|
455 foreach ( $rtl_styles as $rtl_style ) |
|
456 $styles->add_data( $rtl_style, 'rtl', true ); |
|
457 } |
|
458 |
|
459 /** |
|
460 * Reorder JavaScript scripts array to place prototype before jQuery. |
|
461 * |
|
462 * @since 2.3.1 |
|
463 * |
|
464 * @param array $js_array JavaScript scripst array |
|
465 * @return array Reordered array, if needed. |
|
466 */ |
|
467 function wp_prototype_before_jquery( $js_array ) { |
|
468 if ( false === $jquery = array_search( 'jquery', $js_array, true ) ) |
|
469 return $js_array; |
|
470 |
|
471 if ( false === $prototype = array_search( 'prototype', $js_array, true ) ) |
|
472 return $js_array; |
|
473 |
|
474 if ( $prototype < $jquery ) |
|
475 return $js_array; |
|
476 |
|
477 unset($js_array[$prototype]); |
|
478 |
|
479 array_splice( $js_array, $jquery, 0, 'prototype' ); |
|
480 |
|
481 return $js_array; |
|
482 } |
|
483 |
|
484 /** |
|
485 * Load localized script just in time for MCE. |
|
486 * |
|
487 * These localizations require information that may not be loaded even by init. |
|
488 * |
|
489 * @since 2.5.0 |
|
490 */ |
|
491 function wp_just_in_time_script_localization() { |
|
492 |
|
493 wp_localize_script( 'autosave', 'autosaveL10n', array( |
|
494 'autosaveInterval' => AUTOSAVE_INTERVAL, |
|
495 'previewPageText' => __('Preview this Page'), |
|
496 'previewPostText' => __('Preview this Post'), |
|
497 'requestFile' => admin_url('admin-ajax.php'), |
|
498 'savingText' => __('Saving Draft…'), |
|
499 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), |
|
500 'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};' |
|
501 ) ); |
|
502 } |
|
503 |
|
504 /** |
|
505 * Administration Panel CSS for changing the styles. |
|
506 * |
|
507 * If installing the 'wp-admin/' directory will be replaced with './'. |
|
508 * |
|
509 * The $_wp_admin_css_colors global manages the Administration Panels CSS |
|
510 * stylesheet that is loaded. The option that is set is 'admin_color' and is the |
|
511 * color and key for the array. The value for the color key is an object with |
|
512 * a 'url' parameter that has the URL path to the CSS file. |
|
513 * |
|
514 * The query from $src parameter will be appended to the URL that is given from |
|
515 * the $_wp_admin_css_colors array value URL. |
|
516 * |
|
517 * @since 2.6.0 |
|
518 * @uses $_wp_admin_css_colors |
|
519 * |
|
520 * @param string $src Source URL. |
|
521 * @param string $handle Either 'colors' or 'colors-rtl'. |
|
522 * @return string URL path to CSS stylesheet for Administration Panels. |
|
523 */ |
|
524 function wp_style_loader_src( $src, $handle ) { |
|
525 if ( defined('WP_INSTALLING') ) |
|
526 return preg_replace( '#^wp-admin/#', './', $src ); |
|
527 |
|
528 if ( 'colors' == $handle || 'colors-rtl' == $handle ) { |
|
529 global $_wp_admin_css_colors; |
|
530 $color = get_user_option('admin_color'); |
|
531 if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) |
|
532 $color = 'fresh'; |
|
533 $color = $_wp_admin_css_colors[$color]; |
|
534 $parsed = parse_url( $src ); |
|
535 $url = $color->url; |
|
536 if ( isset($parsed['query']) && $parsed['query'] ) { |
|
537 wp_parse_str( $parsed['query'], $qv ); |
|
538 $url = add_query_arg( $qv, $url ); |
|
539 } |
|
540 return $url; |
|
541 } |
|
542 |
|
543 return $src; |
|
544 } |
|
545 |
|
546 /** |
|
547 * Prints the script queue in the HTML head on admin pages. |
|
548 * |
|
549 * Postpones the scripts that were queued for the footer. |
|
550 * print_footer_scripts() is called in the footer to print these scripts. |
|
551 * |
|
552 * @since 2.8 |
|
553 * @see wp_print_scripts() |
|
554 */ |
|
555 function print_head_scripts() { |
|
556 global $wp_scripts, $concatenate_scripts; |
|
557 |
|
558 if ( ! did_action('wp_print_scripts') ) |
|
559 do_action('wp_print_scripts'); |
|
560 |
|
561 if ( !is_a($wp_scripts, 'WP_Scripts') ) |
|
562 $wp_scripts = new WP_Scripts(); |
|
563 |
|
564 script_concat_settings(); |
|
565 $wp_scripts->do_concat = $concatenate_scripts; |
|
566 $wp_scripts->do_head_items(); |
|
567 |
|
568 if ( apply_filters('print_head_scripts', true) ) |
|
569 _print_scripts(); |
|
570 |
|
571 $wp_scripts->reset(); |
|
572 return $wp_scripts->done; |
|
573 } |
|
574 |
|
575 /** |
|
576 * Prints the scripts that were queued for the footer on admin pages. |
|
577 * |
|
578 * @since 2.8 |
|
579 */ |
|
580 function print_footer_scripts() { |
|
581 global $wp_scripts, $concatenate_scripts; |
|
582 |
|
583 if ( ! did_action('wp_print_footer_scripts') ) |
|
584 do_action('wp_print_footer_scripts'); |
|
585 |
|
586 if ( !is_a($wp_scripts, 'WP_Scripts') ) |
|
587 return array(); // No need to run if not instantiated. |
|
588 |
|
589 script_concat_settings(); |
|
590 $wp_scripts->do_concat = $concatenate_scripts; |
|
591 $wp_scripts->do_footer_items(); |
|
592 |
|
593 if ( apply_filters('print_footer_scripts', true) ) |
|
594 _print_scripts(); |
|
595 |
|
596 $wp_scripts->reset(); |
|
597 return $wp_scripts->done; |
|
598 } |
|
599 |
|
600 function _print_scripts() { |
|
601 global $wp_scripts, $compress_scripts; |
|
602 |
|
603 $zip = $compress_scripts ? 1 : 0; |
|
604 if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) |
|
605 $zip = 'gzip'; |
|
606 |
|
607 if ( !empty($wp_scripts->concat) ) { |
|
608 |
|
609 if ( !empty($wp_scripts->print_code) ) { |
|
610 echo "<script type='text/javascript'>\n"; |
|
611 echo "/* <![CDATA[ */\n"; |
|
612 echo $wp_scripts->print_code; |
|
613 echo "/* ]]> */\n"; |
|
614 echo "</script>\n"; |
|
615 } |
|
616 |
|
617 $ver = md5("$wp_scripts->concat_version"); |
|
618 $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . trim($wp_scripts->concat, ', ') . "&ver=$ver"; |
|
619 echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n"; |
|
620 } |
|
621 |
|
622 if ( !empty($wp_scripts->print_html) ) |
|
623 echo $wp_scripts->print_html; |
|
624 } |
|
625 |
|
626 /** |
|
627 * Prints the script queue in the HTML head on the front end. |
|
628 * |
|
629 * Postpones the scripts that were queued for the footer. |
|
630 * wp_print_footer_scripts() is called in the footer to print these scripts. |
|
631 * |
|
632 * @since 2.8 |
|
633 */ |
|
634 function wp_print_head_scripts() { |
|
635 if ( ! did_action('wp_print_scripts') ) |
|
636 do_action('wp_print_scripts'); |
|
637 |
|
638 global $wp_scripts; |
|
639 |
|
640 if ( !is_a($wp_scripts, 'WP_Scripts') ) |
|
641 return array(); // no need to run if nothing is queued |
|
642 |
|
643 return print_head_scripts(); |
|
644 } |
|
645 |
|
646 /** |
|
647 * Prints the scripts that were queued for the footer on the front end. |
|
648 * |
|
649 * @since 2.8 |
|
650 */ |
|
651 function wp_print_footer_scripts() { |
|
652 return print_footer_scripts(); |
|
653 } |
|
654 |
|
655 /** |
|
656 * Wrapper for do_action('wp_enqueue_scripts') |
|
657 * |
|
658 * Allows plugins to queue scripts for the front end using wp_enqueue_script(). |
|
659 * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available. |
|
660 * |
|
661 * @since 2.8 |
|
662 */ |
|
663 function wp_enqueue_scripts() { |
|
664 do_action('wp_enqueue_scripts'); |
|
665 } |
|
666 |
|
667 function print_admin_styles() { |
|
668 global $wp_styles, $concatenate_scripts, $compress_css; |
|
669 |
|
670 if ( !is_a($wp_styles, 'WP_Styles') ) |
|
671 $wp_styles = new WP_Styles(); |
|
672 |
|
673 script_concat_settings(); |
|
674 $wp_styles->do_concat = $concatenate_scripts; |
|
675 $zip = $compress_css ? 1 : 0; |
|
676 if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) |
|
677 $zip = 'gzip'; |
|
678 |
|
679 $wp_styles->do_items(false); |
|
680 |
|
681 if ( apply_filters('print_admin_styles', true) ) { |
|
682 if ( !empty($wp_styles->concat) ) { |
|
683 $dir = $wp_styles->text_direction; |
|
684 $ver = md5("$wp_styles->concat_version{$dir}"); |
|
685 $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . "&ver=$ver"; |
|
686 echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n"; |
|
687 } |
|
688 |
|
689 if ( !empty($wp_styles->print_html) ) |
|
690 echo $wp_styles->print_html; |
|
691 } |
|
692 |
|
693 $wp_styles->do_concat = false; |
|
694 $wp_styles->concat = $wp_styles->concat_version = $wp_styles->print_html = ''; |
|
695 return $wp_styles->done; |
|
696 } |
|
697 |
|
698 function script_concat_settings() { |
|
699 global $concatenate_scripts, $compress_scripts, $compress_css; |
|
700 |
|
701 $compressed_output = ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ); |
|
702 |
|
703 if ( ! isset($concatenate_scripts) ) { |
|
704 $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true; |
|
705 if ( ! is_admin() || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ) |
|
706 $concatenate_scripts = false; |
|
707 } |
|
708 |
|
709 if ( ! isset($compress_scripts) ) { |
|
710 $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true; |
|
711 if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) |
|
712 $compress_scripts = false; |
|
713 } |
|
714 |
|
715 if ( ! isset($compress_css) ) { |
|
716 $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true; |
|
717 if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) |
|
718 $compress_css = false; |
|
719 } |
|
720 } |
|
721 |
|
722 add_action( 'wp_default_scripts', 'wp_default_scripts' ); |
|
723 add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); |
|
724 add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); |
|
725 |
|
726 add_action( 'wp_default_styles', 'wp_default_styles' ); |
|
727 add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); |