The customize_controls_print_scripts WordPress PHP action fires when Customizer control scripts are printed.
Usage
add_action('customize_controls_print_scripts', 'your_custom_function');
function your_custom_function() {
// your custom code here
}
Parameters
This action does not have any parameters.
More information
See WordPress Developer Resources: customize_controls_print_scripts
Examples
Enqueue a custom script for the theme customizer
This code enqueues a custom JavaScript file for the theme customizer screen.
add_action('customize_controls_print_scripts', 'enqueue_customizer_script');
function enqueue_customizer_script() {
wp_enqueue_script('your-customizer-script', get_template_directory_uri() . '/js/customizer.js', array('jquery'), '1.0', true);
}
Add custom JavaScript to the theme customizer
This code adds custom JavaScript directly to the theme customizer screen.
add_action('customize_controls_print_scripts', 'add_customizer_inline_script');
function add_customizer_inline_script() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// your custom jQuery code here
});
</script>
<?php
}
Add CSS to the theme customizer
This code adds custom CSS to the theme customizer screen.
add_action('customize_controls_print_scripts', 'add_customizer_inline_css');
function add_customizer_inline_css() {
?>
<style type="text/css">
/* your custom CSS here */
</style>
<?php
}
Modify theme customizer controls
This code manipulates theme customizer controls using JavaScript.
add_action('customize_controls_print_scripts', 'modify_customizer_controls');
function modify_customizer_controls() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Hide a specific control
$('li#customize-control-your-control-id').hide();
});
</script>
<?php
}
Add custom HTML to the theme customizer
This code adds custom HTML to the theme customizer screen.
add_action('customize_controls_print_scripts', 'add_custom_html_to_customizer');
function add_custom_html_to_customizer() {
?>
<div class="your-custom-html">
<!-- your custom HTML content here -->
</div>
<?php
}