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