WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#16699 closed defect (bug) (invalid)

wp_enqueue_script prints current WordPress version not script version

Reported by: rfair404 Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: General Keywords:
Focuses: Cc:

Description

When using wp_enqueue_script and wp_register_script the resulting html output in the header looks like this.

<script type="text/javascript" src="http://192.168.1.133/wp-content/themes/pnap/lib/flash/player-files/jwplayer.js?ver=3.2-bleeding"></script>

Notice that the version is 3.2-bleeding which is the the script version, but the wordpress version.

here is the register and enqueue scripts...

add_action('init', 'pnap_flash_register_swfobject');
function pnap_flash_register_swfobject() {
wp_register_script('jwplayer', PNAP_FLA_URL.'/player-files/jwplayer.js');
}
add_action('wp_print_scripts', 'pnap_flash_enqueue_swfobject');
function pnap_flash_enqueue_swfobject() {
wp_enqueue_script('jwplayer');
}

The good news is that this does not seem to cause any problems at the time being.

Change History (7)

#1 @rfair404
10 years ago

As a follow up, I know that I am not including a version number when registering the script, but that is displayed as an optional argument on codex, so theoretically shouldn't leaving it blank just not show a version number at all?

#2 follow-up: @dd32
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

This is the expected behaviour.

You can pass a NULL parameter in as the version to prevent any version number being printed. See the documentation for this.

#3 in reply to: ↑ 2 @hakre
10 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Replying to dd32:

This is the expected behaviour.

You can pass a NULL parameter in as the version to prevent any version number being printed. See the documentation for this.

Passing NULL to optional parameters in PHP can trigger the default value (might vary accross PHP versions), which is FALSE here. So do you wanted to say that passing FALSE prevent any version number being printed?

#4 follow-up: @scribu
10 years ago

So do you wanted to say that passing FALSE prevent any version number being printed?

No, he meant NULL. FALSE means the WP version is used (akward, yes).

Passing NULL to optional parameters in PHP can trigger the default value

Do you have a reference for that statement?

#5 @scribu
10 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

Also, please don't reopen tickets without a clear rationale for doing so.

#6 @scribu
10 years ago

In other words, you don't need to re-open a ticket just to ask for clarifications.

#7 in reply to: ↑ 4 @hakre
10 years ago

Replying to scribu:

So do you wanted to say that passing FALSE prevent any version number being printed?

No, he meant NULL. FALSE means the WP version is used (akward, yes).

Thanks for clarification.

Passing NULL to optional parameters in PHP can trigger the default value

Do you have a reference for that statement?

I'm not able to verify that in a timely manner, no. I knew that some PHP internal functions do so, but for user-code this does not seem to be the case for the PHP configurations I was able to test against.

Note: See TracTickets for help on using tickets.