wp_kses_split2 [ WordPress Function ]
| Access: |
|
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Callback for wp_kses_split for fixing malformed HTML tags.
This function does a lot of work. It rejects some very malformed things like <:::>. It returns an empty string, if the element isn't allowed (look ma, no strip_tags()!). Otherwise it splits the tag into an element and an attribute list.
After the tag is split into an element and an attribute list, it is run through another filter which will remove illegal attributes and once that is completed, will be returned.
Source
<?php
function wp_kses_split2($string, $allowed_html, $allowed_protocols) {
$string = wp_kses_stripslashes($string);
if (substr($string, 0, 1) != '<')
return '>';
# It matched a ">" character
if ( '<!--' == substr( $string, 0, 4 ) ) {
$string = str_replace( array('<!--', '-->'), '', $string );
while ( $string != ($newstring = wp_kses($string, $allowed_html, $allowed_protocols)) )
$string = $newstring;
if ( $string == '' )
return '';
// prevent multiple dashes in comments
$string = preg_replace('/--+/', '-', $string);
// prevent three dashes closing a comment
$string = preg_replace('/-$/', '', $string);
return "<!--{$string}-->";
}
# Allow HTML comments
if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches))
return '';
# It's seriously malformed
$slash = trim($matches[1]);
$elem = $matches[2];
$attrlist = $matches[3];
if ( ! isset($allowed_html[strtolower($elem)]) )
return '';
# They are using a not allowed HTML element
if ($slash != '')
return "</$elem>";
# No attributes are allowed for closing elements
return wp_kses_attr( $elem, $attrlist, $allowed_html, $allowed_protocols );
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/wp kses split2 « WordPress Codex
Description. Callback for wp_kses_split() for fixing malformed HTML tags. This function does a lot of work. It rejects some very malformed things like <:::>.
codex.wordpress.org - wp_kses_split2() WordPress function reference, arguments and ...
Callback for wp_kses_split for fixing malformed HTML tags.
queryposts.com - 常用函数-wp_kses_split2() | WordPress啦!
该函数进行大量工作。wp_kses_split2()拒绝<:::>等不完整字符。如果某个元素不 允许出现,wp_kses_split2()返回空字符。否则wp_kses_split2()会将标签拆分为一个 ...
www.wordpress.la - PHPXRef 0.7 : WordPress : Detail view of kses.php
wp_kses_hook() wp_kses_version() wp_kses_split() _wp_kses_split_callback() wp_kses_split2() wp_kses_attr() wp_kses_hair() wp_kses_check_attr_val() ...
phpxref.ftwr.co.uk