Tagged: wp_enqueue_script
- This topic has 5 replies, 2 voices, and was last updated 6 years, 7 months ago by
Steve.
-
AuthorPosts
-
-
June 18, 2015 at 11:39 am #3898
windir10MemberHi !
First of all, well done for your plugin, it’s awesome for building custom forms fastly and the array syntax is very flexible !But I meet a problem with the use of wp_scripts object and his function “add_data”. The condition appears 2 times in the generated source code.
If I desactivate Piklist, all is ok…
Here’s my code in functions.php :
global $wp_scripts; wp_register_script('html5shiv-script', '//html5shiv.googlecode.com/svn/trunk/html5.js'); $wp_scripts->add_data('html5shiv-script', 'conditional', 'lt IE 9'); wp_enqueue_script('html5shiv-script');And here’s the generated html code :
<!--[if lt IE 9]> <!--[if lt IE 9]> <script type='text/javascript' src='//html5shiv.googlecode.com/svn/trunk/html5.js?ver=4.2.2'></script> <![endif]--> <![endif]-->Any ideas ? Thanks !
-
June 19, 2015 at 1:47 pm #3899
SteveKeymaster@windir10– Welcome to the Piklist Community!
Before WordPress 4.2 it wasn’t easy to conditionally load enqueued scripts… so Piklist, of course, made it super easy. Now, WP 4.2 has added in this feature, and that’s where your duplicate code is coming from.
I just pushed Piklist v0.9.4.27 to WordPress.org. It has a conditional that will only load the Piklist code in WP 4.1 and lower.
Thank you for finding this!
Let us know if you still have issues.
-
June 22, 2015 at 5:48 am #3902
windir10MemberThanks a lot for the fast support. Indeed, issue is fixed with the v0.9.4.27. Great job !
-
June 22, 2015 at 10:34 am #3906
SteveKeymasterGreat! If you are happy with our support and Piklist, please consider leaving us a 5 Star review on WordPress.org. It really helps the project.
-
June 22, 2015 at 10:46 am #3908
windir10MemberIt’s done 😉
-
June 22, 2015 at 10:52 am #3909
SteveKeymasterThat you so much for the great review!
Closing ticket.
-
-
AuthorPosts
- The topic ‘Enqueue conditional script with wp_scripts’ is closed to new replies.