This is because you are using wp_kses_post to sanitize the output data, try without it:
<?php echo get_theme_mod( 'script-code'); ?>
also remove it from here:
$wp_customize->add_setting (
'script-code',
array (
'default' => esc_html__( 'Script Code', 'x' ),
'sanitize_callback' => '' // remove wp_kses_post
)
);
also make sure you are using the right name of your theme mod you can check that in two ways:
1.- do a var_dump(get_theme_mods());
check there how is named.
2.- Inspect the HTML
code of your control in the customizer
the id
without the prefix customize-control-
is the name of your theme mod.
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?
- Customizer JS API: Adding a “dropdown-pages” control
- Accessing customizer values in javascript
- 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
- (Google Map API) Geocode was not successful for the following reason: REQUEST_DENIED
- Generate random number between two numbers in JavaScript
- Difference between npx and npm?
- How do I copy to the clipboard in JavaScript?
- Array of JSON Objects
- Cannot read property ‘push’ of undefined when combining arrays
- How to call an async arrow function with await
- Get the current URL with JavaScript?
- How do I empty an array in JavaScript?
- What’s the difference between event.stopPropagation and event.preventDefault?
- Firebase Permission Denied
- Using Javascript in CSS
- How can I mock an ES6 module import using Jest?
- What is “assert” in JavaScript?
- How does the data-toggle attribute work? (What’s its API?)
- Appending to an object
- What is the meaning of “$” sign in JavaScript
- How to determine the installed webpack version
- Error: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of type ‘Node’
- How to validate date with format “mm/dd/yyyy” in JavaScript?
- React.js – Can’t read property of undefined
- SyntaxError: import declarations may only appear at top level of a module
- Jest TypeError: Path must be a string. Received undefined
- For loop for HTMLCollection elements
- Refresh/reload the content in Div using jquery/ajax
- How to take keyboard input in JavaScript?
- Convert CSV data into JSON format using Javascript
- d3 is not defined – ReferenceError
- How can I get form data with JavaScript/jQuery?
- How do I load an HTML page in a div using JavaScript?
- Check time difference in Javascript
- Strip all non-numeric characters from string in JavaScript
- Javascript – Track mouse position
- Finding the max value of an attribute in an array of objects
- How to initialize an array’s length in JavaScript?
- How to set text color for my d3 chart title?
- Adding javascript to child theme
- What does l10n.js do in WordPress 3.1? And how do I remove it?
- How to add javascript just before the closing body tag in the footer of WordPress
- Open media frame and select an attachment
- How to pre-fill Google Forms URLs with logged-in WordPress user’s data
- Use of Javascript with Dojo/Dijit on a WordPress page
- WordPress loads whole jQuery UI library
- Javascript that will execute on only child pages of a specific parent
- WordPress Customizer Control with React
- What is the Javascript event for an item being added to the cart in Woocommerce?
- Script Localization doesn’t work
- Uncaught TypeError [closed]
- Building a Featured Gallery component for Gutenberg
- Should I manually resolve WP Core File security issues or await a subsequent WP release?
- My code will not execute in wordpress, even though I’ve been told the code is fine
- Gutenberg – dynamically created element: how to set onChange?
- JSX SVG Icon with WordPress
- Can I just insert JavaScript by using ?
- Gutenberg Edit Block Inspector Controls and save
- JavaScript and Google PageSpeed + wp_enqueue_script
- Adding javascript blocks to a single file and adding it to the header
- How to integrate a different (JavaScript) editor in WordPress?
- Add Javascript/Html into a WordPress
- How To Include JS Script with WP 2023 Theme
- Update js file on wordpress page after making changes
- Gutenberg core/file add style support in js/ json
- uploading image to wordpress site with javascript fetch function failed