I'm using the theme Sage from Roots.
/**
* Theme assets
*/
function assets() {
wp_enqueue_style('sage/css', Assets\asset_path('styles/main.css'), false, null);
if (is_single() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
wp_enqueue_script('sage/js', Assets\asset_path('scripts/main.js'), ['jquery'], null, true);
wp_enqueue_script('extras', Assets\asset_path('scripts/extras.js'), [], null, true);
wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?key=MY_API_KEY&callback=initMap' ), [], null, true);
}
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\assets', 100);
The first two instances of wp_enqueue_script work fine but after I added the google maps API, I get:
Parse error: syntax error, unexpected ',' in /srv/www/***/current/web/app/themes/*********/lib/setup.php on line 106
Line 106 is the google maps line. Where is the extra comma? I know that it isn't a typo futher up/down in the script because if I remove the maps API part, it works as expected.
In this line
wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?key=MY_API_KEY&callback=initMap' ), [], null, true);
Your brackets don't match up