Given a setting with an ID of “foo” you can obtain the value via:
var value = wp.customize( 'foo' ).get()
To ensure that the setting is registered before you attempt to get its value, you can use this deferred pattern:
wp.customize( 'foo', function( setting ) {
var value = setting.get();
// ...
});
This should look familiar because these calls are very common in JS that gets enqueued in the Customizer preview for handling setting change previews via postMessage
.
Related Posts:
- Customizer JS API
- Is it Possible to Extend WP Customize JS Methods?
- wp.customize.bind ready event not fired
- Detecting WordPress Customizer Panel
- WP Customizer set a value via javascript (to create presets)
- wp_customize_support_script – do I need it?
- Customizer – instantiating settings and controls via javascript
- Customizer JS API: Defining control settings
- Customizer JS API: Adding Setting Dynamically Not Working
- Customizer: When to use customize_preview_init VS customize_controls_enqueue_scripts
- How to overwrite JS variable with wp_localize _script?
- Theme Customiser not live previewing changes on pseudo elements
- the Customizer – proper way to instantiate an image upload control via javascript
- Preserve Javascript Through Customizer Preview Navigation
- How to check if customize previewer is refreshing?
- JavaScript in WordPress Customizer
- Customizer JS API: Adding a “dropdown-pages” control
- Running JS after theme customizer finished initialization
- customize_preview_init: listening for any changes from Customizer preview area
- How to conditionally show/hide controls & sections in WordPress customizer?
- Multiple Conditional Controllers
- WordPress customizer get control
- Using webpack to add customizer live preview functionality – wp.customize is not a function
- Adding and removing hidden buttons from WordPress Customizer Tinymce widget editor using javascript API
- Get a default value of the Customizer setting using wp.customize API (JS)
- How to add customizer control via javascript ( wp.customizer.control.add )
- Load page in customizer preview on panel click?
- Customizer JS API: Defining active_callback for a section
- Adding Code into Theme Customizer Header
- Custom JS text area in customizer is being formatted wrong in document
- customize-controls.js – extend api.previewer
- Multiple jQuery inputs or binds in Customizer Control Javascripts
- Show sections based on a control in WordPress Customizer using JS API
- How do I add a class to Customizer preview based on class of Customizer control? (Customizer Javascript API)
- LayersWP Customizer White Blank Screen
- Get a default customizeAction text for a section using Customizer JS API
- Receive “menu-toogle” event from section menu in customizer
- addEventListener vs onclick
- How do I check if an array includes a value in JavaScript?
- JavaScript document.getElementById().value logs empty value
- What is console.log?
- window.onload vs document.onload
- Fetch: POST JSON data
- JavaScript hide/show element
- Copy array by value
- Compare two dates with JavaScript
- ReferenceError: fetch is not defined
- In reactJS, how to copy text to clipboard?
- How to import image (.svg, .png ) in a React Component
- How do I embed PHP code in JavaScript?
- Make javascript alert Yes/No Instead of Ok/Cancel
- How to create a dialog with “yes” and “no” options
- Adding images to a Bootstrap Carousel with AJAX
- XMLHttpRequest cannot load XXX No ‘Access-Control-Allow-Origin’ header
- Uncaught TypeError: Cannot read property ‘props’ of null
- How to handle the `onKeyPress` event in ReactJS?
- ES6: Create Strings using Template Literals – Freecodecamp
- Youtube api – stop video
- Uncaught TypeError: Cannot read property ‘msie’ of undefined – jQuery tools
- How do I convert an integer to binary in JavaScript?
- What does window.jQuery and window.$ mean?
- How to change date format in JavaScript
- Convert CSV data into JSON format using Javascript
- Can not solve: Geocode was not successful for the following reason: OVER_QUERY_LIMIT
- How to set Angular 4 background image?
- ReactJS – .JS vs .JSX
- How to convert date to timestamp?
- ReactJS: Maximum update depth exceeded error
- React, Uncaught ReferenceError: ReactDOM is not defined
- How to implement “select all” check box in HTML?
- JQuery get the title of a button
- How to open a URL using PHP?
- How to set text color for my d3 chart title?
- Defining a HTML template to append using JQuery
- How do I bind to list of checkbox values with AngularJS?
- Wildcard string comparison in Javascript
- jQuery select option elements by value
- How to change cursor from pointer to finger using jQuery?
- How to get value in an object’s key using a variable referencing that key?
- Button that refreshes the page on click
- jQuery equivalent of body onLoad
- Replace spaces with dashes and make all letters lower-case
- wp_localize_script with boolean and init
- How to Change CSS Variable value in Theme Customizer Live Preview
- WordPress Customizer Control with React
- How do you filter the list of states when country is selected? [closed]
- Prevent update_checkout from firing mid-typing
- How to move core js files into the footer
- Building a Featured Gallery component for Gutenberg
- Suddenly extra hex string in tags
- Retrieving data about comments and likes
- Including Styles and JS files to work ON my plugin interface
- Linking wp_enqueue can’t find the javascript file (adds “?ver=x.x.x” to the src)
- Gutenberg – useEffect manipulate DOM after block re-renders DOM
- Javascript working on jsfiddle but not wordpress site?
- Drodown list return issue
- Spans in gutenberg
- Put dynamic Javascript in header after doing operations
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- custom page url slug needs illegal ?id=1 for javascript