PageRenderTime 53ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-includes/script-loader.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 826 lines | 505 code | 156 blank | 165 comment | 90 complexity | c80728930689d40be9d45b6389b7f6db MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  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. /** BackPress: WordPress Dependencies Class */
  24. require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
  25. /** BackPress: WordPress Scripts Class */
  26. require( ABSPATH . WPINC . '/class.wp-scripts.php' );
  27. /** BackPress: WordPress Scripts Functions */
  28. require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
  29. /** BackPress: WordPress Styles Class */
  30. require( ABSPATH . WPINC . '/class.wp-styles.php' );
  31. /** BackPress: WordPress Styles Functions */
  32. require( ABSPATH . WPINC . '/functions.wp-styles.php' );
  33. /**
  34. * Register all WordPress scripts.
  35. *
  36. * Localizes some of them.
  37. * args order: $scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );
  38. * when last arg === 1 queues the script for the footer
  39. *
  40. * @since 2.6.0
  41. *
  42. * @param object $scripts WP_Scripts object.
  43. */
  44. function wp_default_scripts( &$scripts ) {
  45. if ( !$guessurl = site_url() )
  46. $guessurl = wp_guess_url();
  47. $scripts->base_url = $guessurl;
  48. $scripts->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
  49. $scripts->default_version = get_bloginfo( 'version' );
  50. $scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/');
  51. $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
  52. $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js" );
  53. $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
  54. did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
  55. 'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete.")
  56. ) );
  57. $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );
  58. $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 );
  59. did_action( 'init' ) && $scripts->localize( 'quicktags', 'quicktagsL10n', array(
  60. 'wordLookup' => __('Enter a word to look up:'),
  61. 'dictionaryLookup' => esc_attr(__('Dictionary lookup')),
  62. 'lookup' => esc_attr(__('lookup')),
  63. 'closeAllOpenTags' => esc_attr(__('Close all open tags')),
  64. 'closeTags' => esc_attr(__('close tags')),
  65. 'enterURL' => __('Enter the URL'),
  66. 'enterImageURL' => __('Enter the URL of the image'),
  67. 'enterImageDescription' => __('Enter a description of the image'),
  68. 'fullscreen' => __('fullscreen'),
  69. 'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
  70. 'textdirection' => esc_attr( __('text direction') ),
  71. 'toggleTextdirection' => esc_attr( __('Toggle Editor Text Direction') )
  72. ) );
  73. $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );
  74. $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), false, 1 );
  75. $scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), false, 1 );
  76. $scripts->add( 'prototype', '/wp-includes/js/prototype.js', array(), '1.6.1');
  77. $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1 );
  78. did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
  79. 'noPerm' => __('You do not have permission to do that.'),
  80. 'broken' => __('An unidentified error has occurred.')
  81. ) );
  82. $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 );
  83. did_action( 'init' ) && $scripts->localize( 'wp-pointer', 'wpPointerL10n', array(
  84. 'dismiss' => __('Dismiss'),
  85. ) );
  86. $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), false, 1 );
  87. $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), false, 1 );
  88. $scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.8.3');
  89. $scripts->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.8.3');
  90. $scripts->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.8.3');
  91. $scripts->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.8.3');
  92. $scripts->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.8.3');
  93. $scripts->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.8.3' );
  94. $scripts->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.8.3');
  95. $scripts->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.8.3');
  96. // not used in core, replaced by Jcrop.js
  97. $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop') );
  98. $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', array(), '1.7.2' );
  99. // full jQuery UI
  100. $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui/jquery.ui.core.min.js', array('jquery'), '1.8.20', 1 );
  101. $scripts->add( 'jquery-effects-core', '/wp-includes/js/jquery/ui/jquery.effects.core.min.js', array('jquery'), '1.8.20', 1 );
  102. $scripts->add( 'jquery-effects-blind', '/wp-includes/js/jquery/ui/jquery.effects.blind.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  103. $scripts->add( 'jquery-effects-bounce', '/wp-includes/js/jquery/ui/jquery.effects.bounce.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  104. $scripts->add( 'jquery-effects-clip', '/wp-includes/js/jquery/ui/jquery.effects.clip.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  105. $scripts->add( 'jquery-effects-drop', '/wp-includes/js/jquery/ui/jquery.effects.drop.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  106. $scripts->add( 'jquery-effects-explode', '/wp-includes/js/jquery/ui/jquery.effects.explode.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  107. $scripts->add( 'jquery-effects-fade', '/wp-includes/js/jquery/ui/jquery.effects.fade.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  108. $scripts->add( 'jquery-effects-fold', '/wp-includes/js/jquery/ui/jquery.effects.fold.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  109. $scripts->add( 'jquery-effects-highlight', '/wp-includes/js/jquery/ui/jquery.effects.highlight.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  110. $scripts->add( 'jquery-effects-pulsate', '/wp-includes/js/jquery/ui/jquery.effects.pulsate.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  111. $scripts->add( 'jquery-effects-scale', '/wp-includes/js/jquery/ui/jquery.effects.scale.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  112. $scripts->add( 'jquery-effects-shake', '/wp-includes/js/jquery/ui/jquery.effects.shake.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  113. $scripts->add( 'jquery-effects-slide', '/wp-includes/js/jquery/ui/jquery.effects.slide.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  114. $scripts->add( 'jquery-effects-transfer', '/wp-includes/js/jquery/ui/jquery.effects.transfer.min.js', array('jquery-effects-core'), '1.8.20', 1 );
  115. $scripts->add( 'jquery-ui-accordion', '/wp-includes/js/jquery/ui/jquery.ui.accordion.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.20', 1 );
  116. $scripts->add( 'jquery-ui-autocomplete', '/wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js', array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position'), '1.8.20', 1 );
  117. $scripts->add( 'jquery-ui-button', '/wp-includes/js/jquery/ui/jquery.ui.button.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.20', 1 );
  118. $scripts->add( 'jquery-ui-datepicker', '/wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js', array('jquery-ui-core'), '1.8.20', 1 );
  119. $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui/jquery.ui.dialog.min.js', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.8.20', 1 );
  120. $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui/jquery.ui.draggable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.20', 1 );
  121. $scripts->add( 'jquery-ui-droppable', '/wp-includes/js/jquery/ui/jquery.ui.droppable.min.js', array('jquery-ui-draggable'), '1.8.20', 1 );
  122. $scripts->add( 'jquery-ui-mouse', '/wp-includes/js/jquery/ui/jquery.ui.mouse.min.js', array('jquery-ui-widget'), '1.8.20', 1 );
  123. $scripts->add( 'jquery-ui-position', '/wp-includes/js/jquery/ui/jquery.ui.position.min.js', array('jquery'), '1.8.20', 1 );
  124. $scripts->add( 'jquery-ui-progressbar', '/wp-includes/js/jquery/ui/jquery.ui.progressbar.min.js', array('jquery-ui-widget'), '1.8.20', 1 );
  125. $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui/jquery.ui.resizable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.20', 1 );
  126. $scripts->add( 'jquery-ui-selectable', '/wp-includes/js/jquery/ui/jquery.ui.selectable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.20', 1 );
  127. $scripts->add( 'jquery-ui-slider', '/wp-includes/js/jquery/ui/jquery.ui.slider.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.20', 1 );
  128. $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui/jquery.ui.sortable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.20', 1 );
  129. $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.20', 1 );
  130. $scripts->add( 'jquery-ui-widget', '/wp-includes/js/jquery/ui/jquery.ui.widget.min.js', array('jquery'), '1.8.20', 1 );
  131. // deprecated, not used in core, most functionality is included in jQuery 1.3
  132. $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '2.73', 1 );
  133. // jQuery plugins
  134. $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color$suffix.js", array('jquery'), '2.0-4561m', 1 );
  135. $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113', 1 );
  136. $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m', 1 );
  137. $scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7', 1 );
  138. $scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2', 1 );
  139. $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m', 1 );
  140. $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), false, 1 );
  141. $scripts->add( 'jquery-touch-punch', "/wp-includes/js/jquery/jquery.ui.touch-punch.js", array('jquery-ui-widget', 'jquery-ui-mouse'), '0.2.2', 1 );
  142. $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20111117', 1 );
  143. did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array(
  144. 'next' => __('Next &gt;'),
  145. 'prev' => __('&lt; Prev'),
  146. 'image' => __('Image'),
  147. 'of' => __('of'),
  148. 'close' => __('Close'),
  149. 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
  150. 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
  151. 'closeImage' => includes_url('js/thickbox/tb-close.png')
  152. ) );
  153. $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop$suffix.js", array('jquery'), '0.9.8-20110113');
  154. $scripts->add( 'swfobject', "/wp-includes/js/swfobject.js", array(), '2.2-20120417');
  155. // common bits for both uploaders
  156. $max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
  157. if ( empty($max_upload_size) )
  158. $max_upload_size = __('not configured');
  159. // error message for both plupload and swfupload
  160. $uploader_l10n = array(
  161. 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
  162. 'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
  163. 'zero_byte_file' => __('This file is empty. Please try another.'),
  164. 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
  165. 'not_an_image' => __('This file is not an image. Please try another.'),
  166. 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
  167. 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
  168. 'default_error' => __('An error occurred in the upload. Please try again later.'),
  169. 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
  170. 'upload_limit_exceeded' => __('You may only upload 1 file.'),
  171. 'http_error' => __('HTTP error.'),
  172. 'upload_failed' => __('Upload failed.'),
  173. 'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
  174. 'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
  175. 'io_error' => __('IO error.'),
  176. 'security_error' => __('Security error.'),
  177. 'file_cancelled' => __('File canceled.'),
  178. 'upload_stopped' => __('Upload stopped.'),
  179. 'dismiss' => __('Dismiss'),
  180. 'crunching' => __('Crunching&hellip;'),
  181. 'deleted' => __('moved to the trash.'),
  182. 'error_uploading' => __('&#8220;%s&#8221; has failed to upload.')
  183. );
  184. $scripts->add( 'plupload', '/wp-includes/js/plupload/plupload.js', '1.5.4' );
  185. $scripts->add( 'plupload-html5', '/wp-includes/js/plupload/plupload.html5.js', array('plupload'), '1.5.4' );
  186. $scripts->add( 'plupload-flash', '/wp-includes/js/plupload/plupload.flash.js', array('plupload'), '1.5.4' );
  187. $scripts->add( 'plupload-silverlight', '/wp-includes/js/plupload/plupload.silverlight.js', array('plupload'), '1.5.4' );
  188. $scripts->add( 'plupload-html4', '/wp-includes/js/plupload/plupload.html4.js', array('plupload'), '1.5.4' );
  189. // cannot use the plupload.full.js, as it loads browserplus init JS from Yahoo
  190. $scripts->add( 'plupload-all', false, array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4'), '1.5.4' );
  191. $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload-all', 'jquery') );
  192. did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
  193. $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array('plupload-all', 'jquery', 'json2') );
  194. did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );
  195. // keep 'swfupload' for back-compat.
  196. $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113');
  197. $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201a');
  198. $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201');
  199. $scripts->add( 'swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201');
  200. if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) {
  201. // queue all SWFUpload scripts that are used by default
  202. $scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201');
  203. } else {
  204. $scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201a');
  205. }
  206. $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20110524');
  207. did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n );
  208. $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js" );
  209. $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2011-02-23');
  210. $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 );
  211. $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), false, 1 );
  212. did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
  213. 'empty' => __('Strength indicator'),
  214. 'short' => __('Very weak'),
  215. 'bad' => __('Weak'),
  216. /* translators: password strength */
  217. 'good' => _x('Medium', 'password strength'),
  218. 'strong' => __('Strong'),
  219. 'mismatch' => __('Mismatch')
  220. ) );
  221. $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), false, 1 );
  222. $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
  223. $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 );
  224. $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), false, 1 );
  225. did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array(
  226. 'title' => __('Insert/edit link'),
  227. 'update' => __('Update'),
  228. 'save' => __('Add Link'),
  229. 'noTitle' => __('(no title)'),
  230. 'noMatchesFound' => __('No matches found.')
  231. ) );
  232. $scripts->add( 'wpdialogs', "/wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 );
  233. $scripts->add( 'wpdialogs-popup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", array( 'wpdialogs' ), false, 1 );
  234. $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), false, 1 );
  235. did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array(
  236. /* translators: If your word count is based on single characters (East Asian characters),
  237. enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
  238. 'type' => 'characters' == _x( 'words', 'word count: words or characters?' ) ? 'c' : 'w',
  239. ) );
  240. $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), false, 1 );
  241. $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), 'r6', 1 );
  242. $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2' ), false, 1 );
  243. $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
  244. $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 );
  245. $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base' ), false, 1 );
  246. did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array(
  247. 'activate' => __( 'Save &amp; Activate' ),
  248. 'save' => __( 'Save &amp; Publish' ),
  249. 'saved' => __( 'Saved' ),
  250. 'cancel' => __( 'Cancel' ),
  251. 'close' => __( 'Close' ),
  252. 'cheatin' => __( 'Cheatin&#8217; uh?' ),
  253. ) );
  254. if ( is_admin() ) {
  255. $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ) );
  256. $scripts->add_data( 'ajaxcat', 'group', 1 );
  257. did_action( 'init' ) && $scripts->localize( 'ajaxcat', 'catL10n', array(
  258. 'add' => esc_attr(__('Add')),
  259. 'how' => __('Separate multiple categories with commas.')
  260. ) );
  261. $scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), false, 1 );
  262. $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), false, 1 );
  263. did_action( 'init' ) && $scripts->localize( 'admin-tags', 'tagsl10n', array(
  264. 'noPerm' => __('You do not have permission to do that.'),
  265. 'broken' => __('An unidentified error has occurred.')
  266. ));
  267. $scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), false, 1 );
  268. $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'quicktags', 'jquery-query'), false, 1 );
  269. did_action( 'init' ) && $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
  270. 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
  271. 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
  272. 'replyApprove' => __( 'Approve and Reply' ),
  273. 'reply' => __( 'Reply' )
  274. ) );
  275. $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1 );
  276. $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 );
  277. $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), false, 1 );
  278. did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array(
  279. 'ok' => __('OK'),
  280. 'cancel' => __('Cancel'),
  281. 'publishOn' => __('Publish on:'),
  282. 'publishOnFuture' => __('Schedule for:'),
  283. 'publishOnPast' => __('Published on:'),
  284. 'showcomm' => __('Show more comments'),
  285. 'endcomm' => __('No more comments found.'),
  286. 'publish' => __('Publish'),
  287. 'schedule' => __('Schedule'),
  288. 'update' => __('Update'),
  289. 'savePending' => __('Save as Pending'),
  290. 'saveDraft' => __('Save Draft'),
  291. 'private' => __('Private'),
  292. 'public' => __('Public'),
  293. 'publicSticky' => __('Public, Sticky'),
  294. 'password' => __('Password Protected'),
  295. 'privatelyPublished' => __('Privately Published'),
  296. 'published' => __('Published'),
  297. 'comma' => _x( ',', 'tag delimiter' ),
  298. ) );
  299. $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), false, 1 );
  300. $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery') );
  301. $scripts->add_data( 'comment', 'group', 1 );
  302. did_action( 'init' ) && $scripts->localize( 'comment', 'commentL10n', array(
  303. 'submittedOn' => __('Submitted on:')
  304. ) );
  305. $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
  306. $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
  307. $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'jquery' ), false, 1 );
  308. // @todo: Core no longer uses theme-preview.js. Remove?
  309. $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), false, 1 );
  310. $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), false, 1 );
  311. did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
  312. 'error' => __('Error while saving the changes.'),
  313. 'ntdeltitle' => __('Remove From Bulk Edit'),
  314. 'notitle' => __('(no title)'),
  315. 'comma' => _x( ',', 'tag delimiter' ),
  316. ) );
  317. $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), false, 1 );
  318. did_action( 'init' ) && $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
  319. 'error' => __('Error while saving the changes.')
  320. ) );
  321. $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), false, 1 );
  322. did_action( 'init' ) && $scripts->localize( 'plugin-install', 'plugininstallL10n', array(
  323. 'plugin_information' => __('Plugin Information:'),
  324. 'ays' => __('Are you sure you want to install this plugin?')
  325. ) );
  326. $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
  327. $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 );
  328. $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
  329. $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery-ui-draggable' ), false, 1 );
  330. $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), false, 1 );
  331. did_action( 'init' ) && $scripts->localize( 'image-edit', 'imageEditL10n', array(
  332. 'error' => __( 'Could not load the preview image. Please reload the page and try again.' )
  333. ));
  334. $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
  335. did_action( 'init' ) && $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
  336. 'setThumbnail' => __( 'Use as featured image' ),
  337. 'saving' => __( 'Saving...' ),
  338. 'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
  339. 'done' => __( 'Done' )
  340. ) );
  341. // Navigation Menus
  342. $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array('jquery-ui-sortable') );
  343. did_action( 'init' ) && $scripts->localize( 'nav-menu', 'navMenuL10n', array(
  344. 'noResultsFound' => _x('No results found.', 'search results'),
  345. 'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
  346. 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.')
  347. ) );
  348. $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), false, 1 );
  349. $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 );
  350. }
  351. }
  352. /**
  353. * Assign default styles to $styles object.
  354. *
  355. * Nothing is returned, because the $styles parameter is passed by reference.
  356. * Meaning that whatever object is passed will be updated without having to
  357. * reassign the variable that was passed back to the same value. This saves
  358. * memory.
  359. *
  360. * Adding default styles is not the only task, it also assigns the base_url
  361. * property, the default version, and text direction for the object.
  362. *
  363. * @since 2.6.0
  364. *
  365. * @param object $styles
  366. */
  367. function wp_default_styles( &$styles ) {
  368. if ( ! $guessurl = site_url() )
  369. $guessurl = wp_guess_url();
  370. $styles->base_url = $guessurl;
  371. $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
  372. $styles->default_version = get_bloginfo( 'version' );
  373. $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
  374. $styles->default_dirs = array('/wp-admin/', '/wp-includes/css/');
  375. $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
  376. $rtl_styles = array( 'wp-admin', 'ie', 'media', 'admin-bar', 'wplink', 'customize-controls' );
  377. // Any rtl stylesheets that don't have a .dev version for ltr
  378. $no_suffix = array( 'farbtastic' );
  379. $styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css" );
  380. $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" );
  381. $styles->add_data( 'ie', 'conditional', 'lte IE 7' );
  382. // Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string.
  383. $styles->add( 'colors', true, array('wp-admin') );
  384. // do not refer to these directly, the right one is queued by the above "meta" colors handle
  385. $styles->add( 'colors-fresh', "/wp-admin/css/colors-fresh$suffix.css", array('wp-admin') );
  386. $styles->add( 'colors-classic', "/wp-admin/css/colors-classic$suffix.css", array('wp-admin') );
  387. $styles->add( 'media', "/wp-admin/css/media$suffix.css" );
  388. $styles->add( 'install', "/wp-admin/css/install$suffix.css" );
  389. $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css' );
  390. $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u1' );
  391. $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
  392. $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
  393. $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css" );
  394. $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css" );
  395. $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css" );
  396. $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css" );
  397. $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie' ) );
  398. foreach ( $rtl_styles as $rtl_style ) {
  399. $styles->add_data( $rtl_style, 'rtl', true );
  400. if ( $suffix && ! in_array( $rtl_style, $no_suffix ) )
  401. $styles->add_data( $rtl_style, 'suffix', $suffix );
  402. }
  403. }
  404. /**
  405. * Reorder JavaScript scripts array to place prototype before jQuery.
  406. *
  407. * @since 2.3.1
  408. *
  409. * @param array $js_array JavaScript scripts array
  410. * @return array Reordered array, if needed.
  411. */
  412. function wp_prototype_before_jquery( $js_array ) {
  413. if ( false === $jquery = array_search( 'jquery', $js_array, true ) )
  414. return $js_array;
  415. if ( false === $prototype = array_search( 'prototype', $js_array, true ) )
  416. return $js_array;
  417. if ( $prototype < $jquery )
  418. return $js_array;
  419. unset($js_array[$prototype]);
  420. array_splice( $js_array, $jquery, 0, 'prototype' );
  421. return $js_array;
  422. }
  423. /**
  424. * Load localized data on print rather than initialization.
  425. *
  426. * These localizations require information that may not be loaded even by init.
  427. *
  428. * @since 2.5.0
  429. */
  430. function wp_just_in_time_script_localization() {
  431. wp_localize_script( 'autosave', 'autosaveL10n', array(
  432. 'autosaveInterval' => AUTOSAVE_INTERVAL,
  433. 'savingText' => __('Saving Draft&#8230;'),
  434. 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.')
  435. ) );
  436. }
  437. /**
  438. * Administration Screen CSS for changing the styles.
  439. *
  440. * If installing the 'wp-admin/' directory will be replaced with './'.
  441. *
  442. * The $_wp_admin_css_colors global manages the Administration Screens CSS
  443. * stylesheet that is loaded. The option that is set is 'admin_color' and is the
  444. * color and key for the array. The value for the color key is an object with
  445. * a 'url' parameter that has the URL path to the CSS file.
  446. *
  447. * The query from $src parameter will be appended to the URL that is given from
  448. * the $_wp_admin_css_colors array value URL.
  449. *
  450. * @since 2.6.0
  451. * @uses $_wp_admin_css_colors
  452. *
  453. * @param string $src Source URL.
  454. * @param string $handle Either 'colors' or 'colors-rtl'.
  455. * @return string URL path to CSS stylesheet for Administration Screens.
  456. */
  457. function wp_style_loader_src( $src, $handle ) {
  458. if ( defined('WP_INSTALLING') )
  459. return preg_replace( '#^wp-admin/#', './', $src );
  460. if ( 'colors' == $handle || 'colors-rtl' == $handle ) {
  461. global $_wp_admin_css_colors;
  462. $color = get_user_option('admin_color');
  463. if ( empty($color) || !isset($_wp_admin_css_colors[$color]) )
  464. $color = 'fresh';
  465. $color = $_wp_admin_css_colors[$color];
  466. $parsed = parse_url( $src );
  467. $url = $color->url;
  468. if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG )
  469. $url = preg_replace('/.css$|.css(?=\?)/', '.dev.css', $url);
  470. if ( isset($parsed['query']) && $parsed['query'] ) {
  471. wp_parse_str( $parsed['query'], $qv );
  472. $url = add_query_arg( $qv, $url );
  473. }
  474. return $url;
  475. }
  476. return $src;
  477. }
  478. /**
  479. * Prints the script queue in the HTML head on admin pages.
  480. *
  481. * Postpones the scripts that were queued for the footer.
  482. * print_footer_scripts() is called in the footer to print these scripts.
  483. *
  484. * @since 2.8
  485. * @see wp_print_scripts()
  486. */
  487. function print_head_scripts() {
  488. global $wp_scripts, $concatenate_scripts;
  489. if ( ! did_action('wp_print_scripts') )
  490. do_action('wp_print_scripts');
  491. if ( !is_a($wp_scripts, 'WP_Scripts') )
  492. $wp_scripts = new WP_Scripts();
  493. script_concat_settings();
  494. $wp_scripts->do_concat = $concatenate_scripts;
  495. $wp_scripts->do_head_items();
  496. if ( apply_filters('print_head_scripts', true) )
  497. _print_scripts();
  498. $wp_scripts->reset();
  499. return $wp_scripts->done;
  500. }
  501. /**
  502. * Prints the scripts that were queued for the footer or too late for the HTML head.
  503. *
  504. * @since 2.8
  505. */
  506. function print_footer_scripts() {
  507. global $wp_scripts, $concatenate_scripts;
  508. if ( !is_a($wp_scripts, 'WP_Scripts') )
  509. return array(); // No need to run if not instantiated.
  510. script_concat_settings();
  511. $wp_scripts->do_concat = $concatenate_scripts;
  512. $wp_scripts->do_footer_items();
  513. if ( apply_filters('print_footer_scripts', true) )
  514. _print_scripts();
  515. $wp_scripts->reset();
  516. return $wp_scripts->done;
  517. }
  518. /**
  519. * @internal use
  520. */
  521. function _print_scripts() {
  522. global $wp_scripts, $compress_scripts;
  523. $zip = $compress_scripts ? 1 : 0;
  524. if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
  525. $zip = 'gzip';
  526. if ( !empty($wp_scripts->concat) ) {
  527. if ( !empty($wp_scripts->print_code) ) {
  528. echo "\n<script type='text/javascript'>\n";
  529. echo "/* <![CDATA[ */\n"; // not needed in HTML 5
  530. echo $wp_scripts->print_code;
  531. echo "/* ]]> */\n";
  532. echo "</script>\n";
  533. }
  534. $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . trim($wp_scripts->concat, ', ') . '&ver=' . $wp_scripts->default_version;
  535. echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n";
  536. }
  537. if ( !empty($wp_scripts->print_html) )
  538. echo $wp_scripts->print_html;
  539. }
  540. /**
  541. * Prints the script queue in the HTML head on the front end.
  542. *
  543. * Postpones the scripts that were queued for the footer.
  544. * wp_print_footer_scripts() is called in the footer to print these scripts.
  545. *
  546. * @since 2.8
  547. */
  548. function wp_print_head_scripts() {
  549. if ( ! did_action('wp_print_scripts') )
  550. do_action('wp_print_scripts');
  551. global $wp_scripts;
  552. if ( !is_a($wp_scripts, 'WP_Scripts') )
  553. return array(); // no need to run if nothing is queued
  554. return print_head_scripts();
  555. }
  556. /**
  557. * Private, for use in *_footer_scripts hooks
  558. *
  559. * @since 3.3.0
  560. */
  561. function _wp_footer_scripts() {
  562. print_late_styles();
  563. print_footer_scripts();
  564. }
  565. /**
  566. * Hooks to print the scripts and styles in the footer.
  567. *
  568. * @since 2.8
  569. */
  570. function wp_print_footer_scripts() {
  571. do_action('wp_print_footer_scripts');
  572. }
  573. /**
  574. * Wrapper for do_action('wp_enqueue_scripts')
  575. *
  576. * Allows plugins to queue scripts for the front end using wp_enqueue_script().
  577. * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
  578. *
  579. * @since 2.8
  580. */
  581. function wp_enqueue_scripts() {
  582. do_action('wp_enqueue_scripts');
  583. }
  584. /**
  585. * Prints the styles queue in the HTML head on admin pages.
  586. *
  587. * @since 2.8
  588. */
  589. function print_admin_styles() {
  590. global $wp_styles, $concatenate_scripts, $compress_css;
  591. if ( !is_a($wp_styles, 'WP_Styles') )
  592. $wp_styles = new WP_Styles();
  593. script_concat_settings();
  594. $wp_styles->do_concat = $concatenate_scripts;
  595. $zip = $compress_css ? 1 : 0;
  596. if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
  597. $zip = 'gzip';
  598. $wp_styles->do_items(false);
  599. if ( apply_filters('print_admin_styles', true) )
  600. _print_styles();
  601. $wp_styles->reset();
  602. return $wp_styles->done;
  603. }
  604. /**
  605. * Prints the styles that were queued too late for the HTML head.
  606. *
  607. * @since 3.3.0
  608. */
  609. function print_late_styles() {
  610. global $wp_styles, $concatenate_scripts;
  611. if ( !is_a($wp_styles, 'WP_Styles') )
  612. return;
  613. $wp_styles->do_concat = $concatenate_scripts;
  614. $wp_styles->do_footer_items();
  615. if ( apply_filters('print_late_styles', true) )
  616. _print_styles();
  617. $wp_styles->reset();
  618. return $wp_styles->done;
  619. }
  620. /**
  621. * @internal use
  622. */
  623. function _print_styles() {
  624. global $wp_styles, $compress_css;
  625. $zip = $compress_css ? 1 : 0;
  626. if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
  627. $zip = 'gzip';
  628. if ( !empty($wp_styles->concat) ) {
  629. $dir = $wp_styles->text_direction;
  630. $ver = $wp_styles->default_version;
  631. $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . '&ver=' . $ver;
  632. echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
  633. if ( !empty($wp_styles->print_code) ) {
  634. echo "<style type='text/css'>\n";
  635. echo $wp_styles->print_code;
  636. echo "\n</style>\n";
  637. }
  638. }
  639. if ( !empty($wp_styles->print_html) )
  640. echo $wp_styles->print_html;
  641. }
  642. /**
  643. * Determine the concatenation and compression settings for scripts and styles.
  644. *
  645. * @since 2.8
  646. */
  647. function script_concat_settings() {
  648. global $concatenate_scripts, $compress_scripts, $compress_css;
  649. $compressed_output = ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') );
  650. if ( ! isset($concatenate_scripts) ) {
  651. $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true;
  652. if ( ! is_admin() || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) )
  653. $concatenate_scripts = false;
  654. }
  655. if ( ! isset($compress_scripts) ) {
  656. $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true;
  657. if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
  658. $compress_scripts = false;
  659. }
  660. if ( ! isset($compress_css) ) {
  661. $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true;
  662. if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
  663. $compress_css = false;
  664. }
  665. }
  666. add_action( 'wp_default_scripts', 'wp_default_scripts' );
  667. add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
  668. add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
  669. add_action( 'wp_default_styles', 'wp_default_styles' );
  670. add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );