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
- Delete tables from database when deleting plugin
- Get a list of all WordPress.org Plugins?
- How to build an API as a plugin
- How to run Two WordPress blogs with different themes and with single database and same content
- Plugins or Tutorials for displaying data from SQL-db on WP-page? [closed]
- How do I check what plugins are enabled via the database?
- Can I explicitly specify ENGINE=InnoDB in WordPress?
- 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?
- Send Data to WordPress from kiosk
- Get the last post ID
- Add agenda items and notifications
- How to count number of records found in a database table?
- 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?
- The plugin generated x characters of unexpected output, $wpdb not defined
- Advanced Integration – WordPress + YOURLS
- clean wp_options table unused rows
- Get Plugin Information from Multiple Sites Externally
- Storing Email Account Passwords for SMTP Mailing for a WordPress Plugin
- Keep user’s privileges on accessing contents in JSON response
- 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?
- Make id column as AUTO INCREMENT on plugin activation
- Best way to hook a custom url?
- Saving Custom Post types and fields to a custom table
- When to use action hooks and plugins
- WordPress JSON API remove posts from a specific category
- How to create custom tables in WordPress using my own plugin?
- DROP TABLE with uninstall hook not working
- how to oauth1 Wp plug-in revoke/reset.?
- How to modify WCMP Rest API response?
- How can I perform high-level database merging for WordPress within continues delivery?
- Limit post creation by role
- WordPress Backend HA (Automatic failover)
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- wp_editor content in plugin options page
- Multiple instance of data in plugin custom database table on plugin activation
- WordPress plugin creating database in localhost but not on real host
- WordPress api call using wp-ajax returns error 400
- Is it necessary to auto delete my WP plugin database tables when users deactivate/delete my plugin?
- How do i edit the plugin files in DataBase via phpMyAdmin?
- How to insert and call new data in wordpress website database through a plugin
- Issue running db create table query from static method
- Problem of encoding characters (apostrophes) in my posts publications
- Separate database for a wordpress plugin
- Is there a rule for wordpress plugins developers to not do any database changes upon update?
- How to do database for download stats?
- How to get theme’s info from wordpress.org/themes using api.wordpress.org?
- What is the WordPress approach to custom data?
- Custom API plugin to execute 3rd party API to retrieve data
- How retreive saved data from gravity forms in my template?
- Api external with wordpress
- How can ι create my own (custom) WordPress table/list?
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- WordPress plugin boilerplate table create
- How to relate 3 wordpress components with each other (Create database relationships)
- Creating a search form and displaying results
- How can I store data from custom fields to custom tables?
- How to access the WordPress DB from a plugin file
- How to display results from a data table with an encrypted user id?
- add_action for publish_post doesn’t work
- Getting URL GET parameter with Code snippets and storing it in database?
- How to convert Currency from USD to other IP Based currency in Php function
- Same Plugin tables between wordpress installations
- Bulk Edit Media Library alt, caption, image names
- Cant create table on plugin activation
- Escape commas in REST API
- Optimise wordpress database using SQL after deleting registered images from Media Folder
- How to implement data residency in my WordPress site
- How to use third-party SendGrid Email Validation API in Gravity Forms?
- Moving a few select DB tables to a new WP instance
- is it possible to fetch data from a remote api while admin is writing a new post?
- How wordpress handle urls present in db for external wp-content directory
- wp_remote_post To external API multiple values with the same key
- Using Filters to modify contect – DB query results alwats appear fist
- wp rest api (v2) filter not working (404 error – rest_no_route)
- Many to many relationship for variable products
- Is it a good practice to use wordpress database to store pages contents which loading to page dynamically?
- Where do the section input fields values are stored in database
- How to create a custom page for unrelated database?
- Convert HTML5/CSS3 site to WordPress Theme (need a lot of plugins) or just use the API?
- How to save information related to post in database?
- RSS Feed has no Items (Possible Plugins Conflict)
- A plugin is giving me “You do not have sufficient permissions to access this page.” error
- How to find an option in the database?
- wpdb get_var is not returning any result (verified mysql query returns only one value)
- Creating fields in the database
- Allow users to enter and edit data in one-to-many configuration
- Updating WordPress [closed]
- How to add/manage Followers (email subscribers) via API?
- Text Wrapping in WPDataTables
- Am having issues intergrating this api into my wordpress site, any help please?
- Store large dataset in WordPress installation temporary
- Is it possible to create post in wordpress using postman?