Support » Plugin: Stellar Places » api key?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Micah Wood

    (@woodent)

    There can be. If your usage exceeds the API usage limits and you need to purchase additional quota: https://developers.google.com/maps/documentation/javascript/tutorial#api_key

    Thank you,

    Would I need to modify the init.php to include the key, or just call it first in my own page template? It looks like filtering enqueue scripts isn’t an option. (Maybe an admin page where I could set a key)

    Plugin Author Micah Wood

    (@woodent)

    I’ll probably end up implementing an admin page where you can add an API key. However, you can easily implement it without touching the plugin code:

    define( 'STELLAR_PLACES_GOOGLE_MAPS_API_KEY', 'apiKeyGoesHere' );
    
    if( defined( 'STELLAR_PLACES_GOOGLE_MAPS_API_KEY' ) ) {
        add_filter( 'script_loader_src', 'stellar_places_add_google_maps_api_key' );
    
        function stellar_places_add_google_maps_api_key( $src, $handle ) {
    	if ( 'google-maps-js-api' == $handle || 'google-maps-js-api-places-library' == $handle ) {
    		$src = add_query_arg( 'key', STELLAR_PLACES_GOOGLE_MAPS_API_KEY, $src );
    	}
    	return $src;
        }
    }

    I’d probably add the constant definition to your wp-config.php file and then drop the rest of the code in a custom site-specific plugin.

    oh brilliant. thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘api key?’ is closed to new replies.