Welcome, visitor! Log in
 

Source View: sanitize_html_class

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
930      //Strip out any % encoded octets
931      $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class );
932
933      //Limit to A-Z,a-z,0-9,_,-
934      $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized );
935
936      if ( '' == $sanitized )
937           $sanitized = $fallback;
938
939      return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );
940 }
941
942 /**
943  * Converts a number of characters from a string.
944  *
945  * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are
946  * converted into correct XHTML and Unicode characters are converted to the
947  * valid range.
948  *