724 posts
  • Author had a Free File of the Month
  • Grew a moustache for the Envato Movember competition
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
  • Beta Tester
  • Microlancer Beta Tester
  • Bought between 50 and 99 items
  • Referred between 1 and 9 users
  • Has been a member for 1-2 years
+1 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?

3364 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred more than 2000 users
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+4 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.

724 posts
  • Author had a Free File of the Month
  • Grew a moustache for the Envato Movember competition
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
  • Beta Tester
  • Microlancer Beta Tester
  • Bought between 50 and 99 items
  • Referred between 1 and 9 users
  • Has been a member for 1-2 years
+1 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
  • Referred between 10 and 49 users
  • Europe
  • Exclusive Author
  • Has been a member for 1-2 years
  • Bought between 1 and 9 items
  • Sold between 10 000 and 50 000 dollars
codenegar says

Check if “wp_print_scripts” works?

724 posts
  • Author had a Free File of the Month
  • Grew a moustache for the Envato Movember competition
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
  • Beta Tester
  • Microlancer Beta Tester
  • Bought between 50 and 99 items
  • Referred between 1 and 9 users
  • Has been a member for 1-2 years
+1 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.

306 posts Keeping Things Simple
  • Elite Author
  • Exclusive Author
  • Referred between 500 and 999 users
  • Has been a member for 1-2 years
  • Bought between 1 and 9 items
  • Portugal
  • Microlancer Beta Tester
+2 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 :)

279 posts
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Has been a member for 1-2 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
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.

724 posts
  • Author had a Free File of the Month
  • Grew a moustache for the Envato Movember competition
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
  • Beta Tester
  • Microlancer Beta Tester
  • Bought between 50 and 99 items
  • Referred between 1 and 9 users
  • Has been a member for 1-2 years
+1 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