Reputation: 41
hi i use this code in my wp site
function theme_files() {
$scripts = [
// ['handle' => 'date', 'src'=>'jquery.ui.datepicker-cc.all.min.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true],
['handle' => 'date', 'src'=>'js-persian-cal.min.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true],
['handle' => 'paralax', 'src'=>'jquery.fullpage.min.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true],
['handle' => 'fullslud', 'src'=>'jquery.superslides.min.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true],
['handle' => 'carousel', 'src'=>'owl-carousel.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true],
['handle' => 'mmenu', 'src'=>'jquery.mmenu.min.all.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true],
['handle' => 'lightbox', 'src'=>'lightbox.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true],
['handle' => 'masonry', 'src'=>'masonry.pkgd.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true],
['handle' => 'template', 'src'=>'theme.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true],
['handle' => 'selectbox', 'src'=>'select2.min.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true]
];
for ($i=0; $i < sizeof($scripts); $i++) {
wp_enqueue_script( $scripts[$i]['handle'], get_template_directory_uri() . '/js/' . $scripts[$i]['src'], $scripts[$i]['dep'], $scripts[$i]['ver'] );
}
}
but my customer migrate his website to a host with old version of php and i get syntax error
and i need to convert this array to old version. can any one help me?
Upvotes: 3
Views: 42
Reputation: 1531
Use from following structure:
$scripts = array(
array('handle' => 'date', 'src'=>'js-persian-cal.min.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true),
array('handle' => 'paralax', 'src'=>'jquery.fullpage.min.js','dep'=> array( 'jquery' ),'var'=> false,'in_foot'=> true)
);
I had same issue and converted my arrays to old structure.
foreach($scripts as $script){
wp_enqueue_script( $script['handle'], get_template_directory_uri() . '/js/' . $script['src'], $script['dep'], $script['ver'] );
}
Upvotes: 1