wp_kses_attr [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Removes all attributes, if none are allowed for this element.
If some are allowed it calls wp_kses_hair() to split them further, and then it builds up new HTML code from the data that kses_hair() returns. It also removes "<" and ">" characters, if there are any left. One more thing it does is to check if the tag has a closing XHTML slash, and if it does, it puts one in the returned code as well.
Source
<?php
function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) {
# Is there a closing XHTML slash at the end of the attributes?
$xhtml_slash = '';
if (preg_match('%\s*/\s*$%', $attr))
$xhtml_slash = ' /';
# Are any attributes allowed at all for this element?
if ( ! isset($allowed_html[strtolower($element)]) || count($allowed_html[strtolower($element)]) == 0 )
return "<$element$xhtml_slash>";
# Split it
$attrarr = wp_kses_hair($attr, $allowed_protocols);
# Go through $attrarr, and save the allowed attributes for this element
# in $attr2
$attr2 = '';
$allowed_attr = $allowed_html[strtolower($element)];
foreach ($attrarr as $arreach) {
if ( ! isset( $allowed_attr[strtolower($arreach['name'])] ) )
continue; # the attribute is not allowed
$current = $allowed_attr[strtolower($arreach['name'])];
if ( $current == '' )
continue; # the attribute is not allowed
if ( strtolower( $arreach['name'] ) == 'style' ) {
$orig_value = $arreach['value'];
$value = safecss_filter_attr( $orig_value );
if ( empty( $value ) )
continue;
$arreach['value'] = $value;
$arreach['whole'] = str_replace( $orig_value, $value, $arreach['whole'] );
}
if ( ! is_array($current) ) {
$attr2 .= ' '.$arreach['whole'];
# there are no checks
} else {
# there are some checks
$ok = true;
foreach ($current as $currkey => $currval) {
if ( ! wp_kses_check_attr_val($arreach['value'], $arreach['vless'], $currkey, $currval) ) {
$ok = false;
break;
}
}
if ( $ok )
$attr2 .= ' '.$arreach['whole']; # it passed them
} # if !is_array($current)
} # foreach
# Remove any "<" or ">" characters
$attr2 = preg_replace('/[<>]/', '', $attr2);
return "<$element$attr2$xhtml_slash>";
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/wp kses attr « WordPress Codex
Description. Removes all attributes, if none are allowed for this element. If some are allowed it calls wp_kses_hair() to split them further, and then it builds up ...
codex.wordpress.org - filter » Otto on WordPress
Apr 9, 2010 ... But eventually, it calls wp_kses_attr. The wp_kses_attr is what parses the attributes of any HTML tag into chunks and then removes them ...
ottopress.com - 常用函数-wp_kses_attr() | WordPress啦!
<?php wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) ?> ... wp_kses_attr()位于wp-includes/kses.php中。 ‹ 常用函数-wp_kses_array_lc() ...
www.wordpress.la - Docs for page kses.php
wp_kses_attr (line 650). Removes all attributes, if none are allowed for this element. If some are allowed it calls wp_kses_hair() to split them further, and then it ...
phpdoc.ftwr.co.uk