[ Index ]

PHP Cross Reference of WordPress 3.0 beta 1

[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/wp-includes/ -> script-loader.php (source)

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


Generated: Mon Apr 5 14:26:09 2010 Cross-referenced by PHPXref 0.7