1002 posts
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 50+ items on Envato Market
  • Contributed a free file of the month
+6 more
greenline says

I have a buyer, he uses a free template from template-help.com.

The wp_enqueue_script call which I use in one of my plugins does not execute when the plugin is used with themes downloaded from template-help.com

Anyone experienced that before?

3431 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Volunteer moderator says

Assuming you attached your wp_enqueue_script() call to the right action hook, the theme probably forgot to include wp_head() or wp_footer() in its header.php and/or footer.php. In that case the action to print header/footer scripts would never be called.

1002 posts
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 50+ items on Envato Market
  • Contributed a free file of the month
+6 more
greenline says

This is how I call wp_enqueue_script():

/**
 * Register plugin's javascript
 */
function my_scripts() {
  wp_register_script('myplugin', plugins_url('includes/myplugin.js', __FILE__), '1,0');
}
add_action('wp_enqueue_scripts', 'my_scripts');

/**
 * Define the shortcode and its attributes
 */
function myshortcode($atts) {
  // Enqueue jquery script and plugin's script
  wp_enqueue_script("jquery");
  wp_enqueue_script('myplugin');
  ....
}

EDIT: I removed from the code any reference to my plugin’s name.

362 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+3 more
codenegar says

Check if “wp_print_scripts” works?

1002 posts
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 50+ items on Envato Market
  • Contributed a free file of the month
+6 more
greenline says

Thanks, I will try. The problem is, the customer is a beginner without programming knowledge and he also does not give me admin access :-) Nice as always. And, of course – the issue appears on the live website.

326 posts Keeping Things Simple
  • Has referred 500+ members
  • Has sold $125,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 1+ items on Envato Market
+8 more
cmoreira says

Assuming you attached your wp_enqueue_script() call to the right action hook, the theme probably forgot to include wp_head() or wp_footer() in its header.php and/or footer.php. In that case the action to print header/footer scripts would never be called.
this solved all the similar problems I add from clients.

If he can’t add this lines of code himself, and doesn’t give you admin access… then… not much more you can do :)

280 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
PrimaThemes says

I tried to modify your code above, please try this if needed

/**
 * Register plugin's javascript
 */
function my_scripts() {
  wp_register_script('myplugin', plugins_url('includes/myplugin.js', __FILE__), array( 'jquery' ), '1.0', true);
}
add_action('wp_enqueue_scripts', 'my_scripts');

/**
 * Define the shortcode and its attributes
 */
function myshortcode($atts) {
  // Enqueue jquery script and plugin's script
  wp_enqueue_script('myplugin');
  ....
}

Your javascript requires jquery, so I put the $deps=array('jquery') on the dependency list, and no need to call jquery again on your shortcode. Then i put $in_footer=true to make sure that your javascript will be executed on footer. This is a better approach.


Thanks, I will try. The problem is, the customer is a beginner without programming knowledge and he also does not give me admin access :-) Nice as always. And, of course – the issue appears on the live website.

No need to be a developer to do this. I always try to give simple explanation for this type of buyer. The point is, they need to check it by himself. You can start making a standard answer for this.

For example:

- I believe that something wrong with your free theme. If you want to use free theme, I recommend you to download it from official WordPress repository, http://wordpress.org/themes/ because it follows all WordPress standard and already checked by WordPress reviewer.

- If you want to help me to check, you can go to Appearance – Editor, and click header.php on the left to edit this file and search wp_head. Then click footer.php on the left to edit this file and search wp_footer. If you can’t find it, it means that your theme is not standard and the theme developer has to fix it.

1002 posts
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 50+ items on Envato Market
  • Contributed a free file of the month
+6 more
greenline says

Thank you so much PrimaThemes! Such a detailed and helpful answer!
I will make these changes in the following version of my plugin too.

We just got it sorted out after about 5 hours of emails & debugging together – it turned out that functions.php and header.php from the free theme had some errors.

Pffff I have 10 years experience as Java&web developer … PHP still has some secrets for me :) I like your approach about free themes :) I never knew how to tell people that free themes have bugs without offending them.

Thank you guys for your help. Another happy customer, time to go to sleep.

by
by
by
by
by
by