The best way to do this is to use wp_localize_script()
, it serves exactly the purpose you are mentioning: passing strings to Javascript from PHP. You can do all sorts of interesting things with that: as a rule of thumb, use that when you want PHP to communicate with Javascript.
In your case you want something like this:
$ritc = array( 'initialize' => '63864593a4153879' );
wp_localize_script( '{your_script_handle}', 'ritc', $ritc );
In this way you can call ritc.initialize
in your Javascript.
Be aware that you must use wp_localize_script
after you have enqueued your script and passing your script $handle
as a parameter.
Related Posts:
- force enqueue script to be first in order of prominence
- Dequeue / Deregister script and replace it with a new plugin
- Add extra parameter in tag using script_loader_tag
- How to avoid redefining requirejs in plugin when another plugin also uses requirejs
- Problem in loading javascript in footer
- React JSX in WordPress Plugin Development
- Enqueue WordPress plugin scripts below all other JS
- How can I remove the WordPress-Version (?ver=5.x) from my plugin
- Is there a loading priority for login_enqueue_scripts?
- Deactivate JS Script in Plugin Shortcode
- Remove / overwrite some functions in buddypress.js
- Add type to enqueued script inside plugin
- Why can I not deregister my style and script on custom post type?
- Modifying a JS file with data from plugin settings
- Get php var inside javascript file (making plugin)
- How to call plugin path in JS?
- How do I sanitize a javascript text?
- How can a Firebase user registration and login be integrated into a WordPress site?
- How do I make my wordpress page more friendly for mobile viewers?
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- How can I make content disappear when a user logs in?
- WordPress Enqueue Script Chaos (jQuery & Foundation.js)
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- ‘Lazy loading’ list of posts with pagination
- Check javascript file Proper way in functions.php
- How to include admin-ajax when loading external javascript
- how would I include a js file with tags into wordpress?
- Very stubborn wp_register_script / add_action vs remove
- How to localize value of posts
- Google Maps and Yandex Maps doesn’t work correctly
- Prevent CSS/JS loading when plugin is not used
- wp_enqueue_scripts not working inside shortcode
- How to create popup same as wordpress popup feature
- Gutenberg List Extension Block
- How do I make sure a plugin loads a script after jQuery
- Avoiding Duplicate function names in Post Loop (WP_Footer script)
- prettyPhoto media loading very slowly in Chrome
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Using custom JS plugins with WordPress?
- Override Javascript in a Plugin?
- Use wp_enqueue_scripts from included php file
- Making a plugin only available on the front-end for the logged in super admin
- Change upload folder for a CPT
- add input in custom javascript from WordPress pages/posts
- Redux Framework: Page freezes on typing in Editor
- Delay JavaScript files from loading
- “Conflict” with jQuery (or its plugins)?
- How to execute a plugin on a single page only?
- MediaElement.js works on one site but not the other?
- Pass user role to javascript code inside body
- How to get specific string/value from an array? php [closed]
- Background Music WP [closed]
- Adding a simple Javascript file with a plugin
- Deregister scripts from plugin
- Custom CSS not being added by plugin
- Social share buttons text shows up on post excerpts
- Dropdown menu on click change
- How do I override all stylesheets and scripts without a plugin
- Plugin Admin panel checkbox unchecked after submit
- Custom Plugin scripts from admin working in frontend
- Send Array from JS to php file then insert it in wp database through a plugin
- Gutenberg: Prevent links from being clickable in the block. Error: “Cannot destructure property ‘frameElement’ of ‘r’ as it is null.”
- How to override Plugin javascript function : $(‘body’).on(‘change’,’.class’)
- Connect / Login WordPress Hosted Website or Blog with NodeJs
- How to fetch WordPress database values in JavaScript widget
- Possible way of having multiple Gutenberg instances for a page?
- Woocommerce add products to cart
- Show popup on click
- how i retreive the post content while editing it in real time however the editor is tinymce or gutenberg
- How to properly enqueue jQuery knob on WordPress without conflict?
- Javascript not getting injected into page
- Why does my custom plugin only function correctly once per page?
- How to get a specific string from a url
- Does anybody know how to insert a complete jquery plugin into a wordpress elementor-page?
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- Woocommerce – Change variations output
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Problem in functions.php file
- Customizer preview URL not updating when settings reset to default
- Caching of combined CSS and JS fails because of losing MIME types through combining by PHP
- wp_enqueue_scrpts seems not to get called
- show-hide based on select option jquery wordpress
- Speed issues because of CSS & JavaScript
- Having trouble going from Jfiddle to implementing in WordPress :(
- How to create a dashboard for logged-in users with custom functionality? [closed]
- Creating a user ‘add custom field’ section
- Javascript not working
- Creating custom URL for async content
- How do I convince this button to do something when it is clicked?
- Plugin – including external javascript calling google maps
- plugin’s script and style enqueing not working on Thesis
- Element works, but not on wordpress site [duplicate]
- how woocommerce swatch color name when hovered or selected
- How to create post comparison in wordpress
- WordPress shortcode plugin not working
- FacetWP: Plugin breaks button/modal functionality inside searchable content area
- TypeErrors with Yoast, jQuery in conflict?
- Count div with class (.length) only shows 0 [closed]
- Vanilla javascript in custom gutenberg block not working