2

I was trying to dig into this deeper, but I couldn't find any useful ways/hooks to add a little disclaimer above the Additional CSS code editor in the Wordpress Customizer. If anyone has a starting point of how i can add something simple like that, it would be greatly appreciated.

The section I am talking about is wp-admin > Appearance > Customize > Additonal CSS

We basically want to add a disclaimer to our clients about using that section, and I wanted to do it the Wordpress way, and not hack anything using jQuery (to add it) or in core.

1

Yep. I was able to show it by default using:

<?php
add_action('customize_controls_print_styles', function()  {
?>
    <style id="custom-css">
        #sub-accordion-section-custom_css .description {
            display: block !important;
        }
    </style>
<?php
});

Thanks for your help!

0

You will need the get_section method of the $wp_customizer class. Like this:

add_action( 'customize_register', 'wpse261932_change_css_title', 15 );

function wpse261932_change_css_title () {
  global $wp_customize;
  $wp_customize->get_section('custom_css')->title = __('Additional CSS. Be careful!', 'textdomain');
  }

For some reason the description has display:none on it in this panel, even though that would be a more logical place to show your disclaimer.

  • Ah... Good call @cjbj. The description would definitely be better, and from the looks of it, you can show the description by clicking on the question mark button, and it will drop down. Now I wonder if I could hook into the javascript that controls that whole feature, and after some even is triggered, trigger a click on the question mark to drop it down. Or, maybe i could do something with CSS. – Aaron Olin Mar 31 '17 at 20:34
  • You could queue a css file for the customizer to have the description shown by default – cjbj Mar 31 '17 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.