Inside the __construct() you can put this
global $shortcode_id;
$shortcode_id = 0;
in the display_gallery_shortcode() function you can do this
<?php
global $shortcode_id;
$shortcode_id ++;
$settings_arr = array();//Here is your settings for each shortcode
ob_start();
?>
<script>
if(!my_plugin_data) var my_plugin_data = {}
my_plugin_data[<?php echo $shortcode_id ?>] = <?php echo json_encode($settings_arr) ?>
</script>
<div>MY SHORTCODE CONTENT GOES HERE</div>
<?php
return ob_get_clean();
Try to reload the page and check the variable in the javascript console.
console.log(my_plugin_data);
Related Posts:
- do_shortcode inside AJAX callback
- Custom Shortcode AJAX 400 Bad Request
- How can I run shortcode after click with ajax
- Ajax not returning anything on form submit
- How to use shortcodes on a widget sidebar when doing an ajax call?
- Shortcodes not working in an AJAX call
- Wp_localize_script from Shortcode [closed]
- How to get gallery id inserted to a post?
- How to add AJAX in a custom PHP function using Google sheets API
- AJAX and Shortcode with Parameters
- wp_editor in thickbox
- do_shortcode via ajax
- Pass data back to TinyMCE from Thickbox
- Getting error on submitting form using Ajax with shortcode
- Regenerating WordPress shortcodes based on value with AJAX
- Use Contact Form 7 with Ajax
- AJAX and do_shortcode
- Remove a short code and update it’s content (AJAX)
- Multiple shortcodes only use attributes from one of the shortcodes on custom plugin
- Cannot modify class property from shortcode handler function
- Use Shortcode on Custom Page
- Do embed shortcode on wordpress ajax request
- Ajax callback and shortcode functionality
- Load next post by ID on a single page
- Access Shortcode in ajax code?
- load plugin with ajax [duplicate]
- Why is my ajax live search not working when i use a shortcode to call it?
- How to handle Ajax Calls, when using same shortcodes (with different parameters, e.g. ‘post-type’)?
- Working with Shortcode, AJAX, Elementor
- Conditionally Loading JavaScript/CSS for Shortcodes
- Show shortcode without executing it
- Use AJAX in shortcode
- Run visual composer code in php page
- Shortcodes, HTML tables, and multiple rows
- Does a shortcode with a single attribute have to use an array?
- Use [shortcode=”value”] instead of [shortcode att=”value”]?
- I dont want to show shortcode in tag
- Post loop created via shortcode not displaying shortcode in content
- Pass shortcode variables to template
- passing multiple parents value into a shortcode
- Is it possible to add a repeater field to TinyMCE’s option window?
- Shortcodes: Pros and Cons
- esc_attr not working in shortcode
- Raw output (preventing wpautop)
- Conditionally loading Facebook PHP SDK in shortcode
- Help with shortcode in admin-ajax [closed]
- Can’t understand $atts in functions?
- Are .MP3 files with capital letter extensions allowed in [audio] shortcode?
- How to handle shortcodes when using the JSON API
- Are shortcode functions applied while rendering the content, or are they executed and stored with the post content?
- is_admin() returns false in save_post hook with Gutenberg editor
- Get Posts shortcode plugin and meta_query?
- possibility to control embedded video timeline with buttons and links external to the player
- Gravity forms customize field markup for the same form appearing in different places
- Gallery shortcode – change link file image size? (not using default fullsize image)
- Edit shortcode in post content programatically
- Shortcode in posts called by ajax is not working
- How to change to local video player on shortcode ultimate to video.js?
- Adding shortcode field to edit gallery / Gallery Settings
- Shortcode not showing anything
- return unformatted content in encosing shortcode
- How to display Feedburner subscription count as plain text via a shortcode in post/page editor of my WordPress blog?
- Function result goes outside div
- Shortcode in my childtheme is not working
- Displaying shortcode in footer
- Are Shortcode Attributes Always Passed As Strings?
- Show form per shortcode
- Use another action instead of the shortcode API to display the last time a user logged in
- Default WordPress shortcodes not working?
- Pass fileurl parameter into shortcode from Advanced Custom Fields
- Shortcode arguments to another shortcode
- Sanitize or treatment of string in editor via shortcode
- Getting jQuery AJAX to work in WordPress (getting -1)
- Can’t render shortcode when html tag contains hyphen
- Not to escape a text
- Color on Shortcode insert that creates a button
- shortcode doesnt work on excerpt
- Adding Author URL to Nav Menu via Shortcode
- Displaying an interactive web map on my wordpress site
- Pagination for custom posts loop
- Modify [caption] shortcode so and are not used?
- May an attribute have no value?
- How to Call Related Post based on Categories Inside Post Content with Shortcode?
- How to strip header tags & shortcodes from the_excerpt()
- shortcode display metainformation as linked image
- Reusable Dynamic Taxonomy Shortcode
- Can’t place endwhile in the loop properly in a shortcode
- How to reduce the image size inside an icon? [closed]
- How to insert visual compser post grid shortcode in a custom page template? [closed]
- WordPress plugin shortcodes not outputting anything
- Shortcode tags appear on mobile themes
- Manipulated shortcode output
- Where is escaped the shortcode?
- Changing layout of defaul gallery output to masonry
- shortcode change variable base on user
- Inserting shortcode is blanking excerpt – any ideas?
- How to enable on custom shortcodes
- Nested ShortCode works inside the_content, but not outside of it
- How to reuse php templates as shortcodes?
- Shortcode attributes from meta query variables