Skip to main content
Tweeted twitter.com/StackWordPress/status/891573688860016640
edited tags
Link
Johansson
  • 15.4k
  • 11
  • 43
  • 79
Source Link
Owaiz Yusufi
  • 502
  • 1
  • 5
  • 19

It would be a right way to enqueue the script using foreach loop?

It would be a right way to enqueue the scripts using foreach loop only for jquery, jquery-ui-widget, jquery-UI-accordion, jquery-ui-slider, jquery-ui-tabs, jquery-ui-datepicker, Jquery-ui-dialog and Jquery-ui-button because I have to write it many times so

I have make it like this:

 $jquery_ui = array(
    'jquery',
    'jquery-ui-core',
    'jquery-ui-widget',
    'jquery-ui-accordion',
    'jquery-ui-slider',
    'jquery-ui-tabs',
    'jquery-ui-datepicker',
    'jquery-ui-dialog',
    'jquery-ui-button',
 );

 // Framework JS
foreach ($jquery_ui as $ui) {
    wp_enqueue_script($ui);
}

So I just want to know this laziness is a right way or not:)