WordPress Page Template Plugin: Bug Fix – box-replacement.js issue

By Haktan Suren, PhD
In Blog
May 2nd, 2013
0 Comments
6404 Views

There is a bug on WordPress Page Template Plugin that I have recently discovered. In the plugin, there is a JS file dependent on Jquery. But when it is enqueued in the WordPress, it was not stated dependency on Jquery so it results in loading before jquery if jquery is not enqueued before. As a result of that, it generates error in browser console and causes js clashes and conflicts. I hope this bug fix helps other people who are also having the same problem and the author of the plugin considers this in the future update.

Replace this

wp_enqueue_script('pgt-helper', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/scripts/functions.js');
wp_enqueue_script('pgt-ajax', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/scripts/ajax.js');
wp_enqueue_script('pgt-box-placement', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/scripts/box-placement.js');
wp_enqueue_style('pgt-style-admin', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/css/style.admin.css');

with

wp_enqueue_script('pgt-helper', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/scripts/functions.js');
wp_enqueue_script('pgt-ajax', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/scripts/ajax.js');
wp_enqueue_script('pgt-box-placement', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/scripts/box-placement.js', array('jquery'));
wp_enqueue_style('pgt-style-admin', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/css/style.admin.css');

About the Author

Haktan Suren, PhD
- Webguru, Programmer, Web developer, and Father :)

Wrap your code in <code class="{language}"></code> tags to embed!

Leave a Reply

E-mail address is required for commenting. However, it won't be visible to other users.

Loading Facebook Comments ...
Loading Disqus Comments ...