It’s basically a unique id of the script you registered or enqueued before.
Let’s say we enqueued a two scripts with wp_enqueue_script():
wp_enqueue_script( 'my_script_1','/js/some_script.js' );
wp_enqueue_script( 'my_script_2','/js/some_other_script.js' );
Now you want to pass your $data
to the script #2 with wp_localize_script():
wp_localize_script( 'my_script_2', 'my_script_2_local', $data );
After this – when WordPress prints out your my_script_2
it will print out your $data
variables along with it so you can use them in your script.
As you can see my_script_2
is our handle here – it makes the link between our script functions.
Related Posts:
- How can I run AJAX on a button click event?
- How-to implement admin Ajax inside an admin WP_List_Table?
- WP_LOCALIZE_SCRIPT doesn’t work
- How to localize admin.php only once
- wp.template() returns tags in Ajax response
- Update Data parameter of a wp_localize_script() call
- Translate javascript with WordPress built-in localization API for static strings
- About a programming language starts with [closed]
- Using JavaScript in WordPress page to call for server data using AJAX
- Filterable posts using categories
- Ajax Response Error | just getting error as the response
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- How can I rewrite a URL to pass requests to a custom method via AJAX? (I can’t use admin-ajax.php)
- get post attachment using ajax
- Dashboard – get status and position of metaboxes and pass them to ajax method
- How to prevent UNDO on guternberg block editor
- Create a new post using rest api and save featured image using an external image url
- how to search users by ajax live search
- Do I have to worry about useState causing a re-render?
- Creating a custom Gutenberg block with columns
- Ajax random number always the same
- “import declarations may only appear at top level of a module” when importing WooCommerce API node module
- How to get Metabox custom field to show checked if value is updated using post meta query?
- Gutenberg: import dependency or assign from global variable?
- Storing data in wordpress database from ajax call from different website
- My WordPress plugin cannot load my JavaScript file
- javascript datatables in a plugin
- How to send Ajax request from my plugin in admin dashboard?
- Fatal error: Uncaught Error: Call to undefined function get_option()
- Create custom HTML/JS app inside page
- AJAX success response is not working but it’s saving my changes
- Use just a shortcode from another page
- template_redirect or admin-ajax.php?
- add javascript files only when plugin is called?
- how to get context information inside my funcion
- Inserting code to HTML view from a pop up initiated from visual view
- Plugin – Make sure jquery is loaded in my settings page plus my JS file
- How can I avoid conflicts between plugin and theme?
- How to control an elements classes from multiple Gutenberg sidebar controls?
- Why is wp_localize_script returning false?
- How should I go about registering JavaScript that isn’t a file? [duplicate]
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- AJAX form post returns 0
- jquery & ajax sending data to php
- wp_localize_script is not adding a global variable for javascript
- should i be checking for jquery before enqueing it in a plugin
- Can’t get AJAX call working in custom plugin
- Bad Request in AJAX
- Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
- 400 Bad Request, in wordpress theme development, wp_ajax
- Ajax is not working in a loop
- ajax recursive calls on wordpress returning answers outsite the function scope
- Loading custom js file on the admin page through plugin
- Ajax submit result opens in admin-ajax.php
- Are there any security risks when submitting data-attribute data through AJAX?
- Run JavaScript validation script on form submit in plugin
- Custom Plugin – CSS works, JS doesn’t
- insert query on a custom table using ajax with jQuery plugin Jeditable
- How to get error object returned by wp_create_user
- Plugin AJAX Save to Custom Table
- Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
- Data not insert and update through ajax and jQuery in admin page?
- Setting a JSON web token from a secondary api as a secure cookie on WordPress
- WP ajax requests not stacking?
- Need help about understand api, wp, $ syntax in WordPress plugin script
- How do I get rid of my inclusion race-condition on wp_enqueue_script
- Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
- How to add a panel/box/widget/are/screen to the right side of edit post/page confusion
- Insert Into Post Not Working For Audio File Using jQuery
- Service Worker Uncaught (in promise) DOMException
- Developing the save function in Gutenberg blocks
- Gutenberg – is it ok to load dependencies multiple times?
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- AJAX button with success callback. (Titan Framework)
- ajax working when function is on child theme but not in plugin page
- AJAX call to admin-ajax.php by subscriber returns home page
- AJAX call returns ‘testtest0’ instead of ‘test’ – why?
- Ajax function is not working on WordPress
- Best practice for plugin: always detect admin-ajax call?
- add_action wp_ajax_ not loading in plugin file WP Network
- Is there a better way to access transients using javascript
- Why is the form not updating when I select a new sector from the list?
- Referencing files in JavaScript in WordPress Plugin
- How to insert HTML/CSS/JS into my iframe plugin?
- Workflow for new importer plugin – your advices?
- Plugin Form Submitting to admin-ajax.php instead of admin-post.php
- Ajax +wordpress onClick link redirect to new page and create html content
- Use options to control jQuery plugin
- Is there a WordPress plugin to design WebGL? [closed]
- Should I put my plugin javascript inline?
- How to localize data array in plugin’s option page
- AJAX request not routing through proxy
- Get cat parameter from admin-ajax
- How to write a shopping queue line plugin with a queue button?
- Get localize of a loaded javascript
- WordPress (pagenow link) in ajaxurl change after i change plugin language
- How to use wp_send_json() and output the value with ajax?
- wp.media libary pdf type
- Ajax on the Administration Side of plugin – returns 0
- How to do admin ajax request in a plugin for rest api