Ashley Brown Ashley Brown - 1 year ago 91
PHP Question

WP enqueue Google Maps API syntax error

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('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', '//' ), [], 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.

Answer Source

In this line

wp_enqueue_script('google-maps', '//' ), [], null, true);

Your brackets don't match up

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download