Assuming you are using wp_enqueue_script to load the .js, then use wp_localize_script to set the value of your key.
Another option is to use wp_add_inline_script instead of wp_localize_script
.
Related Posts:
- How to access data in wordpress database externally using php
- How do I show data from gravity forms in my template? [closed]
- I Want to Get A Plugin Version Number Dynamically
- Delete tables from database when deleting plugin
- Is it bad practice to create own table for a plugin?
- How to Add an Index to Plugin Database table
- How can I delete orphan keys in WordPress database tables?
- Is there a plugin that will override the “Error establishing a database connection” message? [closed]
- How to delete all records from or empty a custom database table?
- Get a list of all WordPress.org Plugins?
- What are these entries in the database? Looks similar to JSON
- [Plugin WPML] : How to create a translation of a post using the WPML API?
- WordPress sharding: which multi-DB plugin to use?
- What WordPress API function lists active/inactive plugins?
- Creating two database tables via plugin
- How to properly insert data into custom table via plugin
- How does WordPress handle MySQL row lock errors?
- How to make sense of the active_plugins option_value to enable and disable certain plugins from the database?
- Change Page’s Tag Using functions.php File
- How to build an API as a plugin
- How to empty wordpress custom post Database table
- Get Latest Plugin Version from WP API
- insert data in database table from plugin with WP3.1
- Simple form that saves to database
- How to run Two WordPress blogs with different themes and with single database and same content
- $wpdb->get_results leaking memory
- Plugins or Tutorials for displaying data from SQL-db on WP-page? [closed]
- Insert query inserts 2 entries, should insert 1
- Using Vagrant for customizable WordPress Multi-sites [closed]
- How should I use register_setting, add_settings_section, & add_settings_field in my plugin’s options page?
- Is it a bad practice to go directly to the mysql database while developing a plugin?
- Updating WordPress – the best approach (updating wp core, plugins and db)
- How do I check what plugins are enabled via the database?
- How do I retrieve a list of popular plugins using the WordPress.org Plugin API?
- How to store ACF custom fields data in a custom table
- Can I explicitly specify ENGINE=InnoDB in WordPress?
- How can a Firebase user registration and login be integrated into a WordPress site?
- Bad Request (Invalid Hostname) on working server, database problem
- Plugin Not Working, But Only On GoDaddy Hosted site
- Create custom column in post table in wordpress
- Custom database or Custom Post Types?
- Using custom code, how can I fetch data from the WordPress plugin repo?
- Can’t use /wp-json/wp/v2/plugins API endpoint even as administrator
- Custom database table for plugin not creating on activation
- Send Data to WordPress from kiosk
- WordPress plugin DB upgrade
- Multisite functions to communicate with individual site functions
- How to update widget_text in the wp_options table
- Get the last post ID
- Add agenda items and notifications
- Does the WordPress API have Modal Dialogs
- How to count number of records found in a database table?
- Should I global $wpdb outside of any of my plugin’s functions scope?
- prefix table and plugins
- An Unexpected HTTP Error occurred during the API request
- Taking WordPress table prefixes into account
- Changing BIGINT to INT
- WordPress register_activation_hook table creation not working
- How to add Edit | Delete button on rows?
- REST-API: extend media-endpoint
- How to check if WordPress is updating plugins?
- The plugin generated x characters of unexpected output, $wpdb not defined
- Custom routing for plugins
- Advanced Integration – WordPress + YOURLS
- how to show database content in wordpress post
- What is the easiest way to implement cascading database upgrade for my plugin?
- clean wp_options table unused rows
- Get Plugin Information from Multiple Sites Externally
- Ajax with jQuery UI dialog not working
- How to edit/delete single row items in a table on my own menu page
- What is the best way to move a plugin´s subdirectory+files to wp-content/uploads-directory?
- Create or Update thousands of woocommerce products via PHP
- Storing Email Account Passwords for SMTP Mailing for a WordPress Plugin
- Looking for a solution – slightly convoluted problem
- Remove obsolete plugins artifacts from database tables
- Keep user’s privileges on accessing contents in JSON response
- If I delete plugins via FTP are settings kept in DB?
- greatest() function returns undefined property
- Get total number of comment of the posts written by an author
- How to write one comment and publish on every post using database or plugin?
- Is the wordpress user-model changed in wpmu?
- Default Plugin Settings Not Writing to Database
- Creating Tables on Network Activation
- Make id column as AUTO INCREMENT on plugin activation
- What kind of data is that?
- Cannot login to ADMIN even after changing password in phpmyadmin
- Unable to create new database table upon plugin activation using dbDelta
- Where to hook my plugin’s action
- Embed a Google Sheet as you view it in a separate tab?
- Best way to hook a custom url?
- How to determine what is generating large amount of database queries?
- Building an email signup form. Where should the information be saved in the DB?
- Saving Custom Post types and fields to a custom table
- How can I add an options page for my class based plugin?
- Sending WP posts to external API
- Retrieving a Value from a wp-database
- Need help restoring my WordPress blog
- WP plugins for building a database?
- Where does WordPress store plugin (enabled/disabled) status for multisite?
- CMB2 Repeatable Group & JSON API