Just finished now the sanitize callback for RGBA colors.and tested in my theme and working perfect, and its taking RGBA values
please find the code
function awstheme_sanitize_rgba( $color ) {
if ( empty( $color ) || is_array( $color ) )
return 'rgba(0,0,0,0)';
// If string does not start with 'rgba', then treat as hex
// sanitize the hex color and finally convert hex to rgba
if ( false === strpos( $color, 'rgba' ) ) {
return sanitize_hex_color( $color );
}
// By now we know the string is formatted as an rgba color so we need to further sanitize it.
$color = str_replace( ' ', '', $color );
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')';}
Related Posts:
- Escaping and sanitizing SVGs in metabox textarea
- Must I serialize/sanitize/escape array data before using set_transient?
- How to use wp_filter_oembed_result?
- Escaping data from database (users table) is necessary?
- Should I sanitize an email address before passing it to the is_email() function?
- Should HTML output be passed through esc_html() AND wp_kses()?
- Sanitize and data validation with apply_filters() function
- What is the difference between wp_strip_all_tags and wp_filter_nohtml_kses?
- What’s the difference between esc_* functions?
- Reason for Lowercase usernames
- What is the best way to sanitize data?
- How to escape custom css?
- Escaping WP_Query tax_query when term has special character(s)
- Should nonce be sanitized?
- esc_url removes white space. Can I change that to using ‘-‘?
- WP Coding standards – escaping the inescapable?
- Sanitatizing when using the posts_where hook
- why is esc_html() returning nothing given a string containing a high-bit character?
- Sanitizing comments or escaping comment_text()
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- How Could I sanitize the receive data from this code
- Echo JavaScript Safely
- How to sanitize user input?
- Which escape function to use when escaping an email or plain text?
- WP_Editor – Saving Value into Plugin Option – Stripping HTML
- wp_kses ignore allowed and allow everything
- Sanitize array callback for the WordPress Settings API
- What is the safe way to print tracking code / pixel code before tag or tag
- How to escape $_GET and check if isset?
- How to escape html generate by a loop
- What’s a safe / good way to output HTML safely within WordPress templates?
- Do Not Understand → Rule No. 4: Making Data Safe Is About Context [closed]
- Sanitizing output that contains quotes?
- Do we need to escape data that we receive from theme options?
- WP_Customize_Manager: How to get control ID
- Escaping WP_Query tax_query when term has special character(s)
- Escaping and sanitization
- Escaping WP_Query tax_query when term has special character(s)
- Sanitization html output itself
- Post text sanitization after publishing/editing – changes are not saved
- wp_set_object_terms() without accents
- esc_url, esc_url_raw or sanitize_url?
- Properly sanitize an input field “Name “
- how to sanitizing $_POST with the correct way?
- What is the proper way to sanitize $_POST and $_GET vars?
- Why is sanitize_text_field() selectively trimming data?
- How to Git stash pop specific stash in 1.8.3?
- Illegal Escape Character “\”
- Escape Character in SQL Server
- What does it mean to escape a string?
- Invalid escape sequence (valid ones are \b \t \n \f \r \” \’ \\ )
- Difference between esc_url() and esc_url_raw()
- Custom page with variables in url. Nice url with add_rewrite_rule
- How to correctly escape query variables to be used in WP_Query
- Sanitation needed for WP_Query or get_posts calls?
- Do I need to escape data passed to wp_localize_script()?
- Can I create customizer setting that can handle plugin shortcode?
- Make shortcode work with nested double quotes
- Default WordPress settings API data sanitization
- How do I sanitize a javascript text?
- Escaping built-in WP function return strings
- Importing JSON feed should the content be sanitized?
- esc_url not working within add_settings_field callback
- Prevent add_shortcode from escaping a tag
- array_map() for sanitizing $_POST
- Allow all attributes in $allowedposttags tags
- Correct processing of `$_POST`, following WordPress Coding Standards
- Quotes being escaped inside wp_editor when saved with wp_kses_post
- When I re-save a post with [code] sections, the entities are double-escaped (> becomes > etc)
- Settings API – sanitize_callback is not called and it leads to an incorrect behavior
- wp_query not searching with apostrophe
- Best Practice for Validating and Sanitizing Data
- Storing HTML in wp_options
- What is the proper way to validate and sanitize JSON response from REST API?
- Can i use the same sanitize function on multiple theme mod textboxes?
- What function removes apostrophes when making a slug?
- How to sanitize uploaded file filename from a plugin?
- Something is unescaping all html entities before output to browser [closed]
- Securing/Escaping Output of file content – reading via fread() in PHP
- Customizer: Category Select Sanitize
- WordPress stripping away backslashes from HTML
- Prevent invalid or empty values from being saved to the database and retain the form field values upon error
- Theme Customizier sanitize_callback not working
- Change wp_sanitize function?
- Why the WP Core team does not allow filter_* functions? [closed]
- data-type=”” … needed post tags stripped of characters
- confused about sanitize_email after is_email [duplicate]
- HTML escaping data with ajax requests
- Invalidate username if it contains @ symbol
- Contact Form Security
- How to safely escape data that contains HTML attributes
- Change user nicename without sanitize
- HTML in category name
- Do I need to sanitize $_POST[‘keyword’] before send to ‘s’ parameter?
- site_url() returns with additional backslashes
- Sanitize and Save metabox values
- Does it make sense to sanitize the output of an SVG file?
- WooCommerce custom SVG coloring tool [closed]
- What is best practice when escaping the_title()?
- If necessary, how should wp_get_attachment_image() and its parameters be escaped?