From 12de05107e4c8b006bde6ee8916f34eb476d08da Mon Sep 17 00:00:00 2001 From: donncha Date: Fri, 13 Jun 2008 17:21:00 +0000 Subject: WP Merge with revision 8075 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1328 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/class.wp-scripts.php | 89 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 wp-includes/class.wp-scripts.php (limited to 'wp-includes/class.wp-scripts.php') diff --git a/wp-includes/class.wp-scripts.php b/wp-includes/class.wp-scripts.php new file mode 100644 index 0000000..d829c8e --- /dev/null +++ b/wp-includes/class.wp-scripts.php @@ -0,0 +1,89 @@ +do_items( $handles ); + } + + function print_scripts_l10n( $handle ) { + if ( empty($this->registered[$handle]->extra['l10n']) || empty($this->registered[$handle]->extra['l10n'][0]) || !is_array($this->registered[$handle]->extra['l10n'][1]) ) + return false; + + $object_name = $this->registered[$handle]->extra['l10n'][0]; + + echo "\n"; + + return true; + } + + function do_item( $handle ) { + if ( !parent::do_item($handle) ) + return false; + + $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version; + if ( isset($this->args[$handle]) ) + $ver .= '&' . $this->args[$handle]; + + $src = $this->registered[$handle]->src; + if ( !preg_match('|^https?://|', $src) ) { + $src = $this->base_url . $src; + } + + $src = add_query_arg('ver', $ver, $src); + $src = clean_url(apply_filters( 'script_loader_src', $src, $handle )); + + $this->print_scripts_l10n( $handle ); + + echo "\n"; + + return true; + } + + /** + * Localizes a script + * + * Localizes only if script has already been added + * + * @param string handle Script name + * @param string object_name Name of JS object to hold l10n info + * @param array l10n Array of JS var name => localized string + * @return bool Successful localization + */ + function localize( $handle, $object_name, $l10n ) { + if ( !$object_name || !$l10n ) + return false; + return $this->add_data( $handle, 'l10n', array( $object_name, $l10n ) ); + } + + function all_deps( $handles, $recursion = false ) { + $r = parent::all_deps( $handles, $recursion ); + if ( !$recursion ) + $this->to_do = apply_filters( 'print_scripts_array', $this->to_do ); + return $r; + } +} -- cgit