diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
commit | 3a4570b0fc8b3d6339bef71d17d7701554e0bbf7 (patch) | |
tree | 2a06e5261263c68d8afd95a6328879dc289cb909 /wp-includes/script-loader.php | |
parent | b83c34a7010faee0223f6037025c350da12e05e6 (diff) | |
download | wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.gz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.xz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.zip |
Merge with WP 2.3 - testing use only!
Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1069 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/script-loader.php')
-rw-r--r-- | wp-includes/script-loader.php | 128 |
1 files changed, 75 insertions, 53 deletions
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 8ee90aa..2a7730c 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -2,6 +2,7 @@ class WP_Scripts { var $scripts = array(); var $queue = array(); + var $to_print = array(); var $printed = array(); var $args = array(); @@ -11,8 +12,11 @@ class WP_Scripts { function default_scripts() { $this->add( 'dbx', '/wp-includes/js/dbx.js', false, '2.05' ); + $this->add( 'fat', '/wp-includes/js/fat.js', false, '1.0-RC1_3660' ); + $this->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); + $this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3958' ); $this->localize( 'quicktags', 'quicktagsL10n', array( 'quickLinks' => __('(Quick Links)'), @@ -25,11 +29,15 @@ class WP_Scripts { 'enterImageURL' => __('Enter the URL of the image'), 'enterImageDescription' => __('Enter a description of the image') ) ); + $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' ); - $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20070326' ); + + $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20070528' ); $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); - $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070225' ); - $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0-0'); + $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070528' ); + + $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.1.1'); + $this->add( 'autosave', '/wp-includes/js/autosave.js', array('prototype', 'sack'), '20070306'); $this->localize( 'autosave', 'autosaveL10n', array( 'autosaveInterval' => apply_filters('autosave_interval', '120'), @@ -38,6 +46,7 @@ class WP_Scripts { 'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php', 'savingText' => __('Saving Draft...') ) ); + $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306'); $this->localize( 'wp-ajax', 'WPAjaxL10n', array( 'defaultUrl' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php', @@ -45,21 +54,28 @@ class WP_Scripts { 'strangeText' => __("Something strange happened. Try refreshing the page."), 'whoaText' => __("Slow down, I'm still sending your data!") ) ); + $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306' ); $this->localize( 'listman', 'listManL10n', array( 'jumpText' => __('Jump to new item'), 'delText' => __('Are you sure you want to delete this %thing%?') ) ); - $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.0'); - $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.0'); - $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.0'); - $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.0'); - $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.0'); - $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.0'); - $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.0'); + + $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/scriptaculous.js', array('prototype'), '1.7.1-b3'); + $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.1-b3'); + $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.1-b3'); + $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.1-b3'); + $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.1-b3'); + $this->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.7.1-b3' ); + $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.1-b3'); + $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.1-b3'); + $this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118'); - $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.2'); + + $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.4'); + $this->add( 'jquery-form', '/wp-includes/js/jquery/jquery.form.js', array('jquery'), '1.0.3'); $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2'); + if ( is_admin() ) { global $pagenow; $man = false; @@ -78,7 +94,7 @@ class WP_Scripts { break; endswitch; if ( $man ) { - $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key.js', array('dbx'), '20070417' ); + $this->add( 'dbx-admin-key', '/wp-admin/js/dbx-admin-key.js', array('dbx'), '20070417' ); $this->localize( 'dbx-admin-key', 'dbxL10n', array( 'manager' => $man, 'open' => __('open'), @@ -89,17 +105,22 @@ class WP_Scripts { 'toggleKey' => __(', or press the enter key to %toggle% it'), ) ); } - $this->add( 'ajaxcat', '/wp-admin/cat.js', array('listman'), '20070417' ); + $this->add( 'ajaxcat', '/wp-admin/js/cat.js', array('listman'), '20070724' ); $this->localize( 'ajaxcat', 'catL10n', array( 'add' => attribute_escape(__('Add')), 'how' => __('Separate multiple categories with commas.') ) ); - $this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' ); - $this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' ); - $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '20070327' ); - $this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '4583' ); - $this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' ); - $this->add( 'upload', '/wp-admin/upload.js', array('prototype'), '20070306' ); + $this->add( 'ajaxlinkcat', '/wp-admin/js/link-cat.js', array('listman'), '200700601' ); + $this->localize( 'ajaxlinkcat', 'linkcatL10n', array( + 'add' => attribute_escape(__('Add')), + 'how' => __('Separate multiple categories with commas.') + ) ); + $this->add( 'admin-categories', '/wp-admin/js/categories.js', array('listman'), '3684' ); + $this->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('listman'), '3733' ); + $this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('listman'), '20070327' ); + $this->add( 'admin-users', '/wp-admin/js/users.js', array('listman'), '4583' ); + $this->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); + $this->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' ); $this->localize( 'upload', 'uploadL10n', array( 'browseTitle' => attribute_escape(__('Browse your files')), 'back' => __('« Back'), @@ -134,27 +155,15 @@ class WP_Scripts { * @return array Scripts that have been printed */ function print_scripts( $handles = false ) { + global $wp_db_version; + // Print the queue if nothing is passed. If a string is passed, print that script. If an array is passed, print those scripts. $handles = false === $handles ? $this->queue : (array) $handles; - $handles = $this->all_deps( $handles ); - $this->_print_scripts( $handles ); - return $this->printed; - } + $this->all_deps( $handles ); - /** - * Internally used helper function for printing script tags - * - * @param array handles Hierarchical array of scripts to be printed - * @see WP_Scripts::all_deps() - */ - function _print_scripts( $handles ) { - global $wp_db_version; + $to_print = apply_filters( 'print_scripts_array', array_keys($this->to_print) ); - foreach( array_keys($handles) as $handle ) { - if ( !$handles[$handle] ) - return; - elseif ( is_array($handles[$handle]) ) - $this->_print_scripts( $handles[$handle] ); + foreach( $to_print as $handle ) { if ( !in_array($handle, $this->printed) && isset($this->scripts[$handle]) ) { if ( $this->scripts[$handle]->src ) { // Else it defines a group. $ver = $this->scripts[$handle]->ver ? $this->scripts[$handle]->ver : $wp_db_version; @@ -162,11 +171,11 @@ class WP_Scripts { $ver .= '&' . $this->args[$handle]; $src = 0 === strpos($this->scripts[$handle]->src, 'http://') ? $this->scripts[$handle]->src : get_option( 'siteurl' ) . $this->scripts[$handle]->src; $src = $this->scripts[$handle]->src; - + if (!preg_match('|^https?://|', $src)) { $src = get_option('siteurl') . $src; } - + $src = add_query_arg('ver', $ver, $src); $src = clean_url(apply_filters( 'script_loader_src', $src )); echo "<script type='text/javascript' src='$src'></script>\n"; @@ -175,6 +184,9 @@ class WP_Scripts { $this->printed[] = $handle; } } + + $this->to_print = array(); + return $this->printed; } function print_scripts_l10n( $handle ) { @@ -199,33 +211,43 @@ class WP_Scripts { /** * Determines dependencies of scripts * - * Recursively builds hierarchical array of script dependencies. Does NOT catch infinite loops. + * Recursively builds array of scripts to print taking dependencies into account. Does NOT catch infinite loops. * * @param mixed handles Accepts (string) script name or (array of strings) script names * @param bool recursion Used internally when function calls itself - * @return array Hierarchical array of dependencies */ function all_deps( $handles, $recursion = false ) { - if ( ! $handles = (array) $handles ) - return array(); - $return = array(); + if ( !$handles = (array) $handles ) + return false; + foreach ( $handles as $handle ) { $handle = explode('?', $handle); if ( isset($handle[1]) ) $this->args[$handle[0]] = $handle[1]; $handle = $handle[0]; - if ( is_null($return[$handle]) ) // Prime the return array with $handles - $return[$handle] = true; - if ( $this->scripts[$handle]->deps ) { - if ( false !== $return[$handle] && array_diff($this->scripts[$handle]->deps, array_keys($this->scripts)) ) - $return[$handle] = false; // Script required deps which don't exist + + if ( isset($this->to_print[$handle]) ) // Already grobbed it and its deps + continue; + + $keep_going = true; + if ( !isset($this->scripts[$handle]) ) + $keep_going = false; // Script doesn't exist + elseif ( $this->scripts[$handle]->deps && array_diff($this->scripts[$handle]->deps, array_keys($this->scripts)) ) + $keep_going = false; // Script requires deps which don't exist (not a necessary check. efficiency?) + elseif ( $this->scripts[$handle]->deps && !$this->all_deps( $this->scripts[$handle]->deps, true ) ) + $keep_going = false; // Script requires deps which don't exist + + if ( !$keep_going ) { // Either script or its deps don't exist. + if ( $recursion ) + return false; // Abort this branch. else - $return[$handle] = $this->all_deps( $this->scripts[$handle]->deps, true ); // Build the hierarchy - } - if ( $recursion && false === $return[$handle] ) - return false; // Cut the branch + continue; // We're at the top level. Move on to the next one. + } + + $this->to_print[$handle] = true; } - return $return; + + return true; } /** |