• I am developing a wordpress theme. In the backend, the user has the possibility to modify the design. Example : wordpress-bacckend

    The values provided by the user are used in the <head> tag. Example:

    <?php function capacity_css_js_in_head() { ?>
        .slide-text{
            color: <?php echo $capacity_slide_text_color ; ?>;
        }
    <?php 
    }
    add_action( 'wp_head', 'capacity_css_js_in_head' );

    how can I correctly escape $capacity_slide_text_color?

Viewing 1 replies (of 1 total)
  • For that particular example, you would use sanitize_hex_color and perhaps maybe_hash_hex_color if it’s not rgba.
    Take a look at all the available functions.

    Consider using range inputs, so the user isn’t typing a value, but moving a visual control (which is limited to the correct values), and the preview can show instant results.

Viewing 1 replies (of 1 total)
  • The topic ‘Escape CSS attributes values in or inside tags’ is closed to new replies.