Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Can you link to a page with the issue?
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Can you unminify your code so that you can debug it easier?
done.
Search:
<script type="text/javascript">/* <![
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
This code is found inside the page/ post ‘Text’ editor? Have you considered separating out using a Custom JS plugin instead?
I do believe the problem is this new function on 4.2.3 version of WordPress:
/**
* Replace characters or phrases within HTML elements only.
*
* @since 4.2.3
*
* @param string $haystack The text which has to be formatted.
* @param array $replace_pairs In the form array('from' => 'to', ...).
* @return string The formatted text.
*/
function wp_replace_in_html_tags( $haystack, $replace_pairs ) {
Our code work fine in previous version of wordpress and the automatic upgrade broke our function.
Of course, we can change our pages and change the code for a custom plugin and a custom shortcode, but you have a error in your code.
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
I always thought the ‘Text’ editor should only contain code that the ‘Visual’ editor can contain. So, that excludes JavaScript. It seems you were using a hacky way to get the JS in there in the first place:
<!--
It’s very usual include javascript into page and post of WordPress before 4.2.3. If you have your criteria it is a new.
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
The recommended techniques have always been to enqueue JavaScript using your Child Theme functions.php file: https://codex.ww.wp.xz.cn/Using_Javascript
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
For posts, it says only call the function name in your Text editor. Don’t write JS code there: https://codex.ww.wp.xz.cn/Using_Javascript#JavaScript_in_Posts
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Use a plugin if you don’t want to enqueue things https://ww.wp.xz.cn/plugins/tc-custom-javascript/
We are move the code to a external javascript and work fine as:
<script src="/lib/themes/DiviChild/partnerLogo.js"></script>
Thanks
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
I see your problem, maybe the Codex needs to be updated. I asked to discuss with the Codex community if the “JavaScript in Posts” article is still relevant.
Not sure if this works for you; https://codex.ww.wp.xz.cn/Talk:Using_Javascript
I’ve found an easy solution and posted it in another thread – https://ww.wp.xz.cn/support/topic/no-javascript-redirects-after-wordpress-423?replies=4.
However, what we are doing is slightly dirty so it is probably better to enqueue or use a plugin.
THis solution don’t work in my cases because some javascript characters are transformet as [, ], etc.
Thks