sanitize_html_class

Filters a sanitized HTML class string.

Description

apply_filters( 'sanitize_html_class', (string) $sanitized, (string) $class, (string) $fallback ); 

Parameters (3)

0. $sanitized (string)
The sanitized HTML class.
1. $class (string)
HTML class before sanitization.
2. $fallback (string)
The fallback string.

Usage

To run the hook, copy the example below.
  1. $sanitized = apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback ); 
  2.  
  3. if ( !empty( $sanitized ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the sanitize_html_class callback 
  2. function filter_sanitize_html_class( $sanitized, $class, $fallback ) { 
  3. // make filter magic happen here... 
  4. return $sanitized
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'sanitize_html_class', 'filter_sanitize_html_class', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'sanitize_html_class', 'filter_sanitize_html_class', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/formatting.php  
  1. return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );