WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 7 years ago

Last modified 9 months ago

#21969 closed defect (bug) (fixed)

Wrong URL in wp_enqueue_script()

Reported by: pavelevap Owned by: nacin
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.4
Component: Themes Keywords: has-patch
Focuses: Cc:

Description

This problem is probably related to fixed ticket #21749

Example theme directory

wp-content/themes/Some Theme/Theme

I noticed it with one premium theme. Users usually upload downloaded files through FTP with one more parent directory.

Function get_template_directory_uri() returns right URL:

wp-content/themes/Some Theme/Theme

But using it with wp_enqueue_script():

wp_enqueue_script( 'maxheight',  get_template_directory_uri() . '/js/maxheight.js' );

it returns wrong URL:

wp-content/themes/SomeTheme/Theme/js/maxheight.js

And script is not loaded in the end (Not Found error).

Reproduced on current trunk and 3.4.x.

Attachments (2)

21969.patch (815 bytes) - added by SergeyBiryukov 8 years ago.
21969.diff (537 bytes) - added by kovshenin 7 years ago.

Download all attachments as: .zip

Change History (11)

#1 @SergeyBiryukov
8 years ago

  • Keywords has-patch added

Related: ticket:21749:2

get_*_directory_uri() should probably return encoded results, like their WP_Theme counterparts.

#2 @SergeyBiryukov
8 years ago

  • Version changed from trunk to 3.4

#3 @ocean90
7 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.9

#4 @nacin
7 years ago

  • Keywords needs-unit-tests added

I'm good with this. Let's just get some unit tests. It should be possible to filter the stylesheet values and then call the function.

#5 @azizur
7 years ago

  • Keywords needs-unit-tests removed

Looks like ticket #21749 has got unit tests to cover this scenario.

#6 @nacin
7 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 27710:

Encode spaces in get_template_directory_uri() and get_stylesheet_directory_uri().

props SergeyBiryukov.
fixes #21969.

@kovshenin
7 years ago

#7 @kovshenin
7 years ago

  • Keywords commit removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

r27710 broke some unit tests:

  • Tests_XMLRPC_wp_getOptions::test_option_values_subscriber
  • Tests_XMLRPC_wp_getOptions::test_option_values_admin

See 21969.diff.

#8 @SergeyBiryukov
7 years ago

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

In 27915:

Fix copy/paste error in [27710].

props kovshenin.
fixes #21969.

This ticket was mentioned in Slack in #core by sergey. View the logs.


9 months ago

Note: See TracTickets for help on using tickets.