Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#45512 closed defect (bug) (invalid)

After WordPress 5.0 update js_escape is deprecated

Reported by: adampatterson's profile adampatterson Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.0
Component: Formatting Keywords:
Focuses: javascript Cc:

Description

After upgrading to WordPress 5.0 locally, I get the following error.

Notice: js_escape is <strong>deprecated</strong> since version 2.8.0! Use esc_js() instead. in /wp-includes/functions.php on line 3861

Looking at the core file I can clearly see that the function is still part of formatting.php where esc_js calls apply_filters on js_escape which is deprecated and recommends that I use esc_js.

https://github.com/WordPress/WordPress/blob/56c162fbc9867f923862f64f1b4570d885f1ff03/wp-includes/formatting.php#L4272

https://github.com/WordPress/WordPress/blob/6fd8080e7ee7599b36d4528f72a8ced612130b8c/wp-includes/deprecated.php#L2053

I don't know why I haven't experienced this before as it looks like to code hasn't been changed in a long time.

My Plugins are up to date and many of them include esc_js such as Woo Commerce and JetPack.

Change History (4)

#1 @dd32
6 years ago

  • Keywords reporter-feedback added

Hey @adampatterson,

I believe you'll find that one of your up-to-date plugins is calling escape_js(). The likely explanation is that it had some 5.0-only functionality built in ready for release, but since you weren't yet on 5.0 it wasn't running that part of the code.

esc_js() calls the js_escape filter but doesn't call the escape_js() function at all.

You can use a plugin such as Query Monitor to debug what plugin is calling js_escape() and causing the deprecated notice.

#2 @SergeyBiryukov
6 years ago

  • Component changed from General to Formatting
  • Focuses javascript added

#3 @adampatterson
6 years ago

Thanks!

Yea I was confused because esc_js is frequently used by many plugins.

But it turns out that Woopra ( hasn't been updated in over a year ) was the culprit.

Last edited 6 years ago by adampatterson (previous) (diff)

#4 @swissspidy
6 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.