Viewing 5 reply threads
  • Author
    Posts
    • #3898
      windir10
      Member

      Hi !
      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 !

    • #3899
      Steve
      Keymaster

      @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.

    • #3902
      windir10
      Member

      Thanks a lot for the fast support. Indeed, issue is fixed with the v0.9.4.27. Great job !

    • #3906
      Steve
      Keymaster

      Great! 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.

    • #3908
      windir10
      Member

      It’s done 😉

    • #3909
      Steve
      Keymaster

      That you so much for the great review!

      Closing ticket.

Viewing 5 reply threads
  • The topic ‘Enqueue conditional script with wp_scripts’ is closed to new replies.