convert_invalid_entities

函数
convert_invalid_entities ( $content )
参数
  • (string) $content String with entities that need converting.
    Required:
返回值
  • (string) Converted string.
定义位置
相关方法
convert_smilies_sort_nav_menu_itemswp_kses_named_entitieswp_convert_hr_to_byteswp_kses_normalize_entities
引入
4.3.0
弃用
-

convert_invalid_entities: 这个函数从一个字符串中删除无效的HTML实体。无效的实体会在一些浏览器中引起显示问题,所以这个函数被用来确保只使用有效的实体。

将无效的Unicode引用范围转换为有效范围。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function convert_invalid_entities( $content ) {
$wp_htmltranswinuni = array(
'€' => '€', // The Euro sign.
'' => '',
'‚' => '‚', // These are Windows CP1252 specific characters.
'ƒ' => 'ƒ', // They would look weird on non-Windows browsers.
'„' => '„',
'…' => '…',
'†' => '†',
'‡' => '‡',
'ˆ' => 'ˆ',
'‰' => '‰',
'Š' => 'Š',
'‹' => '‹',
'Œ' => 'Œ',
'' => '',
'Ž' => 'Ž',
'' => '',
'' => '',
'‘' => '‘',
'’' => '’',
'“' => '“',
'”' => '”',
'•' => '•',
'–' => '–',
'—' => '—',
'˜' => '˜',
'™' => '™',
'š' => 'š',
'›' => '›',
'œ' => 'œ',
'' => '',
'ž' => 'ž',
'Ÿ' => 'Ÿ',
);
if ( strpos( $content, '&#1' ) !== false ) {
$content = strtr( $content, $wp_htmltranswinuni );
}
return $content;
}
function convert_invalid_entities( $content ) { $wp_htmltranswinuni = array( '€' => '€', // The Euro sign. '' => '', '‚' => '‚', // These are Windows CP1252 specific characters. 'ƒ' => 'ƒ', // They would look weird on non-Windows browsers. '„' => '„', '…' => '…', '†' => '†', '‡' => '‡', 'ˆ' => 'ˆ', '‰' => '‰', 'Š' => 'Š', '‹' => '‹', 'Œ' => 'Œ', '' => '', 'Ž' => 'Ž', '' => '', '' => '', '‘' => '‘', '’' => '’', '“' => '“', '”' => '”', '•' => '•', '–' => '–', '—' => '—', '˜' => '˜', '™' => '™', 'š' => 'š', '›' => '›', 'œ' => 'œ', '' => '', 'ž' => 'ž', 'Ÿ' => 'Ÿ', ); if ( strpos( $content, '&#1' ) !== false ) { $content = strtr( $content, $wp_htmltranswinuni ); } return $content; }
function convert_invalid_entities( $content ) {
	$wp_htmltranswinuni = array(
		'€' => '€', // The Euro sign.
		'' => '',
		'‚' => '‚', // These are Windows CP1252 specific characters.
		'ƒ' => 'ƒ',  // They would look weird on non-Windows browsers.
		'„' => '„',
		'…' => '…',
		'†' => '†',
		'‡' => '‡',
		'ˆ' => 'ˆ',
		'‰' => '‰',
		'Š' => 'Š',
		'‹' => '‹',
		'Œ' => 'Œ',
		'' => '',
		'Ž' => 'Ž',
		'' => '',
		'' => '',
		'‘' => '‘',
		'’' => '’',
		'“' => '“',
		'”' => '”',
		'•' => '•',
		'–' => '–',
		'—' => '—',
		'˜' => '˜',
		'™' => '™',
		'š' => 'š',
		'›' => '›',
		'œ' => 'œ',
		'' => '',
		'ž' => 'ž',
		'Ÿ' => 'Ÿ',
	);

	if ( strpos( $content, '&#1' ) !== false ) {
		$content = strtr( $content, $wp_htmltranswinuni );
	}

	return $content;
}

常见问题

FAQs
查看更多 >