do_shortcodes_in_html_tags

函数


do_shortcodes_in_html_tags ( $content, $ignore_html, $tagnames )
参数
  • (string)
    $content
    Content to search for shortcodes.
    Required:
  • (bool)
    $ignore_html
    When true, all square braces inside elements will be encoded.
    Required:
  • (array)
    $tagnames
    List of shortcodes to find.
    Required:
返回值
  • (string) Content with shortcodes filtered out.
定义位置
  • wp-includes/shortcodes.php
    , line 385
引入
4.2.3
弃用

只在HTML元素内部搜索简码并处理它们。

任何留在元素内的[或]字符都将被HTML编码,以防止干扰元素外的简码。假设$content已经被KSES处理。如果在标签中嵌套了角括号,具有unfiltered_html功能的用户可能会得到意想不到的输出。

function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) {
	// Normalize entities in unfiltered HTML before adding placeholders.
	$trans   = array(
		'[' => '[',
		']' => ']',
	);
	$content = strtr( $content, $trans );
	$trans   = array(
		'[' => '[',
		']' => ']',
	);

	$pattern = get_shortcode_regex( $tagnames );
	$textarr = wp_html_split( $content );

	foreach ( $textarr as &$element ) {
		if ( '' === $element || '.
			if ( 1 === preg_match( '%^ 0 ) {
					// Sanitize the shortcode output using KSES.
					$new_attr = wp_kses_one_attr( $new_attr, $elname );
					if ( '' !== trim( $new_attr ) ) {
						// The shortcode is safe to use now.
						$attr = $new_attr;
					}
				}
			}
		}
		$element = $front . implode( '', $attributes ) . $back;

		// Now encode any remaining '[' or ']' chars.
		$element = strtr( $element, $trans );
	}

	$content = implode( '', $textarr );

	return $content;
}