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