Title: Passing Parameters?
Last modified: August 20, 2016

---

# Passing Parameters?

 *  Resolved [AJ Mallory](https://wordpress.org/support/users/jasonm4563/)
 * (@jasonm4563)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/passing-parameters/)
 * Writing a plugin to use google maps and I’m trying to figure out how to pass 
   the api key. The end result should look like `<script type='text/javascript' 
   src='http://maps.google.com/api/js?key=API_KEY_FROM _PHP_Script&sensor=false'
   >` I can’t seem to figure out how to append the “API_KEY_FROM_PHP_script” part.
   I think I need to call wp_register_script and such. I’m pretty sure I need this
   <script> tag in the header section of the eventual resulting page/post.
 * Anyone care to point me in the proper direction?
    Much Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [michael.mariart](https://wordpress.org/support/users/michaelmariart/)
 * (@michaelmariart)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/passing-parameters/#post-3069306)
 * This will depend on how you are going to use your plugin. If it’s only for yourself,
   then you can hard-code your key into the code there. If you are going to distribute
   the plugin somewhere you should store the value using
    `update_option('gmaps_key',
   $key);` and then retrieve it using `get_option ("gmaps_key");`
 * Of course, the names that I’ve used there can be changed to suit your own purposes.
 *  Thread Starter [AJ Mallory](https://wordpress.org/support/users/jasonm4563/)
 * (@jasonm4563)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/passing-parameters/#post-3069342)
 * Thanks for the response, not quite what I’m looking for. I have all the DB stuff
   working fine. What I need help with is how to get the variable output to the 
   client browser. I know when I have it figured out I will feel stupid as I’m sure
   the answer is quite simple and should be obvious, but it’s not…
 * Normally using plan PHP I would just write this `<script type='text/javascript'
   src='http://maps.googleapis.com/maps/api/js?key=" . $myarray_options['api_key']."&
   sensor=false'></script>` and it would head on its way. How do I get this into
   the header section using wordpress?
 * Thanks again.
 *  Thread Starter [AJ Mallory](https://wordpress.org/support/users/jasonm4563/)
 * (@jasonm4563)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/passing-parameters/#post-3069350)
 * Looks like I figured it out. You simply add the needed stuff when you call wp_register_script
   like this `wp_register_script('google_map_ref', 'http://maps.googleapis.com/maps/
   api/js?key='. $myarray_options["api_key"] .'&sensor=false');`
 * Hope this will help someone else looking for this info…

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Passing Parameters?’ is closed to new replies.

## Tags

 * [google maps api](https://wordpress.org/support/topic-tag/google-maps-api/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [AJ Mallory](https://wordpress.org/support/users/jasonm4563/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/passing-parameters/#post-3069350)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
