Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




sanitize_html_class [ WordPress Function ]

sanitize_html_class ( $class, $fallback = '' )
Parameters:
  • (string) $class The classname to be sanitized
  • (string) $fallback Optional. The value to return if the sanitization end's up as an empty string. Defaults to an empty string.
Returns:
  • (string) The sanitized value
Defined at:



Santizes a html classname to ensure it only contains valid characters

Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty string then it will return the alternative value supplied.

Source


<?php
function sanitize_html_class$class$fallback '' ) {
    
//Strip out any % encoded octets
    
$sanitized preg_replace'|%[a-fA-F0-9][a-fA-F0-9]|'''$class );

    
//Limit to A-Z,a-z,0-9,_,-
    
$sanitized preg_replace'/[^A-Za-z0-9_-]/'''$sanitized );

    if ( 
'' == $sanitized )
        
$sanitized $fallback;

    return 
apply_filters'sanitize_html_class'$sanitized$class$fallback );
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics