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 you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- ajaxurl not defined on front end
- Why does WordPress add 0 (zero) to an Ajax response?
- How to include jQuery and JavaScript files correctly?
- Saving data-URI to media library
- How to implement color picker from wordpress in my plugin?
- Nonces can be reused multiple times? Bug / Security issue?
- Add async script
- API to trigger prompt on leaving page
- Test to see if jQuery or Prototype is queued by another plugin?
- jQuery in header or footer
- How to Add a .js file Only in one specific Page Dynamically to Head
- How to prevent loading of all plugin’s resources?
- How to enable users to down-vote in this simple voting counter (that uses the post meta)?
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Using Ajax call in jQuery doesn’t work in widget
- Making a custom widget that includes a tinymce and works in Site Origin Page Builder
- Timeout on Admin-Ajax?
- What’s the better way to add an inline script?
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- Ajax in WordPress – path issue
- Gutenberg: useDispatch is not a function – @wordpress/data included
- Make a list with header and subtext in Gutenberg blocks
- How to Load Plugin JS in theme’s footer section
- how to include javascript file and css file in wordpress
- Why is my javascript not invoked in my hooks except wp_head?
- include wp-blog-header not working on MAMP
- Slow WP_query due to nested wp_query. Need Suggestions
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- Woocommerce checkout update totals with datepicker
- Including the necessary functions for a custom ajax registration form
- get post attachment using ajax
- Dashboard – get status and position of metaboxes and pass them to ajax method
- how to search users by ajax live search
- javascript datatables in a plugin
- 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
- Why is wp_localize_script returning false?
- 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()?
- should i be checking for jquery before enqueing it in a plugin
- Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
- Ajax is not working in a loop
- Loading custom js file on the admin page through plugin
- Setting a JSON web token from a secondary api as a secure cookie on WordPress
- How do I get rid of my inclusion race-condition on wp_enqueue_script
- Gutenberg – is it ok to load dependencies multiple times?
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- AJAX call to admin-ajax.php by subscriber returns home page
- Ajax function is not working on WordPress
- Referencing files in JavaScript in WordPress Plugin
- Workflow for new importer plugin – your advices?
- Use options to control jQuery plugin
- How to localize data array in plugin’s option page
- AJAX request not routing through proxy
- Get localize of a loaded javascript
- How to use wp_send_json() and output the value with ajax?
- Ajax on the Administration Side of plugin – returns 0
- GET request return value as error instead of success
- What happens/fires when you select a block in the editor?
- Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
- ajax stopped working when not logged in wordpress
- jQueryUI draggable doesn’t work in WordPress plugin
- Reading plugin settings in esnext wordpress block
- Dynamically modify content added to table via javascript
- ajax response strips multidimensional array and unable to decode
- AJAX update fails for public/non-admin users
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- Javascript scroll eventHandler only working when I’m logged in in WordPress
- Replace the WordPress Media Library Uploader
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- $_SESSION inside php function executed by AJAX
- Two same AJAX calls – one is working, other doesn’t
- How to handle ajax Request in a complex-structured plugin?
- Pass javascript result to shortcode executer function
- How to get values from Tinymce visual editor popup?
- Add language localisation to javascript alert?
- How to display archive by selecting year and then selecting month
- Ajax call not working with
- WP Ajax on page load not working on bluehost but was working on Godaddy
- Can’t get query string in ajax call
- An adiitional function fires on my AJAX submit
- Fatal error: Call to a member function query() on a non-object in my ajaxpage
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- How do I access the contents of WordPress Classic editor in admin area with JavaScript?
- How react js and other Javascript Technologies works on WordPress plugin?
- Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?
- Trouble Importing whatsapp-web.js in a WordPress Plugin Development
- WordPress plugin boilerplate AJAX functionality