Add entity 2 ncr converter. http://mosquito.wordpress.org/view.php?id=929 Props: Kaf Oseo
git-svn-id: http://svn.automattic.com/wordpress/trunk@2517 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
08b02d95bc
commit
2cdb8f3852
|
@ -48,21 +48,17 @@ add_filter('comment_text', 'make_clickable');
|
||||||
add_filter('comment_text', 'wpautop', 30);
|
add_filter('comment_text', 'wpautop', 30);
|
||||||
add_filter('comment_text', 'convert_smilies', 20);
|
add_filter('comment_text', 'convert_smilies', 20);
|
||||||
|
|
||||||
add_filter('comment_text_rss', 'htmlspecialchars');
|
|
||||||
|
|
||||||
add_filter('comment_excerpt', 'convert_chars');
|
add_filter('comment_excerpt', 'convert_chars');
|
||||||
add_filter('the_excerpt_rss', 'convert_chars');
|
|
||||||
|
|
||||||
// Places to balance tags on input
|
// Places to balance tags on input
|
||||||
add_filter('content_save_pre', 'balanceTags', 50);
|
add_filter('content_save_pre', 'balanceTags', 50);
|
||||||
add_filter('excerpt_save_pre', 'balanceTags', 50);
|
add_filter('excerpt_save_pre', 'balanceTags', 50);
|
||||||
add_filter('comment_save_pre', 'balanceTags', 50);
|
add_filter('comment_save_pre', 'balanceTags', 50);
|
||||||
|
|
||||||
|
// Misc. title, content, and excerpt filters
|
||||||
add_filter('the_title', 'convert_chars');
|
add_filter('the_title', 'convert_chars');
|
||||||
add_filter('the_title', 'trim');
|
add_filter('the_title', 'trim');
|
||||||
|
|
||||||
add_filter('the_title_rss', 'strip_tags');
|
|
||||||
|
|
||||||
add_filter('the_content', 'convert_smilies');
|
add_filter('the_content', 'convert_smilies');
|
||||||
add_filter('the_content', 'convert_chars');
|
add_filter('the_content', 'convert_chars');
|
||||||
add_filter('the_content', 'wpautop');
|
add_filter('the_content', 'wpautop');
|
||||||
|
@ -70,11 +66,23 @@ add_filter('the_content', 'wpautop');
|
||||||
add_filter('the_excerpt', 'convert_smilies');
|
add_filter('the_excerpt', 'convert_smilies');
|
||||||
add_filter('the_excerpt', 'convert_chars');
|
add_filter('the_excerpt', 'convert_chars');
|
||||||
add_filter('the_excerpt', 'wpautop');
|
add_filter('the_excerpt', 'wpautop');
|
||||||
|
|
||||||
add_filter('get_the_excerpt', 'wp_trim_excerpt');
|
add_filter('get_the_excerpt', 'wp_trim_excerpt');
|
||||||
|
|
||||||
add_filter('sanitize_title', 'sanitize_title_with_dashes');
|
add_filter('sanitize_title', 'sanitize_title_with_dashes');
|
||||||
|
|
||||||
|
// RSS filters
|
||||||
|
add_filter('the_title_rss', 'strip_tags');
|
||||||
|
add_filter('the_title_rss', 'ent2ncr', 8);
|
||||||
|
add_filter('the_content_rss', 'ent2ncr', 8);
|
||||||
|
add_filter('the_excerpt_rss', 'convert_chars');
|
||||||
|
add_filter('the_excerpt_rss', 'ent2ncr', 8);
|
||||||
|
add_filter('comment_author_rss', 'ent2ncr', 8);
|
||||||
|
add_filter('comment_text_rss', 'htmlspecialchars');
|
||||||
|
add_filter('comment_text_rss', 'ent2ncr', 8);
|
||||||
|
add_filter('bloginfo_rss', 'ent2ncr', 8);
|
||||||
|
add_filter('the_author', 'ent2ncr', 8);
|
||||||
|
|
||||||
|
// Actions
|
||||||
add_action('publish_post', 'generic_ping');
|
add_action('publish_post', 'generic_ping');
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -722,4 +722,271 @@ function wp_trim_excerpt($text) { // Fakes an excerpt if needed
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ent2ncr($text) {
|
||||||
|
$to_ncr = array(
|
||||||
|
'"' => '"',
|
||||||
|
'&' => '&',
|
||||||
|
'⁄' => '/',
|
||||||
|
'<' => '<',
|
||||||
|
'>' => '>',
|
||||||
|
' ' => ' ',
|
||||||
|
'¡' => '¡',
|
||||||
|
'¢' => '¢',
|
||||||
|
'£' => '£',
|
||||||
|
'¤' => '¤',
|
||||||
|
'¥' => '¥',
|
||||||
|
'\|' => '¦',
|
||||||
|
'¦' => '¦',
|
||||||
|
'&brkbar;' => '¦',
|
||||||
|
'§' => '§',
|
||||||
|
'¨' => '¨',
|
||||||
|
'¨' => '¨',
|
||||||
|
'©' => '©',
|
||||||
|
'ª' => 'ª',
|
||||||
|
'«' => '«',
|
||||||
|
'¬' => '¬',
|
||||||
|
'­' => '­',
|
||||||
|
'®' => '®',
|
||||||
|
'¯' => '¯',
|
||||||
|
'&hibar;' => '¯',
|
||||||
|
'°' => '°',
|
||||||
|
'±' => '±',
|
||||||
|
'²' => '²',
|
||||||
|
'³' => '³',
|
||||||
|
'´' => '´',
|
||||||
|
'µ' => 'µ',
|
||||||
|
'¶' => '¶',
|
||||||
|
'·' => '·',
|
||||||
|
'¸' => '¸',
|
||||||
|
'¹' => '¹',
|
||||||
|
'º' => 'º',
|
||||||
|
'»' => '»',
|
||||||
|
'¼' => '¼',
|
||||||
|
'½' => '½',
|
||||||
|
'¾' => '¾',
|
||||||
|
'¿' => '¿',
|
||||||
|
'À' => 'À',
|
||||||
|
'Á' => 'Á',
|
||||||
|
'Â' => 'Â',
|
||||||
|
'Ã' => 'Ã',
|
||||||
|
'Ä' => 'Ä',
|
||||||
|
'Å' => 'Å',
|
||||||
|
'Æ' => 'Æ',
|
||||||
|
'Ç' => 'Ç',
|
||||||
|
'È' => 'È',
|
||||||
|
'É' => 'É',
|
||||||
|
'Ê' => 'Ê',
|
||||||
|
'Ë' => 'Ë',
|
||||||
|
'Ì' => 'Ì',
|
||||||
|
'Í' => 'Í',
|
||||||
|
'Î' => 'Î',
|
||||||
|
'Ï' => 'Ï',
|
||||||
|
'Ð' => 'Ð',
|
||||||
|
'Ñ' => 'Ñ',
|
||||||
|
'Ò' => 'Ò',
|
||||||
|
'Ó' => 'Ó',
|
||||||
|
'Ô' => 'Ô',
|
||||||
|
'Õ' => 'Õ',
|
||||||
|
'Ö' => 'Ö',
|
||||||
|
'×' => '×',
|
||||||
|
'Ø' => 'Ø',
|
||||||
|
'Ù' => 'Ù',
|
||||||
|
'Ú' => 'Ú',
|
||||||
|
'Û' => 'Û',
|
||||||
|
'Ü' => 'Ü',
|
||||||
|
'Ý' => 'Ý',
|
||||||
|
'Þ' => 'Þ',
|
||||||
|
'ß' => 'ß',
|
||||||
|
'à' => 'à',
|
||||||
|
'á' => 'á',
|
||||||
|
'â' => 'â',
|
||||||
|
'ã' => 'ã',
|
||||||
|
'ä' => 'ä',
|
||||||
|
'å' => 'å',
|
||||||
|
'æ' => 'æ',
|
||||||
|
'ç' => 'ç',
|
||||||
|
'è' => 'è',
|
||||||
|
'é' => 'é',
|
||||||
|
'ê' => 'ê',
|
||||||
|
'ë' => 'ë',
|
||||||
|
'ì' => 'ì',
|
||||||
|
'í' => 'í',
|
||||||
|
'î' => 'î',
|
||||||
|
'ï' => 'ï',
|
||||||
|
'ð' => 'ð',
|
||||||
|
'ñ' => 'ñ',
|
||||||
|
'ò' => 'ò',
|
||||||
|
'ó' => 'ó',
|
||||||
|
'ô' => 'ô',
|
||||||
|
'õ' => 'õ',
|
||||||
|
'ö' => 'ö',
|
||||||
|
'÷' => '÷',
|
||||||
|
'ø' => 'ø',
|
||||||
|
'ù' => 'ù',
|
||||||
|
'ú' => 'ú',
|
||||||
|
'û' => 'û',
|
||||||
|
'ü' => 'ü',
|
||||||
|
'ý' => 'ý',
|
||||||
|
'þ' => 'þ',
|
||||||
|
'ÿ' => 'ÿ',
|
||||||
|
'Œ' => 'Œ',
|
||||||
|
'œ' => 'œ',
|
||||||
|
'Š' => 'Š',
|
||||||
|
'š' => 'š',
|
||||||
|
'Ÿ' => 'Ÿ',
|
||||||
|
'ƒ' => 'ƒ',
|
||||||
|
'ˆ' => 'ˆ',
|
||||||
|
'˜' => '˜',
|
||||||
|
'Α' => 'Α',
|
||||||
|
'Β' => 'Β',
|
||||||
|
'Γ' => 'Γ',
|
||||||
|
'Δ' => 'Δ',
|
||||||
|
'Ε' => 'Ε',
|
||||||
|
'Ζ' => 'Ζ',
|
||||||
|
'Η' => 'Η',
|
||||||
|
'Θ' => 'Θ',
|
||||||
|
'Ι' => 'Ι',
|
||||||
|
'Κ' => 'Κ',
|
||||||
|
'Λ' => 'Λ',
|
||||||
|
'Μ' => 'Μ',
|
||||||
|
'Ν' => 'Ν',
|
||||||
|
'Ξ' => 'Ξ',
|
||||||
|
'Ο' => 'Ο',
|
||||||
|
'Π' => 'Π',
|
||||||
|
'Ρ' => 'Ρ',
|
||||||
|
'Σ' => 'Σ',
|
||||||
|
'Τ' => 'Τ',
|
||||||
|
'Υ' => 'Υ',
|
||||||
|
'Φ' => 'Φ',
|
||||||
|
'Χ' => 'Χ',
|
||||||
|
'Ψ' => 'Ψ',
|
||||||
|
'Ω' => 'Ω',
|
||||||
|
'α' => 'α',
|
||||||
|
'β' => 'β',
|
||||||
|
'γ' => 'γ',
|
||||||
|
'δ' => 'δ',
|
||||||
|
'ε' => 'ε',
|
||||||
|
'ζ' => 'ζ',
|
||||||
|
'η' => 'η',
|
||||||
|
'θ' => 'θ',
|
||||||
|
'ι' => 'ι',
|
||||||
|
'κ' => 'κ',
|
||||||
|
'λ' => 'λ',
|
||||||
|
'μ' => 'μ',
|
||||||
|
'ν' => 'ν',
|
||||||
|
'ξ' => 'ξ',
|
||||||
|
'ο' => 'ο',
|
||||||
|
'π' => 'π',
|
||||||
|
'ρ' => 'ρ',
|
||||||
|
'ς' => 'ς',
|
||||||
|
'σ' => 'σ',
|
||||||
|
'τ' => 'τ',
|
||||||
|
'υ' => 'υ',
|
||||||
|
'φ' => 'φ',
|
||||||
|
'χ' => 'χ',
|
||||||
|
'ψ' => 'ψ',
|
||||||
|
'ω' => 'ω',
|
||||||
|
'ϑ' => 'ϑ',
|
||||||
|
'ϒ' => 'ϒ',
|
||||||
|
'ϖ' => 'ϖ',
|
||||||
|
' ' => ' ',
|
||||||
|
' ' => ' ',
|
||||||
|
' ' => ' ',
|
||||||
|
'‌' => '‌',
|
||||||
|
'‍' => '‍',
|
||||||
|
'‎' => '‎',
|
||||||
|
'‏' => '‏',
|
||||||
|
'–' => '–',
|
||||||
|
'—' => '—',
|
||||||
|
'‘' => '‘',
|
||||||
|
'’' => '’',
|
||||||
|
'‚' => '‚',
|
||||||
|
'“' => '“',
|
||||||
|
'”' => '”',
|
||||||
|
'„' => '„',
|
||||||
|
'†' => '†',
|
||||||
|
'‡' => '‡',
|
||||||
|
'•' => '•',
|
||||||
|
'…' => '…',
|
||||||
|
'‰' => '‰',
|
||||||
|
'′' => '′',
|
||||||
|
'″' => '″',
|
||||||
|
'‹' => '‹',
|
||||||
|
'›' => '›',
|
||||||
|
'‾' => '‾',
|
||||||
|
'⁄' => '⁄',
|
||||||
|
'€' => '€',
|
||||||
|
'ℑ' => 'ℑ',
|
||||||
|
'℘' => '℘',
|
||||||
|
'ℜ' => 'ℜ',
|
||||||
|
'™' => '™',
|
||||||
|
'ℵ' => 'ℵ',
|
||||||
|
'↵' => '↵',
|
||||||
|
'⇐' => '⇐',
|
||||||
|
'⇑' => '⇑',
|
||||||
|
'⇒' => '⇒',
|
||||||
|
'⇓' => '⇓',
|
||||||
|
'⇔' => '⇔',
|
||||||
|
'∀' => '∀',
|
||||||
|
'∂' => '∂',
|
||||||
|
'∃' => '∃',
|
||||||
|
'∅' => '∅',
|
||||||
|
'∇' => '∇',
|
||||||
|
'∈' => '∈',
|
||||||
|
'∉' => '∉',
|
||||||
|
'∋' => '∋',
|
||||||
|
'∏' => '∏',
|
||||||
|
'∑' => '∑',
|
||||||
|
'−' => '−',
|
||||||
|
'∗' => '∗',
|
||||||
|
'√' => '√',
|
||||||
|
'∝' => '∝',
|
||||||
|
'∞' => '∞',
|
||||||
|
'∠' => '∠',
|
||||||
|
'∧' => '∧',
|
||||||
|
'∨' => '∨',
|
||||||
|
'∩' => '∩',
|
||||||
|
'∪' => '∪',
|
||||||
|
'∫' => '∫',
|
||||||
|
'∴' => '∴',
|
||||||
|
'∼' => '∼',
|
||||||
|
'≅' => '≅',
|
||||||
|
'≈' => '≈',
|
||||||
|
'≠' => '≠',
|
||||||
|
'≡' => '≡',
|
||||||
|
'≤' => '≤',
|
||||||
|
'≥' => '≥',
|
||||||
|
'⊂' => '⊂',
|
||||||
|
'⊃' => '⊃',
|
||||||
|
'⊄' => '⊄',
|
||||||
|
'⊆' => '⊆',
|
||||||
|
'⊇' => '⊇',
|
||||||
|
'⊕' => '⊕',
|
||||||
|
'⊗' => '⊗',
|
||||||
|
'⊥' => '⊥',
|
||||||
|
'⋅' => '⋅',
|
||||||
|
'⌈' => '⌈',
|
||||||
|
'⌉' => '⌉',
|
||||||
|
'⌊' => '⌊',
|
||||||
|
'⌋' => '⌋',
|
||||||
|
'⟨' => '〈',
|
||||||
|
'⟩' => '〉',
|
||||||
|
'←' => '←',
|
||||||
|
'↑' => '↑',
|
||||||
|
'→' => '→',
|
||||||
|
'↓' => '↓',
|
||||||
|
'↔' => '↔',
|
||||||
|
'◊' => '◊',
|
||||||
|
'♠' => '♠',
|
||||||
|
'♣' => '♣',
|
||||||
|
'♥' => '♥',
|
||||||
|
'♦' => '♦'
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($to_ncr as $entity => $ncr) {
|
||||||
|
$text = str_replace($entity, $ncr, $text);
|
||||||
|
}
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue