WP_Dependencies: pass NULL to disable script and style version query strings, props scribu amattie, fixes #11315
git-svn-id: http://svn.automattic.com/wordpress/trunk@12558 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
16e175cc0f
commit
7b40c7a03f
|
@ -232,8 +232,6 @@ class _WP_Dependency {
|
|||
@list($this->handle, $this->src, $this->deps, $this->ver, $this->args) = func_get_args();
|
||||
if ( !is_array($this->deps) )
|
||||
$this->deps = array();
|
||||
if ( !$this->ver )
|
||||
$this->ver = false;
|
||||
}
|
||||
|
||||
function add_data( $name, $data ) {
|
||||
|
|
|
@ -90,9 +90,13 @@ class WP_Scripts extends WP_Dependencies {
|
|||
if ( false === $group && in_array($handle, $this->in_footer, true) )
|
||||
$this->in_footer = array_diff( $this->in_footer, (array) $handle );
|
||||
|
||||
$ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
|
||||
if ( null === $this->registered[$handle]->ver )
|
||||
$ver = '';
|
||||
else
|
||||
$ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
|
||||
|
||||
if ( isset($this->args[$handle]) )
|
||||
$ver .= '&' . $this->args[$handle];
|
||||
$ver = $ver ? $ver . '&' . $this->args[$handle] : '?' . $this->args[$handle];
|
||||
|
||||
$src = $this->registered[$handle]->src;
|
||||
|
||||
|
@ -114,7 +118,8 @@ class WP_Scripts extends WP_Dependencies {
|
|||
$src = $this->base_url . $src;
|
||||
}
|
||||
|
||||
$src = add_query_arg('ver', $ver, $src);
|
||||
if ( !empty($ver) )
|
||||
$src = add_query_arg('ver', $ver, $src);
|
||||
$src = esc_url(apply_filters( 'script_loader_src', $src, $handle ));
|
||||
|
||||
if ( $this->do_concat )
|
||||
|
|
|
@ -35,9 +35,13 @@ class WP_Styles extends WP_Dependencies {
|
|||
if ( !parent::do_item($handle) )
|
||||
return false;
|
||||
|
||||
$ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
|
||||
if ( null === $this->registered[$handle]->ver )
|
||||
$ver = '';
|
||||
else
|
||||
$ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
|
||||
|
||||
if ( isset($this->args[$handle]) )
|
||||
$ver .= '&' . $this->args[$handle];
|
||||
$ver = $ver ? $ver . '&' . $this->args[$handle] : '?' . $this->args[$handle];
|
||||
|
||||
if ( $this->do_concat ) {
|
||||
if ( $this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt']) ) {
|
||||
|
@ -100,7 +104,8 @@ class WP_Styles extends WP_Dependencies {
|
|||
$src = $this->base_url . $src;
|
||||
}
|
||||
|
||||
$src = add_query_arg('ver', $ver, $src);
|
||||
if ( !empty($ver) )
|
||||
$src = add_query_arg('ver', $ver, $src);
|
||||
$src = apply_filters( 'style_loader_src', $src, $handle );
|
||||
return esc_url( $src );
|
||||
}
|
||||
|
|
|
@ -38,7 +38,12 @@ function wp_print_scripts( $handles = false ) {
|
|||
* Register new JavaScript file.
|
||||
*
|
||||
* @since r16
|
||||
* @see WP_Dependencies::add() For parameter information.
|
||||
* @param string $handle Script name
|
||||
* @param string $src Script url
|
||||
* @param array $deps (optional) Array of script names on which this script depends
|
||||
* @param string|bool $ver (optional) Script version (used for cache busting), set to NULL to disable
|
||||
* @param bool (optional) Wether to enqueue the script before </head> or before </body>
|
||||
* @return null
|
||||
*/
|
||||
function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
|
||||
global $wp_scripts;
|
||||
|
@ -56,7 +61,7 @@ function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_f
|
|||
* Localizes only if script has already been added.
|
||||
*
|
||||
* @since r16
|
||||
* @see WP_Script::localize()
|
||||
* @see WP_Scripts::localize()
|
||||
*/
|
||||
function wp_localize_script( $handle, $object_name, $l10n ) {
|
||||
global $wp_scripts;
|
||||
|
@ -86,8 +91,8 @@ function wp_deregister_script( $handle ) {
|
|||
* Registers the script if src provided (does NOT overwrite) and enqueues.
|
||||
*
|
||||
* @since r16
|
||||
* @see WP_Script::add(), WP_Script::enqueue()
|
||||
*/
|
||||
* @see wp_register_script() For parameter information.
|
||||
*/
|
||||
function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
|
||||
global $wp_scripts;
|
||||
if ( !is_a($wp_scripts, 'WP_Scripts') )
|
||||
|
|
|
@ -45,9 +45,8 @@ function wp_print_styles( $handles = false ) {
|
|||
* @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
|
||||
* @param array $deps Array of handles of any stylesheet that this stylesheet depends on.
|
||||
* (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
|
||||
* @param string|bool $ver String specifying the stylesheet version number, if it has one. This parameter
|
||||
* is used to ensure that the correct version is sent to the client regardless of caching, and so should be included
|
||||
* if a version number is available and makes sense for the stylesheet.
|
||||
* @param string|bool $ver String specifying the stylesheet version number. Set to NULL to disable.
|
||||
* Used to ensure that the correct version is sent to the client regardless of caching.
|
||||
* @param string $media The media for which this stylesheet has been defined.
|
||||
*/
|
||||
function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
|
||||
|
@ -78,6 +77,8 @@ function wp_deregister_style( $handle ) {
|
|||
/**
|
||||
* Enqueue a CSS style file.
|
||||
*
|
||||
* Registers the style if src provided (does NOT overwrite) and enqueues.
|
||||
*
|
||||
* @since r79
|
||||
* @see WP_Styles::add(), WP_Styles::enqueue()
|
||||
* @global object $wp_styles The WP_Styles object for printing styles.
|
||||
|
|
Loading…
Reference in New Issue