$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Wordpress 5.1 upgrade has lost the parent theme JavaScript|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Wordpress 5.1 upgrade has lost the parent theme JavaScript

matteradmin10PV0评论

I have just upgraded from Wordpress 4.9 to 5.1, which obviously comes with Gutenberg.

One major problem I have is that the parent theme (BeTheme) JavaScript is not being loaded and instead the child theme JavaScript is being loaded for a second time.

After the point where wp_footer() is called I have this:

<script type='text/javascript' src='/wp-content/themes/betheme/assets/animations/animations.min.js?ver=21.1.1.1'></script>
<script type='text/javascript' src='/wp-content/themes/betheme/assets/jplayer/jplayer.min.js?ver=21.1.1.1'></script>
<script type='text/javascript' src='/wp-content/themes/betheme/js/parallax/translate3d.js?ver=21.1.1.1'></script>
<script type='text/javascript' src='/wp-content/themes/crmpiccodotcom/js/scripts.js?ver=21.1.1.1'></script>

Whereas on my old installation the last line would be pointing to the parent theme JavaScript.

What has caused this to change in 5.1?

I have just upgraded from Wordpress 4.9 to 5.1, which obviously comes with Gutenberg.

One major problem I have is that the parent theme (BeTheme) JavaScript is not being loaded and instead the child theme JavaScript is being loaded for a second time.

After the point where wp_footer() is called I have this:

<script type='text/javascript' src='https://crmpicco.localhost/wp-content/themes/betheme/assets/animations/animations.min.js?ver=21.1.1.1'></script>
<script type='text/javascript' src='https://crmpicco.localhost/wp-content/themes/betheme/assets/jplayer/jplayer.min.js?ver=21.1.1.1'></script>
<script type='text/javascript' src='https://crmpicco.localhost/wp-content/themes/betheme/js/parallax/translate3d.js?ver=21.1.1.1'></script>
<script type='text/javascript' src='https://crmpicco.localhost/wp-content/themes/crmpiccodotcom/js/scripts.js?ver=21.1.1.1'></script>

Whereas on my old installation the last line would be pointing to the parent theme JavaScript.

What has caused this to change in 5.1?

Share Improve this question edited Mar 13, 2019 at 8:25 crmpicco asked Mar 12, 2019 at 8:30 crmpiccocrmpicco 8411 gold badge11 silver badges16 bronze badges 2
  • 1 WordPress does not modify third-party themes. More than that, it does not care where your scripts are enqueued from. – Max Yudin Commented Mar 12, 2019 at 8:42
  • Nothing has changed in WordPress that would cause this. Either the parent theme updated and changed something or you've made a change and forgotten about it. Can you share the code you're using to enqueue scripts? Or even how the parent theme enqueues them. – Jacob Peattie Commented Mar 12, 2019 at 11:27
Add a comment  | 

1 Answer 1

Reset to default 1

I traced this back to the name of the scripts.js JavaScript file.

My parent theme (BeTheme) enqueues the main scripts.js like this:

wp_enqueue_script('mfn-scripts', get_theme_file_uri('/js/scripts.js'), array('jquery'), MFN_THEME_VERSION, true);

In my child theme crmpiccodotcom/footer.php I enqueue the scripts.js like this:

// include the crmpiccodotcom child theme JavaScript
add_action('wp_enqueue_scripts', 'crmpiccodotcom_enqueue_scripts');
function crmpiccodotcom_enqueue_scripts() {
    wp_enqueue_script(
        'custom-script',
        CHILD_THEME_URI. '/js/scripts.js',
        array('jquery')
    );
}

Seemingly the name caused a clash and the BeTheme used the child theme's scripts.js instead of it's own, so the fix was to rename the child theme scripts.js -> crmpicco-scripts.js

I believe the issue lies with the BeTheme, which I will take up with them, but certainly a file rename resolves this.

Post a comment

comment list (0)

  1. No comments so far