wp_replace_in_html_tags

函数


wp_replace_in_html_tags ( $haystack, $replace_pairs )
参数
  • (string)
    $haystack
    The text which has to be formatted.
    Required:
  • (array)
    $replace_pairs
    In the form array(‘from’ => ‘to’, …).
    Required:
返回值
  • (string) The formatted text.
定义位置
  • wp-includes/formatting.php
    , line 753
引入
4.2.3
弃用

Replaces characters or phrases within HTML elements only.

function wp_replace_in_html_tags( $haystack, $replace_pairs ) {
	// Find all elements.
	$textarr = wp_html_split( $haystack );
	$changed = false;

	// Optimize when searching for one item.
	if ( 1 === count( $replace_pairs ) ) {
		// Extract $needle and $replace.
		foreach ( $replace_pairs as $needle => $replace ) {
		}

		// Loop through delimiters (elements) only.
		for ( $i = 1, $c = count( $textarr ); $i