Skip to content

Instantly share code, notes, and snippets.

@Fitoussi
Last active April 13, 2016 09:24
Show Gist options
  • Select an option

  • Save Fitoussi/b0552acc6a2d8a2d3e549ef29ff32d24 to your computer and use it in GitHub Desktop.

Select an option

Save Fitoussi/b0552acc6a2d8a2d3e549ef29ff32d24 to your computer and use it in GitHub Desktop.
Apply Google Places Address Autocomplete to an input field
function gmw_include_google_places_api() {
//register google maps api if not already registered
if ( !wp_script_is( 'google-maps', 'registered' ) ) {
wp_register_script( 'google-maps', ( is_ssl() ? 'https' : 'http' ) . '://maps.googleapis.com/maps/api/js?libraries=places&sensor=false', array( 'jquery' ), false );
}
//enqueue google maps api if not already enqueued
if ( !wp_script_is( 'google-maps', 'enqueued' ) ) {
wp_enqueue_script( 'google-maps' );
}
}
add_action( 'wp_enqueue_scripts', 'gmw_include_google_places_api' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment