Projects : mp-wp : mp-wp_genesis
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 | * @package WordPress |
11 | */ |
12 | |
13 | /** BackPress: WordPress Dependencies Class */ |
14 | require( ABSPATH . WPINC . '/class.wp-dependencies.php' ); |
15 | |
16 | /** BackPress: WordPress Scripts Class */ |
17 | require( ABSPATH . WPINC . '/class.wp-scripts.php' ); |
18 | |
19 | /** BackPress: WordPress Scripts Functions */ |
20 | require( ABSPATH . WPINC . '/functions.wp-scripts.php' ); |
21 | |
22 | /** BackPress: WordPress Styles Class */ |
23 | require( ABSPATH . WPINC . '/class.wp-styles.php' ); |
24 | |
25 | /** BackPress: WordPress Styles Functions */ |
26 | require( ABSPATH . WPINC . '/functions.wp-styles.php' ); |
27 | |
28 | /** |
29 | * Setup WordPress scripts to load by default for Administration Panels. |
30 | * |
31 | * Localizes a few of the scripts. |
32 | * |
33 | * @since 2.6.0 |
34 | * |
35 | * @param object $scripts WP_Scripts object. |
36 | */ |
37 | function wp_default_scripts( &$scripts ) { |
38 | if (!$guessurl = site_url()) |
39 | $guessurl = wp_guess_url(); |
40 | |
41 | $scripts->base_url = $guessurl; |
42 | $scripts->default_version = get_bloginfo( 'version' ); |
43 | |
44 | $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'hoverIntent'), '20081210' ); |
45 | $scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); |
46 | |
47 | $scripts->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '20081210' ); |
48 | $scripts->localize( 'quicktags', 'quicktagsL10n', array( |
49 | 'quickLinks' => __('(Quick Links)'), |
50 | 'wordLookup' => __('Enter a word to look up:'), |
51 | 'dictionaryLookup' => attribute_escape(__('Dictionary lookup')), |
52 | 'lookup' => attribute_escape(__('lookup')), |
53 | 'closeAllOpenTags' => attribute_escape(__('Close all open tags')), |
54 | 'closeTags' => attribute_escape(__('close tags')), |
55 | 'enterURL' => __('Enter the URL'), |
56 | 'enterImageURL' => __('Enter the URL of the image'), |
57 | 'enterImageDescription' => __('Enter a description of the image'), |
58 | 'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};' |
59 | ) ); |
60 | |
61 | $scripts->add( 'colorpicker', '/wp-includes/js/colorpicker.js', array('prototype'), '3517' ); |
62 | |
63 | // Modify this version when tinyMCE plugins are changed. |
64 | function mce_version() { |
65 | return '20081129'; |
66 | } |
67 | add_filter( 'tiny_mce_version', 'mce_version' ); |
68 | |
69 | $scripts->add( 'editor', '/wp-admin/js/editor.js', false, mce_version() ); |
70 | |
71 | $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6'); |
72 | |
73 | $scripts->add( 'wp-ajax-response', '/wp-includes/js/wp-ajax-response.js', array('jquery'), '20081210' ); |
74 | $scripts->localize( 'wp-ajax-response', 'wpAjax', array( |
75 | 'noPerm' => __('You do not have permission to do that.'), |
76 | 'broken' => __('An unidentified error has occurred.'), |
77 | 'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};' |
78 | ) ); |
79 | |
80 | $scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20081210' ); |
81 | |
82 | $scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20081210' ); |
83 | $scripts->localize( 'wp-lists', 'wpListL10n', array( |
84 | 'url' => admin_url('admin-ajax.php') |
85 | ) ); |
86 | |
87 | $scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.8.0'); |
88 | $scripts->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.8.0'); |
89 | $scripts->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.8.0'); |
90 | $scripts->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.8.0'); |
91 | $scripts->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.8.0'); |
92 | $scripts->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.8.0' ); |
93 | $scripts->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.8.0'); |
94 | $scripts->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.8.0'); |
95 | |
96 | $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118'); |
97 | |
98 | $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.2.6'); |
99 | $scripts->add( 'jquery-form', '/wp-includes/js/jquery/jquery.form.js', array('jquery'), '2.02'); |
100 | $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.js', array('jquery'), '2.0-4561'); |
101 | $scripts->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2' ); |
102 | $scripts->add( 'suggest', '/wp-includes/js/jquery/suggest.js', array('jquery'), '1.1b'); |
103 | $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20'); |
104 | $scripts->add( 'jquery-hotkeys', '/wp-includes/js/jquery/jquery.hotkeys.js', array('jquery'), '0.0.2' ); |
105 | $scripts->add( 'jquery-table-hotkeys', '/wp-includes/js/jquery/jquery.table-hotkeys.js', array('jquery', 'jquery-hotkeys'), '20081128' ); |
106 | $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1-20080430'); |
107 | $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.2.0-20081031'); |
108 | $scripts->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.2.0-20081031'); |
109 | $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload'), '2.2.0-20081031'); |
110 | $scripts->localize( 'swfupload-degrade', 'uploadDegradeOptions', array( |
111 | 'is_lighttpd_before_150' => is_lighttpd_before_150(), |
112 | ) ); |
113 | $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.2.0-20081031'); |
114 | $scripts->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.2.0-20081201'); |
115 | // these error messages came from the sample swfupload js, they might need changing. |
116 | $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array( |
117 | 'queue_limit_exceeded' => __('You have attempted to queue too many files.'), |
118 | 'file_exceeds_size_limit' => sprintf(__('This file is too big. Your php.ini upload_max_filesize is %s.'), @ini_get('upload_max_filesize')), |
119 | 'zero_byte_file' => __('This file is empty. Please try another.'), |
120 | 'invalid_filetype' => __('This file type is not allowed. Please try another.'), |
121 | 'default_error' => __('An error occurred in the upload. Please try again later.'), |
122 | 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'), |
123 | 'upload_limit_exceeded' => __('You may only upload 1 file.'), |
124 | 'http_error' => __('HTTP error.'), |
125 | 'upload_failed' => __('Upload failed.'), |
126 | 'io_error' => __('IO error.'), |
127 | 'security_error' => __('Security error.'), |
128 | 'file_cancelled' => __('File cancelled.'), |
129 | 'upload_stopped' => __('Upload stopped.'), |
130 | 'dismiss' => __('Dismiss'), |
131 | 'crunching' => __('Crunching…'), |
132 | 'deleted' => __('Deleted'), |
133 | 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' |
134 | ) ); |
135 | |
136 | $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.5.2' ); |
137 | $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core'), '1.5.2' ); |
138 | $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core'), '1.5.2c' ); |
139 | $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui.draggable.js', array('jquery-ui-core'), '1.5.2' ); |
140 | $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' ); |
141 | $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' ); |
142 | |
143 | $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081210'); |
144 | |
145 | if ( is_admin() ) { |
146 | $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20081210' ); |
147 | $scripts->localize( 'ajaxcat', 'catL10n', array( |
148 | 'add' => attribute_escape(__('Add')), |
149 | 'how' => __('Separate multiple categories with commas.'), |
150 | 'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};' |
151 | ) ); |
152 | $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20081210' ); |
153 | $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20081210' ); |
154 | $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20081210' ); |
155 | $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20081210' ); |
156 | $scripts->localize( 'password-strength-meter', 'pwsL10n', array( |
157 | 'empty' => __('Strength indicator'), |
158 | 'short' => __('Very weak'), |
159 | 'bad' => __('Weak'), |
160 | 'good' => _c('Medium|password strength'), |
161 | 'strong' => __('Strong'), |
162 | 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};' |
163 | ) ); |
164 | $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081210' ); |
165 | $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( |
166 | 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), |
167 | 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']) |
168 | ) ); |
169 | $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20081210' ); |
170 | $scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); |
171 | $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery-ui-sortable'), '20081210' ); |
172 | $scripts->localize( 'postbox', 'postboxL10n', array( |
173 | 'requestFile' => admin_url('admin-ajax.php') |
174 | ) ); |
175 | $scripts->add( 'slug', '/wp-admin/js/slug.js', array('jquery'), '20081210' ); |
176 | $scripts->localize( 'slug', 'slugL10n', array( |
177 | 'requestFile' => admin_url('admin-ajax.php'), |
178 | 'save' => __('Save'), |
179 | 'cancel' => __('Cancel'), |
180 | 'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};' |
181 | ) ); |
182 | $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081210' ); |
183 | $scripts->localize( 'post', 'postL10n', array( |
184 | 'tagsUsed' => __('Tags used on this post:'), |
185 | 'add' => attribute_escape(__('Add')), |
186 | 'addTag' => attribute_escape(__('Add new tag')), |
187 | 'separate' => __('Separate tags with commas'), |
188 | 'cancel' => __('Cancel'), |
189 | 'edit' => __('Edit'), |
190 | 'publishOn' => __('Publish on:'), |
191 | 'publishOnFuture' => __('Schedule for:'), |
192 | 'publishOnPast' => __('Published on:'), |
193 | 'showcomm' => __('Show more comments'), |
194 | 'endcomm' => __('No more comments found.'), |
195 | 'publish' => __('Publish'), |
196 | 'schedule' => __('Schedule'), |
197 | 'update' => __('Update Post'), |
198 | 'savePending' => __('Save as Pending'), |
199 | 'saveDraft' => __('Save Draft'), |
200 | 'private' => __('Private'), |
201 | 'public' => __('Public'), |
202 | 'publicSticky' => __('Public, Sticky'), |
203 | 'password' => __('Password Protected'), |
204 | 'privatelyPublished' => __('Privately Published'), |
205 | 'published' => __('Published'), |
206 | 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' |
207 | ) ); |
208 | $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081210' ); |
209 | $scripts->localize( 'page', 'postL10n', array( |
210 | 'cancel' => __('Cancel'), |
211 | 'edit' => __('Edit'), |
212 | 'publishOn' => __('Publish on:'), |
213 | 'publishOnFuture' => __('Schedule for:'), |
214 | 'publishOnPast' => __('Published on:'), |
215 | 'showcomm' => __('Show more comments'), |
216 | 'endcomm' => __('No more comments found.'), |
217 | 'publish' => __('Publish'), |
218 | 'schedule' => __('Schedule'), |
219 | 'update' => __('Update Page'), |
220 | 'savePending' => __('Save as Pending'), |
221 | 'saveDraft' => __('Save Draft'), |
222 | 'private' => __('Private'), |
223 | 'public' => __('Public'), |
224 | 'password' => __('Password Protected'), |
225 | 'privatelyPublished' => __('Privately Published'), |
226 | 'published' => __('Published'), |
227 | 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' |
228 | ) ); |
229 | $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20081210' ); |
230 | $scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081210' ); |
231 | $scripts->localize( 'comment', 'commentL10n', array( |
232 | 'cancel' => __('Cancel'), |
233 | 'edit' => __('Edit'), |
234 | 'submittedOn' => __('Submitted on:'), |
235 | 'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};' |
236 | ) ); |
237 | $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20081210' ); |
238 | $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20081210' ); |
239 | |
240 | $scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081210' ); |
241 | $scripts->localize( 'admin-widgets', 'widgetsL10n', array( |
242 | 'add' => __('Add'), |
243 | 'edit' => __('Edit'), |
244 | 'cancel' => __('Cancel'), |
245 | 'lameReminder' => __('Remember to click the "Save Changes" button at the bottom of the Current Widgets column after you\'re all done!'), |
246 | 'lamerReminder' => __("You're about to leave without having saved your changes!"), |
247 | 'l10n_print_after' => 'try{convertEntities(widgetsL10n);}catch(e){};' |
248 | )); |
249 | |
250 | $scripts->add( 'word-count', '/wp-admin/js/word-count.js', array( 'jquery' ), '20081210' ); |
251 | $scripts->localize( 'word-count', 'wordCountL10n', array( |
252 | 'count' => __('Word count: %d'), |
253 | 'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};' |
254 | )); |
255 | |
256 | $scripts->add( 'wp-gears', '/wp-admin/js/wp-gears.js', false, '20081210' ); |
257 | $scripts->localize( 'wp-gears', 'wpGearsL10n', array( |
258 | 'updateCompleted' => __('Update completed.'), |
259 | 'error' => __('Error:'), |
260 | 'l10n_print_after' => 'try{convertEntities(wpGearsL10n);}catch(e){};' |
261 | )); |
262 | |
263 | $scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20081210' ); |
264 | |
265 | $scripts->add( 'inline-edit-post', '/wp-admin/js/inline-edit-post.js', array( 'jquery', 'jquery-form', 'suggest' ), '20081210' ); |
266 | $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( |
267 | 'error' => __('Error while saving the changes.'), |
268 | 'ntdeltitle' => __('Remove From Bulk Edit'), |
269 | 'notitle' => __('(no title)'), |
270 | 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' |
271 | ) ); |
272 | |
273 | $scripts->add( 'inline-edit-tax', '/wp-admin/js/inline-edit-tax.js', array( 'jquery', 'jquery-form' ), '20081210' ); |
274 | $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( |
275 | 'error' => __('Error while saving the changes.'), |
276 | 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' |
277 | ) ); |
278 | |
279 | $scripts->add( 'plugin-install', '/wp-admin/js/plugin-install.js', array( 'thickbox', 'jquery' ), '20081210' ); |
280 | $scripts->localize( 'plugin-install', 'plugininstallL10n', array( |
281 | 'plugin_information' => __('Plugin Information:'), |
282 | 'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};' |
283 | ) ); |
284 | |
285 | $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); |
286 | |
287 | $scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox' ), '20081210' ); |
288 | |
289 | $scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081210' ); |
290 | |
291 | } |
292 | } |
293 | |
294 | /** |
295 | * Assign default styles to $styles object. |
296 | * |
297 | * Nothing is returned, because the $styles parameter is passed by reference. |
298 | * Meaning that whatever object is passed will be updated without having to |
299 | * reassign the variable that was passed back to the same value. This saves |
300 | * memory. |
301 | * |
302 | * Adding default styles is not the only task, it also assigns the base_url |
303 | * property, the default version, and text direction for the object. |
304 | * |
305 | * @since 2.6.0 |
306 | * |
307 | * @param object $styles |
308 | */ |
309 | function wp_default_styles( &$styles ) { |
310 | // This checks to see if site_url() returns something and if it does not |
311 | // then it assigns $guess_url to wp_guess_url(). Strange format, but it works. |
312 | if ( ! $guessurl = site_url() ) |
313 | $guessurl = wp_guess_url(); |
314 | $styles->base_url = $guessurl; |
315 | $styles->default_version = get_bloginfo( 'version' ); |
316 | $styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr'; |
317 | |
318 | $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' ); |
319 | |
320 | $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20081210' ); |
321 | $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' ); |
322 | |
323 | $styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20081210' ); |
324 | $styles->add_data( 'ie', 'conditional', 'gte IE 6' ); |
325 | |
326 | $styles->add( 'colors', true, array(), '20081210' ); // Register "meta" stylesheet for admin colors |
327 | $styles->add( 'colors-fresh', '/wp-admin/css/colors-fresh.css', array(), '20081210'); // for login.php. Is there a better way? |
328 | $styles->add_data( 'colors-fresh', 'rtl', true ); |
329 | $styles->add( 'colors-classic', '/wp-admin/css/colors-classic.css', array(), '20081210'); |
330 | $styles->add_data( 'colors-classic', 'rtl', true ); |
331 | |
332 | $styles->add( 'global', '/wp-admin/css/global.css', array(), '20081210' ); |
333 | $styles->add( 'media', '/wp-admin/css/media.css', array(), '20081210' ); |
334 | $styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20081210' ); |
335 | $styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20081210' ); |
336 | $styles->add( 'install', '/wp-admin/css/install.css', array(), '20081210' ); |
337 | $styles->add( 'theme-editor', '/wp-admin/css/theme-editor.css', array(), '20081210' ); |
338 | $styles->add( 'press-this', '/wp-admin/css/press-this.css', array(), '20081210' ); |
339 | $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20081210' ); |
340 | $styles->add( 'login', '/wp-admin/css/login.css', array(), '20081210' ); |
341 | $styles->add( 'plugin-install', '/wp-admin/css/plugin-install.css', array(), '20081210' ); |
342 | $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' ); |
343 | |
344 | foreach ( $rtl_styles as $rtl_style ) |
345 | $styles->add_data( $rtl_style, 'rtl', true ); |
346 | } |
347 | |
348 | /** |
349 | * Reorder JavaScript scripts array to place prototype before jQuery. |
350 | * |
351 | * @since 2.3.1 |
352 | * |
353 | * @param array $js_array JavaScript scripst array |
354 | * @return array Reordered array, if needed. |
355 | */ |
356 | function wp_prototype_before_jquery( $js_array ) { |
357 | if ( false === $jquery = array_search( 'jquery', $js_array ) ) |
358 | return $js_array; |
359 | |
360 | if ( false === $prototype = array_search( 'prototype', $js_array ) ) |
361 | return $js_array; |
362 | |
363 | if ( $prototype < $jquery ) |
364 | return $js_array; |
365 | |
366 | unset($js_array[$prototype]); |
367 | |
368 | array_splice( $js_array, $jquery, 0, 'prototype' ); |
369 | |
370 | return $js_array; |
371 | } |
372 | |
373 | /** |
374 | * Load localized script just in time for MCE. |
375 | * |
376 | * These localizations require information that may not be loaded even by init. |
377 | * |
378 | * @since 2.5.0 |
379 | */ |
380 | function wp_just_in_time_script_localization() { |
381 | global $current_user; |
382 | |
383 | wp_localize_script( 'autosave', 'autosaveL10n', array( |
384 | 'autosaveInterval' => AUTOSAVE_INTERVAL, |
385 | 'previewPageText' => __('Preview this Page'), |
386 | 'previewPostText' => __('Preview this Post'), |
387 | 'requestFile' => admin_url('admin-ajax.php'), |
388 | 'savingText' => __('Saving Draft…'), |
389 | 'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};' |
390 | ) ); |
391 | |
392 | $userid = isset($current_user) ? $current_user->ID : 0; |
393 | wp_localize_script( 'common', 'userSettings', array( |
394 | 'url' => SITECOOKIEPATH, |
395 | 'uid' => $userid, |
396 | 'time' => time() |
397 | ) ); |
398 | } |
399 | |
400 | /** |
401 | * Administration Panel CSS for changing the styles. |
402 | * |
403 | * If installing the 'wp-admin/' directory will be replaced with './'. |
404 | * |
405 | * The $_wp_admin_css_colors global manages the Administration Panels CSS |
406 | * stylesheet that is loaded. The option that is set is 'admin_color' and is the |
407 | * color and key for the array. The value for the color key is an object with |
408 | * a 'url' parameter that has the URL path to the CSS file. |
409 | * |
410 | * The query from $src parameter will be appended to the URL that is given from |
411 | * the $_wp_admin_css_colors array value URL. |
412 | * |
413 | * @since 2.6.0 |
414 | * @uses $_wp_admin_css_colors |
415 | * |
416 | * @param string $src Source URL. |
417 | * @param string $handle Either 'colors' or 'colors-rtl'. |
418 | * @return string URL path to CSS stylesheet for Administration Panels. |
419 | */ |
420 | function wp_style_loader_src( $src, $handle ) { |
421 | if ( defined('WP_INSTALLING') ) |
422 | return preg_replace( '#^wp-admin/#', './', $src ); |
423 | |
424 | if ( 'colors' == $handle || 'colors-rtl' == $handle ) { |
425 | global $_wp_admin_css_colors; |
426 | $color = get_user_option('admin_color'); |
427 | if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) |
428 | $color = 'fresh'; |
429 | $color = $_wp_admin_css_colors[$color]; |
430 | $parsed = parse_url( $src ); |
431 | $url = $color->url; |
432 | if ( isset($parsed['query']) && $parsed['query'] ) { |
433 | wp_parse_str( $parsed['query'], $qv ); |
434 | $url = add_query_arg( $qv, $url ); |
435 | } |
436 | return $url; |
437 | } |
438 | |
439 | return $src; |
440 | } |
441 | |
442 | add_action( 'wp_default_scripts', 'wp_default_scripts' ); |
443 | add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); |
444 | add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); |
445 | |
446 | add_action( 'wp_default_styles', 'wp_default_styles' ); |
447 | add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); |