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?
- WordPress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted
- How to remove style and js from theme and add your own style and js where shortcode is used?
- Internationalization autocomplete JS variable
- 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
- How to disable specific plugin in mobile version?
- Is there an earlier hook than login_head or login_enqueue_scripts?
- Best approach to fetch data from wp options to js file or php file
- issues with wp_enqueue_script in my plugin
- Making a plugin only available on the front-end for the logged in super admin
- Can someone please tell me what is wrong with my plugin?
- Updating the Drag-To-Share eXtended share URLs?
- Scripts at the end of the page
- wordpress site | All-in-one-cufon IE Issue
- How to add Internationalization in WordPress using Javascript/React?
- Can I use custom CSS and js plugin to put JavaScript in to validate my forms
- 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]
- Executing Javascript when a New Post is Published
- Set featured image using javascript in post editor
- Display encrypted content on my website
- Is there a standard way to listen for an on change event of a posts featured image
- How to edit content before post update
- Trying to create a private area custom for each user where they upload images to a server [closed]
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- wp.media javascript issue with on select
- jQuery for custom plugin not working with Divi theme
- Bootstrap and Custom CSS in custom plugin are being overwritten by theme
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- add input in custom javascript from WordPress pages/posts
- Advanced AJAX Page Loader ignores other JS code
- How to insert HTML/JavaScript form into WordPress page? [closed]
- accessing wp.media api from a tinymce plugin
- Add custom JavaScript that is a combination of CDN/uploaded files and easily-edited code?
- How to load wp_editor via AJAX
- Redux Framework: Page freezes on typing in Editor
- How to get DEFER or ASYNC attribute to appear when I add a stylesheet with wp_enqueue_style from a plugin? [duplicate]
- How to get my plug-in, wrote in php, to refresh on its own every 5 minutes?
- WordPress 3.8.3. custom theme – sliders won’t load js/css files
- Using TinyMCE in plugin?
- Using window.onload with Ubermenu
- GeoMashup plugin: how to customize cluster markers / icons? [closed]
- Create shortcode to echo javascript
- Redirect to another page using contact form 7? [closed]
- Delay JavaScript files from loading
- “Conflict” with jQuery (or its plugins)?
- JavaScript in a PHP plugin
- Why am I unable to load scripts in head in plugin?
- how to prevent all css and javascripts files from loading
- wordpress add_action() issue in ajax call
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Localizing methods for jQuery append prepend wrap parent
- How to execute a plugin on a single page only?
- how to insert a HTML form into a javascript popup?
- Display a consistent Google Plus icon on ALL pages of my site
- MediaElement.js works on one site but not the other?
- Which plugin can do horizontal scrolling of RSS feeds in WordPress [closed]
- Pass user role to javascript code inside body
- After updating the WordPress getting a syntax error in the console
- How to generate an all in one WordPress New content, plugin and theme update report on a website? [closed]
- wp_dequeue_script for a Plugin
- get specific value of a array | PHP
- How to get specific string/value from an array? php [closed]
- coding a WordPress AJAX Form using PHP to check if User is Logged Out and Show error
- How use wp media upload liberary in react components?
- Access post title from custom meta box on title change
- Background Music WP [closed]
- Custom plugin – load enqueue only for this plugin
- How to use custom Javascript code inside a plugin?
- Why does my jQuery plugin show up as text in WordPress?
- Adding a simple Javascript file with a plugin
- JQuery needs to be defined in , but Gravity Forms is defining it in the
- Disable submit button order
- Enqueue script: link not working in page source
- Deregister scripts from plugin
- Conditional custom redirect
- Executing Javascript in Plugin
- Custom CSS not being added by plugin
- Social share buttons text shows up on post excerpts
- Meta slider plugin only works after first refresh – Object has no method ‘flex slider’