• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_kses_attr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_kses_attr函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_kses_attr函数的具体用法?PHP wp_kses_attr怎么用?PHP wp_kses_attr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_kses_attr函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wp_kses_split2

function wp_kses_split2($string, $allowed_html, $allowed_protocols)
{
    $string = wp_kses_stripslashes($string);
    if (substr($string, 0, 1) != '<') {
        return '&gt;';
    }
    # It matched a ">" character
    if (preg_match('%^<!--(.*?)(-->)?$%', $string, $matches)) {
        $string = str_replace(array('<!--', '-->'), '', $matches[1]);
        while ($string != ($newstring = wp_kses($string, $allowed_html, $allowed_protocols))) {
            $string = $newstring;
        }
        if ($string == '') {
            return '';
        }
        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 "<{$slash}{$elem}>";
    }
    # No attributes are allowed for closing elements
    return wp_kses_attr("{$slash}{$elem}", $attrlist, $allowed_html, $allowed_protocols);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:35,代码来源:kses.php


示例2: wp_kses_split2

function wp_kses_split2($string, $allowed_html, $allowed_protocols)
{
    $string = wp_kses_stripslashes($string);
    if (substr($string, 0, 1) != '<') {
        return '&gt;';
    }
    # It matched a ">" character
    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 (!is_array($allowed_html[strtolower($elem)])) {
        return '';
    }
    # They are using a not allowed HTML element
    return wp_kses_attr("{$slash}{$elem}", $attrlist, $allowed_html, $allowed_protocols);
}
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:20,代码来源:kses.php


示例3: wp_kses_split2

/**
 * 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.
 *
 * @access private
 * @since 1.0.0
 *
 * @param string $string            Content to filter
 * @param array  $allowed_html      Allowed HTML elements
 * @param array  $allowed_protocols Allowed protocols to keep
 * @return string Fixed HTML element
 */
function wp_kses_split2($string, $allowed_html, $allowed_protocols)
{
    $string = wp_kses_stripslashes($string);
    if (substr($string, 0, 1) != '<') {
        return '&gt;';
    }
    // 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 (!is_array($allowed_html)) {
        $allowed_html = wp_kses_allowed_html($allowed_html);
    }
    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);
}
开发者ID:zoran180,项目名称:wp_szf,代码行数:62,代码来源:kses.php


示例4: wp_kses_split2

function wp_kses_split2($string, $allowed_html, $allowed_protocols)
###############################################################################
# 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.
###############################################################################
{
	$string = wp_kses_stripslashes($string);

	if (substr($string, 0, 1) != '<')
		return '&gt;';
	# It matched a ">" character

	if (preg_match('%^<!--(.*?)(-->)?$%', $string, $matches)) {
		$string = str_replace(array('<!--', '-->'), '', $matches[1]);
		while ( $string != $newstring = wp_kses($string, $allowed_html, $allowed_protocols) )
			$string = $newstring;
		if ( $string == '' )
			return '';
		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 "<$slash$elem>";
	# No attributes are allowed for closing elements

	return wp_kses_attr("$slash$elem", $attrlist, $allowed_html, $allowed_protocols);
} # function wp_kses_split2
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:42,代码来源:kses.php


示例5: wp_kses_split2

 function wp_kses_split2($string, $allowed_html, $allowed_protocols, $cutoff = true)
 {
     $string = wp_kses_stripslashes($string);
     if (substr($string, 0, 1) != '<') {
         return '&gt;';
     }
     # It matched a ">" character
     if (!preg_match('%^<\\s*(/\\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) {
         # It's seriously malformed
         if ($cutoff) {
             //hacked by NobuNobu to display not allowed element with &lt; &gt;
             return '';
         } else {
             return str_replace(array('<', '>'), array('&lt;', '&gt;'), $string);
         }
     }
     $slash = trim($matches[1]);
     $elem = $matches[2];
     $attrlist = $matches[3];
     if (!isset($allowed_html[strtolower($elem)]) || !is_array($allowed_html[strtolower($elem)])) {
         # They are using a not allowed HTML element
         if ($cutoff) {
             return '';
         } else {
             //hacked by NobuNobu to display not allowed element with &lt; &gt;
             return str_replace(array('<', '>'), array('&lt;', '&gt;'), $string);
         }
     }
     if ($slash != '') {
         return "<{$slash}{$elem}>";
     }
     # No attributes are allowed for closing elements
     return wp_kses_attr("{$slash}{$elem}", $attrlist, $allowed_html, $allowed_protocols);
 }
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:34,代码来源:kses.php



注:本文中的wp_kses_attr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_kses_attr_parse函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_kses_array_lc函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap