PageRenderTime 51ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-includes/script-loader.php

https://bitbucket.org/aukhanev/xdn-wordpress31
PHP | 793 lines | 507 code | 152 blank | 134 comment | 61 complexity | 3fbd1cbbea9b67ffb5412d485dcb0e50 MD5 | raw file
  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. * Set up WordPress scripts to load by default for Administration Panels.
  35. *
  36. * Localizes a few of the scripts.
  37. * $scripts->add_data( 'script-handle', 'group', 1 ); queues the script for the footer
  38. *
  39. * @since 2.6.0
  40. *
  41. * @param object $scripts WP_Scripts object.
  42. */
  43. function wp_default_scripts( &$scripts ) {
  44. if ( !$guessurl = site_url() )
  45. $guessurl = wp_guess_url();
  46. $scripts->base_url = $guessurl;
  47. $scripts->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
  48. $scripts->default_version = get_bloginfo( 'version' );
  49. $scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/');
  50. $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
  51. // Always ensure that we have the convertEntities function
  52. $scripts->add( 'l10n', "/wp-includes/js/l10n$suffix.js", false, '20101110' );
  53. $scripts->enqueue( 'l10n' );
  54. $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
  55. $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20101211' );
  56. $scripts->add_data( 'common', 'group', 1 );
  57. $scripts->localize( 'common', 'commonL10n', array(
  58. 'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete."),
  59. 'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};'
  60. ) );
  61. $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1' );
  62. $scripts->add_data( 'sack', 'group', 1 );
  63. $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20090307' );
  64. $scripts->add_data( 'quicktags', 'group', 1 );
  65. $scripts->localize( 'quicktags', 'quicktagsL10n', array(
  66. 'quickLinks' => __('(Quick Links)'),
  67. 'wordLookup' => __('Enter a word to look up:'),
  68. 'dictionaryLookup' => esc_attr(__('Dictionary lookup')),
  69. 'lookup' => esc_attr(__('lookup')),
  70. 'closeAllOpenTags' => esc_attr(__('Close all open tags')),
  71. 'closeTags' => esc_attr(__('close tags')),
  72. 'enterURL' => __('Enter the URL'),
  73. 'enterImageURL' => __('Enter the URL of the image'),
  74. 'enterImageDescription' => __('Enter a description of the image'),
  75. 'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};'
  76. ) );
  77. $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );
  78. $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20091124' );
  79. $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6.1');
  80. $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), '20091119' );
  81. $scripts->add_data( 'wp-ajax-response', 'group', 1 );
  82. $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
  83. 'noPerm' => __('You do not have permission to do that.'),
  84. 'broken' => __('An unidentified error has occurred.'),
  85. 'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'
  86. ) );
  87. $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20101004' );
  88. $scripts->add_data( 'autosave', 'group', 1 );
  89. $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20101222' );
  90. $scripts->add_data( 'wp-lists', 'group', 1 );
  91. $scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.8.3');
  92. $scripts->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.8.3');
  93. $scripts->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.8.3');
  94. $scripts->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.8.3');
  95. $scripts->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.8.3');
  96. $scripts->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.8.3' );
  97. $scripts->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.8.3');
  98. $scripts->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.8.3');
  99. // not used in core, replaced by Jcrop.js
  100. $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118');
  101. $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.4.4');
  102. $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.8.9' );
  103. $scripts->add_data( 'jquery-ui-core', 'group', 1 );
  104. $scripts->add( 'jquery-ui-position', '/wp-includes/js/jquery/ui.position.js', array('jquery'), '1.8.9' );
  105. $scripts->add_data( 'jquery-ui-position', 'group', 1 );
  106. $scripts->add( 'jquery-ui-widget', '/wp-includes/js/jquery/ui.widget.js', array('jquery'), '1.8.9' );
  107. $scripts->add_data( 'jquery-ui-widget', 'group', 1 );
  108. $scripts->add( 'jquery-ui-mouse', '/wp-includes/js/jquery/ui.mouse.js', array('jquery', 'jquery-ui-widget'), '1.8.9' );
  109. $scripts->add_data( 'jquery-ui-mouse', 'group', 1 );
  110. $scripts->add( 'jquery-ui-button', '/wp-includes/js/jquery/ui.button.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.9' );
  111. $scripts->add_data( 'jquery-ui-button', 'group', 1 );
  112. $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.9' );
  113. $scripts->add_data( 'jquery-ui-tabs', 'group', 1 );
  114. $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.9' );
  115. $scripts->add_data( 'jquery-ui-sortable', 'group', 1 );
  116. $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui.draggable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.9' );
  117. $scripts->add_data( 'jquery-ui-draggable', 'group', 1 );
  118. $scripts->add( 'jquery-ui-droppable', '/wp-includes/js/jquery/ui.droppable.js', array('jquery-ui-core', 'jquery-ui-mouse', 'jquery-ui-draggable'), '1.8.9' );
  119. $scripts->add_data( 'jquery-ui-droppable', 'group', 1 );
  120. $scripts->add( 'jquery-ui-selectable', '/wp-includes/js/jquery/ui.selectable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.9' );
  121. $scripts->add_data( 'jquery-ui-selectable', 'group', 1 );
  122. $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.9' );
  123. $scripts->add_data( 'jquery-ui-resizable', 'group', 1 );
  124. $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.8.9' );
  125. $scripts->add_data( 'jquery-ui-dialog', 'group', 1 );
  126. // deprecated, not used in core, most functionality is included in jQuery 1.3
  127. $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '2.02m');
  128. $scripts->add_data( 'jquery-form', 'group', 1 );
  129. $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color$suffix.js", array('jquery'), '2.0-4561m');
  130. $scripts->add_data( 'jquery-color', 'group', 1 );
  131. $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113');
  132. $scripts->add_data( 'suggest', 'group', 1 );
  133. $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m');
  134. $scripts->add_data( 'schedule', 'group', 1 );
  135. $scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7' );
  136. $scripts->add_data( 'jquery-query', 'group', 1 );
  137. $scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2' );
  138. $scripts->add_data( 'jquery-serialize-object', 'group', 1 );
  139. $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m' );
  140. $scripts->add_data( 'jquery-hotkeys', 'group', 1 );
  141. $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), '20090102' );
  142. $scripts->add_data( 'jquery-table-hotkeys', 'group', 1 );
  143. $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20100407');
  144. $scripts->add_data( 'thickbox', 'group', 1 );
  145. $scripts->localize( 'thickbox', 'thickboxL10n', array(
  146. 'next' => __('Next &gt;'),
  147. 'prev' => __('&lt; Prev'),
  148. 'image' => __('Image'),
  149. 'of' => __('of'),
  150. 'close' => __('Close'),
  151. 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
  152. 'l10n_print_after' => 'try{convertEntities(thickboxL10n);}catch(e){};'
  153. ) );
  154. $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop$suffix.js", array('jquery'), '0.9.8-20110113');
  155. $scripts->add( 'swfobject', "/wp-includes/js/swfobject.js", false, '2.2');
  156. $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2201-20110113');
  157. $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201');
  158. $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201');
  159. $scripts->add( 'swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201');
  160. if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) {
  161. // queue all SWFUpload scripts that are used by default
  162. $scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201');
  163. } else {
  164. $scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201');
  165. }
  166. $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20100523');
  167. $max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
  168. if ( empty($max_upload_size) )
  169. $max_upload_size = __('not configured');
  170. // these error messages came from the sample swfupload js, they might need changing.
  171. $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array(
  172. 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
  173. 'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'),
  174. 'zero_byte_file' => __('This file is empty. Please try another.'),
  175. 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
  176. 'default_error' => __('An error occurred in the upload. Please try again later.'),
  177. 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
  178. 'upload_limit_exceeded' => __('You may only upload 1 file.'),
  179. 'http_error' => __('HTTP error.'),
  180. 'upload_failed' => __('Upload failed.'),
  181. 'io_error' => __('IO error.'),
  182. 'security_error' => __('Security error.'),
  183. 'file_cancelled' => __('File canceled.'),
  184. 'upload_stopped' => __('Upload stopped.'),
  185. 'dismiss' => __('Dismiss'),
  186. 'crunching' => __('Crunching&hellip;'),
  187. 'deleted' => __('moved to the trash.'),
  188. 'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error'),
  189. 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};',
  190. ) );
  191. $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102');
  192. $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", false, '20110113');
  193. $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.1-20110113' );
  194. $scripts->add_data( 'imgareaselect', 'group', 1 );
  195. $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20101027' );
  196. $scripts->add_data( 'password-strength-meter', 'group', 1 );
  197. $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
  198. 'empty' => __('Strength indicator'),
  199. 'short' => __('Very weak'),
  200. 'bad' => __('Weak'),
  201. /* translators: password strength */
  202. 'good' => _x('Medium', 'password strength'),
  203. 'strong' => __('Strong'),
  204. 'mismatch' => __('Mismatch'),
  205. 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
  206. ) );
  207. $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110113' );
  208. $scripts->add_data( 'user-profile', 'group', 1 );
  209. $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20110131' );
  210. $scripts->add_data( 'admin-bar', 'group', 1 );
  211. $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array('jquery'), '20110111' );
  212. $scripts->localize( 'wplink', 'wpLinkL10n', array(
  213. 'update' => __('Update'),
  214. 'save' => __('Add Link'),
  215. 'noTitle' => __('(no title)'),
  216. 'noMatchesFound' => __('No matches found.'),
  217. 'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};',
  218. ) );
  219. $scripts->add( 'wpdialogs-popup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", array( 'jquery-ui-dialog' ), '20101119' );
  220. if ( is_admin() ) {
  221. $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );
  222. $scripts->add_data( 'ajaxcat', 'group', 1 );
  223. $scripts->localize( 'ajaxcat', 'catL10n', array(
  224. 'add' => esc_attr(__('Add')),
  225. 'how' => __('Separate multiple categories with commas.'),
  226. 'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};'
  227. ) );
  228. $scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), '20091201' );
  229. $scripts->add_data( 'admin-categories', 'group', 1 );
  230. $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), '20101216' );
  231. $scripts->add_data( 'admin-tags', 'group', 1 );
  232. $scripts->localize( 'admin-tags', 'tagsl10n', array(
  233. 'noPerm' => __('You do not have permission to do that.'),
  234. 'broken' => __('An unidentified error has occurred.'),
  235. 'l10n_print_after' => 'try{convertEntities(tagsl10n);}catch(e){};'
  236. ));
  237. $scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
  238. $scripts->add_data( 'admin-custom-fields', 'group', 1 );
  239. $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'jquery-query'), '20110122' );
  240. $scripts->add_data( 'admin-comments', 'group', 1 );
  241. $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
  242. 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
  243. 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last'])
  244. ) );
  245. $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20100403' );
  246. $scripts->add_data( 'xfn', 'group', 1 );
  247. $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' );
  248. $scripts->add_data( 'postbox', 'group', 1 );
  249. $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110203' );
  250. $scripts->add_data( 'post', 'group', 1 );
  251. $scripts->localize( 'post', 'postL10n', array(
  252. 'tagsUsed' => __('Tags used on this post:'),
  253. 'add' => esc_attr(__('Add')),
  254. 'addTag' => esc_attr(__('Add new Tag')),
  255. 'separate' => __('Separate tags with commas'),
  256. 'ok' => __('OK'),
  257. 'cancel' => __('Cancel'),
  258. 'edit' => __('Edit'),
  259. 'publishOn' => __('Publish on:'),
  260. 'publishOnFuture' => __('Schedule for:'),
  261. 'publishOnPast' => __('Published on:'),
  262. 'showcomm' => __('Show more comments'),
  263. 'endcomm' => __('No more comments found.'),
  264. 'publish' => __('Publish'),
  265. 'schedule' => __('Schedule'),
  266. 'update' => __('Update'),
  267. 'savePending' => __('Save as Pending'),
  268. 'saveDraft' => __('Save Draft'),
  269. 'private' => __('Private'),
  270. 'public' => __('Public'),
  271. 'publicSticky' => __('Public, Sticky'),
  272. 'password' => __('Password Protected'),
  273. 'privatelyPublished' => __('Privately Published'),
  274. 'published' => __('Published'),
  275. 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
  276. ) );
  277. $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), '20090526' );
  278. $scripts->add_data( 'link', 'group', 1 );
  279. $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery'), '20091202' );
  280. $scripts->add_data( 'comment', 'group', 1 );
  281. $scripts->localize( 'comment', 'commentL10n', array(
  282. 'cancel' => __('Cancel'),
  283. 'edit' => __('Edit'),
  284. 'submittedOn' => __('Submitted on:'),
  285. 'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'
  286. ) );
  287. $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090516' );
  288. $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110113' );
  289. $scripts->add_data( 'media-upload', 'group', 1 );
  290. $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), '20101007' );
  291. $scripts->add_data( 'admin-widgets', 'group', 1 );
  292. $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20090422' );
  293. $scripts->add_data( 'word-count', 'group', 1 );
  294. $scripts->localize( 'word-count', 'wordCountL10n', array(
  295. 'count' => __('Word count: %d'),
  296. 'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};'
  297. ));
  298. $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'thickbox' ), '20110118' );
  299. $scripts->add_data( 'theme', 'group', 1 );
  300. $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407' );
  301. $scripts->add_data( 'theme-preview', 'group', 1 );
  302. $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20110113' );
  303. $scripts->add_data( 'inline-edit-post', 'group', 1 );
  304. $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
  305. 'error' => __('Error while saving the changes.'),
  306. 'ntdeltitle' => __('Remove From Bulk Edit'),
  307. 'notitle' => __('(no title)'),
  308. 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
  309. ) );
  310. $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), '20100615' );
  311. $scripts->add_data( 'inline-edit-tax', 'group', 1 );
  312. $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
  313. 'error' => __('Error while saving the changes.'),
  314. 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
  315. ) );
  316. $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), '20110113' );
  317. $scripts->add_data( 'plugin-install', 'group', 1 );
  318. $scripts->localize( 'plugin-install', 'plugininstallL10n', array(
  319. 'plugin_information' => __('Plugin Information:'),
  320. 'ays' => __('Are you sure you want to install this plugin?'),
  321. 'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};'
  322. ) );
  323. $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
  324. $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20110113' );
  325. $scripts->add_data( 'dashboard', 'group', 1 );
  326. $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '20090102' );
  327. $scripts->add_data( 'hoverIntent', 'group', 1 );
  328. $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js", null, '20091223' );
  329. $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery-ui-draggable' ), '20101022' );
  330. $scripts->add_data( 'media', 'group', 1 );
  331. $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), '20091111' );
  332. $scripts->add_data( 'image-edit', 'group', 1 );
  333. $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), '20100518' );
  334. $scripts->add_data( 'set-post-thumbnail', 'group', 1 );
  335. $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. 'l10n_print_after' => 'try{convertEntities(setPostThumbnailL10n);}catch(e){};'
  341. ) );
  342. // Navigation Menus
  343. $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array('jquery-ui-sortable'), '20100814' );
  344. $scripts->localize( 'nav-menu', 'navMenuL10n', array(
  345. 'noResultsFound' => _x('No results found.', 'search results'),
  346. 'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
  347. 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
  348. 'l10n_print_after' => 'try{convertEntities(navMenuL10n);}catch(e){};'
  349. ) );
  350. $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20101025' );
  351. $scripts->add_data( 'custom-background', 'group', 1 );
  352. }
  353. }
  354. /**
  355. * Assign default styles to $styles object.
  356. *
  357. * Nothing is returned, because the $styles parameter is passed by reference.
  358. * Meaning that whatever object is passed will be updated without having to
  359. * reassign the variable that was passed back to the same value. This saves
  360. * memory.
  361. *
  362. * Adding default styles is not the only task, it also assigns the base_url
  363. * property, the default version, and text direction for the object.
  364. *
  365. * @since 2.6.0
  366. *
  367. * @param object $styles
  368. */
  369. function wp_default_styles( &$styles ) {
  370. // This checks to see if site_url() returns something and if it does not
  371. // then it assigns $guess_url to wp_guess_url(). Strange format, but it works.
  372. if ( ! $guessurl = site_url() )
  373. $guessurl = wp_guess_url();
  374. $styles->base_url = $guessurl;
  375. $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
  376. $styles->default_version = get_bloginfo( 'version' );
  377. $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
  378. $styles->default_dirs = array('/wp-admin/');
  379. $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
  380. $rtl_styles = array( 'wp-admin', 'global', 'colors', 'colors-fresh', 'colors-classic', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'nav-menu', 'farbtastic', 'admin-bar', 'wplink', 'theme-install' );
  381. // Any rtl stylesheets that don't have a .dev version for ltr
  382. $no_suffix = array( 'farbtastic' );
  383. $styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110214' );
  384. $styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20101102' );
  385. $styles->add_data( 'ie', 'conditional', 'lte IE 7' );
  386. // all colors stylesheets need to have the same query strings (cache manifest compat)
  387. $colors_version = '20110121';
  388. // Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string.
  389. $styles->add( 'colors', true, array(), $colors_version );
  390. // do not refer to these directly, the right one is queued by the above "meta" colors handle
  391. $styles->add( 'colors-fresh', "/wp-admin/css/colors-fresh$suffix.css", array(), $colors_version );
  392. $styles->add( 'colors-classic', "/wp-admin/css/colors-classic$suffix.css", array(), $colors_version );
  393. $styles->add( 'ms', "/wp-admin/css/ms$suffix.css", array(), '20101213' );
  394. $styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20110121' );
  395. $styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20110121' );
  396. $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20110104' );
  397. $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20110121' );
  398. $styles->add( 'install', "/wp-admin/css/install$suffix.css", array(), '20110121' ); // Readme as well
  399. $styles->add( 'theme-editor', "/wp-admin/css/theme-editor$suffix.css", array(), '20101203' );
  400. $styles->add( 'press-this', "/wp-admin/css/press-this$suffix.css", array(), '20110121' );
  401. $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20090514' );
  402. $styles->add( 'login', "/wp-admin/css/login$suffix.css", array(), '20110121' );
  403. $styles->add( 'plugin-install', "/wp-admin/css/plugin-install$suffix.css", array(), '20101230' );
  404. $styles->add( 'theme-install', "/wp-admin/css/theme-install$suffix.css", array(), '20101226' );
  405. $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u' );
  406. $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
  407. $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' );
  408. $styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100907' );
  409. $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20110122' );
  410. $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array(), '20101224' );
  411. $styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101224' );
  412. foreach ( $rtl_styles as $rtl_style ) {
  413. $styles->add_data( $rtl_style, 'rtl', true );
  414. if ( $suffix && ! in_array( $rtl_style, $no_suffix ) )
  415. $styles->add_data( $rtl_style, 'suffix', $suffix );
  416. }
  417. }
  418. /**
  419. * Reorder JavaScript scripts array to place prototype before jQuery.
  420. *
  421. * @since 2.3.1
  422. *
  423. * @param array $js_array JavaScript scripst array
  424. * @return array Reordered array, if needed.
  425. */
  426. function wp_prototype_before_jquery( $js_array ) {
  427. if ( false === $jquery = array_search( 'jquery', $js_array, true ) )
  428. return $js_array;
  429. if ( false === $prototype = array_search( 'prototype', $js_array, true ) )
  430. return $js_array;
  431. if ( $prototype < $jquery )
  432. return $js_array;
  433. unset($js_array[$prototype]);
  434. array_splice( $js_array, $jquery, 0, 'prototype' );
  435. return $js_array;
  436. }
  437. /**
  438. * Load localized data on print rather than initialization.
  439. *
  440. * These localizations require information that may not be loaded even by init.
  441. *
  442. * @since 2.5.0
  443. */
  444. function wp_just_in_time_script_localization() {
  445. wp_localize_script( 'autosave', 'autosaveL10n', array(
  446. 'autosaveInterval' => AUTOSAVE_INTERVAL,
  447. 'previewPageText' => __('Preview this Page'),
  448. 'previewPostText' => __('Preview this Post'),
  449. 'requestFile' => admin_url('admin-ajax.php'),
  450. 'savingText' => __('Saving Draft&#8230;'),
  451. 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
  452. 'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};'
  453. ) );
  454. }
  455. /**
  456. * Administration Panel CSS for changing the styles.
  457. *
  458. * If installing the 'wp-admin/' directory will be replaced with './'.
  459. *
  460. * The $_wp_admin_css_colors global manages the Administration Panels CSS
  461. * stylesheet that is loaded. The option that is set is 'admin_color' and is the
  462. * color and key for the array. The value for the color key is an object with
  463. * a 'url' parameter that has the URL path to the CSS file.
  464. *
  465. * The query from $src parameter will be appended to the URL that is given from
  466. * the $_wp_admin_css_colors array value URL.
  467. *
  468. * @since 2.6.0
  469. * @uses $_wp_admin_css_colors
  470. *
  471. * @param string $src Source URL.
  472. * @param string $handle Either 'colors' or 'colors-rtl'.
  473. * @return string URL path to CSS stylesheet for Administration Panels.
  474. */
  475. function wp_style_loader_src( $src, $handle ) {
  476. if ( defined('WP_INSTALLING') )
  477. return preg_replace( '#^wp-admin/#', './', $src );
  478. if ( 'colors' == $handle || 'colors-rtl' == $handle ) {
  479. global $_wp_admin_css_colors;
  480. $color = get_user_option('admin_color');
  481. if ( empty($color) || !isset($_wp_admin_css_colors[$color]) )
  482. $color = 'fresh';
  483. $color = $_wp_admin_css_colors[$color];
  484. $parsed = parse_url( $src );
  485. $url = $color->url;
  486. if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG )
  487. $url = preg_replace('/.css$|.css(?=\?)/', '.dev.css', $url);
  488. if ( isset($parsed['query']) && $parsed['query'] ) {
  489. wp_parse_str( $parsed['query'], $qv );
  490. $url = add_query_arg( $qv, $url );
  491. }
  492. return $url;
  493. }
  494. return $src;
  495. }
  496. /**
  497. * Prints the script queue in the HTML head on admin pages.
  498. *
  499. * Postpones the scripts that were queued for the footer.
  500. * print_footer_scripts() is called in the footer to print these scripts.
  501. *
  502. * @since 2.8
  503. * @see wp_print_scripts()
  504. */
  505. function print_head_scripts() {
  506. global $wp_scripts, $concatenate_scripts;
  507. if ( ! did_action('wp_print_scripts') )
  508. do_action('wp_print_scripts');
  509. if ( !is_a($wp_scripts, 'WP_Scripts') )
  510. $wp_scripts = new WP_Scripts();
  511. script_concat_settings();
  512. $wp_scripts->do_items( 'l10n' );
  513. $wp_scripts->do_concat = $concatenate_scripts;
  514. $wp_scripts->do_head_items();
  515. if ( apply_filters('print_head_scripts', true) )
  516. _print_scripts();
  517. $wp_scripts->reset();
  518. return $wp_scripts->done;
  519. }
  520. /**
  521. * Prints the scripts that were queued for the footer on admin pages.
  522. *
  523. * @since 2.8
  524. */
  525. function print_footer_scripts() {
  526. global $wp_scripts, $concatenate_scripts;
  527. if ( ! did_action('wp_print_footer_scripts') )
  528. do_action('wp_print_footer_scripts');
  529. if ( !is_a($wp_scripts, 'WP_Scripts') )
  530. return array(); // No need to run if not instantiated.
  531. script_concat_settings();
  532. $wp_scripts->do_concat = $concatenate_scripts;
  533. $wp_scripts->do_footer_items();
  534. if ( apply_filters('print_footer_scripts', true) )
  535. _print_scripts();
  536. $wp_scripts->reset();
  537. return $wp_scripts->done;
  538. }
  539. function _print_scripts() {
  540. global $wp_scripts, $compress_scripts;
  541. $zip = $compress_scripts ? 1 : 0;
  542. if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
  543. $zip = 'gzip';
  544. if ( !empty($wp_scripts->concat) ) {
  545. if ( !empty($wp_scripts->print_code) ) {
  546. echo "<script type='text/javascript'>\n";
  547. echo "/* <![CDATA[ */\n";
  548. echo $wp_scripts->print_code;
  549. echo "/* ]]> */\n";
  550. echo "</script>\n";
  551. }
  552. $ver = md5("$wp_scripts->concat_version");
  553. $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . trim($wp_scripts->concat, ', ') . "&ver=$ver";
  554. echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n";
  555. }
  556. if ( !empty($wp_scripts->print_html) )
  557. echo $wp_scripts->print_html;
  558. }
  559. /**
  560. * Prints the script queue in the HTML head on the front end.
  561. *
  562. * Postpones the scripts that were queued for the footer.
  563. * wp_print_footer_scripts() is called in the footer to print these scripts.
  564. *
  565. * @since 2.8
  566. */
  567. function wp_print_head_scripts() {
  568. if ( ! did_action('wp_print_scripts') )
  569. do_action('wp_print_scripts');
  570. global $wp_scripts;
  571. if ( !is_a($wp_scripts, 'WP_Scripts') )
  572. return array(); // no need to run if nothing is queued
  573. return print_head_scripts();
  574. }
  575. /**
  576. * Prints the scripts that were queued for the footer on the front end.
  577. *
  578. * @since 2.8
  579. */
  580. function wp_print_footer_scripts() {
  581. return print_footer_scripts();
  582. }
  583. /**
  584. * Wrapper for do_action('wp_enqueue_scripts')
  585. *
  586. * Allows plugins to queue scripts for the front end using wp_enqueue_script().
  587. * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
  588. *
  589. * @since 2.8
  590. */
  591. function wp_enqueue_scripts() {
  592. do_action('wp_enqueue_scripts');
  593. }
  594. function print_admin_styles() {
  595. global $wp_styles, $concatenate_scripts, $compress_css;
  596. if ( !is_a($wp_styles, 'WP_Styles') )
  597. $wp_styles = new WP_Styles();
  598. script_concat_settings();
  599. $wp_styles->do_concat = $concatenate_scripts;
  600. $zip = $compress_css ? 1 : 0;
  601. if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
  602. $zip = 'gzip';
  603. $wp_styles->do_items(false);
  604. if ( apply_filters('print_admin_styles', true) ) {
  605. if ( !empty($wp_styles->concat) ) {
  606. $dir = $wp_styles->text_direction;
  607. $ver = md5("$wp_styles->concat_version{$dir}");
  608. $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . "&ver=$ver";
  609. echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
  610. }
  611. if ( !empty($wp_styles->print_html) )
  612. echo $wp_styles->print_html;
  613. }
  614. $wp_styles->do_concat = false;
  615. $wp_styles->concat = $wp_styles->concat_version = $wp_styles->print_html = '';
  616. return $wp_styles->done;
  617. }
  618. function script_concat_settings() {
  619. global $concatenate_scripts, $compress_scripts, $compress_css;
  620. $compressed_output = ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') );
  621. if ( ! isset($concatenate_scripts) ) {
  622. $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true;
  623. if ( ! is_admin() || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) )
  624. $concatenate_scripts = false;
  625. }
  626. if ( ! isset($compress_scripts) ) {
  627. $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true;
  628. if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
  629. $compress_scripts = false;
  630. }
  631. if ( ! isset($compress_css) ) {
  632. $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true;
  633. if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
  634. $compress_css = false;
  635. }
  636. }
  637. add_action( 'wp_default_scripts', 'wp_default_scripts' );
  638. add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
  639. add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
  640. add_action( 'wp_default_styles', 'wp_default_styles' );
  641. add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );