You can use the wp_localize_script to pass a variable to your javascript.
Here is an example:
wp_register_script('your_script_name', 'path/to/script.js');
$variables = array (
'footer_caption' => $attr['footer_caption'],
);
wp_localize_script('your_script_name', 'js_object_name', $variables );
wp_enqueue_script('your_script_name');
Then you can acces to this variable by:
js_object_name.footer_caption
Related Posts:
- wordpress site | All-in-one-cufon IE Issue
- Using window.onload with Ubermenu
- Redirect to another page using contact form 7? [closed]
- wordpress add_action() issue in ajax call
- How to get a specific string from a url
- How do I output user_registered time in my correct timezone?
- force enqueue script to be first in order of prominence
- How to call plugin path in JS?
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- How can I make content disappear when a user logs in?
- How to fetch serialized data from wordpress options
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- Check javascript file Proper way in functions.php
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Add jQuery to WordPress page
- How to use wp-ajax in wp-cron
- How do I use WordPress PHP functions in my Javascript code?
- White text on white background in TinyMCE when wp_editor is called in WP 3.9
- Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
- How can I make the “Preview Post” button save and preview in the same window?
- Creating an Exit Confirmation Popup
- Difference between register_block_type & wp.blocks.registerBlockType
- How to create popup same as wordpress popup feature
- jQuery function didn’t work in my plugin
- how to include a simple jquery file into a wordpress plugin
- Problem in loading javascript in footer
- JQuery not working in my plugin [closed]
- add mediaelement.js plugins into WordPress video player control bar
- Shortcode button dosent work for all posts. Work for first post only
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Notepad sticky plugin
- Best approach to fetch data from wp options to js file or php file
- Adding a slider captcha to the comment system
- How to put JQuery/Ajax inside shortcode?
- Can someone please tell me what is wrong with my plugin?
- Error with Image Slide plug-in/ s3slider in WP
- WordPress function not being called from jQuery method
- Change upload folder for a CPT
- How to get the element ID from new menu list that added with add_filter()?
- Override Plugin Script Fucnction in WordPress
- Time consuming callbacks in customizer
- Modifying a .js Function for Print [QZ Tray, WooCommerce POS]
- add image crop function like in wp customizer
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- How to edit content before post update
- Using Wishlist Member and I need to access a user’s status
- How to insert HTML/JavaScript form into WordPress page? [closed]
- Javascript from Easy-Fancybox place into footer
- Plugin Admin panel checkbox unchecked after submit
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- Custom Plugin scripts from admin working in frontend
- Code for unique user visit count on every page WordPress
- Ajax call not working in wordpress through a plugin
- Send Array from JS to php file then insert it in wp database through a plugin
- Jquery POST Ajax Return null data in wordpress
- How do I reinit WordPress plugins dynamically using jS?
- WordPress jQuery Post – Amending Variable Value Within Function Command
- login form should redirect to register page for in 1st login next time it should redirected to home page
- Possible way of having multiple Gutenberg instances for a page?
- Woocommerce add products to cart
- Overriding inline !important CSS with Javscript code snippet with media query
- Creating an array from form inputs before it is posted to the options database
- WP Ajax DB issues
- Get the link title attribute and send it google analytics as custom label via google tag manager using beehive pro for WordPress
- Calling PHP function with AJAX
- How to properly enqueue jQuery knob on WordPress without conflict?
- Ajax Call not Working in Plugin
- Why does my custom plugin only function correctly once per page?
- Does anybody know how to insert a complete jquery plugin into a wordpress elementor-page?
- JS working when used normally but not in wordpress
- How can I create a secure file download in WordPress?
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- update_post_meta is not working for me when I use e.preventDefault for update button
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- Website always load twice on start
- Problem with wordpress has_action() function
- Multiple image selection custom widget
- Custom Field used to allow a Free Story; no longer works
- Create a form and have custom menu display based on user answers?
- Show the subcategory name based on current product
- Woocommerce – Change variations output
- How to solve Blocked a frame with origin from accessing a cross origin frame error in wordpress?
- Speeding up WordPress on a Local Network
- Plugin error “array_key_exists(): The first argument should be either a string or an integer” [closed]
- Conditional Fields depending on checkboxes
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Caching of combined CSS and JS fails because of losing MIME types through combining by PHP
- Help with customising love it plugin (use within foreach)
- Number format in thousands on highcharts in wpdatatable plugin
- Embed Javascript code to registered users only
- show-hide based on select option jquery wordpress
- Javascript in plugin not working
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- How to create a dashboard for logged-in users with custom functionality? [closed]
- Creating a user ‘add custom field’ section
- Media Playlist Plugin
- Page doesn’t load
- AJAX doesn’t pass variables to the php function in the plugin
- How to set up php,javascript and css to allow for our finished product to be displayed within a page?
- What is the process for reimplementing a back up WordPress?