author | ymh <ymh.work@gmail.com> |
Tue, 22 Oct 2019 16:11:46 +0200 | |
changeset 15 | 3d4e9c994f10 |
parent 9 | 177826044cd9 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Main WordPress Formatting API. |
|
4 |
* |
|
5 |
* Handles many functions for formatting output. |
|
6 |
* |
|
7 |
* @package WordPress |
|
8 |
*/ |
|
9 |
||
10 |
/** |
|
11 |
* Replaces common plain text characters into formatted entities |
|
12 |
* |
|
13 |
* As an example, |
|
5 | 14 |
* |
15 |
* 'cause today's effort makes it worth tomorrow's "holiday" ... |
|
16 |
* |
|
0 | 17 |
* Becomes: |
5 | 18 |
* |
19 |
* ’cause today’s effort makes it worth tomorrow’s “holiday” … |
|
20 |
* |
|
0 | 21 |
* Code within certain html blocks are skipped. |
22 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
* Do not use this function before the {@see 'init'} action hook; everything will break. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
24 |
* |
0 | 25 |
* @since 0.71 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
* @global array $wp_cockneyreplace Array of formatted entities for certain common phrases |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
* @global array $shortcode_tags |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
* @staticvar array $static_characters |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
* @staticvar array $static_replacements |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
* @staticvar array $dynamic_characters |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
* @staticvar array $dynamic_replacements |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
* @staticvar array $default_no_texturize_tags |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
* @staticvar array $default_no_texturize_shortcodes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* @staticvar bool $run_texturize |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
* @staticvar string $apos |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* @staticvar string $prime |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
* @staticvar string $double_prime |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
* @staticvar string $opening_quote |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
* @staticvar string $closing_quote |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
* @staticvar string $opening_single_quote |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
* @staticvar string $closing_single_quote |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
* @staticvar string $open_q_flag |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
* @staticvar string $open_sq_flag |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
* @staticvar string $apos_flag |
0 | 46 |
* |
47 |
* @param string $text The text to be formatted |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
* @param bool $reset Set to true for unit testing. Translated patterns will reset. |
0 | 49 |
* @return string The string replaced with html entities |
50 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
function wptexturize( $text, $reset = false ) { |
5 | 52 |
global $wp_cockneyreplace, $shortcode_tags; |
9 | 53 |
static $static_characters = null, |
54 |
$static_replacements = null, |
|
55 |
$dynamic_characters = null, |
|
56 |
$dynamic_replacements = null, |
|
57 |
$default_no_texturize_tags = null, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
$default_no_texturize_shortcodes = null, |
9 | 59 |
$run_texturize = true, |
60 |
$apos = null, |
|
61 |
$prime = null, |
|
62 |
$double_prime = null, |
|
63 |
$opening_quote = null, |
|
64 |
$closing_quote = null, |
|
65 |
$opening_single_quote = null, |
|
66 |
$closing_single_quote = null, |
|
67 |
$open_q_flag = '<!--oq-->', |
|
68 |
$open_sq_flag = '<!--osq-->', |
|
69 |
$apos_flag = '<!--apos-->'; |
|
5 | 70 |
|
71 |
// If there's nothing to do, just stop. |
|
72 |
if ( empty( $text ) || false === $run_texturize ) { |
|
73 |
return $text; |
|
74 |
} |
|
75 |
||
76 |
// Set up static variables. Run once only. |
|
77 |
if ( $reset || ! isset( $static_characters ) ) { |
|
78 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
* Filters whether to skip running wptexturize(). |
5 | 80 |
* |
81 |
* Passing false to the filter will effectively short-circuit wptexturize(). |
|
82 |
* returning the original text passed to the function instead. |
|
83 |
* |
|
84 |
* The filter runs only once, the first time wptexturize() is called. |
|
85 |
* |
|
86 |
* @since 4.0.0 |
|
87 |
* |
|
88 |
* @see wptexturize() |
|
89 |
* |
|
90 |
* @param bool $run_texturize Whether to short-circuit wptexturize(). |
|
91 |
*/ |
|
92 |
$run_texturize = apply_filters( 'run_wptexturize', $run_texturize ); |
|
93 |
if ( false === $run_texturize ) { |
|
94 |
return $text; |
|
95 |
} |
|
96 |
||
0 | 97 |
/* translators: opening curly double quote */ |
98 |
$opening_quote = _x( '“', 'opening curly double quote' ); |
|
99 |
/* translators: closing curly double quote */ |
|
100 |
$closing_quote = _x( '”', 'closing curly double quote' ); |
|
101 |
||
102 |
/* translators: apostrophe, for example in 'cause or can't */ |
|
103 |
$apos = _x( '’', 'apostrophe' ); |
|
104 |
||
105 |
/* translators: prime, for example in 9' (nine feet) */ |
|
106 |
$prime = _x( '′', 'prime' ); |
|
107 |
/* translators: double prime, for example in 9" (nine inches) */ |
|
108 |
$double_prime = _x( '″', 'double prime' ); |
|
109 |
||
110 |
/* translators: opening curly single quote */ |
|
111 |
$opening_single_quote = _x( '‘', 'opening curly single quote' ); |
|
112 |
/* translators: closing curly single quote */ |
|
113 |
$closing_single_quote = _x( '’', 'closing curly single quote' ); |
|
114 |
||
115 |
/* translators: en dash */ |
|
116 |
$en_dash = _x( '–', 'en dash' ); |
|
117 |
/* translators: em dash */ |
|
118 |
$em_dash = _x( '—', 'em dash' ); |
|
119 |
||
9 | 120 |
$default_no_texturize_tags = array( 'pre', 'code', 'kbd', 'style', 'script', 'tt' ); |
121 |
$default_no_texturize_shortcodes = array( 'code' ); |
|
0 | 122 |
|
123 |
// if a plugin has provided an autocorrect array, use it |
|
9 | 124 |
if ( isset( $wp_cockneyreplace ) ) { |
125 |
$cockney = array_keys( $wp_cockneyreplace ); |
|
5 | 126 |
$cockneyreplace = array_values( $wp_cockneyreplace ); |
0 | 127 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
/* translators: This is a comma-separated list of words that defy the syntax of quotations in normal use, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
* for example... 'We do not have enough words yet' ... is a typical quoted phrase. But when we write |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
* lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
*/ |
9 | 132 |
$cockney = explode( |
133 |
',', |
|
134 |
_x( |
|
135 |
"'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em", |
|
136 |
'Comma-separated list of words to texturize in your language' |
|
137 |
) |
|
138 |
); |
|
139 |
||
140 |
$cockneyreplace = explode( |
|
141 |
',', |
|
142 |
_x( |
|
143 |
'’tain’t,’twere,’twas,’tis,’twill,’til,’bout,’nuff,’round,’cause,’em', |
|
144 |
'Comma-separated list of replacement words in your language' |
|
145 |
) |
|
146 |
); |
|
0 | 147 |
} |
148 |
||
9 | 149 |
$static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); |
5 | 150 |
$static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); |
151 |
||
152 |
// Pattern-based replacements of characters. |
|
153 |
// Sort the remaining patterns into several arrays for performance tuning. |
|
9 | 154 |
$dynamic_characters = array( |
155 |
'apos' => array(), |
|
156 |
'quote' => array(), |
|
157 |
'dash' => array(), |
|
158 |
); |
|
159 |
$dynamic_replacements = array( |
|
160 |
'apos' => array(), |
|
161 |
'quote' => array(), |
|
162 |
'dash' => array(), |
|
163 |
); |
|
164 |
$dynamic = array(); |
|
165 |
$spaces = wp_spaces_regexp(); |
|
5 | 166 |
|
167 |
// '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. |
|
168 |
if ( "'" !== $apos || "'" !== $closing_single_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
$dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_single_quote; |
5 | 170 |
} |
171 |
if ( "'" !== $apos || '"' !== $closing_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
$dynamic[ '/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_quote; |
5 | 173 |
} |
174 |
||
175 |
// '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0. |
|
176 |
if ( "'" !== $apos ) { |
|
9 | 177 |
$dynamic['/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/'] = $apos_flag; |
5 | 178 |
} |
179 |
||
180 |
// Quoted Numbers like '0.42' |
|
181 |
if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
$dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $open_sq_flag . '$1' . $closing_single_quote; |
5 | 183 |
} |
184 |
||
185 |
// Single quote at start, or preceded by (, {, <, [, ", -, or spaces. |
|
186 |
if ( "'" !== $opening_single_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
187 |
$dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $open_sq_flag; |
5 | 188 |
} |
189 |
||
190 |
// Apostrophe in a word. No spaces, double apostrophes, or other punctuation. |
|
191 |
if ( "'" !== $apos ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
$dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos_flag; |
0 | 193 |
} |
5 | 194 |
|
9 | 195 |
$dynamic_characters['apos'] = array_keys( $dynamic ); |
5 | 196 |
$dynamic_replacements['apos'] = array_values( $dynamic ); |
9 | 197 |
$dynamic = array(); |
5 | 198 |
|
199 |
// Quoted Numbers like "42" |
|
200 |
if ( '"' !== $opening_quote && '"' !== $closing_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
$dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $open_q_flag . '$1' . $closing_quote; |
5 | 202 |
} |
203 |
||
204 |
// Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces. |
|
205 |
if ( '"' !== $opening_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
206 |
$dynamic[ '/(?<=\A|[([{\-]|<|' . $spaces . ')"(?!' . $spaces . ')/' ] = $open_q_flag; |
5 | 207 |
} |
208 |
||
9 | 209 |
$dynamic_characters['quote'] = array_keys( $dynamic ); |
5 | 210 |
$dynamic_replacements['quote'] = array_values( $dynamic ); |
9 | 211 |
$dynamic = array(); |
5 | 212 |
|
213 |
// Dashes and spaces |
|
9 | 214 |
$dynamic['/---/'] = $em_dash; |
5 | 215 |
$dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash; |
9 | 216 |
$dynamic['/(?<!xn)--/'] = $en_dash; |
217 |
$dynamic[ '/(?<=^|' . $spaces . ')-(?=$|' . $spaces . ')/' ] = $en_dash; |
|
218 |
||
219 |
$dynamic_characters['dash'] = array_keys( $dynamic ); |
|
5 | 220 |
$dynamic_replacements['dash'] = array_values( $dynamic ); |
0 | 221 |
} |
222 |
||
223 |
// Must do this every time in case plugins use these filters in a context sensitive manner |
|
5 | 224 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
* Filters the list of HTML elements not to texturize. |
5 | 226 |
* |
227 |
* @since 2.8.0 |
|
228 |
* |
|
229 |
* @param array $default_no_texturize_tags An array of HTML element names. |
|
230 |
*/ |
|
231 |
$no_texturize_tags = apply_filters( 'no_texturize_tags', $default_no_texturize_tags ); |
|
232 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
233 |
* Filters the list of shortcodes not to texturize. |
5 | 234 |
* |
235 |
* @since 2.8.0 |
|
236 |
* |
|
237 |
* @param array $default_no_texturize_shortcodes An array of shortcode names. |
|
238 |
*/ |
|
239 |
$no_texturize_shortcodes = apply_filters( 'no_texturize_shortcodes', $default_no_texturize_shortcodes ); |
|
0 | 240 |
|
9 | 241 |
$no_texturize_tags_stack = array(); |
0 | 242 |
$no_texturize_shortcodes_stack = array(); |
243 |
||
5 | 244 |
// Look for shortcodes and HTML elements. |
245 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
preg_match_all( '@\[/?([^<>&/\[\]\x00-\x20=]++)@', $text, $matches ); |
9 | 247 |
$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
$found_shortcodes = ! empty( $tagnames ); |
9 | 249 |
$shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : ''; |
250 |
$regex = _get_wptexturize_split_regex( $shortcode_regex ); |
|
5 | 251 |
|
252 |
$textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); |
|
0 | 253 |
|
254 |
foreach ( $textarr as &$curl ) { |
|
5 | 255 |
// Only call _wptexturize_pushpop_element if $curl is a delimiter. |
0 | 256 |
$first = $curl[0]; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
if ( '<' === $first ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
if ( '<!--' === substr( $curl, 0, 4 ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
// This is an HTML comment delimiter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
262 |
// This is an HTML element delimiter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
// Replace each & with & unless it already looks like an entity. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
$curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
_wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
} |
5 | 269 |
} elseif ( '' === trim( $curl ) ) { |
270 |
// This is a newline between delimiters. Performance improves when we check this. |
|
271 |
continue; |
|
272 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
} elseif ( '[' === $first && $found_shortcodes && 1 === preg_match( '/^' . $shortcode_regex . '$/', $curl ) ) { |
5 | 274 |
// This is a shortcode delimiter. |
275 |
||
276 |
if ( '[[' !== substr( $curl, 0, 2 ) && ']]' !== substr( $curl, -2 ) ) { |
|
277 |
// Looks like a normal shortcode. |
|
278 |
_wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes ); |
|
279 |
} else { |
|
280 |
// Looks like an escaped shortcode. |
|
281 |
continue; |
|
282 |
} |
|
283 |
} elseif ( empty( $no_texturize_shortcodes_stack ) && empty( $no_texturize_tags_stack ) ) { |
|
284 |
// This is neither a delimiter, nor is this content inside of no_texturize pairs. Do texturize. |
|
285 |
||
286 |
$curl = str_replace( $static_characters, $static_replacements, $curl ); |
|
287 |
||
288 |
if ( false !== strpos( $curl, "'" ) ) { |
|
289 |
$curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
$curl = wptexturize_primes( $curl, "'", $prime, $open_sq_flag, $closing_single_quote ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
$curl = str_replace( $apos_flag, $apos, $curl ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
$curl = str_replace( $open_sq_flag, $opening_single_quote, $curl ); |
5 | 293 |
} |
294 |
if ( false !== strpos( $curl, '"' ) ) { |
|
295 |
$curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
296 |
$curl = wptexturize_primes( $curl, '"', $double_prime, $open_q_flag, $closing_quote ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
$curl = str_replace( $open_q_flag, $opening_quote, $curl ); |
5 | 298 |
} |
299 |
if ( false !== strpos( $curl, '-' ) ) { |
|
300 |
$curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl ); |
|
301 |
} |
|
302 |
||
303 |
// 9x9 (times), but never 0x9999 |
|
304 |
if ( 1 === preg_match( '/(?<=\d)x\d/', $curl ) ) { |
|
305 |
// Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one! |
|
306 |
$curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl ); |
|
307 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
// Replace each & with & unless it already looks like an entity. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
$curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl ); |
0 | 311 |
} |
312 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
return implode( '', $textarr ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
* Implements a logic tree to determine whether or not "7'." represents seven feet, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
* then converts the special char into either a prime char or a closing quote char. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
* @param string $haystack The plain text to be searched. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
* @param string $needle The character to search for such as ' or ". |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
* @param string $prime The prime char to use for replacement. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
* @param string $open_quote The opening quote char. Opening quote replacement must be |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
* accomplished already. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
* @param string $close_quote The closing quote char to use for replacement. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
* @return string The $haystack value after primes and quotes replacements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quote ) { |
9 | 332 |
$spaces = wp_spaces_regexp(); |
333 |
$flag = '<!--wp-prime-or-quote-->'; |
|
334 |
$quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|>|" . $spaces . ')/'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
$prime_pattern = "/(?<=\\d)$needle/"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
$flag_after_digit = "/(?<=\\d)$flag/"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
$flag_no_digit = "/(?<!\\d)$flag/"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
$sentences = explode( $open_quote, $haystack ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
foreach ( $sentences as $key => &$sentence ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
if ( false === strpos( $sentence, $needle ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
} elseif ( 0 !== $key && 0 === substr_count( $sentence, $close_quote ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
$sentence = preg_replace( $quote_pattern, $flag, $sentence, -1, $count ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
if ( $count > 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
// This sentence appears to have multiple closing quotes. Attempt Vulcan logic. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
$sentence = preg_replace( $flag_no_digit, $close_quote, $sentence, -1, $count2 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
if ( 0 === $count2 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
// Try looking for a quote followed by a period. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
$count2 = substr_count( $sentence, "$flag." ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
if ( $count2 > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
// Assume the rightmost quote-period match is the end of quotation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
$pos = strrpos( $sentence, "$flag." ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
// When all else fails, make the rightmost candidate a closing quote. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
// This is most likely to be problematic in the context of bug #18549. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
$pos = strrpos( $sentence, $flag ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
360 |
$sentence = substr_replace( $sentence, $close_quote, $pos, strlen( $flag ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
// Use conventional replacement on any remaining primes and quotes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
363 |
$sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
$sentence = preg_replace( $flag_after_digit, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
$sentence = str_replace( $flag, $close_quote, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
} elseif ( 1 == $count ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
// Found only one closing quote candidate, so give it priority over primes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
$sentence = str_replace( $flag, $close_quote, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
$sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
// No closing quotes found. Just run primes pattern. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
$sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
$sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
$sentence = preg_replace( $quote_pattern, $close_quote, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
if ( '"' == $needle && false !== strpos( $sentence, '"' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
$sentence = str_replace( '"', $close_quote, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
return implode( $open_quote, $sentences ); |
0 | 384 |
} |
385 |
||
386 |
/** |
|
387 |
* Search for disabled element tags. Push element to stack on tag open and pop |
|
5 | 388 |
* on tag close. |
389 |
* |
|
390 |
* Assumes first char of $text is tag opening and last char is tag closing. |
|
391 |
* Assumes second char of $text is optionally '/' to indicate closing as in </html>. |
|
0 | 392 |
* |
393 |
* @since 2.9.0 |
|
394 |
* @access private |
|
395 |
* |
|
5 | 396 |
* @param string $text Text to check. Must be a tag like `<html>` or `[shortcode]`. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
* @param array $stack List of open tag elements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
* @param array $disabled_elements The tag names to match against. Spaces are not allowed in tag names. |
0 | 399 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) { |
5 | 401 |
// Is it an opening tag or closing tag? |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
if ( isset( $text[1] ) && '/' !== $text[1] ) { |
5 | 403 |
$opening_tag = true; |
404 |
$name_offset = 1; |
|
405 |
} elseif ( 0 == count( $stack ) ) { |
|
406 |
// Stack is empty. Just stop. |
|
407 |
return; |
|
408 |
} else { |
|
409 |
$opening_tag = false; |
|
410 |
$name_offset = 2; |
|
411 |
} |
|
412 |
||
413 |
// Parse out the tag name. |
|
414 |
$space = strpos( $text, ' ' ); |
|
415 |
if ( false === $space ) { |
|
416 |
$space = -1; |
|
417 |
} else { |
|
418 |
$space -= $name_offset; |
|
419 |
} |
|
420 |
$tag = substr( $text, $name_offset, $space ); |
|
421 |
||
422 |
// Handle disabled tags. |
|
423 |
if ( in_array( $tag, $disabled_elements ) ) { |
|
424 |
if ( $opening_tag ) { |
|
0 | 425 |
/* |
426 |
* This disables texturize until we find a closing tag of our type |
|
427 |
* (e.g. <pre>) even if there was invalid nesting before that |
|
428 |
* |
|
429 |
* Example: in the case <pre>sadsadasd</code>"baba"</pre> |
|
430 |
* "baba" won't be texturize |
|
431 |
*/ |
|
432 |
||
5 | 433 |
array_push( $stack, $tag ); |
434 |
} elseif ( end( $stack ) == $tag ) { |
|
435 |
array_pop( $stack ); |
|
0 | 436 |
} |
437 |
} |
|
438 |
} |
|
439 |
||
440 |
/** |
|
441 |
* Replaces double line-breaks with paragraph elements. |
|
442 |
* |
|
443 |
* A group of regex replaces used to identify text formatted with newlines and |
|
5 | 444 |
* replace double line-breaks with HTML paragraph tags. The remaining line-breaks |
445 |
* after conversion become <<br />> tags, unless $br is set to '0' or 'false'. |
|
0 | 446 |
* |
447 |
* @since 0.71 |
|
448 |
* |
|
449 |
* @param string $pee The text which has to be formatted. |
|
5 | 450 |
* @param bool $br Optional. If set, this will convert all remaining line-breaks |
451 |
* after paragraphing. Default true. |
|
0 | 452 |
* @return string Text which has been converted into correct paragraph tags. |
453 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
function wpautop( $pee, $br = true ) { |
0 | 455 |
$pre_tags = array(); |
456 |
||
9 | 457 |
if ( trim( $pee ) === '' ) { |
0 | 458 |
return ''; |
9 | 459 |
} |
0 | 460 |
|
5 | 461 |
// Just to make things a little easier, pad the end. |
462 |
$pee = $pee . "\n"; |
|
463 |
||
464 |
/* |
|
465 |
* Pre tags shouldn't be touched by autop. |
|
466 |
* Replace pre tags with placeholders and bring them back after autop. |
|
467 |
*/ |
|
9 | 468 |
if ( strpos( $pee, '<pre' ) !== false ) { |
0 | 469 |
$pee_parts = explode( '</pre>', $pee ); |
9 | 470 |
$last_pee = array_pop( $pee_parts ); |
471 |
$pee = ''; |
|
472 |
$i = 0; |
|
0 | 473 |
|
474 |
foreach ( $pee_parts as $pee_part ) { |
|
9 | 475 |
$start = strpos( $pee_part, '<pre' ); |
0 | 476 |
|
477 |
// Malformed html? |
|
478 |
if ( $start === false ) { |
|
479 |
$pee .= $pee_part; |
|
480 |
continue; |
|
481 |
} |
|
482 |
||
9 | 483 |
$name = "<pre wp-pre-tag-$i></pre>"; |
484 |
$pre_tags[ $name ] = substr( $pee_part, $start ) . '</pre>'; |
|
0 | 485 |
|
486 |
$pee .= substr( $pee_part, 0, $start ) . $name; |
|
487 |
$i++; |
|
488 |
} |
|
489 |
||
490 |
$pee .= $last_pee; |
|
491 |
} |
|
5 | 492 |
// Change multiple <br>s into two line breaks, which will turn into paragraphs. |
9 | 493 |
$pee = preg_replace( '|<br\s*/?>\s*<br\s*/?>|', "\n\n", $pee ); |
5 | 494 |
|
495 |
$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; |
|
496 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
// Add a double line break above block-level opening tags. |
9 | 498 |
$pee = preg_replace( '!(<' . $allblocks . '[\s/>])!', "\n\n$1", $pee ); |
5 | 499 |
|
500 |
// Add a double line break below block-level closing tags. |
|
9 | 501 |
$pee = preg_replace( '!(</' . $allblocks . '>)!', "$1\n\n", $pee ); |
5 | 502 |
|
503 |
// Standardize newline characters to "\n". |
|
9 | 504 |
$pee = str_replace( array( "\r\n", "\r" ), "\n", $pee ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
506 |
// Find newlines in all elements and add placeholders. |
9 | 507 |
$pee = wp_replace_in_html_tags( $pee, array( "\n" => ' <!-- wpnl --> ' ) ); |
5 | 508 |
|
509 |
// Collapse line breaks before and after <option> elements so they don't get autop'd. |
|
510 |
if ( strpos( $pee, '<option' ) !== false ) { |
|
511 |
$pee = preg_replace( '|\s*<option|', '<option', $pee ); |
|
512 |
$pee = preg_replace( '|</option>\s*|', '</option>', $pee ); |
|
513 |
} |
|
514 |
||
515 |
/* |
|
516 |
* Collapse line breaks inside <object> elements, before <param> and <embed> elements |
|
517 |
* so they don't get autop'd. |
|
518 |
*/ |
|
519 |
if ( strpos( $pee, '</object>' ) !== false ) { |
|
520 |
$pee = preg_replace( '|(<object[^>]*>)\s*|', '$1', $pee ); |
|
521 |
$pee = preg_replace( '|\s*</object>|', '</object>', $pee ); |
|
522 |
$pee = preg_replace( '%\s*(</?(?:param|embed)[^>]*>)\s*%', '$1', $pee ); |
|
0 | 523 |
} |
5 | 524 |
|
525 |
/* |
|
526 |
* Collapse line breaks inside <audio> and <video> elements, |
|
527 |
* before and after <source> and <track> elements. |
|
528 |
*/ |
|
529 |
if ( strpos( $pee, '<source' ) !== false || strpos( $pee, '<track' ) !== false ) { |
|
530 |
$pee = preg_replace( '%([<\[](?:audio|video)[^>\]]*[>\]])\s*%', '$1', $pee ); |
|
531 |
$pee = preg_replace( '%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $pee ); |
|
532 |
$pee = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee ); |
|
533 |
} |
|
534 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
// Collapse line breaks before and after <figcaption> elements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
if ( strpos( $pee, '<figcaption' ) !== false ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
537 |
$pee = preg_replace( '|\s*(<figcaption[^>]*>)|', '$1', $pee ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
538 |
$pee = preg_replace( '|</figcaption>\s*|', '</figcaption>', $pee ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
540 |
|
5 | 541 |
// Remove more than two contiguous line breaks. |
9 | 542 |
$pee = preg_replace( "/\n\n+/", "\n\n", $pee ); |
5 | 543 |
|
544 |
// Split up the contents into an array of strings, separated by double line breaks. |
|
9 | 545 |
$pees = preg_split( '/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY ); |
5 | 546 |
|
547 |
// Reset $pee prior to rebuilding. |
|
0 | 548 |
$pee = ''; |
5 | 549 |
|
550 |
// Rebuild the content as a string, wrapping every bit with a <p>. |
|
551 |
foreach ( $pees as $tinkle ) { |
|
9 | 552 |
$pee .= '<p>' . trim( $tinkle, "\n" ) . "</p>\n"; |
5 | 553 |
} |
554 |
||
555 |
// Under certain strange conditions it could create a P of entirely whitespace. |
|
9 | 556 |
$pee = preg_replace( '|<p>\s*</p>|', '', $pee ); |
5 | 557 |
|
558 |
// Add a closing <p> inside <div>, <address>, or <form> tag if missing. |
|
9 | 559 |
$pee = preg_replace( '!<p>([^<]+)</(div|address|form)>!', '<p>$1</p></$2>', $pee ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
|
5 | 561 |
// If an opening or closing block element tag is wrapped in a <p>, unwrap it. |
9 | 562 |
$pee = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', '$1', $pee ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
|
5 | 564 |
// In some cases <li> may get wrapped in <p>, fix them. |
9 | 565 |
$pee = preg_replace( '|<p>(<li.+?)</p>|', '$1', $pee ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
566 |
|
5 | 567 |
// If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>. |
9 | 568 |
$pee = preg_replace( '|<p><blockquote([^>]*)>|i', '<blockquote$1><p>', $pee ); |
569 |
$pee = str_replace( '</blockquote></p>', '</p></blockquote>', $pee ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
|
5 | 571 |
// If an opening or closing block element tag is preceded by an opening <p> tag, remove it. |
9 | 572 |
$pee = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)!', '$1', $pee ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
573 |
|
5 | 574 |
// If an opening or closing block element tag is followed by a closing <p> tag, remove it. |
9 | 575 |
$pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*</p>!', '$1', $pee ); |
5 | 576 |
|
577 |
// Optionally insert line breaks. |
|
0 | 578 |
if ( $br ) { |
5 | 579 |
// Replace newlines that shouldn't be touched with a placeholder. |
9 | 580 |
$pee = preg_replace_callback( '/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee ); |
5 | 581 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
// Normalize <br> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
583 |
$pee = str_replace( array( '<br>', '<br/>' ), '<br />', $pee ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
584 |
|
5 | 585 |
// Replace any new line characters that aren't preceded by a <br /> with a <br />. |
9 | 586 |
$pee = preg_replace( '|(?<!<br />)\s*\n|', "<br />\n", $pee ); |
5 | 587 |
|
588 |
// Replace newline placeholders with newlines. |
|
9 | 589 |
$pee = str_replace( '<WPPreserveNewline />', "\n", $pee ); |
0 | 590 |
} |
5 | 591 |
|
592 |
// If a <br /> tag is after an opening or closing block tag, remove it. |
|
9 | 593 |
$pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*<br />!', '$1', $pee ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
|
5 | 595 |
// If a <br /> tag is before a subset of opening or closing block tags, remove it. |
9 | 596 |
$pee = preg_replace( '!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee ); |
0 | 597 |
$pee = preg_replace( "|\n</p>$|", '</p>', $pee ); |
598 |
||
5 | 599 |
// Replace placeholder <pre> tags with their original content. |
9 | 600 |
if ( ! empty( $pre_tags ) ) { |
601 |
$pee = str_replace( array_keys( $pre_tags ), array_values( $pre_tags ), $pee ); |
|
602 |
} |
|
0 | 603 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
// Restore newlines in all elements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
605 |
if ( false !== strpos( $pee, '<!-- wpnl -->' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
$pee = str_replace( array( ' <!-- wpnl --> ', '<!-- wpnl -->' ), "\n", $pee ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
|
0 | 609 |
return $pee; |
610 |
} |
|
611 |
||
612 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
* Separate HTML elements and comments from the text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
* @since 4.2.4 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
616 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
* @param string $input The text which has to be formatted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
* @return array The formatted text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
620 |
function wp_html_split( $input ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
return preg_split( get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
* Retrieve the regular expression for an HTML element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
626 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
629 |
* @staticvar string $regex |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
630 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
631 |
* @return string The regular expression |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
632 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
633 |
function get_html_split_regex() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
634 |
static $regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
635 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
if ( ! isset( $regex ) ) { |
9 | 637 |
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
638 |
$comments = |
9 | 639 |
'!' // Start of comment, after the <. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
640 |
. '(?:' // Unroll the loop: Consume everything until --> is found. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
641 |
. '-(?!->)' // Dash not followed by end of comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
. '[^\-]*+' // Consume non-dashes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
. ')*+' // Loop possessively. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
644 |
. '(?:-->)?'; // End of comment. If not found, match all input. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
645 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
$cdata = |
9 | 647 |
'!\[CDATA\[' // Start of comment, after the <. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
648 |
. '[^\]]*+' // Consume non-]. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
649 |
. '(?:' // Unroll the loop: Consume everything until ]]> is found. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
. '](?!]>)' // One ] not followed by end of comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
. '[^\]]*+' // Consume non-]. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
. ')*+' // Loop possessively. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
. '(?:]]>)?'; // End of comment. If not found, match all input. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
654 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
655 |
$escaped = |
9 | 656 |
'(?=' // Is the element escaped? |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
657 |
. '!--' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
. '|' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
. '!\[CDATA\[' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
660 |
. ')' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
. '(?(?=!-)' // If yes, which type? |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
. $comments |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
663 |
. '|' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
. $cdata |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
. ')'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
666 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
$regex = |
9 | 668 |
'/(' // Capture the entire match. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
. '<' // Find start of element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
. '(?' // Conditional expression follows. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
. $escaped // Find end of escaped element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
. '|' // ... else ... |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
. '[^>]*>?' // Find end of normal element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
674 |
. ')' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
675 |
. ')/'; |
9 | 676 |
// phpcs:enable |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
678 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
return $regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
680 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
683 |
* Retrieve the combined regular expression for HTML and shortcodes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
684 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
685 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
686 |
* @ignore |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
* @internal This function will be removed in 4.5.0 per Shortcode API Roadmap. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
688 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
689 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
690 |
* @staticvar string $html_regex |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
691 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
692 |
* @param string $shortcode_regex The result from _get_wptexturize_shortcode_regex(). Optional. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
* @return string The regular expression |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
function _get_wptexturize_split_regex( $shortcode_regex = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
static $html_regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
if ( ! isset( $html_regex ) ) { |
9 | 699 |
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
$comment_regex = |
9 | 701 |
'!' // Start of comment, after the <. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
. '(?:' // Unroll the loop: Consume everything until --> is found. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
. '-(?!->)' // Dash not followed by end of comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
. '[^\-]*+' // Consume non-dashes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
. ')*+' // Loop possessively. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
. '(?:-->)?'; // End of comment. If not found, match all input. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
|
9 | 708 |
$html_regex = // Needs replaced with wp_html_split() per Shortcode API Roadmap. |
709 |
'<' // Find start of element. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
710 |
. '(?(?=!--)' // Is this a comment? |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
. $comment_regex // Find end of comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
. '|' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
. '[^>]*>?' // Find end of element. If not found, match all input. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
. ')'; |
9 | 715 |
// phpcs:enable |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
716 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
718 |
if ( empty( $shortcode_regex ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
719 |
$regex = '/(' . $html_regex . ')/'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
721 |
$regex = '/(' . $html_regex . '|' . $shortcode_regex . ')/'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
723 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
724 |
return $regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
725 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
726 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
727 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
728 |
* Retrieve the regular expression for shortcodes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
729 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
731 |
* @ignore |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
* @internal This function will be removed in 4.5.0 per Shortcode API Roadmap. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
734 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
735 |
* @param array $tagnames List of shortcodes to find. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
736 |
* @return string The regular expression |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
738 |
function _get_wptexturize_shortcode_regex( $tagnames ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
$tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
740 |
$tagregexp = "(?:$tagregexp)(?=[\\s\\]\\/])"; // Excerpt of get_shortcode_regex(). |
9 | 741 |
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
742 |
$regex = |
9 | 743 |
'\[' // Find start of shortcode. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
744 |
. '[\/\[]?' // Shortcodes may begin with [/ or [[ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
745 |
. $tagregexp // Only match registered shortcodes, because performance. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
746 |
. '(?:' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
. '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
748 |
. '|' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
749 |
. '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
750 |
. ')*+' // Possessive critical. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
751 |
. '\]' // Find end of shortcode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
752 |
. '\]?'; // Shortcodes may end with ]] |
9 | 753 |
// phpcs:enable |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
754 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
755 |
return $regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
756 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
757 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
758 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
* Replace characters or phrases within HTML elements only. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
* @since 4.2.3 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
* @param string $haystack The text which has to be formatted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
* @param array $replace_pairs In the form array('from' => 'to', ...). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
765 |
* @return string The formatted text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
767 |
function wp_replace_in_html_tags( $haystack, $replace_pairs ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
768 |
// Find all elements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
769 |
$textarr = wp_html_split( $haystack ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
770 |
$changed = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
771 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
// Optimize when searching for one item. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
773 |
if ( 1 === count( $replace_pairs ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
774 |
// Extract $needle and $replace. |
9 | 775 |
foreach ( $replace_pairs as $needle => $replace ) { |
776 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
777 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
778 |
// Loop through delimiters (elements) only. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) { |
9 | 780 |
if ( false !== strpos( $textarr[ $i ], $needle ) ) { |
781 |
$textarr[ $i ] = str_replace( $needle, $replace, $textarr[ $i ] ); |
|
782 |
$changed = true; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
783 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
784 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
786 |
// Extract all $needles. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
787 |
$needles = array_keys( $replace_pairs ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
789 |
// Loop through delimiters (elements) only. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
790 |
for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
791 |
foreach ( $needles as $needle ) { |
9 | 792 |
if ( false !== strpos( $textarr[ $i ], $needle ) ) { |
793 |
$textarr[ $i ] = strtr( $textarr[ $i ], $replace_pairs ); |
|
794 |
$changed = true; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
// After one strtr() break out of the foreach loop and look at next element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
798 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
799 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
801 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
802 |
if ( $changed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
803 |
$haystack = implode( $textarr ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
804 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
805 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
806 |
return $haystack; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
807 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
808 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
809 |
/** |
0 | 810 |
* Newline preservation help function for wpautop |
811 |
* |
|
812 |
* @since 3.1.0 |
|
813 |
* @access private |
|
814 |
* |
|
815 |
* @param array $matches preg_replace_callback matches array |
|
816 |
* @return string |
|
817 |
*/ |
|
818 |
function _autop_newline_preservation_helper( $matches ) { |
|
9 | 819 |
return str_replace( "\n", '<WPPreserveNewline />', $matches[0] ); |
0 | 820 |
} |
821 |
||
822 |
/** |
|
823 |
* Don't auto-p wrap shortcodes that stand alone |
|
824 |
* |
|
5 | 825 |
* Ensures that shortcodes are not wrapped in `<p>...</p>`. |
0 | 826 |
* |
827 |
* @since 2.9.0 |
|
828 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
829 |
* @global array $shortcode_tags |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
830 |
* |
0 | 831 |
* @param string $pee The content. |
832 |
* @return string The filtered content. |
|
833 |
*/ |
|
834 |
function shortcode_unautop( $pee ) { |
|
835 |
global $shortcode_tags; |
|
836 |
||
9 | 837 |
if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { |
0 | 838 |
return $pee; |
839 |
} |
|
840 |
||
841 |
$tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) ); |
|
9 | 842 |
$spaces = wp_spaces_regexp(); |
843 |
||
844 |
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation |
|
0 | 845 |
$pattern = |
9 | 846 |
'/' |
0 | 847 |
. '<p>' // Opening paragraph |
5 | 848 |
. '(?:' . $spaces . ')*+' // Optional leading whitespace |
0 | 849 |
. '(' // 1: The shortcode |
850 |
. '\\[' // Opening bracket |
|
851 |
. "($tagregexp)" // 2: Shortcode name |
|
852 |
. '(?![\\w-])' // Not followed by word character or hyphen |
|
9 | 853 |
// Unroll the loop: Inside the opening shortcode tag |
0 | 854 |
. '[^\\]\\/]*' // Not a closing bracket or forward slash |
855 |
. '(?:' |
|
856 |
. '\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
857 |
. '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
858 |
. ')*?' |
|
859 |
. '(?:' |
|
860 |
. '\\/\\]' // Self closing tag and closing bracket |
|
861 |
. '|' |
|
862 |
. '\\]' // Closing bracket |
|
863 |
. '(?:' // Unroll the loop: Optionally, anything between the opening and closing shortcode tags |
|
864 |
. '[^\\[]*+' // Not an opening bracket |
|
865 |
. '(?:' |
|
866 |
. '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag |
|
867 |
. '[^\\[]*+' // Not an opening bracket |
|
868 |
. ')*+' |
|
869 |
. '\\[\\/\\2\\]' // Closing shortcode tag |
|
870 |
. ')?' |
|
871 |
. ')' |
|
872 |
. ')' |
|
5 | 873 |
. '(?:' . $spaces . ')*+' // optional trailing whitespace |
0 | 874 |
. '<\\/p>' // closing paragraph |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
875 |
. '/'; |
9 | 876 |
// phpcs:enable |
0 | 877 |
|
878 |
return preg_replace( $pattern, '$1', $pee ); |
|
879 |
} |
|
880 |
||
881 |
/** |
|
882 |
* Checks to see if a string is utf8 encoded. |
|
883 |
* |
|
884 |
* NOTE: This function checks for 5-Byte sequences, UTF8 |
|
885 |
* has Bytes Sequences with a maximum length of 4. |
|
886 |
* |
|
887 |
* @author bmorel at ssi dot fr (modified) |
|
888 |
* @since 1.2.1 |
|
889 |
* |
|
890 |
* @param string $str The string to be checked |
|
891 |
* @return bool True if $str fits a UTF-8 model, false otherwise. |
|
892 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
893 |
function seems_utf8( $str ) { |
5 | 894 |
mbstring_binary_safe_encoding(); |
9 | 895 |
$length = strlen( $str ); |
5 | 896 |
reset_mbstring_encoding(); |
9 | 897 |
for ( $i = 0; $i < $length; $i++ ) { |
898 |
$c = ord( $str[ $i ] ); |
|
899 |
if ( $c < 0x80 ) { |
|
900 |
$n = 0; // 0bbbbbbb |
|
901 |
} elseif ( ( $c & 0xE0 ) == 0xC0 ) { |
|
902 |
$n = 1; // 110bbbbb |
|
903 |
} elseif ( ( $c & 0xF0 ) == 0xE0 ) { |
|
904 |
$n = 2; // 1110bbbb |
|
905 |
} elseif ( ( $c & 0xF8 ) == 0xF0 ) { |
|
906 |
$n = 3; // 11110bbb |
|
907 |
} elseif ( ( $c & 0xFC ) == 0xF8 ) { |
|
908 |
$n = 4; // 111110bb |
|
909 |
} elseif ( ( $c & 0xFE ) == 0xFC ) { |
|
910 |
$n = 5; // 1111110b |
|
911 |
} else { |
|
912 |
return false; // Does not match any model |
|
913 |
} |
|
914 |
for ( $j = 0; $j < $n; $j++ ) { // n bytes matching 10bbbbbb follow ? |
|
915 |
if ( ( ++$i == $length ) || ( ( ord( $str[ $i ] ) & 0xC0 ) != 0x80 ) ) { |
|
0 | 916 |
return false; |
9 | 917 |
} |
0 | 918 |
} |
919 |
} |
|
920 |
return true; |
|
921 |
} |
|
922 |
||
923 |
/** |
|
924 |
* Converts a number of special characters into their HTML entities. |
|
925 |
* |
|
926 |
* Specifically deals with: &, <, >, ", and '. |
|
927 |
* |
|
928 |
* $quote_style can be set to ENT_COMPAT to encode " to |
|
929 |
* ", or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded. |
|
930 |
* |
|
931 |
* @since 1.2.2 |
|
932 |
* @access private |
|
933 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
* @staticvar string $_charset |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
935 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
* @param string $string The text which is to be encoded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
937 |
* @param int|string $quote_style Optional. Converts double quotes if set to ENT_COMPAT, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
938 |
* both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
939 |
* Also compatible with old values; converting single quotes if set to 'single', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
940 |
* double if set to 'double' or both if otherwise set. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
941 |
* Default is ENT_NOQUOTES. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
942 |
* @param string $charset Optional. The character encoding of the string. Default is false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
943 |
* @param bool $double_encode Optional. Whether to encode existing html entities. Default is false. |
0 | 944 |
* @return string The encoded text with HTML entities. |
945 |
*/ |
|
946 |
function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { |
|
947 |
$string = (string) $string; |
|
948 |
||
9 | 949 |
if ( 0 === strlen( $string ) ) { |
0 | 950 |
return ''; |
9 | 951 |
} |
0 | 952 |
|
953 |
// Don't bother if there are no specialchars - saves some processing |
|
9 | 954 |
if ( ! preg_match( '/[&<>"\']/', $string ) ) { |
0 | 955 |
return $string; |
9 | 956 |
} |
0 | 957 |
|
958 |
// Account for the previous behaviour of the function when the $quote_style is not an accepted value |
|
9 | 959 |
if ( empty( $quote_style ) ) { |
0 | 960 |
$quote_style = ENT_NOQUOTES; |
9 | 961 |
} elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { |
0 | 962 |
$quote_style = ENT_QUOTES; |
9 | 963 |
} |
0 | 964 |
|
965 |
// Store the site charset as a static to avoid multiple calls to wp_load_alloptions() |
|
966 |
if ( ! $charset ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
967 |
static $_charset = null; |
0 | 968 |
if ( ! isset( $_charset ) ) { |
969 |
$alloptions = wp_load_alloptions(); |
|
9 | 970 |
$_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; |
0 | 971 |
} |
972 |
$charset = $_charset; |
|
973 |
} |
|
974 |
||
9 | 975 |
if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) { |
0 | 976 |
$charset = 'UTF-8'; |
9 | 977 |
} |
0 | 978 |
|
979 |
$_quote_style = $quote_style; |
|
980 |
||
981 |
if ( $quote_style === 'double' ) { |
|
9 | 982 |
$quote_style = ENT_COMPAT; |
0 | 983 |
$_quote_style = ENT_COMPAT; |
984 |
} elseif ( $quote_style === 'single' ) { |
|
985 |
$quote_style = ENT_NOQUOTES; |
|
986 |
} |
|
987 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
988 |
if ( ! $double_encode ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
989 |
// Guarantee every &entity; is valid, convert &garbage; into &garbage; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
// This is required for PHP < 5.4.0 because ENT_HTML401 flag is unavailable. |
0 | 991 |
$string = wp_kses_normalize_entities( $string ); |
992 |
} |
|
993 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
994 |
$string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
995 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
996 |
// Back-compat. |
9 | 997 |
if ( 'single' === $_quote_style ) { |
0 | 998 |
$string = str_replace( "'", ''', $string ); |
9 | 999 |
} |
0 | 1000 |
|
1001 |
return $string; |
|
1002 |
} |
|
1003 |
||
1004 |
/** |
|
1005 |
* Converts a number of HTML entities into their special characters. |
|
1006 |
* |
|
1007 |
* Specifically deals with: &, <, >, ", and '. |
|
1008 |
* |
|
1009 |
* $quote_style can be set to ENT_COMPAT to decode " entities, |
|
1010 |
* or ENT_QUOTES to do both " and '. Default is ENT_NOQUOTES where no quotes are decoded. |
|
1011 |
* |
|
1012 |
* @since 2.8.0 |
|
1013 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1014 |
* @param string $string The text which is to be decoded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
* @param string|int $quote_style Optional. Converts double quotes if set to ENT_COMPAT, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1016 |
* both single and double if set to ENT_QUOTES or |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1017 |
* none if set to ENT_NOQUOTES. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
* Also compatible with old _wp_specialchars() values; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1019 |
* converting single quotes if set to 'single', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1020 |
* double if set to 'double' or both if otherwise set. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1021 |
* Default is ENT_NOQUOTES. |
0 | 1022 |
* @return string The decoded text without HTML entities. |
1023 |
*/ |
|
1024 |
function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) { |
|
1025 |
$string = (string) $string; |
|
1026 |
||
1027 |
if ( 0 === strlen( $string ) ) { |
|
1028 |
return ''; |
|
1029 |
} |
|
1030 |
||
1031 |
// Don't bother if there are no entities - saves a lot of processing |
|
1032 |
if ( strpos( $string, '&' ) === false ) { |
|
1033 |
return $string; |
|
1034 |
} |
|
1035 |
||
1036 |
// Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value |
|
1037 |
if ( empty( $quote_style ) ) { |
|
1038 |
$quote_style = ENT_NOQUOTES; |
|
9 | 1039 |
} elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { |
0 | 1040 |
$quote_style = ENT_QUOTES; |
1041 |
} |
|
1042 |
||
1043 |
// More complete than get_html_translation_table( HTML_SPECIALCHARS ) |
|
9 | 1044 |
$single = array( |
1045 |
''' => '\'', |
|
1046 |
''' => '\'', |
|
1047 |
); |
|
1048 |
$single_preg = array( |
|
1049 |
'/�*39;/' => ''', |
|
1050 |
'/�*27;/i' => ''', |
|
1051 |
); |
|
1052 |
$double = array( |
|
1053 |
'"' => '"', |
|
1054 |
'"' => '"', |
|
1055 |
'"' => '"', |
|
1056 |
); |
|
1057 |
$double_preg = array( |
|
1058 |
'/�*34;/' => '"', |
|
1059 |
'/�*22;/i' => '"', |
|
1060 |
); |
|
1061 |
$others = array( |
|
1062 |
'<' => '<', |
|
1063 |
'<' => '<', |
|
1064 |
'>' => '>', |
|
1065 |
'>' => '>', |
|
1066 |
'&' => '&', |
|
1067 |
'&' => '&', |
|
1068 |
'&' => '&', |
|
1069 |
); |
|
1070 |
$others_preg = array( |
|
1071 |
'/�*60;/' => '<', |
|
1072 |
'/�*62;/' => '>', |
|
1073 |
'/�*38;/' => '&', |
|
1074 |
'/�*26;/i' => '&', |
|
1075 |
); |
|
0 | 1076 |
|
1077 |
if ( $quote_style === ENT_QUOTES ) { |
|
9 | 1078 |
$translation = array_merge( $single, $double, $others ); |
0 | 1079 |
$translation_preg = array_merge( $single_preg, $double_preg, $others_preg ); |
1080 |
} elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) { |
|
9 | 1081 |
$translation = array_merge( $double, $others ); |
0 | 1082 |
$translation_preg = array_merge( $double_preg, $others_preg ); |
1083 |
} elseif ( $quote_style === 'single' ) { |
|
9 | 1084 |
$translation = array_merge( $single, $others ); |
0 | 1085 |
$translation_preg = array_merge( $single_preg, $others_preg ); |
1086 |
} elseif ( $quote_style === ENT_NOQUOTES ) { |
|
9 | 1087 |
$translation = $others; |
0 | 1088 |
$translation_preg = $others_preg; |
1089 |
} |
|
1090 |
||
1091 |
// Remove zero padding on numeric entities |
|
1092 |
$string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string ); |
|
1093 |
||
1094 |
// Replace characters according to translation table |
|
1095 |
return strtr( $string, $translation ); |
|
1096 |
} |
|
1097 |
||
1098 |
/** |
|
1099 |
* Checks for invalid UTF8 in a string. |
|
1100 |
* |
|
1101 |
* @since 2.8.0 |
|
1102 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1103 |
* @staticvar bool $is_utf8 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1104 |
* @staticvar bool $utf8_pcre |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1105 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
* @param string $string The text which is to be checked. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
* @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false. |
0 | 1108 |
* @return string The checked text. |
1109 |
*/ |
|
1110 |
function wp_check_invalid_utf8( $string, $strip = false ) { |
|
1111 |
$string = (string) $string; |
|
1112 |
||
1113 |
if ( 0 === strlen( $string ) ) { |
|
1114 |
return ''; |
|
1115 |
} |
|
1116 |
||
1117 |
// Store the site charset as a static to avoid multiple calls to get_option() |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1118 |
static $is_utf8 = null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1119 |
if ( ! isset( $is_utf8 ) ) { |
0 | 1120 |
$is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ); |
1121 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1122 |
if ( ! $is_utf8 ) { |
0 | 1123 |
return $string; |
1124 |
} |
|
1125 |
||
1126 |
// Check for support for utf8 in the installed PCRE library once and store the result in a static |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1127 |
static $utf8_pcre = null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1128 |
if ( ! isset( $utf8_pcre ) ) { |
0 | 1129 |
$utf8_pcre = @preg_match( '/^./u', 'a' ); |
1130 |
} |
|
1131 |
// We can't demand utf8 in the PCRE installation, so just return the string in those cases |
|
9 | 1132 |
if ( ! $utf8_pcre ) { |
0 | 1133 |
return $string; |
1134 |
} |
|
1135 |
||
1136 |
// preg_match fails when it encounters invalid UTF8 in $string |
|
1137 |
if ( 1 === @preg_match( '/^./us', $string ) ) { |
|
1138 |
return $string; |
|
1139 |
} |
|
1140 |
||
1141 |
// Attempt to strip the bad chars if requested (not recommended) |
|
1142 |
if ( $strip && function_exists( 'iconv' ) ) { |
|
1143 |
return iconv( 'utf-8', 'utf-8', $string ); |
|
1144 |
} |
|
1145 |
||
1146 |
return ''; |
|
1147 |
} |
|
1148 |
||
1149 |
/** |
|
1150 |
* Encode the Unicode values to be used in the URI. |
|
1151 |
* |
|
1152 |
* @since 1.5.0 |
|
1153 |
* |
|
1154 |
* @param string $utf8_string |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1155 |
* @param int $length Max length of the string |
0 | 1156 |
* @return string String with Unicode encoded for URI. |
1157 |
*/ |
|
1158 |
function utf8_uri_encode( $utf8_string, $length = 0 ) { |
|
9 | 1159 |
$unicode = ''; |
1160 |
$values = array(); |
|
1161 |
$num_octets = 1; |
|
0 | 1162 |
$unicode_length = 0; |
1163 |
||
5 | 1164 |
mbstring_binary_safe_encoding(); |
0 | 1165 |
$string_length = strlen( $utf8_string ); |
5 | 1166 |
reset_mbstring_encoding(); |
1167 |
||
9 | 1168 |
for ( $i = 0; $i < $string_length; $i++ ) { |
0 | 1169 |
|
1170 |
$value = ord( $utf8_string[ $i ] ); |
|
1171 |
||
1172 |
if ( $value < 128 ) { |
|
9 | 1173 |
if ( $length && ( $unicode_length >= $length ) ) { |
0 | 1174 |
break; |
9 | 1175 |
} |
1176 |
$unicode .= chr( $value ); |
|
0 | 1177 |
$unicode_length++; |
1178 |
} else { |
|
5 | 1179 |
if ( count( $values ) == 0 ) { |
1180 |
if ( $value < 224 ) { |
|
1181 |
$num_octets = 2; |
|
1182 |
} elseif ( $value < 240 ) { |
|
1183 |
$num_octets = 3; |
|
1184 |
} else { |
|
1185 |
$num_octets = 4; |
|
1186 |
} |
|
1187 |
} |
|
0 | 1188 |
|
1189 |
$values[] = $value; |
|
1190 |
||
9 | 1191 |
if ( $length && ( $unicode_length + ( $num_octets * 3 ) ) > $length ) { |
0 | 1192 |
break; |
9 | 1193 |
} |
0 | 1194 |
if ( count( $values ) == $num_octets ) { |
5 | 1195 |
for ( $j = 0; $j < $num_octets; $j++ ) { |
1196 |
$unicode .= '%' . dechex( $values[ $j ] ); |
|
0 | 1197 |
} |
1198 |
||
5 | 1199 |
$unicode_length += $num_octets * 3; |
1200 |
||
9 | 1201 |
$values = array(); |
0 | 1202 |
$num_octets = 1; |
1203 |
} |
|
1204 |
} |
|
1205 |
} |
|
1206 |
||
1207 |
return $unicode; |
|
1208 |
} |
|
1209 |
||
1210 |
/** |
|
1211 |
* Converts all accent characters to ASCII characters. |
|
1212 |
* |
|
1213 |
* If there are no accent characters, then the string given is just returned. |
|
1214 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1215 |
* **Accent characters converted:** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1216 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1217 |
* Currency signs: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1218 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1220 |
* | -------- | ----- | ----------- | ------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1221 |
* | U+00A3 | £ | (empty) | British Pound sign | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1222 |
* | U+20AC | € | E | Euro sign | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1223 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
* Decompositions for Latin-1 Supplement: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1226 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1227 |
* | ------- | ----- | ----------- | -------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
* | U+00AA | ª | a | Feminine ordinal indicator | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1229 |
* | U+00BA | º | o | Masculine ordinal indicator | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1230 |
* | U+00C0 | À | A | Latin capital letter A with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1231 |
* | U+00C1 | Á | A | Latin capital letter A with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1232 |
* | U+00C2 | Â | A | Latin capital letter A with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1233 |
* | U+00C3 | Ã | A | Latin capital letter A with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1234 |
* | U+00C4 | Ä | A | Latin capital letter A with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1235 |
* | U+00C5 | Å | A | Latin capital letter A with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1236 |
* | U+00C6 | Æ | AE | Latin capital letter AE | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
* | U+00C7 | Ç | C | Latin capital letter C with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1238 |
* | U+00C8 | È | E | Latin capital letter E with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1239 |
* | U+00C9 | É | E | Latin capital letter E with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1240 |
* | U+00CA | Ê | E | Latin capital letter E with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1241 |
* | U+00CB | Ë | E | Latin capital letter E with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
* | U+00CC | Ì | I | Latin capital letter I with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1243 |
* | U+00CD | Í | I | Latin capital letter I with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
* | U+00CE | Î | I | Latin capital letter I with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
* | U+00CF | Ï | I | Latin capital letter I with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1246 |
* | U+00D0 | Ð | D | Latin capital letter Eth | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1247 |
* | U+00D1 | Ñ | N | Latin capital letter N with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1248 |
* | U+00D2 | Ò | O | Latin capital letter O with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1249 |
* | U+00D3 | Ó | O | Latin capital letter O with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
* | U+00D4 | Ô | O | Latin capital letter O with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1251 |
* | U+00D5 | Õ | O | Latin capital letter O with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1252 |
* | U+00D6 | Ö | O | Latin capital letter O with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
* | U+00D8 | Ø | O | Latin capital letter O with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
* | U+00D9 | Ù | U | Latin capital letter U with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
* | U+00DA | Ú | U | Latin capital letter U with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
* | U+00DB | Û | U | Latin capital letter U with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
* | U+00DC | Ü | U | Latin capital letter U with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
* | U+00DD | Ý | Y | Latin capital letter Y with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1259 |
* | U+00DE | Þ | TH | Latin capital letter Thorn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1260 |
* | U+00DF | ß | s | Latin small letter sharp s | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1261 |
* | U+00E0 | à | a | Latin small letter a with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
* | U+00E1 | á | a | Latin small letter a with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1263 |
* | U+00E2 | â | a | Latin small letter a with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
* | U+00E3 | ã | a | Latin small letter a with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1265 |
* | U+00E4 | ä | a | Latin small letter a with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1266 |
* | U+00E5 | å | a | Latin small letter a with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1267 |
* | U+00E6 | æ | ae | Latin small letter ae | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
* | U+00E7 | ç | c | Latin small letter c with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1269 |
* | U+00E8 | è | e | Latin small letter e with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
* | U+00E9 | é | e | Latin small letter e with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1271 |
* | U+00EA | ê | e | Latin small letter e with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1272 |
* | U+00EB | ë | e | Latin small letter e with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1273 |
* | U+00EC | ì | i | Latin small letter i with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1274 |
* | U+00ED | í | i | Latin small letter i with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1275 |
* | U+00EE | î | i | Latin small letter i with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
* | U+00EF | ï | i | Latin small letter i with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
* | U+00F0 | ð | d | Latin small letter Eth | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1278 |
* | U+00F1 | ñ | n | Latin small letter n with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1279 |
* | U+00F2 | ò | o | Latin small letter o with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
* | U+00F3 | ó | o | Latin small letter o with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1281 |
* | U+00F4 | ô | o | Latin small letter o with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1282 |
* | U+00F5 | õ | o | Latin small letter o with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1283 |
* | U+00F6 | ö | o | Latin small letter o with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1284 |
* | U+00F8 | ø | o | Latin small letter o with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1285 |
* | U+00F9 | ù | u | Latin small letter u with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1286 |
* | U+00FA | ú | u | Latin small letter u with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1287 |
* | U+00FB | û | u | Latin small letter u with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1288 |
* | U+00FC | ü | u | Latin small letter u with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1289 |
* | U+00FD | ý | y | Latin small letter y with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1290 |
* | U+00FE | þ | th | Latin small letter Thorn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1291 |
* | U+00FF | ÿ | y | Latin small letter y with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1292 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1293 |
* Decompositions for Latin Extended-A: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1294 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1295 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1296 |
* | ------- | ----- | ----------- | ------------------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1297 |
* | U+0100 | Ā | A | Latin capital letter A with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1298 |
* | U+0101 | ā | a | Latin small letter a with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1299 |
* | U+0102 | Ă | A | Latin capital letter A with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
* | U+0103 | ă | a | Latin small letter a with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1301 |
* | U+0104 | Ą | A | Latin capital letter A with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
* | U+0105 | ą | a | Latin small letter a with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
* | U+01006 | Ć | C | Latin capital letter C with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1304 |
* | U+0107 | ć | c | Latin small letter c with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1305 |
* | U+0108 | Ĉ | C | Latin capital letter C with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1306 |
* | U+0109 | ĉ | c | Latin small letter c with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1307 |
* | U+010A | Ċ | C | Latin capital letter C with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1308 |
* | U+010B | ċ | c | Latin small letter c with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1309 |
* | U+010C | Č | C | Latin capital letter C with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1310 |
* | U+010D | č | c | Latin small letter c with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1311 |
* | U+010E | Ď | D | Latin capital letter D with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1312 |
* | U+010F | ď | d | Latin small letter d with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1313 |
* | U+0110 | Đ | D | Latin capital letter D with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1314 |
* | U+0111 | đ | d | Latin small letter d with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1315 |
* | U+0112 | Ē | E | Latin capital letter E with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1316 |
* | U+0113 | ē | e | Latin small letter e with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1317 |
* | U+0114 | Ĕ | E | Latin capital letter E with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1318 |
* | U+0115 | ĕ | e | Latin small letter e with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1319 |
* | U+0116 | Ė | E | Latin capital letter E with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1320 |
* | U+0117 | ė | e | Latin small letter e with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1321 |
* | U+0118 | Ę | E | Latin capital letter E with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1322 |
* | U+0119 | ę | e | Latin small letter e with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1323 |
* | U+011A | Ě | E | Latin capital letter E with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1324 |
* | U+011B | ě | e | Latin small letter e with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1325 |
* | U+011C | Ĝ | G | Latin capital letter G with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1326 |
* | U+011D | ĝ | g | Latin small letter g with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1327 |
* | U+011E | Ğ | G | Latin capital letter G with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1328 |
* | U+011F | ğ | g | Latin small letter g with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1329 |
* | U+0120 | Ġ | G | Latin capital letter G with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1330 |
* | U+0121 | ġ | g | Latin small letter g with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1331 |
* | U+0122 | Ģ | G | Latin capital letter G with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1332 |
* | U+0123 | ģ | g | Latin small letter g with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1333 |
* | U+0124 | Ĥ | H | Latin capital letter H with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1334 |
* | U+0125 | ĥ | h | Latin small letter h with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1335 |
* | U+0126 | Ħ | H | Latin capital letter H with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1336 |
* | U+0127 | ħ | h | Latin small letter h with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1337 |
* | U+0128 | Ĩ | I | Latin capital letter I with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1338 |
* | U+0129 | ĩ | i | Latin small letter i with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1339 |
* | U+012A | Ī | I | Latin capital letter I with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1340 |
* | U+012B | ī | i | Latin small letter i with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1341 |
* | U+012C | Ĭ | I | Latin capital letter I with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1342 |
* | U+012D | ĭ | i | Latin small letter i with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1343 |
* | U+012E | Į | I | Latin capital letter I with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1344 |
* | U+012F | į | i | Latin small letter i with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1345 |
* | U+0130 | İ | I | Latin capital letter I with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1346 |
* | U+0131 | ı | i | Latin small letter dotless i | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1347 |
* | U+0132 | IJ | IJ | Latin capital ligature IJ | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1348 |
* | U+0133 | ij | ij | Latin small ligature ij | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1349 |
* | U+0134 | Ĵ | J | Latin capital letter J with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1350 |
* | U+0135 | ĵ | j | Latin small letter j with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1351 |
* | U+0136 | Ķ | K | Latin capital letter K with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
* | U+0137 | ķ | k | Latin small letter k with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1353 |
* | U+0138 | ĸ | k | Latin small letter Kra | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
* | U+0139 | Ĺ | L | Latin capital letter L with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1355 |
* | U+013A | ĺ | l | Latin small letter l with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1356 |
* | U+013B | Ļ | L | Latin capital letter L with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1357 |
* | U+013C | ļ | l | Latin small letter l with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1358 |
* | U+013D | Ľ | L | Latin capital letter L with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1359 |
* | U+013E | ľ | l | Latin small letter l with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1360 |
* | U+013F | Ŀ | L | Latin capital letter L with middle dot | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1361 |
* | U+0140 | ŀ | l | Latin small letter l with middle dot | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1362 |
* | U+0141 | Ł | L | Latin capital letter L with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1363 |
* | U+0142 | ł | l | Latin small letter l with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1364 |
* | U+0143 | Ń | N | Latin capital letter N with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1365 |
* | U+0144 | ń | n | Latin small letter N with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1366 |
* | U+0145 | Ņ | N | Latin capital letter N with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1367 |
* | U+0146 | ņ | n | Latin small letter n with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1368 |
* | U+0147 | Ň | N | Latin capital letter N with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1369 |
* | U+0148 | ň | n | Latin small letter n with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1370 |
* | U+0149 | ʼn | n | Latin small letter n preceded by apostrophe | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1371 |
* | U+014A | Ŋ | N | Latin capital letter Eng | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1372 |
* | U+014B | ŋ | n | Latin small letter Eng | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1373 |
* | U+014C | Ō | O | Latin capital letter O with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1374 |
* | U+014D | ō | o | Latin small letter o with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1375 |
* | U+014E | Ŏ | O | Latin capital letter O with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1376 |
* | U+014F | ŏ | o | Latin small letter o with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1377 |
* | U+0150 | Ő | O | Latin capital letter O with double acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1378 |
* | U+0151 | ő | o | Latin small letter o with double acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1379 |
* | U+0152 | Œ | OE | Latin capital ligature OE | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1380 |
* | U+0153 | œ | oe | Latin small ligature oe | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1381 |
* | U+0154 | Ŕ | R | Latin capital letter R with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1382 |
* | U+0155 | ŕ | r | Latin small letter r with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1383 |
* | U+0156 | Ŗ | R | Latin capital letter R with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1384 |
* | U+0157 | ŗ | r | Latin small letter r with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1385 |
* | U+0158 | Ř | R | Latin capital letter R with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1386 |
* | U+0159 | ř | r | Latin small letter r with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1387 |
* | U+015A | Ś | S | Latin capital letter S with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1388 |
* | U+015B | ś | s | Latin small letter s with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1389 |
* | U+015C | Ŝ | S | Latin capital letter S with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1390 |
* | U+015D | ŝ | s | Latin small letter s with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
* | U+015E | Ş | S | Latin capital letter S with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1392 |
* | U+015F | ş | s | Latin small letter s with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1393 |
* | U+0160 | Š | S | Latin capital letter S with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
* | U+0161 | š | s | Latin small letter s with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1395 |
* | U+0162 | Ţ | T | Latin capital letter T with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
* | U+0163 | ţ | t | Latin small letter t with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1397 |
* | U+0164 | Ť | T | Latin capital letter T with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1398 |
* | U+0165 | ť | t | Latin small letter t with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1399 |
* | U+0166 | Ŧ | T | Latin capital letter T with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
* | U+0167 | ŧ | t | Latin small letter t with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1401 |
* | U+0168 | Ũ | U | Latin capital letter U with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1402 |
* | U+0169 | ũ | u | Latin small letter u with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1403 |
* | U+016A | Ū | U | Latin capital letter U with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1404 |
* | U+016B | ū | u | Latin small letter u with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1405 |
* | U+016C | Ŭ | U | Latin capital letter U with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1406 |
* | U+016D | ŭ | u | Latin small letter u with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1407 |
* | U+016E | Ů | U | Latin capital letter U with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1408 |
* | U+016F | ů | u | Latin small letter u with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1409 |
* | U+0170 | Ű | U | Latin capital letter U with double acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1410 |
* | U+0171 | ű | u | Latin small letter u with double acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1411 |
* | U+0172 | Ų | U | Latin capital letter U with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1412 |
* | U+0173 | ų | u | Latin small letter u with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1413 |
* | U+0174 | Ŵ | W | Latin capital letter W with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1414 |
* | U+0175 | ŵ | w | Latin small letter w with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1415 |
* | U+0176 | Ŷ | Y | Latin capital letter Y with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1416 |
* | U+0177 | ŷ | y | Latin small letter y with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1417 |
* | U+0178 | Ÿ | Y | Latin capital letter Y with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1418 |
* | U+0179 | Ź | Z | Latin capital letter Z with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1419 |
* | U+017A | ź | z | Latin small letter z with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1420 |
* | U+017B | Ż | Z | Latin capital letter Z with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1421 |
* | U+017C | ż | z | Latin small letter z with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1422 |
* | U+017D | Ž | Z | Latin capital letter Z with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1423 |
* | U+017E | ž | z | Latin small letter z with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1424 |
* | U+017F | ſ | s | Latin small letter long s | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1425 |
* | U+01A0 | Ơ | O | Latin capital letter O with horn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1426 |
* | U+01A1 | ơ | o | Latin small letter o with horn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1427 |
* | U+01AF | Ư | U | Latin capital letter U with horn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1428 |
* | U+01B0 | ư | u | Latin small letter u with horn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1429 |
* | U+01CD | Ǎ | A | Latin capital letter A with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1430 |
* | U+01CE | ǎ | a | Latin small letter a with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1431 |
* | U+01CF | Ǐ | I | Latin capital letter I with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1432 |
* | U+01D0 | ǐ | i | Latin small letter i with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1433 |
* | U+01D1 | Ǒ | O | Latin capital letter O with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1434 |
* | U+01D2 | ǒ | o | Latin small letter o with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1435 |
* | U+01D3 | Ǔ | U | Latin capital letter U with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1436 |
* | U+01D4 | ǔ | u | Latin small letter u with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1437 |
* | U+01D5 | Ǖ | U | Latin capital letter U with diaeresis and macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1438 |
* | U+01D6 | ǖ | u | Latin small letter u with diaeresis and macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
* | U+01D7 | Ǘ | U | Latin capital letter U with diaeresis and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1440 |
* | U+01D8 | ǘ | u | Latin small letter u with diaeresis and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1441 |
* | U+01D9 | Ǚ | U | Latin capital letter U with diaeresis and caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1442 |
* | U+01DA | ǚ | u | Latin small letter u with diaeresis and caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
* | U+01DB | Ǜ | U | Latin capital letter U with diaeresis and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
* | U+01DC | ǜ | u | Latin small letter u with diaeresis and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1446 |
* Decompositions for Latin Extended-B: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1448 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
* | -------- | ----- | ----------- | ----------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
* | U+0218 | Ș | S | Latin capital letter S with comma below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1451 |
* | U+0219 | ș | s | Latin small letter s with comma below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1452 |
* | U+021A | Ț | T | Latin capital letter T with comma below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1453 |
* | U+021B | ț | t | Latin small letter t with comma below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1454 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1455 |
* Vowels with diacritic (Chinese, Hanyu Pinyin): |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1456 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1457 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1458 |
* | -------- | ----- | ----------- | ----------------------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1459 |
* | U+0251 | ɑ | a | Latin small letter alpha | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1460 |
* | U+1EA0 | Ạ | A | Latin capital letter A with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1461 |
* | U+1EA1 | ạ | a | Latin small letter a with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
* | U+1EA2 | Ả | A | Latin capital letter A with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
* | U+1EA3 | ả | a | Latin small letter a with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
* | U+1EA4 | Ấ | A | Latin capital letter A with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
* | U+1EA5 | ấ | a | Latin small letter a with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1466 |
* | U+1EA6 | Ầ | A | Latin capital letter A with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1467 |
* | U+1EA7 | ầ | a | Latin small letter a with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1468 |
* | U+1EA8 | Ẩ | A | Latin capital letter A with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1469 |
* | U+1EA9 | ẩ | a | Latin small letter a with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1470 |
* | U+1EAA | Ẫ | A | Latin capital letter A with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1471 |
* | U+1EAB | ẫ | a | Latin small letter a with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1472 |
* | U+1EA6 | Ậ | A | Latin capital letter A with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1473 |
* | U+1EAD | ậ | a | Latin small letter a with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1474 |
* | U+1EAE | Ắ | A | Latin capital letter A with breve and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1475 |
* | U+1EAF | ắ | a | Latin small letter a with breve and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1476 |
* | U+1EB0 | Ằ | A | Latin capital letter A with breve and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1477 |
* | U+1EB1 | ằ | a | Latin small letter a with breve and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1478 |
* | U+1EB2 | Ẳ | A | Latin capital letter A with breve and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1479 |
* | U+1EB3 | ẳ | a | Latin small letter a with breve and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1480 |
* | U+1EB4 | Ẵ | A | Latin capital letter A with breve and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1481 |
* | U+1EB5 | ẵ | a | Latin small letter a with breve and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1482 |
* | U+1EB6 | Ặ | A | Latin capital letter A with breve and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1483 |
* | U+1EB7 | ặ | a | Latin small letter a with breve and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1484 |
* | U+1EB8 | Ẹ | E | Latin capital letter E with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1485 |
* | U+1EB9 | ẹ | e | Latin small letter e with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1486 |
* | U+1EBA | Ẻ | E | Latin capital letter E with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1487 |
* | U+1EBB | ẻ | e | Latin small letter e with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1488 |
* | U+1EBC | Ẽ | E | Latin capital letter E with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1489 |
* | U+1EBD | ẽ | e | Latin small letter e with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1490 |
* | U+1EBE | Ế | E | Latin capital letter E with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1491 |
* | U+1EBF | ế | e | Latin small letter e with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1492 |
* | U+1EC0 | Ề | E | Latin capital letter E with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1493 |
* | U+1EC1 | ề | e | Latin small letter e with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1494 |
* | U+1EC2 | Ể | E | Latin capital letter E with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1495 |
* | U+1EC3 | ể | e | Latin small letter e with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1496 |
* | U+1EC4 | Ễ | E | Latin capital letter E with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1497 |
* | U+1EC5 | ễ | e | Latin small letter e with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1498 |
* | U+1EC6 | Ệ | E | Latin capital letter E with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1499 |
* | U+1EC7 | ệ | e | Latin small letter e with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1500 |
* | U+1EC8 | Ỉ | I | Latin capital letter I with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1501 |
* | U+1EC9 | ỉ | i | Latin small letter i with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1502 |
* | U+1ECA | Ị | I | Latin capital letter I with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1503 |
* | U+1ECB | ị | i | Latin small letter i with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1504 |
* | U+1ECC | Ọ | O | Latin capital letter O with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1505 |
* | U+1ECD | ọ | o | Latin small letter o with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1506 |
* | U+1ECE | Ỏ | O | Latin capital letter O with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1507 |
* | U+1ECF | ỏ | o | Latin small letter o with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1508 |
* | U+1ED0 | Ố | O | Latin capital letter O with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1509 |
* | U+1ED1 | ố | o | Latin small letter o with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1510 |
* | U+1ED2 | Ồ | O | Latin capital letter O with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1511 |
* | U+1ED3 | ồ | o | Latin small letter o with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1512 |
* | U+1ED4 | Ổ | O | Latin capital letter O with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1513 |
* | U+1ED5 | ổ | o | Latin small letter o with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1514 |
* | U+1ED6 | Ỗ | O | Latin capital letter O with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1515 |
* | U+1ED7 | ỗ | o | Latin small letter o with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1516 |
* | U+1ED8 | Ộ | O | Latin capital letter O with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1517 |
* | U+1ED9 | ộ | o | Latin small letter o with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1518 |
* | U+1EDA | Ớ | O | Latin capital letter O with horn and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1519 |
* | U+1EDB | ớ | o | Latin small letter o with horn and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1520 |
* | U+1EDC | Ờ | O | Latin capital letter O with horn and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1521 |
* | U+1EDD | ờ | o | Latin small letter o with horn and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1522 |
* | U+1EDE | Ở | O | Latin capital letter O with horn and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1523 |
* | U+1EDF | ở | o | Latin small letter o with horn and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1524 |
* | U+1EE0 | Ỡ | O | Latin capital letter O with horn and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1525 |
* | U+1EE1 | ỡ | o | Latin small letter o with horn and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1526 |
* | U+1EE2 | Ợ | O | Latin capital letter O with horn and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1527 |
* | U+1EE3 | ợ | o | Latin small letter o with horn and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1528 |
* | U+1EE4 | Ụ | U | Latin capital letter U with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1529 |
* | U+1EE5 | ụ | u | Latin small letter u with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1530 |
* | U+1EE6 | Ủ | U | Latin capital letter U with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1531 |
* | U+1EE7 | ủ | u | Latin small letter u with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1532 |
* | U+1EE8 | Ứ | U | Latin capital letter U with horn and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1533 |
* | U+1EE9 | ứ | u | Latin small letter u with horn and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1534 |
* | U+1EEA | Ừ | U | Latin capital letter U with horn and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1535 |
* | U+1EEB | ừ | u | Latin small letter u with horn and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1536 |
* | U+1EEC | Ử | U | Latin capital letter U with horn and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1537 |
* | U+1EED | ử | u | Latin small letter u with horn and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1538 |
* | U+1EEE | Ữ | U | Latin capital letter U with horn and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1539 |
* | U+1EEF | ữ | u | Latin small letter u with horn and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1540 |
* | U+1EF0 | Ự | U | Latin capital letter U with horn and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1541 |
* | U+1EF1 | ự | u | Latin small letter u with horn and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1542 |
* | U+1EF2 | Ỳ | Y | Latin capital letter Y with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1543 |
* | U+1EF3 | ỳ | y | Latin small letter y with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1544 |
* | U+1EF4 | Ỵ | Y | Latin capital letter Y with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1545 |
* | U+1EF5 | ỵ | y | Latin small letter y with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1546 |
* | U+1EF6 | Ỷ | Y | Latin capital letter Y with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1547 |
* | U+1EF7 | ỷ | y | Latin small letter y with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1548 |
* | U+1EF8 | Ỹ | Y | Latin capital letter Y with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1549 |
* | U+1EF9 | ỹ | y | Latin small letter y with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1550 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1551 |
* German (`de_DE`), German formal (`de_DE_formal`), German (Switzerland) formal (`de_CH`), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1552 |
* and German (Switzerland) informal (`de_CH_informal`) locales: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1553 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1554 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1555 |
* | -------- | ----- | ----------- | --------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1556 |
* | U+00C4 | Ä | Ae | Latin capital letter A with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1557 |
* | U+00E4 | ä | ae | Latin small letter a with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1558 |
* | U+00D6 | Ö | Oe | Latin capital letter O with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1559 |
* | U+00F6 | ö | oe | Latin small letter o with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1560 |
* | U+00DC | Ü | Ue | Latin capital letter U with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1561 |
* | U+00FC | ü | ue | Latin small letter u with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1562 |
* | U+00DF | ß | ss | Latin small letter sharp s | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1563 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1564 |
* Danish (`da_DK`) locale: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1565 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1566 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1567 |
* | -------- | ----- | ----------- | --------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1568 |
* | U+00C6 | Æ | Ae | Latin capital letter AE | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1569 |
* | U+00E6 | æ | ae | Latin small letter ae | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1570 |
* | U+00D8 | Ø | Oe | Latin capital letter O with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1571 |
* | U+00F8 | ø | oe | Latin small letter o with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1572 |
* | U+00C5 | Å | Aa | Latin capital letter A with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1573 |
* | U+00E5 | å | aa | Latin small letter a with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1574 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1575 |
* Catalan (`ca`) locale: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1576 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1577 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1578 |
* | -------- | ----- | ----------- | --------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1579 |
* | U+00B7 | l·l | ll | Flown dot (between two Ls) | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1580 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1581 |
* Serbian (`sr_RS`) and Bosnian (`bs_BA`) locales: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1582 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1583 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1584 |
* | -------- | ----- | ----------- | --------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1585 |
* | U+0110 | Đ | DJ | Latin capital letter D with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1586 |
* | U+0111 | đ | dj | Latin small letter d with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1587 |
* |
0 | 1588 |
* @since 1.2.1 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1589 |
* @since 4.6.0 Added locale support for `de_CH`, `de_CH_informal`, and `ca`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1590 |
* @since 4.7.0 Added locale support for `sr_RS`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1591 |
* @since 4.8.0 Added locale support for `bs_BA`. |
0 | 1592 |
* |
1593 |
* @param string $string Text that might have accent characters |
|
1594 |
* @return string Filtered string with replaced "nice" characters. |
|
1595 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1596 |
function remove_accents( $string ) { |
9 | 1597 |
if ( ! preg_match( '/[\x80-\xff]/', $string ) ) { |
0 | 1598 |
return $string; |
9 | 1599 |
} |
1600 |
||
1601 |
if ( seems_utf8( $string ) ) { |
|
0 | 1602 |
$chars = array( |
9 | 1603 |
// Decompositions for Latin-1 Supplement |
1604 |
'ª' => 'a', |
|
1605 |
'º' => 'o', |
|
1606 |
'À' => 'A', |
|
1607 |
'Á' => 'A', |
|
1608 |
'Â' => 'A', |
|
1609 |
'Ã' => 'A', |
|
1610 |
'Ä' => 'A', |
|
1611 |
'Å' => 'A', |
|
1612 |
'Æ' => 'AE', |
|
1613 |
'Ç' => 'C', |
|
1614 |
'È' => 'E', |
|
1615 |
'É' => 'E', |
|
1616 |
'Ê' => 'E', |
|
1617 |
'Ë' => 'E', |
|
1618 |
'Ì' => 'I', |
|
1619 |
'Í' => 'I', |
|
1620 |
'Î' => 'I', |
|
1621 |
'Ï' => 'I', |
|
1622 |
'Ð' => 'D', |
|
1623 |
'Ñ' => 'N', |
|
1624 |
'Ò' => 'O', |
|
1625 |
'Ó' => 'O', |
|
1626 |
'Ô' => 'O', |
|
1627 |
'Õ' => 'O', |
|
1628 |
'Ö' => 'O', |
|
1629 |
'Ù' => 'U', |
|
1630 |
'Ú' => 'U', |
|
1631 |
'Û' => 'U', |
|
1632 |
'Ü' => 'U', |
|
1633 |
'Ý' => 'Y', |
|
1634 |
'Þ' => 'TH', |
|
1635 |
'ß' => 's', |
|
1636 |
'à' => 'a', |
|
1637 |
'á' => 'a', |
|
1638 |
'â' => 'a', |
|
1639 |
'ã' => 'a', |
|
1640 |
'ä' => 'a', |
|
1641 |
'å' => 'a', |
|
1642 |
'æ' => 'ae', |
|
1643 |
'ç' => 'c', |
|
1644 |
'è' => 'e', |
|
1645 |
'é' => 'e', |
|
1646 |
'ê' => 'e', |
|
1647 |
'ë' => 'e', |
|
1648 |
'ì' => 'i', |
|
1649 |
'í' => 'i', |
|
1650 |
'î' => 'i', |
|
1651 |
'ï' => 'i', |
|
1652 |
'ð' => 'd', |
|
1653 |
'ñ' => 'n', |
|
1654 |
'ò' => 'o', |
|
1655 |
'ó' => 'o', |
|
1656 |
'ô' => 'o', |
|
1657 |
'õ' => 'o', |
|
1658 |
'ö' => 'o', |
|
1659 |
'ø' => 'o', |
|
1660 |
'ù' => 'u', |
|
1661 |
'ú' => 'u', |
|
1662 |
'û' => 'u', |
|
1663 |
'ü' => 'u', |
|
1664 |
'ý' => 'y', |
|
1665 |
'þ' => 'th', |
|
1666 |
'ÿ' => 'y', |
|
1667 |
'Ø' => 'O', |
|
1668 |
// Decompositions for Latin Extended-A |
|
1669 |
'Ā' => 'A', |
|
1670 |
'ā' => 'a', |
|
1671 |
'Ă' => 'A', |
|
1672 |
'ă' => 'a', |
|
1673 |
'Ą' => 'A', |
|
1674 |
'ą' => 'a', |
|
1675 |
'Ć' => 'C', |
|
1676 |
'ć' => 'c', |
|
1677 |
'Ĉ' => 'C', |
|
1678 |
'ĉ' => 'c', |
|
1679 |
'Ċ' => 'C', |
|
1680 |
'ċ' => 'c', |
|
1681 |
'Č' => 'C', |
|
1682 |
'č' => 'c', |
|
1683 |
'Ď' => 'D', |
|
1684 |
'ď' => 'd', |
|
1685 |
'Đ' => 'D', |
|
1686 |
'đ' => 'd', |
|
1687 |
'Ē' => 'E', |
|
1688 |
'ē' => 'e', |
|
1689 |
'Ĕ' => 'E', |
|
1690 |
'ĕ' => 'e', |
|
1691 |
'Ė' => 'E', |
|
1692 |
'ė' => 'e', |
|
1693 |
'Ę' => 'E', |
|
1694 |
'ę' => 'e', |
|
1695 |
'Ě' => 'E', |
|
1696 |
'ě' => 'e', |
|
1697 |
'Ĝ' => 'G', |
|
1698 |
'ĝ' => 'g', |
|
1699 |
'Ğ' => 'G', |
|
1700 |
'ğ' => 'g', |
|
1701 |
'Ġ' => 'G', |
|
1702 |
'ġ' => 'g', |
|
1703 |
'Ģ' => 'G', |
|
1704 |
'ģ' => 'g', |
|
1705 |
'Ĥ' => 'H', |
|
1706 |
'ĥ' => 'h', |
|
1707 |
'Ħ' => 'H', |
|
1708 |
'ħ' => 'h', |
|
1709 |
'Ĩ' => 'I', |
|
1710 |
'ĩ' => 'i', |
|
1711 |
'Ī' => 'I', |
|
1712 |
'ī' => 'i', |
|
1713 |
'Ĭ' => 'I', |
|
1714 |
'ĭ' => 'i', |
|
1715 |
'Į' => 'I', |
|
1716 |
'į' => 'i', |
|
1717 |
'İ' => 'I', |
|
1718 |
'ı' => 'i', |
|
1719 |
'IJ' => 'IJ', |
|
1720 |
'ij' => 'ij', |
|
1721 |
'Ĵ' => 'J', |
|
1722 |
'ĵ' => 'j', |
|
1723 |
'Ķ' => 'K', |
|
1724 |
'ķ' => 'k', |
|
1725 |
'ĸ' => 'k', |
|
1726 |
'Ĺ' => 'L', |
|
1727 |
'ĺ' => 'l', |
|
1728 |
'Ļ' => 'L', |
|
1729 |
'ļ' => 'l', |
|
1730 |
'Ľ' => 'L', |
|
1731 |
'ľ' => 'l', |
|
1732 |
'Ŀ' => 'L', |
|
1733 |
'ŀ' => 'l', |
|
1734 |
'Ł' => 'L', |
|
1735 |
'ł' => 'l', |
|
1736 |
'Ń' => 'N', |
|
1737 |
'ń' => 'n', |
|
1738 |
'Ņ' => 'N', |
|
1739 |
'ņ' => 'n', |
|
1740 |
'Ň' => 'N', |
|
1741 |
'ň' => 'n', |
|
1742 |
'ʼn' => 'n', |
|
1743 |
'Ŋ' => 'N', |
|
1744 |
'ŋ' => 'n', |
|
1745 |
'Ō' => 'O', |
|
1746 |
'ō' => 'o', |
|
1747 |
'Ŏ' => 'O', |
|
1748 |
'ŏ' => 'o', |
|
1749 |
'Ő' => 'O', |
|
1750 |
'ő' => 'o', |
|
1751 |
'Œ' => 'OE', |
|
1752 |
'œ' => 'oe', |
|
1753 |
'Ŕ' => 'R', |
|
1754 |
'ŕ' => 'r', |
|
1755 |
'Ŗ' => 'R', |
|
1756 |
'ŗ' => 'r', |
|
1757 |
'Ř' => 'R', |
|
1758 |
'ř' => 'r', |
|
1759 |
'Ś' => 'S', |
|
1760 |
'ś' => 's', |
|
1761 |
'Ŝ' => 'S', |
|
1762 |
'ŝ' => 's', |
|
1763 |
'Ş' => 'S', |
|
1764 |
'ş' => 's', |
|
1765 |
'Š' => 'S', |
|
1766 |
'š' => 's', |
|
1767 |
'Ţ' => 'T', |
|
1768 |
'ţ' => 't', |
|
1769 |
'Ť' => 'T', |
|
1770 |
'ť' => 't', |
|
1771 |
'Ŧ' => 'T', |
|
1772 |
'ŧ' => 't', |
|
1773 |
'Ũ' => 'U', |
|
1774 |
'ũ' => 'u', |
|
1775 |
'Ū' => 'U', |
|
1776 |
'ū' => 'u', |
|
1777 |
'Ŭ' => 'U', |
|
1778 |
'ŭ' => 'u', |
|
1779 |
'Ů' => 'U', |
|
1780 |
'ů' => 'u', |
|
1781 |
'Ű' => 'U', |
|
1782 |
'ű' => 'u', |
|
1783 |
'Ų' => 'U', |
|
1784 |
'ų' => 'u', |
|
1785 |
'Ŵ' => 'W', |
|
1786 |
'ŵ' => 'w', |
|
1787 |
'Ŷ' => 'Y', |
|
1788 |
'ŷ' => 'y', |
|
1789 |
'Ÿ' => 'Y', |
|
1790 |
'Ź' => 'Z', |
|
1791 |
'ź' => 'z', |
|
1792 |
'Ż' => 'Z', |
|
1793 |
'ż' => 'z', |
|
1794 |
'Ž' => 'Z', |
|
1795 |
'ž' => 'z', |
|
1796 |
'ſ' => 's', |
|
1797 |
// Decompositions for Latin Extended-B |
|
1798 |
'Ș' => 'S', |
|
1799 |
'ș' => 's', |
|
1800 |
'Ț' => 'T', |
|
1801 |
'ț' => 't', |
|
1802 |
// Euro Sign |
|
1803 |
'€' => 'E', |
|
1804 |
// GBP (Pound) Sign |
|
1805 |
'£' => '', |
|
1806 |
// Vowels with diacritic (Vietnamese) |
|
1807 |
// unmarked |
|
1808 |
'Ơ' => 'O', |
|
1809 |
'ơ' => 'o', |
|
1810 |
'Ư' => 'U', |
|
1811 |
'ư' => 'u', |
|
1812 |
// grave accent |
|
1813 |
'Ầ' => 'A', |
|
1814 |
'ầ' => 'a', |
|
1815 |
'Ằ' => 'A', |
|
1816 |
'ằ' => 'a', |
|
1817 |
'Ề' => 'E', |
|
1818 |
'ề' => 'e', |
|
1819 |
'Ồ' => 'O', |
|
1820 |
'ồ' => 'o', |
|
1821 |
'Ờ' => 'O', |
|
1822 |
'ờ' => 'o', |
|
1823 |
'Ừ' => 'U', |
|
1824 |
'ừ' => 'u', |
|
1825 |
'Ỳ' => 'Y', |
|
1826 |
'ỳ' => 'y', |
|
1827 |
// hook |
|
1828 |
'Ả' => 'A', |
|
1829 |
'ả' => 'a', |
|
1830 |
'Ẩ' => 'A', |
|
1831 |
'ẩ' => 'a', |
|
1832 |
'Ẳ' => 'A', |
|
1833 |
'ẳ' => 'a', |
|
1834 |
'Ẻ' => 'E', |
|
1835 |
'ẻ' => 'e', |
|
1836 |
'Ể' => 'E', |
|
1837 |
'ể' => 'e', |
|
1838 |
'Ỉ' => 'I', |
|
1839 |
'ỉ' => 'i', |
|
1840 |
'Ỏ' => 'O', |
|
1841 |
'ỏ' => 'o', |
|
1842 |
'Ổ' => 'O', |
|
1843 |
'ổ' => 'o', |
|
1844 |
'Ở' => 'O', |
|
1845 |
'ở' => 'o', |
|
1846 |
'Ủ' => 'U', |
|
1847 |
'ủ' => 'u', |
|
1848 |
'Ử' => 'U', |
|
1849 |
'ử' => 'u', |
|
1850 |
'Ỷ' => 'Y', |
|
1851 |
'ỷ' => 'y', |
|
1852 |
// tilde |
|
1853 |
'Ẫ' => 'A', |
|
1854 |
'ẫ' => 'a', |
|
1855 |
'Ẵ' => 'A', |
|
1856 |
'ẵ' => 'a', |
|
1857 |
'Ẽ' => 'E', |
|
1858 |
'ẽ' => 'e', |
|
1859 |
'Ễ' => 'E', |
|
1860 |
'ễ' => 'e', |
|
1861 |
'Ỗ' => 'O', |
|
1862 |
'ỗ' => 'o', |
|
1863 |
'Ỡ' => 'O', |
|
1864 |
'ỡ' => 'o', |
|
1865 |
'Ữ' => 'U', |
|
1866 |
'ữ' => 'u', |
|
1867 |
'Ỹ' => 'Y', |
|
1868 |
'ỹ' => 'y', |
|
1869 |
// acute accent |
|
1870 |
'Ấ' => 'A', |
|
1871 |
'ấ' => 'a', |
|
1872 |
'Ắ' => 'A', |
|
1873 |
'ắ' => 'a', |
|
1874 |
'Ế' => 'E', |
|
1875 |
'ế' => 'e', |
|
1876 |
'Ố' => 'O', |
|
1877 |
'ố' => 'o', |
|
1878 |
'Ớ' => 'O', |
|
1879 |
'ớ' => 'o', |
|
1880 |
'Ứ' => 'U', |
|
1881 |
'ứ' => 'u', |
|
1882 |
// dot below |
|
1883 |
'Ạ' => 'A', |
|
1884 |
'ạ' => 'a', |
|
1885 |
'Ậ' => 'A', |
|
1886 |
'ậ' => 'a', |
|
1887 |
'Ặ' => 'A', |
|
1888 |
'ặ' => 'a', |
|
1889 |
'Ẹ' => 'E', |
|
1890 |
'ẹ' => 'e', |
|
1891 |
'Ệ' => 'E', |
|
1892 |
'ệ' => 'e', |
|
1893 |
'Ị' => 'I', |
|
1894 |
'ị' => 'i', |
|
1895 |
'Ọ' => 'O', |
|
1896 |
'ọ' => 'o', |
|
1897 |
'Ộ' => 'O', |
|
1898 |
'ộ' => 'o', |
|
1899 |
'Ợ' => 'O', |
|
1900 |
'ợ' => 'o', |
|
1901 |
'Ụ' => 'U', |
|
1902 |
'ụ' => 'u', |
|
1903 |
'Ự' => 'U', |
|
1904 |
'ự' => 'u', |
|
1905 |
'Ỵ' => 'Y', |
|
1906 |
'ỵ' => 'y', |
|
1907 |
// Vowels with diacritic (Chinese, Hanyu Pinyin) |
|
1908 |
'ɑ' => 'a', |
|
1909 |
// macron |
|
1910 |
'Ǖ' => 'U', |
|
1911 |
'ǖ' => 'u', |
|
1912 |
// acute accent |
|
1913 |
'Ǘ' => 'U', |
|
1914 |
'ǘ' => 'u', |
|
1915 |
// caron |
|
1916 |
'Ǎ' => 'A', |
|
1917 |
'ǎ' => 'a', |
|
1918 |
'Ǐ' => 'I', |
|
1919 |
'ǐ' => 'i', |
|
1920 |
'Ǒ' => 'O', |
|
1921 |
'ǒ' => 'o', |
|
1922 |
'Ǔ' => 'U', |
|
1923 |
'ǔ' => 'u', |
|
1924 |
'Ǚ' => 'U', |
|
1925 |
'ǚ' => 'u', |
|
1926 |
// grave accent |
|
1927 |
'Ǜ' => 'U', |
|
1928 |
'ǜ' => 'u', |
|
0 | 1929 |
); |
1930 |
||
1931 |
// Used for locale-specific rules |
|
1932 |
$locale = get_locale(); |
|
1933 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1934 |
if ( 'de_DE' == $locale || 'de_DE_formal' == $locale || 'de_CH' == $locale || 'de_CH_informal' == $locale ) { |
9 | 1935 |
$chars['Ä'] = 'Ae'; |
1936 |
$chars['ä'] = 'ae'; |
|
1937 |
$chars['Ö'] = 'Oe'; |
|
1938 |
$chars['ö'] = 'oe'; |
|
1939 |
$chars['Ü'] = 'Ue'; |
|
1940 |
$chars['ü'] = 'ue'; |
|
1941 |
$chars['ß'] = 'ss'; |
|
5 | 1942 |
} elseif ( 'da_DK' === $locale ) { |
9 | 1943 |
$chars['Æ'] = 'Ae'; |
1944 |
$chars['æ'] = 'ae'; |
|
1945 |
$chars['Ø'] = 'Oe'; |
|
1946 |
$chars['ø'] = 'oe'; |
|
1947 |
$chars['Å'] = 'Aa'; |
|
1948 |
$chars['å'] = 'aa'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1949 |
} elseif ( 'ca' === $locale ) { |
9 | 1950 |
$chars['l·l'] = 'll'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1951 |
} elseif ( 'sr_RS' === $locale || 'bs_BA' === $locale ) { |
9 | 1952 |
$chars['Đ'] = 'DJ'; |
1953 |
$chars['đ'] = 'dj'; |
|
0 | 1954 |
} |
1955 |
||
9 | 1956 |
$string = strtr( $string, $chars ); |
0 | 1957 |
} else { |
5 | 1958 |
$chars = array(); |
0 | 1959 |
// Assume ISO-8859-1 if not UTF-8 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1960 |
$chars['in'] = "\x80\x83\x8a\x8e\x9a\x9e" |
9 | 1961 |
. "\x9f\xa2\xa5\xb5\xc0\xc1\xc2" |
1962 |
. "\xc3\xc4\xc5\xc7\xc8\xc9\xca" |
|
1963 |
. "\xcb\xcc\xcd\xce\xcf\xd1\xd2" |
|
1964 |
. "\xd3\xd4\xd5\xd6\xd8\xd9\xda" |
|
1965 |
. "\xdb\xdc\xdd\xe0\xe1\xe2\xe3" |
|
1966 |
. "\xe4\xe5\xe7\xe8\xe9\xea\xeb" |
|
1967 |
. "\xec\xed\xee\xef\xf1\xf2\xf3" |
|
1968 |
. "\xf4\xf5\xf6\xf8\xf9\xfa\xfb" |
|
1969 |
. "\xfc\xfd\xff"; |
|
1970 |
||
1971 |
$chars['out'] = 'EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'; |
|
1972 |
||
1973 |
$string = strtr( $string, $chars['in'], $chars['out'] ); |
|
1974 |
$double_chars = array(); |
|
1975 |
$double_chars['in'] = array( "\x8c", "\x9c", "\xc6", "\xd0", "\xde", "\xdf", "\xe6", "\xf0", "\xfe" ); |
|
1976 |
$double_chars['out'] = array( 'OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th' ); |
|
1977 |
$string = str_replace( $double_chars['in'], $double_chars['out'], $string ); |
|
0 | 1978 |
} |
1979 |
||
1980 |
return $string; |
|
1981 |
} |
|
1982 |
||
1983 |
/** |
|
1984 |
* Sanitizes a filename, replacing whitespace with dashes. |
|
1985 |
* |
|
1986 |
* Removes special characters that are illegal in filenames on certain |
|
1987 |
* operating systems and special characters requiring special escaping |
|
1988 |
* to manipulate at the command line. Replaces spaces and consecutive |
|
1989 |
* dashes with a single dash. Trims period, dash and underscore from beginning |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1990 |
* and end of filename. It is not guaranteed that this function will return a |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1991 |
* filename that is allowed to be uploaded. |
0 | 1992 |
* |
1993 |
* @since 2.1.0 |
|
1994 |
* |
|
1995 |
* @param string $filename The filename to be sanitized |
|
1996 |
* @return string The sanitized filename |
|
1997 |
*/ |
|
1998 |
function sanitize_file_name( $filename ) { |
|
9 | 1999 |
$filename_raw = $filename; |
2000 |
$special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', chr( 0 ) ); |
|
5 | 2001 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2002 |
* Filters the list of characters to remove from a filename. |
5 | 2003 |
* |
2004 |
* @since 2.8.0 |
|
2005 |
* |
|
2006 |
* @param array $special_chars Characters to remove. |
|
2007 |
* @param string $filename_raw Filename as it was passed into sanitize_file_name(). |
|
2008 |
*/ |
|
2009 |
$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); |
|
9 | 2010 |
$filename = preg_replace( "#\x{00a0}#siu", ' ', $filename ); |
2011 |
$filename = str_replace( $special_chars, '', $filename ); |
|
2012 |
$filename = str_replace( array( '%20', '+' ), '-', $filename ); |
|
2013 |
$filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); |
|
2014 |
$filename = trim( $filename, '.-_' ); |
|
0 | 2015 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2016 |
if ( false === strpos( $filename, '.' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2017 |
$mime_types = wp_get_mime_types(); |
9 | 2018 |
$filetype = wp_check_filetype( 'test.' . $filename, $mime_types ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2019 |
if ( $filetype['ext'] === $filename ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2020 |
$filename = 'unnamed-file.' . $filetype['ext']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2021 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2022 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2023 |
|
0 | 2024 |
// Split the filename into a base and extension[s] |
9 | 2025 |
$parts = explode( '.', $filename ); |
0 | 2026 |
|
2027 |
// Return if only one extension |
|
5 | 2028 |
if ( count( $parts ) <= 2 ) { |
2029 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2030 |
* Filters a sanitized filename string. |
5 | 2031 |
* |
2032 |
* @since 2.8.0 |
|
2033 |
* |
|
2034 |
* @param string $filename Sanitized filename. |
|
2035 |
* @param string $filename_raw The filename prior to sanitization. |
|
2036 |
*/ |
|
2037 |
return apply_filters( 'sanitize_file_name', $filename, $filename_raw ); |
|
2038 |
} |
|
0 | 2039 |
|
2040 |
// Process multiple extensions |
|
9 | 2041 |
$filename = array_shift( $parts ); |
2042 |
$extension = array_pop( $parts ); |
|
2043 |
$mimes = get_allowed_mime_types(); |
|
0 | 2044 |
|
5 | 2045 |
/* |
2046 |
* Loop over any intermediate extensions. Postfix them with a trailing underscore |
|
2047 |
* if they are a 2 - 5 character long alpha string not in the extension whitelist. |
|
2048 |
*/ |
|
9 | 2049 |
foreach ( (array) $parts as $part ) { |
0 | 2050 |
$filename .= '.' . $part; |
2051 |
||
9 | 2052 |
if ( preg_match( '/^[a-zA-Z]{2,5}\d?$/', $part ) ) { |
0 | 2053 |
$allowed = false; |
2054 |
foreach ( $mimes as $ext_preg => $mime_match ) { |
|
2055 |
$ext_preg = '!^(' . $ext_preg . ')$!i'; |
|
2056 |
if ( preg_match( $ext_preg, $part ) ) { |
|
2057 |
$allowed = true; |
|
2058 |
break; |
|
2059 |
} |
|
2060 |
} |
|
9 | 2061 |
if ( ! $allowed ) { |
0 | 2062 |
$filename .= '_'; |
9 | 2063 |
} |
0 | 2064 |
} |
2065 |
} |
|
2066 |
$filename .= '.' . $extension; |
|
5 | 2067 |
/** This filter is documented in wp-includes/formatting.php */ |
9 | 2068 |
return apply_filters( 'sanitize_file_name', $filename, $filename_raw ); |
0 | 2069 |
} |
2070 |
||
2071 |
/** |
|
2072 |
* Sanitizes a username, stripping out unsafe characters. |
|
2073 |
* |
|
2074 |
* Removes tags, octets, entities, and if strict is enabled, will only keep |
|
2075 |
* alphanumeric, _, space, ., -, @. After sanitizing, it passes the username, |
|
2076 |
* raw username (the username in the parameter), and the value of $strict as |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2077 |
* parameters for the {@see 'sanitize_user'} filter. |
0 | 2078 |
* |
2079 |
* @since 2.0.0 |
|
2080 |
* |
|
2081 |
* @param string $username The username to be sanitized. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2082 |
* @param bool $strict If set limits $username to specific characters. Default false. |
0 | 2083 |
* @return string The sanitized username, after passing through filters. |
2084 |
*/ |
|
2085 |
function sanitize_user( $username, $strict = false ) { |
|
2086 |
$raw_username = $username; |
|
9 | 2087 |
$username = wp_strip_all_tags( $username ); |
2088 |
$username = remove_accents( $username ); |
|
0 | 2089 |
// Kill octets |
2090 |
$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); |
|
2091 |
$username = preg_replace( '/&.+?;/', '', $username ); // Kill entities |
|
2092 |
||
2093 |
// If strict, reduce to ASCII for max portability. |
|
9 | 2094 |
if ( $strict ) { |
0 | 2095 |
$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); |
9 | 2096 |
} |
0 | 2097 |
|
2098 |
$username = trim( $username ); |
|
2099 |
// Consolidate contiguous whitespace |
|
2100 |
$username = preg_replace( '|\s+|', ' ', $username ); |
|
2101 |
||
5 | 2102 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2103 |
* Filters a sanitized username string. |
5 | 2104 |
* |
2105 |
* @since 2.0.1 |
|
2106 |
* |
|
2107 |
* @param string $username Sanitized username. |
|
2108 |
* @param string $raw_username The username prior to sanitization. |
|
2109 |
* @param bool $strict Whether to limit the sanitization to specific characters. Default false. |
|
2110 |
*/ |
|
0 | 2111 |
return apply_filters( 'sanitize_user', $username, $raw_username, $strict ); |
2112 |
} |
|
2113 |
||
2114 |
/** |
|
2115 |
* Sanitizes a string key. |
|
2116 |
* |
|
2117 |
* Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed. |
|
2118 |
* |
|
2119 |
* @since 3.0.0 |
|
2120 |
* |
|
2121 |
* @param string $key String key |
|
2122 |
* @return string Sanitized key |
|
2123 |
*/ |
|
2124 |
function sanitize_key( $key ) { |
|
2125 |
$raw_key = $key; |
|
9 | 2126 |
$key = strtolower( $key ); |
2127 |
$key = preg_replace( '/[^a-z0-9_\-]/', '', $key ); |
|
5 | 2128 |
|
2129 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2130 |
* Filters a sanitized key string. |
5 | 2131 |
* |
2132 |
* @since 3.0.0 |
|
2133 |
* |
|
2134 |
* @param string $key Sanitized key. |
|
2135 |
* @param string $raw_key The key prior to sanitization. |
|
2136 |
*/ |
|
0 | 2137 |
return apply_filters( 'sanitize_key', $key, $raw_key ); |
2138 |
} |
|
2139 |
||
2140 |
/** |
|
2141 |
* Sanitizes a title, or returns a fallback title. |
|
2142 |
* |
|
2143 |
* Specifically, HTML and PHP tags are stripped. Further actions can be added |
|
2144 |
* via the plugin API. If $title is empty and $fallback_title is set, the latter |
|
2145 |
* will be used. |
|
2146 |
* |
|
2147 |
* @since 1.0.0 |
|
2148 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2149 |
* @param string $title The string to be sanitized. |
0 | 2150 |
* @param string $fallback_title Optional. A title to use if $title is empty. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2151 |
* @param string $context Optional. The operation for which the string is sanitized |
0 | 2152 |
* @return string The sanitized string. |
2153 |
*/ |
|
2154 |
function sanitize_title( $title, $fallback_title = '', $context = 'save' ) { |
|
2155 |
$raw_title = $title; |
|
2156 |
||
9 | 2157 |
if ( 'save' == $context ) { |
2158 |
$title = remove_accents( $title ); |
|
2159 |
} |
|
0 | 2160 |
|
5 | 2161 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2162 |
* Filters a sanitized title string. |
5 | 2163 |
* |
2164 |
* @since 1.2.0 |
|
2165 |
* |
|
2166 |
* @param string $title Sanitized title. |
|
2167 |
* @param string $raw_title The title prior to sanitization. |
|
2168 |
* @param string $context The context for which the title is being sanitized. |
|
2169 |
*/ |
|
2170 |
$title = apply_filters( 'sanitize_title', $title, $raw_title, $context ); |
|
0 | 2171 |
|
9 | 2172 |
if ( '' === $title || false === $title ) { |
0 | 2173 |
$title = $fallback_title; |
9 | 2174 |
} |
0 | 2175 |
|
2176 |
return $title; |
|
2177 |
} |
|
2178 |
||
2179 |
/** |
|
2180 |
* Sanitizes a title with the 'query' context. |
|
2181 |
* |
|
2182 |
* Used for querying the database for a value from URL. |
|
2183 |
* |
|
2184 |
* @since 3.1.0 |
|
2185 |
* |
|
2186 |
* @param string $title The string to be sanitized. |
|
2187 |
* @return string The sanitized string. |
|
2188 |
*/ |
|
2189 |
function sanitize_title_for_query( $title ) { |
|
2190 |
return sanitize_title( $title, '', 'query' ); |
|
2191 |
} |
|
2192 |
||
2193 |
/** |
|
2194 |
* Sanitizes a title, replacing whitespace and a few other characters with dashes. |
|
2195 |
* |
|
2196 |
* Limits the output to alphanumeric characters, underscore (_) and dash (-). |
|
2197 |
* Whitespace becomes a dash. |
|
2198 |
* |
|
2199 |
* @since 1.2.0 |
|
2200 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2201 |
* @param string $title The title to be sanitized. |
0 | 2202 |
* @param string $raw_title Optional. Not used. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2203 |
* @param string $context Optional. The operation for which the string is sanitized. |
0 | 2204 |
* @return string The sanitized title. |
2205 |
*/ |
|
2206 |
function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) { |
|
9 | 2207 |
$title = strip_tags( $title ); |
0 | 2208 |
// Preserve escaped octets. |
9 | 2209 |
$title = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title ); |
0 | 2210 |
// Remove percent signs that are not part of an octet. |
9 | 2211 |
$title = str_replace( '%', '', $title ); |
0 | 2212 |
// Restore octets. |
9 | 2213 |
$title = preg_replace( '|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title ); |
2214 |
||
2215 |
if ( seems_utf8( $title ) ) { |
|
2216 |
if ( function_exists( 'mb_strtolower' ) ) { |
|
2217 |
$title = mb_strtolower( $title, 'UTF-8' ); |
|
0 | 2218 |
} |
9 | 2219 |
$title = utf8_uri_encode( $title, 200 ); |
0 | 2220 |
} |
2221 |
||
9 | 2222 |
$title = strtolower( $title ); |
0 | 2223 |
|
2224 |
if ( 'save' == $context ) { |
|
2225 |
// Convert nbsp, ndash and mdash to hyphens |
|
2226 |
$title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2227 |
// Convert nbsp, ndash and mdash HTML entities to hyphens |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2228 |
$title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2229 |
// Convert forward slash to hyphen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2230 |
$title = str_replace( '/', '-', $title ); |
0 | 2231 |
|
2232 |
// Strip these characters entirely |
|
9 | 2233 |
$title = str_replace( |
2234 |
array( |
|
2235 |
// soft hyphens |
|
2236 |
'%c2%ad', |
|
2237 |
// iexcl and iquest |
|
2238 |
'%c2%a1', |
|
2239 |
'%c2%bf', |
|
2240 |
// angle quotes |
|
2241 |
'%c2%ab', |
|
2242 |
'%c2%bb', |
|
2243 |
'%e2%80%b9', |
|
2244 |
'%e2%80%ba', |
|
2245 |
// curly quotes |
|
2246 |
'%e2%80%98', |
|
2247 |
'%e2%80%99', |
|
2248 |
'%e2%80%9c', |
|
2249 |
'%e2%80%9d', |
|
2250 |
'%e2%80%9a', |
|
2251 |
'%e2%80%9b', |
|
2252 |
'%e2%80%9e', |
|
2253 |
'%e2%80%9f', |
|
2254 |
// copy, reg, deg, hellip and trade |
|
2255 |
'%c2%a9', |
|
2256 |
'%c2%ae', |
|
2257 |
'%c2%b0', |
|
2258 |
'%e2%80%a6', |
|
2259 |
'%e2%84%a2', |
|
2260 |
// acute accents |
|
2261 |
'%c2%b4', |
|
2262 |
'%cb%8a', |
|
2263 |
'%cc%81', |
|
2264 |
'%cd%81', |
|
2265 |
// grave accent, macron, caron |
|
2266 |
'%cc%80', |
|
2267 |
'%cc%84', |
|
2268 |
'%cc%8c', |
|
2269 |
), |
|
2270 |
'', |
|
2271 |
$title |
|
2272 |
); |
|
0 | 2273 |
|
2274 |
// Convert times to x |
|
2275 |
$title = str_replace( '%c3%97', 'x', $title ); |
|
2276 |
} |
|
2277 |
||
9 | 2278 |
$title = preg_replace( '/&.+?;/', '', $title ); // kill entities |
2279 |
$title = str_replace( '.', '-', $title ); |
|
2280 |
||
2281 |
$title = preg_replace( '/[^%a-z0-9 _-]/', '', $title ); |
|
2282 |
$title = preg_replace( '/\s+/', '-', $title ); |
|
2283 |
$title = preg_replace( '|-+|', '-', $title ); |
|
2284 |
$title = trim( $title, '-' ); |
|
0 | 2285 |
|
2286 |
return $title; |
|
2287 |
} |
|
2288 |
||
2289 |
/** |
|
5 | 2290 |
* Ensures a string is a valid SQL 'order by' clause. |
2291 |
* |
|
2292 |
* Accepts one or more columns, with or without a sort order (ASC / DESC). |
|
2293 |
* e.g. 'column_1', 'column_1, column_2', 'column_1 ASC, column_2 DESC' etc. |
|
2294 |
* |
|
2295 |
* Also accepts 'RAND()'. |
|
0 | 2296 |
* |
2297 |
* @since 2.5.1 |
|
2298 |
* |
|
5 | 2299 |
* @param string $orderby Order by clause to be validated. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2300 |
* @return string|false Returns $orderby if valid, false otherwise. |
0 | 2301 |
*/ |
5 | 2302 |
function sanitize_sql_orderby( $orderby ) { |
2303 |
if ( preg_match( '/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby ) || preg_match( '/^\s*RAND\(\s*\)\s*$/i', $orderby ) ) { |
|
2304 |
return $orderby; |
|
2305 |
} |
|
2306 |
return false; |
|
0 | 2307 |
} |
2308 |
||
2309 |
/** |
|
2310 |
* Sanitizes an HTML classname to ensure it only contains valid characters. |
|
2311 |
* |
|
2312 |
* Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty |
|
2313 |
* string then it will return the alternative value supplied. |
|
2314 |
* |
|
2315 |
* @todo Expand to support the full range of CDATA that a class attribute can contain. |
|
2316 |
* |
|
2317 |
* @since 2.8.0 |
|
2318 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2319 |
* @param string $class The classname to be sanitized |
5 | 2320 |
* @param string $fallback Optional. The value to return if the sanitization ends up as an empty string. |
9 | 2321 |
* Defaults to an empty string. |
0 | 2322 |
* @return string The sanitized value |
2323 |
*/ |
|
2324 |
function sanitize_html_class( $class, $fallback = '' ) { |
|
2325 |
//Strip out any % encoded octets |
|
2326 |
$sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class ); |
|
2327 |
||
2328 |
//Limit to A-Z,a-z,0-9,_,- |
|
2329 |
$sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); |
|
2330 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2331 |
if ( '' == $sanitized && $fallback ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2332 |
return sanitize_html_class( $fallback ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2333 |
} |
5 | 2334 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2335 |
* Filters a sanitized HTML class string. |
5 | 2336 |
* |
2337 |
* @since 2.8.0 |
|
2338 |
* |
|
2339 |
* @param string $sanitized The sanitized HTML class. |
|
2340 |
* @param string $class HTML class before sanitization. |
|
2341 |
* @param string $fallback The fallback string. |
|
2342 |
*/ |
|
0 | 2343 |
return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback ); |
2344 |
} |
|
2345 |
||
2346 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2347 |
* Converts lone & characters into `&` (a.k.a. `&`) |
0 | 2348 |
* |
2349 |
* @since 0.71 |
|
2350 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2351 |
* @param string $content String of characters to be converted. |
0 | 2352 |
* @param string $deprecated Not used. |
2353 |
* @return string Converted string. |
|
2354 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2355 |
function convert_chars( $content, $deprecated = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2356 |
if ( ! empty( $deprecated ) ) { |
0 | 2357 |
_deprecated_argument( __FUNCTION__, '0.71' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2358 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2359 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2360 |
if ( strpos( $content, '&' ) !== false ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2361 |
$content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2362 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2363 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2364 |
return $content; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2365 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2366 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2367 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2368 |
* Converts invalid Unicode references range to valid range. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2369 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2370 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2371 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2372 |
* @param string $content String with entities that need converting. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2373 |
* @return string Converted string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2374 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2375 |
function convert_invalid_entities( $content ) { |
0 | 2376 |
$wp_htmltranswinuni = array( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2377 |
'€' => '€', // the Euro sign |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2378 |
'' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2379 |
'‚' => '‚', // these are Windows CP1252 specific characters |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2380 |
'ƒ' => 'ƒ', // they would look weird on non-Windows browsers |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2381 |
'„' => '„', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2382 |
'…' => '…', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2383 |
'†' => '†', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2384 |
'‡' => '‡', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2385 |
'ˆ' => 'ˆ', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2386 |
'‰' => '‰', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2387 |
'Š' => 'Š', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2388 |
'‹' => '‹', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2389 |
'Œ' => 'Œ', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2390 |
'' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2391 |
'Ž' => 'Ž', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2392 |
'' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2393 |
'' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2394 |
'‘' => '‘', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2395 |
'’' => '’', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2396 |
'“' => '“', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2397 |
'”' => '”', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2398 |
'•' => '•', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2399 |
'–' => '–', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2400 |
'—' => '—', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2401 |
'˜' => '˜', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2402 |
'™' => '™', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2403 |
'š' => 'š', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2404 |
'›' => '›', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2405 |
'œ' => 'œ', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2406 |
'' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2407 |
'ž' => 'ž', |
9 | 2408 |
'Ÿ' => 'Ÿ', |
0 | 2409 |
); |
2410 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2411 |
if ( strpos( $content, '' ) !== false ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2412 |
$content = strtr( $content, $wp_htmltranswinuni ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2413 |
} |
0 | 2414 |
|
2415 |
return $content; |
|
2416 |
} |
|
2417 |
||
2418 |
/** |
|
2419 |
* Balances tags if forced to, or if the 'use_balanceTags' option is set to true. |
|
2420 |
* |
|
2421 |
* @since 0.71 |
|
2422 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2423 |
* @param string $text Text to be balanced |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2424 |
* @param bool $force If true, forces balancing, ignoring the value of the option. Default false. |
0 | 2425 |
* @return string Balanced text |
2426 |
*/ |
|
2427 |
function balanceTags( $text, $force = false ) { |
|
9 | 2428 |
if ( $force || get_option( 'use_balanceTags' ) == 1 ) { |
0 | 2429 |
return force_balance_tags( $text ); |
5 | 2430 |
} else { |
0 | 2431 |
return $text; |
5 | 2432 |
} |
0 | 2433 |
} |
2434 |
||
2435 |
/** |
|
2436 |
* Balances tags of string using a modified stack. |
|
2437 |
* |
|
2438 |
* @since 2.0.4 |
|
2439 |
* |
|
2440 |
* @author Leonard Lin <leonard@acm.org> |
|
2441 |
* @license GPL |
|
2442 |
* @copyright November 4, 2001 |
|
2443 |
* @version 1.1 |
|
2444 |
* @todo Make better - change loop condition to $text in 1.2 |
|
2445 |
* @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004 |
|
9 | 2446 |
* 1.1 Fixed handling of append/stack pop order of end text |
2447 |
* Added Cleaning Hooks |
|
2448 |
* 1.0 First Version |
|
0 | 2449 |
* |
2450 |
* @param string $text Text to be balanced. |
|
2451 |
* @return string Balanced text. |
|
2452 |
*/ |
|
2453 |
function force_balance_tags( $text ) { |
|
9 | 2454 |
$tagstack = array(); |
0 | 2455 |
$stacksize = 0; |
9 | 2456 |
$tagqueue = ''; |
2457 |
$newtext = ''; |
|
0 | 2458 |
// Known single-entity/self-closing tags |
2459 |
$single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' ); |
|
2460 |
// Tags that can be immediately nested within themselves |
|
2461 |
$nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' ); |
|
2462 |
||
2463 |
// WP bug fix for comments - in case you REALLY meant to type '< !--' |
|
9 | 2464 |
$text = str_replace( '< !--', '< !--', $text ); |
0 | 2465 |
// WP bug fix for LOVE <3 (and other situations with '<' before a number) |
9 | 2466 |
$text = preg_replace( '#<([0-9]{1})#', '<$1', $text ); |
2467 |
||
2468 |
while ( preg_match( '/<(\/?[\w:]*)\s*([^>]*)>/', $text, $regex ) ) { |
|
0 | 2469 |
$newtext .= $tagqueue; |
2470 |
||
9 | 2471 |
$i = strpos( $text, $regex[0] ); |
2472 |
$l = strlen( $regex[0] ); |
|
0 | 2473 |
|
2474 |
// clear the shifter |
|
2475 |
$tagqueue = ''; |
|
2476 |
// Pop or Push |
|
9 | 2477 |
if ( isset( $regex[1][0] ) && '/' == $regex[1][0] ) { // End Tag |
2478 |
$tag = strtolower( substr( $regex[1], 1 ) ); |
|
0 | 2479 |
// if too many closing tags |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2480 |
if ( $stacksize <= 0 ) { |
0 | 2481 |
$tag = ''; |
2482 |
// or close to be safe $tag = '/' . $tag; |
|
9 | 2483 |
|
2484 |
// if stacktop value = tag close value then pop |
|
2485 |
} elseif ( $tagstack[ $stacksize - 1 ] == $tag ) { // found closing tag |
|
0 | 2486 |
$tag = '</' . $tag . '>'; // Close Tag |
2487 |
// Pop |
|
2488 |
array_pop( $tagstack ); |
|
2489 |
$stacksize--; |
|
2490 |
} else { // closing tag not at top, search for it |
|
9 | 2491 |
for ( $j = $stacksize - 1; $j >= 0; $j-- ) { |
2492 |
if ( $tagstack[ $j ] == $tag ) { |
|
2493 |
// add tag to tagqueue |
|
2494 |
for ( $k = $stacksize - 1; $k >= $j; $k-- ) { |
|
0 | 2495 |
$tagqueue .= '</' . array_pop( $tagstack ) . '>'; |
2496 |
$stacksize--; |
|
2497 |
} |
|
2498 |
break; |
|
2499 |
} |
|
2500 |
} |
|
2501 |
$tag = ''; |
|
2502 |
} |
|
2503 |
} else { // Begin Tag |
|
9 | 2504 |
$tag = strtolower( $regex[1] ); |
0 | 2505 |
|
2506 |
// Tag Cleaning |
|
2507 |
||
2508 |
// If it's an empty tag "< >", do nothing |
|
2509 |
if ( '' == $tag ) { |
|
2510 |
// do nothing |
|
9 | 2511 |
} elseif ( substr( $regex[2], -1 ) == '/' ) { // ElseIf it presents itself as a self-closing tag... |
0 | 2512 |
// ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and |
2513 |
// immediately close it with a closing tag (the tag will encapsulate no text as a result) |
|
9 | 2514 |
if ( ! in_array( $tag, $single_tags ) ) { |
0 | 2515 |
$regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag"; |
9 | 2516 |
} |
2517 |
} elseif ( in_array( $tag, $single_tags ) ) { // ElseIf it's a known single-entity tag but it doesn't close itself, do so |
|
0 | 2518 |
$regex[2] .= '/'; |
9 | 2519 |
} else { // Else it's not a single-entity tag |
0 | 2520 |
// If the top of the stack is the same as the tag we want to push, close previous tag |
9 | 2521 |
if ( $stacksize > 0 && ! in_array( $tag, $nestable_tags ) && $tagstack[ $stacksize - 1 ] == $tag ) { |
0 | 2522 |
$tagqueue = '</' . array_pop( $tagstack ) . '>'; |
2523 |
$stacksize--; |
|
2524 |
} |
|
2525 |
$stacksize = array_push( $tagstack, $tag ); |
|
2526 |
} |
|
2527 |
||
2528 |
// Attributes |
|
2529 |
$attributes = $regex[2]; |
|
9 | 2530 |
if ( ! empty( $attributes ) && $attributes[0] != '>' ) { |
0 | 2531 |
$attributes = ' ' . $attributes; |
9 | 2532 |
} |
0 | 2533 |
|
2534 |
$tag = '<' . $tag . $attributes . '>'; |
|
2535 |
//If already queuing a close tag, then put this tag on, too |
|
9 | 2536 |
if ( ! empty( $tagqueue ) ) { |
0 | 2537 |
$tagqueue .= $tag; |
9 | 2538 |
$tag = ''; |
0 | 2539 |
} |
2540 |
} |
|
9 | 2541 |
$newtext .= substr( $text, 0, $i ) . $tag; |
2542 |
$text = substr( $text, $i + $l ); |
|
0 | 2543 |
} |
2544 |
||
2545 |
// Clear Tag Queue |
|
2546 |
$newtext .= $tagqueue; |
|
2547 |
||
2548 |
// Add Remaining text |
|
2549 |
$newtext .= $text; |
|
2550 |
||
2551 |
// Empty Stack |
|
9 | 2552 |
while ( $x = array_pop( $tagstack ) ) { |
0 | 2553 |
$newtext .= '</' . $x . '>'; // Add remaining tags to close |
9 | 2554 |
} |
0 | 2555 |
|
2556 |
// WP fix for the bug with HTML comments |
|
9 | 2557 |
$newtext = str_replace( '< !--', '<!--', $newtext ); |
2558 |
$newtext = str_replace( '< !--', '< !--', $newtext ); |
|
0 | 2559 |
|
2560 |
return $newtext; |
|
2561 |
} |
|
2562 |
||
2563 |
/** |
|
2564 |
* Acts on text which is about to be edited. |
|
2565 |
* |
|
2566 |
* The $content is run through esc_textarea(), which uses htmlspecialchars() |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2567 |
* to convert special characters to HTML entities. If `$richedit` is set to true, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2568 |
* it is simply a holder for the {@see 'format_to_edit'} filter. |
0 | 2569 |
* |
2570 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2571 |
* @since 4.4.0 The `$richedit` parameter was renamed to `$rich_text` for clarity. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2572 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2573 |
* @param string $content The text about to be edited. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2574 |
* @param bool $rich_text Optional. Whether `$content` should be considered rich text, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2575 |
* in which case it would not be passed through esc_textarea(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2576 |
* Default false. |
0 | 2577 |
* @return string The text after the filter (and possibly htmlspecialchars()) has been run. |
2578 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2579 |
function format_to_edit( $content, $rich_text = false ) { |
5 | 2580 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2581 |
* Filters the text to be formatted for editing. |
5 | 2582 |
* |
2583 |
* @since 1.2.0 |
|
2584 |
* |
|
2585 |
* @param string $content The text, prior to formatting for editing. |
|
2586 |
*/ |
|
0 | 2587 |
$content = apply_filters( 'format_to_edit', $content ); |
9 | 2588 |
if ( ! $rich_text ) { |
0 | 2589 |
$content = esc_textarea( $content ); |
9 | 2590 |
} |
0 | 2591 |
return $content; |
2592 |
} |
|
2593 |
||
2594 |
/** |
|
2595 |
* Add leading zeros when necessary. |
|
2596 |
* |
|
2597 |
* If you set the threshold to '4' and the number is '10', then you will get |
|
2598 |
* back '0010'. If you set the threshold to '4' and the number is '5000', then you |
|
2599 |
* will get back '5000'. |
|
2600 |
* |
|
2601 |
* Uses sprintf to append the amount of zeros based on the $threshold parameter |
|
2602 |
* and the size of the number. If the number is large enough, then no zeros will |
|
2603 |
* be appended. |
|
2604 |
* |
|
2605 |
* @since 0.71 |
|
2606 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2607 |
* @param int $number Number to append zeros to if not greater than threshold. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2608 |
* @param int $threshold Digit places number needs to be to not have zeros added. |
0 | 2609 |
* @return string Adds leading zeros to number if needed. |
2610 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2611 |
function zeroise( $number, $threshold ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2612 |
return sprintf( '%0' . $threshold . 's', $number ); |
0 | 2613 |
} |
2614 |
||
2615 |
/** |
|
2616 |
* Adds backslashes before letters and before a number at the start of a string. |
|
2617 |
* |
|
2618 |
* @since 0.71 |
|
2619 |
* |
|
2620 |
* @param string $string Value to which backslashes will be added. |
|
2621 |
* @return string String with backslashes inserted. |
|
2622 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2623 |
function backslashit( $string ) { |
9 | 2624 |
if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) { |
0 | 2625 |
$string = '\\\\' . $string; |
9 | 2626 |
} |
0 | 2627 |
return addcslashes( $string, 'A..Za..z' ); |
2628 |
} |
|
2629 |
||
2630 |
/** |
|
2631 |
* Appends a trailing slash. |
|
2632 |
* |
|
5 | 2633 |
* Will remove trailing forward and backslashes if it exists already before adding |
2634 |
* a trailing forward slash. This prevents double slashing a string or path. |
|
0 | 2635 |
* |
2636 |
* The primary use of this is for paths and thus should be used for paths. It is |
|
2637 |
* not restricted to paths and offers no specific path support. |
|
2638 |
* |
|
2639 |
* @since 1.2.0 |
|
2640 |
* |
|
2641 |
* @param string $string What to add the trailing slash to. |
|
2642 |
* @return string String with trailing slash added. |
|
2643 |
*/ |
|
5 | 2644 |
function trailingslashit( $string ) { |
2645 |
return untrailingslashit( $string ) . '/'; |
|
0 | 2646 |
} |
2647 |
||
2648 |
/** |
|
5 | 2649 |
* Removes trailing forward slashes and backslashes if they exist. |
0 | 2650 |
* |
2651 |
* The primary use of this is for paths and thus should be used for paths. It is |
|
2652 |
* not restricted to paths and offers no specific path support. |
|
2653 |
* |
|
2654 |
* @since 2.2.0 |
|
2655 |
* |
|
5 | 2656 |
* @param string $string What to remove the trailing slashes from. |
2657 |
* @return string String without the trailing slashes. |
|
0 | 2658 |
*/ |
5 | 2659 |
function untrailingslashit( $string ) { |
2660 |
return rtrim( $string, '/\\' ); |
|
0 | 2661 |
} |
2662 |
||
2663 |
/** |
|
2664 |
* Adds slashes to escape strings. |
|
2665 |
* |
|
2666 |
* Slashes will first be removed if magic_quotes_gpc is set, see {@link |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2667 |
* https://secure.php.net/magic_quotes} for more details. |
0 | 2668 |
* |
2669 |
* @since 0.71 |
|
2670 |
* |
|
2671 |
* @param string $gpc The string returned from HTTP request data. |
|
2672 |
* @return string Returns a string escaped with slashes. |
|
2673 |
*/ |
|
9 | 2674 |
function addslashes_gpc( $gpc ) { |
2675 |
if ( get_magic_quotes_gpc() ) { |
|
2676 |
$gpc = stripslashes( $gpc ); |
|
2677 |
} |
|
2678 |
||
2679 |
return wp_slash( $gpc ); |
|
0 | 2680 |
} |
2681 |
||
2682 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2683 |
* Navigates through an array, object, or scalar, and removes slashes from the values. |
0 | 2684 |
* |
2685 |
* @since 2.0.0 |
|
2686 |
* |
|
2687 |
* @param mixed $value The value to be stripped. |
|
2688 |
* @return mixed Stripped value. |
|
2689 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2690 |
function stripslashes_deep( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2691 |
return map_deep( $value, 'stripslashes_from_strings_only' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2692 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2693 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2694 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2695 |
* Callback function for `stripslashes_deep()` which strips slashes from strings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2696 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2697 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2698 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2699 |
* @param mixed $value The array or string to be stripped. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2700 |
* @return mixed $value The stripped value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2701 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2702 |
function stripslashes_from_strings_only( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2703 |
return is_string( $value ) ? stripslashes( $value ) : $value; |
0 | 2704 |
} |
2705 |
||
2706 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2707 |
* Navigates through an array, object, or scalar, and encodes the values to be used in a URL. |
0 | 2708 |
* |
2709 |
* @since 2.2.0 |
|
2710 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2711 |
* @param mixed $value The array or string to be encoded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2712 |
* @return mixed $value The encoded value. |
0 | 2713 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2714 |
function urlencode_deep( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2715 |
return map_deep( $value, 'urlencode' ); |
0 | 2716 |
} |
2717 |
||
2718 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2719 |
* Navigates through an array, object, or scalar, and raw-encodes the values to be used in a URL. |
0 | 2720 |
* |
2721 |
* @since 3.4.0 |
|
2722 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2723 |
* @param mixed $value The array or string to be encoded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2724 |
* @return mixed $value The encoded value. |
0 | 2725 |
*/ |
2726 |
function rawurlencode_deep( $value ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2727 |
return map_deep( $value, 'rawurlencode' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2728 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2729 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2730 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2731 |
* Navigates through an array, object, or scalar, and decodes URL-encoded values |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2732 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2733 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2734 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2735 |
* @param mixed $value The array or string to be decoded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2736 |
* @return mixed $value The decoded value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2737 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2738 |
function urldecode_deep( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2739 |
return map_deep( $value, 'urldecode' ); |
0 | 2740 |
} |
2741 |
||
2742 |
/** |
|
2743 |
* Converts email addresses characters to HTML entities to block spam bots. |
|
2744 |
* |
|
2745 |
* @since 0.71 |
|
2746 |
* |
|
2747 |
* @param string $email_address Email address. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2748 |
* @param int $hex_encoding Optional. Set to 1 to enable hex encoding. |
0 | 2749 |
* @return string Converted email address. |
2750 |
*/ |
|
2751 |
function antispambot( $email_address, $hex_encoding = 0 ) { |
|
2752 |
$email_no_spam_address = ''; |
|
5 | 2753 |
for ( $i = 0, $len = strlen( $email_address ); $i < $len; $i++ ) { |
0 | 2754 |
$j = rand( 0, 1 + $hex_encoding ); |
2755 |
if ( $j == 0 ) { |
|
9 | 2756 |
$email_no_spam_address .= '&#' . ord( $email_address[ $i ] ) . ';'; |
0 | 2757 |
} elseif ( $j == 1 ) { |
9 | 2758 |
$email_no_spam_address .= $email_address[ $i ]; |
0 | 2759 |
} elseif ( $j == 2 ) { |
9 | 2760 |
$email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[ $i ] ) ), 2 ); |
0 | 2761 |
} |
2762 |
} |
|
2763 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2764 |
return str_replace( '@', '@', $email_no_spam_address ); |
0 | 2765 |
} |
2766 |
||
2767 |
/** |
|
2768 |
* Callback to convert URI match to HTML A element. |
|
2769 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2770 |
* This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable(). |
0 | 2771 |
* |
2772 |
* @since 2.3.2 |
|
2773 |
* @access private |
|
2774 |
* |
|
2775 |
* @param array $matches Single Regex Match. |
|
2776 |
* @return string HTML A element with URI address. |
|
2777 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2778 |
function _make_url_clickable_cb( $matches ) { |
0 | 2779 |
$url = $matches[2]; |
2780 |
||
2781 |
if ( ')' == $matches[3] && strpos( $url, '(' ) ) { |
|
2782 |
// If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL. |
|
2783 |
// Then we can let the parenthesis balancer do its thing below. |
|
9 | 2784 |
$url .= $matches[3]; |
0 | 2785 |
$suffix = ''; |
2786 |
} else { |
|
2787 |
$suffix = $matches[3]; |
|
2788 |
} |
|
2789 |
||
2790 |
// Include parentheses in the URL only if paired |
|
2791 |
while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { |
|
2792 |
$suffix = strrchr( $url, ')' ) . $suffix; |
|
9 | 2793 |
$url = substr( $url, 0, strrpos( $url, ')' ) ); |
0 | 2794 |
} |
2795 |
||
9 | 2796 |
$url = esc_url( $url ); |
2797 |
if ( empty( $url ) ) { |
|
0 | 2798 |
return $matches[0]; |
9 | 2799 |
} |
0 | 2800 |
|
2801 |
return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix; |
|
2802 |
} |
|
2803 |
||
2804 |
/** |
|
2805 |
* Callback to convert URL match to HTML A element. |
|
2806 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2807 |
* This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable(). |
0 | 2808 |
* |
2809 |
* @since 2.3.2 |
|
2810 |
* @access private |
|
2811 |
* |
|
2812 |
* @param array $matches Single Regex Match. |
|
2813 |
* @return string HTML A element with URL address. |
|
2814 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2815 |
function _make_web_ftp_clickable_cb( $matches ) { |
9 | 2816 |
$ret = ''; |
0 | 2817 |
$dest = $matches[2]; |
2818 |
$dest = 'http://' . $dest; |
|
2819 |
||
2820 |
// removed trailing [.,;:)] from URL |
|
9 | 2821 |
if ( in_array( substr( $dest, -1 ), array( '.', ',', ';', ':', ')' ) ) === true ) { |
2822 |
$ret = substr( $dest, -1 ); |
|
2823 |
$dest = substr( $dest, 0, strlen( $dest ) - 1 ); |
|
0 | 2824 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2825 |
|
9 | 2826 |
$dest = esc_url( $dest ); |
2827 |
if ( empty( $dest ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2828 |
return $matches[0]; |
9 | 2829 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2830 |
|
0 | 2831 |
return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret"; |
2832 |
} |
|
2833 |
||
2834 |
/** |
|
2835 |
* Callback to convert email address match to HTML A element. |
|
2836 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2837 |
* This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable(). |
0 | 2838 |
* |
2839 |
* @since 2.3.2 |
|
2840 |
* @access private |
|
2841 |
* |
|
2842 |
* @param array $matches Single Regex Match. |
|
2843 |
* @return string HTML A element with email address. |
|
2844 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2845 |
function _make_email_clickable_cb( $matches ) { |
0 | 2846 |
$email = $matches[2] . '@' . $matches[3]; |
2847 |
return $matches[1] . "<a href=\"mailto:$email\">$email</a>"; |
|
2848 |
} |
|
2849 |
||
2850 |
/** |
|
2851 |
* Convert plaintext URI to HTML links. |
|
2852 |
* |
|
2853 |
* Converts URI, www and ftp, and email addresses. Finishes by fixing links |
|
2854 |
* within links. |
|
2855 |
* |
|
2856 |
* @since 0.71 |
|
2857 |
* |
|
2858 |
* @param string $text Content to convert URIs. |
|
2859 |
* @return string Content with converted URIs. |
|
2860 |
*/ |
|
2861 |
function make_clickable( $text ) { |
|
9 | 2862 |
$r = ''; |
2863 |
$textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags |
|
5 | 2864 |
$nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code> |
0 | 2865 |
foreach ( $textarr as $piece ) { |
5 | 2866 |
|
9 | 2867 |
if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) || preg_match( '|^<script[\s>]|i', $piece ) || preg_match( '|^<style[\s>]|i', $piece ) ) { |
5 | 2868 |
$nested_code_pre++; |
9 | 2869 |
} elseif ( $nested_code_pre && ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) || '</script>' === strtolower( $piece ) || '</style>' === strtolower( $piece ) ) ) { |
5 | 2870 |
$nested_code_pre--; |
9 | 2871 |
} |
5 | 2872 |
|
2873 |
if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) { |
|
0 | 2874 |
$r .= $piece; |
2875 |
continue; |
|
2876 |
} |
|
2877 |
||
2878 |
// Long strings might contain expensive edge cases ... |
|
2879 |
if ( 10000 < strlen( $piece ) ) { |
|
2880 |
// ... break it up |
|
2881 |
foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses |
|
2882 |
if ( 2101 < strlen( $chunk ) ) { |
|
2883 |
$r .= $chunk; // Too big, no whitespace: bail. |
|
2884 |
} else { |
|
2885 |
$r .= make_clickable( $chunk ); |
|
2886 |
} |
|
2887 |
} |
|
2888 |
} else { |
|
2889 |
$ret = " $piece "; // Pad with whitespace to simplify the regexes |
|
2890 |
||
2891 |
$url_clickable = '~ |
|
2892 |
([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation |
|
2893 |
( # 2: URL |
|
2894 |
[\\w]{1,20}+:// # Scheme and hier-part prefix |
|
2895 |
(?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long |
|
2896 |
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character |
|
2897 |
(?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character |
|
2898 |
[\'.,;:!?)] # Punctuation URL character |
|
2899 |
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character |
|
2900 |
)* |
|
2901 |
) |
|
2902 |
(\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing) |
|
2903 |
~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character. |
|
9 | 2904 |
// Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. |
0 | 2905 |
|
2906 |
$ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); |
|
2907 |
||
2908 |
$ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); |
|
2909 |
$ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); |
|
2910 |
||
2911 |
$ret = substr( $ret, 1, -1 ); // Remove our whitespace padding. |
|
9 | 2912 |
$r .= $ret; |
0 | 2913 |
} |
2914 |
} |
|
2915 |
||
2916 |
// Cleanup of accidental links within links |
|
9 | 2917 |
return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', '$1$3</a>', $r ); |
0 | 2918 |
} |
2919 |
||
2920 |
/** |
|
2921 |
* Breaks a string into chunks by splitting at whitespace characters. |
|
2922 |
* The length of each returned chunk is as close to the specified length goal as possible, |
|
2923 |
* with the caveat that each chunk includes its trailing delimiter. |
|
2924 |
* Chunks longer than the goal are guaranteed to not have any inner whitespace. |
|
2925 |
* |
|
2926 |
* Joining the returned chunks with empty delimiters reconstructs the input string losslessly. |
|
2927 |
* |
|
2928 |
* Input string must have no null characters (or eventual transformations on output chunks must not care about null characters) |
|
2929 |
* |
|
5 | 2930 |
* _split_str_by_whitespace( "1234 67890 1234 67890a cd 1234 890 123456789 1234567890a 45678 1 3 5 7 90 ", 10 ) == |
2931 |
* array ( |
|
2932 |
* 0 => '1234 67890 ', // 11 characters: Perfect split |
|
2933 |
* 1 => '1234 ', // 5 characters: '1234 67890a' was too long |
|
2934 |
* 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long |
|
2935 |
* 3 => '1234 890 ', // 11 characters: Perfect split |
|
2936 |
* 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long |
|
2937 |
* 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split |
|
2938 |
* 6 => ' 45678 ', // 11 characters: Perfect split |
|
2939 |
* 7 => '1 3 5 7 90 ', // 11 characters: End of $string |
|
2940 |
* ); |
|
0 | 2941 |
* |
2942 |
* @since 3.4.0 |
|
2943 |
* @access private |
|
2944 |
* |
|
2945 |
* @param string $string The string to split. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2946 |
* @param int $goal The desired chunk length. |
0 | 2947 |
* @return array Numeric array of chunks. |
2948 |
*/ |
|
2949 |
function _split_str_by_whitespace( $string, $goal ) { |
|
2950 |
$chunks = array(); |
|
2951 |
||
2952 |
$string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" ); |
|
2953 |
||
2954 |
while ( $goal < strlen( $string_nullspace ) ) { |
|
2955 |
$pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" ); |
|
2956 |
||
2957 |
if ( false === $pos ) { |
|
2958 |
$pos = strpos( $string_nullspace, "\000", $goal + 1 ); |
|
2959 |
if ( false === $pos ) { |
|
2960 |
break; |
|
2961 |
} |
|
2962 |
} |
|
2963 |
||
9 | 2964 |
$chunks[] = substr( $string, 0, $pos + 1 ); |
2965 |
$string = substr( $string, $pos + 1 ); |
|
0 | 2966 |
$string_nullspace = substr( $string_nullspace, $pos + 1 ); |
2967 |
} |
|
2968 |
||
2969 |
if ( $string ) { |
|
2970 |
$chunks[] = $string; |
|
2971 |
} |
|
2972 |
||
2973 |
return $chunks; |
|
2974 |
} |
|
2975 |
||
2976 |
/** |
|
2977 |
* Adds rel nofollow string to all HTML A elements in content. |
|
2978 |
* |
|
2979 |
* @since 1.5.0 |
|
2980 |
* |
|
2981 |
* @param string $text Content that may contain HTML A elements. |
|
2982 |
* @return string Converted content. |
|
2983 |
*/ |
|
2984 |
function wp_rel_nofollow( $text ) { |
|
2985 |
// This is a pre save filter, so text is already escaped. |
|
9 | 2986 |
$text = stripslashes( $text ); |
2987 |
$text = preg_replace_callback( '|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2988 |
return wp_slash( $text ); |
0 | 2989 |
} |
2990 |
||
2991 |
/** |
|
2992 |
* Callback to add rel=nofollow string to HTML A element. |
|
2993 |
* |
|
2994 |
* Will remove already existing rel="nofollow" and rel='nofollow' from the |
|
2995 |
* string to prevent from invalidating (X)HTML. |
|
2996 |
* |
|
2997 |
* @since 2.3.0 |
|
2998 |
* |
|
2999 |
* @param array $matches Single Match |
|
3000 |
* @return string HTML A Element with rel nofollow. |
|
3001 |
*/ |
|
3002 |
function wp_rel_nofollow_callback( $matches ) { |
|
3003 |
$text = $matches[1]; |
|
9 | 3004 |
$atts = wp_kses_hair( $matches[1], wp_allowed_protocols() ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3005 |
$rel = 'nofollow'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3006 |
|
9 | 3007 |
if ( ! empty( $atts['href'] ) ) { |
3008 |
if ( in_array( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) { |
|
3009 |
if ( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) { |
|
3010 |
return "<a $text>"; |
|
3011 |
} |
|
3012 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3013 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3014 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3015 |
if ( ! empty( $atts['rel'] ) ) { |
9 | 3016 |
$parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3017 |
if ( false === array_search( 'nofollow', $parts ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3018 |
$parts[] = 'nofollow'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3019 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3020 |
$rel = implode( ' ', $parts ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3021 |
unset( $atts['rel'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3022 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3023 |
$html = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3024 |
foreach ( $atts as $name => $value ) { |
9 | 3025 |
if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) { |
3026 |
$html .= $name . ' '; |
|
3027 |
} else { |
|
3028 |
$html .= "{$name}=\"" . esc_attr( $value['value'] ) . '" '; |
|
3029 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3030 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3031 |
$text = trim( $html ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3032 |
} |
9 | 3033 |
return "<a $text rel=\"" . esc_attr( $rel ) . '">'; |
3034 |
} |
|
3035 |
||
3036 |
/** |
|
3037 |
* Adds rel noreferrer and noopener to all HTML A elements that have a target. |
|
3038 |
* |
|
3039 |
* @since 5.1.0 |
|
3040 |
* |
|
3041 |
* @param string $text Content that may contain HTML A elements. |
|
3042 |
* @return string Converted content. |
|
3043 |
*/ |
|
3044 |
function wp_targeted_link_rel( $text ) { |
|
3045 |
// Don't run (more expensive) regex if no links with targets. |
|
3046 |
if ( stripos( $text, 'target' ) !== false && stripos( $text, '<a ' ) !== false ) { |
|
3047 |
$text = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $text ); |
|
3048 |
} |
|
3049 |
||
3050 |
return $text; |
|
3051 |
} |
|
3052 |
||
3053 |
/** |
|
3054 |
* Callback to add rel="noreferrer noopener" string to HTML A element. |
|
3055 |
* |
|
3056 |
* Will not duplicate existing noreferrer and noopener values |
|
3057 |
* to prevent from invalidating the HTML. |
|
3058 |
* |
|
3059 |
* @since 5.1.0 |
|
3060 |
* |
|
3061 |
* @param array $matches Single Match |
|
3062 |
* @return string HTML A Element with rel noreferrer noopener in addition to any existing values |
|
3063 |
*/ |
|
3064 |
function wp_targeted_link_rel_callback( $matches ) { |
|
3065 |
$link_html = $matches[1]; |
|
3066 |
$rel_match = array(); |
|
3067 |
||
3068 |
/** |
|
3069 |
* Filters the rel values that are added to links with `target` attribute. |
|
3070 |
* |
|
3071 |
* @since 5.1.0 |
|
3072 |
* |
|
3073 |
* @param string The rel values. |
|
3074 |
* @param string $link_html The matched content of the link tag including all HTML attributes. |
|
3075 |
*/ |
|
3076 |
$rel = apply_filters( 'wp_targeted_link_rel', 'noopener noreferrer', $link_html ); |
|
3077 |
||
3078 |
// Avoid additional regex if the filter removes rel values. |
|
3079 |
if ( ! $rel ) { |
|
3080 |
return "<a $link_html>"; |
|
3081 |
} |
|
3082 |
||
3083 |
// Value with delimiters, spaces around are optional. |
|
3084 |
$attr_regex = '|rel\s*=\s*?(\\\\{0,1}["\'])(.*?)\\1|i'; |
|
3085 |
preg_match( $attr_regex, $link_html, $rel_match ); |
|
3086 |
||
3087 |
if ( empty( $rel_match[0] ) ) { |
|
3088 |
// No delimiters, try with a single value and spaces, because `rel = va"lue` is totally fine... |
|
3089 |
$attr_regex = '|rel\s*=(\s*)([^\s]*)|i'; |
|
3090 |
preg_match( $attr_regex, $link_html, $rel_match ); |
|
3091 |
} |
|
3092 |
||
3093 |
if ( ! empty( $rel_match[0] ) ) { |
|
3094 |
$parts = preg_split( '|\s+|', strtolower( $rel_match[2] ) ); |
|
3095 |
$parts = array_map( 'esc_attr', $parts ); |
|
3096 |
$needed = explode( ' ', $rel ); |
|
3097 |
$parts = array_unique( array_merge( $parts, $needed ) ); |
|
3098 |
$delimiter = trim( $rel_match[1] ) ? $rel_match[1] : '"'; |
|
3099 |
$rel = 'rel=' . $delimiter . trim( implode( ' ', $parts ) ) . $delimiter; |
|
3100 |
$link_html = str_replace( $rel_match[0], $rel, $link_html ); |
|
3101 |
} elseif ( preg_match( '|target\s*=\s*?\\\\"|', $link_html ) ) { |
|
3102 |
$link_html .= " rel=\\\"$rel\\\""; |
|
3103 |
} elseif ( preg_match( '#(target|href)\s*=\s*?\'#', $link_html ) ) { |
|
3104 |
$link_html .= " rel='$rel'"; |
|
3105 |
} else { |
|
3106 |
$link_html .= " rel=\"$rel\""; |
|
3107 |
} |
|
3108 |
||
3109 |
return "<a $link_html>"; |
|
3110 |
} |
|
3111 |
||
3112 |
/** |
|
3113 |
* Adds all filters modifying the rel attribute of targeted links. |
|
3114 |
* |
|
3115 |
* @since 5.1.0 |
|
3116 |
*/ |
|
3117 |
function wp_init_targeted_link_rel_filters() { |
|
3118 |
$filters = array( |
|
3119 |
'title_save_pre', |
|
3120 |
'content_save_pre', |
|
3121 |
'excerpt_save_pre', |
|
3122 |
'content_filtered_save_pre', |
|
3123 |
'pre_comment_content', |
|
3124 |
'pre_term_description', |
|
3125 |
'pre_link_description', |
|
3126 |
'pre_link_notes', |
|
3127 |
'pre_user_description', |
|
3128 |
); |
|
3129 |
||
3130 |
foreach ( $filters as $filter ) { |
|
3131 |
add_filter( $filter, 'wp_targeted_link_rel' ); |
|
3132 |
}; |
|
3133 |
} |
|
3134 |
||
3135 |
/** |
|
3136 |
* Removes all filters modifying the rel attribute of targeted links. |
|
3137 |
* |
|
3138 |
* @since 5.1.0 |
|
3139 |
*/ |
|
3140 |
function wp_remove_targeted_link_rel_filters() { |
|
3141 |
$filters = array( |
|
3142 |
'title_save_pre', |
|
3143 |
'content_save_pre', |
|
3144 |
'excerpt_save_pre', |
|
3145 |
'content_filtered_save_pre', |
|
3146 |
'pre_comment_content', |
|
3147 |
'pre_term_description', |
|
3148 |
'pre_link_description', |
|
3149 |
'pre_link_notes', |
|
3150 |
'pre_user_description', |
|
3151 |
); |
|
3152 |
||
3153 |
foreach ( $filters as $filter ) { |
|
3154 |
remove_filter( $filter, 'wp_targeted_link_rel' ); |
|
3155 |
}; |
|
0 | 3156 |
} |
3157 |
||
3158 |
/** |
|
3159 |
* Convert one smiley code to the icon graphic file equivalent. |
|
3160 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3161 |
* Callback handler for convert_smilies(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3162 |
* |
0 | 3163 |
* Looks up one smiley code in the $wpsmiliestrans global array and returns an |
5 | 3164 |
* `<img>` string for that smiley. |
0 | 3165 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3166 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3167 |
* |
0 | 3168 |
* @global array $wpsmiliestrans |
3169 |
* |
|
3170 |
* @param array $matches Single match. Smiley code to convert to image. |
|
3171 |
* @return string Image string for smiley. |
|
3172 |
*/ |
|
3173 |
function translate_smiley( $matches ) { |
|
3174 |
global $wpsmiliestrans; |
|
3175 |
||
9 | 3176 |
if ( count( $matches ) == 0 ) { |
0 | 3177 |
return ''; |
9 | 3178 |
} |
0 | 3179 |
|
3180 |
$smiley = trim( reset( $matches ) ); |
|
9 | 3181 |
$img = $wpsmiliestrans[ $smiley ]; |
3182 |
||
3183 |
$matches = array(); |
|
3184 |
$ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false; |
|
5 | 3185 |
$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ); |
3186 |
||
3187 |
// Don't convert smilies that aren't images - they're probably emoji. |
|
3188 |
if ( ! in_array( $ext, $image_exts ) ) { |
|
3189 |
return $img; |
|
3190 |
} |
|
3191 |
||
3192 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3193 |
* Filters the Smiley image URL before it's used in the image element. |
5 | 3194 |
* |
3195 |
* @since 2.9.0 |
|
3196 |
* |
|
3197 |
* @param string $smiley_url URL for the smiley image. |
|
3198 |
* @param string $img Filename for the smiley image. |
|
3199 |
* @param string $site_url Site URL, as returned by site_url(). |
|
3200 |
*/ |
|
0 | 3201 |
$src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() ); |
3202 |
||
5 | 3203 |
return sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', esc_url( $src_url ), esc_attr( $smiley ) ); |
0 | 3204 |
} |
3205 |
||
3206 |
/** |
|
3207 |
* Convert text equivalent of smilies to images. |
|
3208 |
* |
|
3209 |
* Will only convert smilies if the option 'use_smilies' is true and the global |
|
3210 |
* used in the function isn't empty. |
|
3211 |
* |
|
3212 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3213 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3214 |
* @global string|array $wp_smiliessearch |
0 | 3215 |
* |
3216 |
* @param string $text Content to convert smilies from text. |
|
3217 |
* @return string Converted content with text smilies replaced with images. |
|
3218 |
*/ |
|
5 | 3219 |
function convert_smilies( $text ) { |
0 | 3220 |
global $wp_smiliessearch; |
3221 |
$output = ''; |
|
5 | 3222 |
if ( get_option( 'use_smilies' ) && ! empty( $wp_smiliessearch ) ) { |
0 | 3223 |
// HTML loop taken from texturize function, could possible be consolidated |
5 | 3224 |
$textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between |
9 | 3225 |
$stop = count( $textarr );// loop stuff |
5 | 3226 |
|
3227 |
// Ignore proessing of specific tags |
|
9 | 3228 |
$tags_to_ignore = 'code|pre|style|script|textarea'; |
5 | 3229 |
$ignore_block_element = ''; |
3230 |
||
3231 |
for ( $i = 0; $i < $stop; $i++ ) { |
|
9 | 3232 |
$content = $textarr[ $i ]; |
5 | 3233 |
|
3234 |
// If we're in an ignore block, wait until we find its closing tag |
|
9 | 3235 |
if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) { |
5 | 3236 |
$ignore_block_element = $matches[1]; |
0 | 3237 |
} |
5 | 3238 |
|
3239 |
// If it's not a tag and not in ignore block |
|
9 | 3240 |
if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) { |
5 | 3241 |
$content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content ); |
3242 |
} |
|
3243 |
||
3244 |
// did we exit ignore block |
|
9 | 3245 |
if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) { |
5 | 3246 |
$ignore_block_element = ''; |
3247 |
} |
|
3248 |
||
0 | 3249 |
$output .= $content; |
3250 |
} |
|
3251 |
} else { |
|
3252 |
// return default text. |
|
3253 |
$output = $text; |
|
3254 |
} |
|
3255 |
return $output; |
|
3256 |
} |
|
3257 |
||
3258 |
/** |
|
3259 |
* Verifies that an email is valid. |
|
3260 |
* |
|
3261 |
* Does not grok i18n domains. Not RFC compliant. |
|
3262 |
* |
|
3263 |
* @since 0.71 |
|
3264 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3265 |
* @param string $email Email address to verify. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3266 |
* @param bool $deprecated Deprecated. |
0 | 3267 |
* @return string|bool Either false or the valid email address. |
3268 |
*/ |
|
3269 |
function is_email( $email, $deprecated = false ) { |
|
9 | 3270 |
if ( ! empty( $deprecated ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3271 |
_deprecated_argument( __FUNCTION__, '3.0.0' ); |
9 | 3272 |
} |
0 | 3273 |
|
3274 |
// Test for the minimum length the email can be |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3275 |
if ( strlen( $email ) < 6 ) { |
5 | 3276 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3277 |
* Filters whether an email address is valid. |
5 | 3278 |
* |
3279 |
* This filter is evaluated under several different contexts, such as 'email_too_short', |
|
3280 |
* 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
|
3281 |
* 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context. |
|
3282 |
* |
|
3283 |
* @since 2.8.0 |
|
3284 |
* |
|
3285 |
* @param bool $is_email Whether the email address has passed the is_email() checks. Default false. |
|
3286 |
* @param string $email The email address being checked. |
|
3287 |
* @param string $context Context under which the email was tested. |
|
3288 |
*/ |
|
0 | 3289 |
return apply_filters( 'is_email', false, $email, 'email_too_short' ); |
3290 |
} |
|
3291 |
||
3292 |
// Test for an @ character after the first position |
|
3293 |
if ( strpos( $email, '@', 1 ) === false ) { |
|
5 | 3294 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3295 |
return apply_filters( 'is_email', false, $email, 'email_no_at' ); |
3296 |
} |
|
3297 |
||
3298 |
// Split out the local and domain parts |
|
3299 |
list( $local, $domain ) = explode( '@', $email, 2 ); |
|
3300 |
||
3301 |
// LOCAL PART |
|
3302 |
// Test for invalid characters |
|
9 | 3303 |
if ( ! preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { |
5 | 3304 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3305 |
return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); |
3306 |
} |
|
3307 |
||
3308 |
// DOMAIN PART |
|
3309 |
// Test for sequences of periods |
|
3310 |
if ( preg_match( '/\.{2,}/', $domain ) ) { |
|
5 | 3311 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3312 |
return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); |
3313 |
} |
|
3314 |
||
3315 |
// Test for leading and trailing periods and whitespace |
|
3316 |
if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { |
|
5 | 3317 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3318 |
return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); |
3319 |
} |
|
3320 |
||
3321 |
// Split the domain into subs |
|
3322 |
$subs = explode( '.', $domain ); |
|
3323 |
||
3324 |
// Assume the domain will have at least two subs |
|
3325 |
if ( 2 > count( $subs ) ) { |
|
5 | 3326 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3327 |
return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); |
3328 |
} |
|
3329 |
||
3330 |
// Loop through each sub |
|
3331 |
foreach ( $subs as $sub ) { |
|
3332 |
// Test for leading and trailing hyphens and whitespace |
|
3333 |
if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { |
|
5 | 3334 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3335 |
return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); |
3336 |
} |
|
3337 |
||
3338 |
// Test for invalid characters |
|
9 | 3339 |
if ( ! preg_match( '/^[a-z0-9-]+$/i', $sub ) ) { |
5 | 3340 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3341 |
return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); |
3342 |
} |
|
3343 |
} |
|
3344 |
||
3345 |
// Congratulations your email made it! |
|
5 | 3346 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3347 |
return apply_filters( 'is_email', $email, $email, null ); |
3348 |
} |
|
3349 |
||
3350 |
/** |
|
3351 |
* Convert to ASCII from email subjects. |
|
3352 |
* |
|
3353 |
* @since 1.2.0 |
|
3354 |
* |
|
3355 |
* @param string $string Subject line |
|
3356 |
* @return string Converted string to ASCII |
|
3357 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3358 |
function wp_iso_descrambler( $string ) { |
0 | 3359 |
/* this may only work with iso-8859-1, I'm afraid */ |
9 | 3360 |
if ( ! preg_match( '#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches ) ) { |
0 | 3361 |
return $string; |
3362 |
} else { |
|
9 | 3363 |
$subject = str_replace( '_', ' ', $matches[2] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3364 |
return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject ); |
0 | 3365 |
} |
3366 |
} |
|
3367 |
||
3368 |
/** |
|
3369 |
* Helper function to convert hex encoded chars to ASCII |
|
3370 |
* |
|
3371 |
* @since 3.1.0 |
|
3372 |
* @access private |
|
3373 |
* |
|
3374 |
* @param array $match The preg_replace_callback matches array |
|
5 | 3375 |
* @return string Converted chars |
0 | 3376 |
*/ |
3377 |
function _wp_iso_convert( $match ) { |
|
3378 |
return chr( hexdec( strtolower( $match[1] ) ) ); |
|
3379 |
} |
|
3380 |
||
3381 |
/** |
|
3382 |
* Returns a date in the GMT equivalent. |
|
3383 |
* |
|
3384 |
* Requires and returns a date in the Y-m-d H:i:s format. If there is a |
|
3385 |
* timezone_string available, the date is assumed to be in that timezone, |
|
3386 |
* otherwise it simply subtracts the value of the 'gmt_offset' option. Return |
|
3387 |
* format can be overridden using the $format parameter. |
|
3388 |
* |
|
3389 |
* @since 1.2.0 |
|
3390 |
* |
|
3391 |
* @param string $string The date to be converted. |
|
3392 |
* @param string $format The format string for the returned date (default is Y-m-d H:i:s) |
|
3393 |
* @return string GMT version of the date provided. |
|
3394 |
*/ |
|
3395 |
function get_gmt_from_date( $string, $format = 'Y-m-d H:i:s' ) { |
|
3396 |
$tz = get_option( 'timezone_string' ); |
|
3397 |
if ( $tz ) { |
|
3398 |
$datetime = date_create( $string, new DateTimeZone( $tz ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3399 |
if ( ! $datetime ) { |
0 | 3400 |
return gmdate( $format, 0 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3401 |
} |
0 | 3402 |
$datetime->setTimezone( new DateTimeZone( 'UTC' ) ); |
3403 |
$string_gmt = $datetime->format( $format ); |
|
3404 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3405 |
if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3406 |
$datetime = strtotime( $string ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3407 |
if ( false === $datetime ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3408 |
return gmdate( $format, 0 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3409 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3410 |
return gmdate( $format, $datetime ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3411 |
} |
0 | 3412 |
$string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] ); |
9 | 3413 |
$string_gmt = gmdate( $format, $string_time - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
0 | 3414 |
} |
3415 |
return $string_gmt; |
|
3416 |
} |
|
3417 |
||
3418 |
/** |
|
3419 |
* Converts a GMT date into the correct format for the blog. |
|
3420 |
* |
|
3421 |
* Requires and returns a date in the Y-m-d H:i:s format. If there is a |
|
3422 |
* timezone_string available, the returned date is in that timezone, otherwise |
|
3423 |
* it simply adds the value of gmt_offset. Return format can be overridden |
|
3424 |
* using the $format parameter |
|
3425 |
* |
|
3426 |
* @since 1.2.0 |
|
3427 |
* |
|
3428 |
* @param string $string The date to be converted. |
|
3429 |
* @param string $format The format string for the returned date (default is Y-m-d H:i:s) |
|
3430 |
* @return string Formatted date relative to the timezone / GMT offset. |
|
3431 |
*/ |
|
3432 |
function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) { |
|
3433 |
$tz = get_option( 'timezone_string' ); |
|
3434 |
if ( $tz ) { |
|
3435 |
$datetime = date_create( $string, new DateTimeZone( 'UTC' ) ); |
|
9 | 3436 |
if ( ! $datetime ) { |
0 | 3437 |
return date( $format, 0 ); |
9 | 3438 |
} |
0 | 3439 |
$datetime->setTimezone( new DateTimeZone( $tz ) ); |
3440 |
$string_localtime = $datetime->format( $format ); |
|
3441 |
} else { |
|
9 | 3442 |
if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) { |
0 | 3443 |
return date( $format, 0 ); |
9 | 3444 |
} |
3445 |
$string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] ); |
|
0 | 3446 |
$string_localtime = gmdate( $format, $string_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
3447 |
} |
|
3448 |
return $string_localtime; |
|
3449 |
} |
|
3450 |
||
3451 |
/** |
|
3452 |
* Computes an offset in seconds from an iso8601 timezone. |
|
3453 |
* |
|
3454 |
* @since 1.5.0 |
|
3455 |
* |
|
3456 |
* @param string $timezone Either 'Z' for 0 offset or '±hhmm'. |
|
3457 |
* @return int|float The offset in seconds. |
|
3458 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3459 |
function iso8601_timezone_to_offset( $timezone ) { |
0 | 3460 |
// $timezone is either 'Z' or '[+|-]hhmm' |
9 | 3461 |
if ( $timezone == 'Z' ) { |
0 | 3462 |
$offset = 0; |
3463 |
} else { |
|
9 | 3464 |
$sign = ( substr( $timezone, 0, 1 ) == '+' ) ? 1 : -1; |
3465 |
$hours = intval( substr( $timezone, 1, 2 ) ); |
|
3466 |
$minutes = intval( substr( $timezone, 3, 4 ) ) / 60; |
|
3467 |
$offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes ); |
|
0 | 3468 |
} |
3469 |
return $offset; |
|
3470 |
} |
|
3471 |
||
3472 |
/** |
|
3473 |
* Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]. |
|
3474 |
* |
|
3475 |
* @since 1.5.0 |
|
3476 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3477 |
* @param string $date_string Date and time in ISO 8601 format {@link https://en.wikipedia.org/wiki/ISO_8601}. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3478 |
* @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'. |
0 | 3479 |
* @return string The date and time in MySQL DateTime format - Y-m-d H:i:s. |
3480 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3481 |
function iso8601_to_datetime( $date_string, $timezone = 'user' ) { |
9 | 3482 |
$timezone = strtolower( $timezone ); |
3483 |
||
3484 |
if ( $timezone == 'gmt' ) { |
|
3485 |
||
3486 |
preg_match( '#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits ); |
|
3487 |
||
3488 |
if ( ! empty( $date_bits[7] ) ) { // we have a timezone, so let's compute an offset |
|
3489 |
$offset = iso8601_timezone_to_offset( $date_bits[7] ); |
|
0 | 3490 |
} else { // we don't have a timezone, so we assume user local timezone (not server's!) |
9 | 3491 |
$offset = HOUR_IN_SECONDS * get_option( 'gmt_offset' ); |
0 | 3492 |
} |
3493 |
||
9 | 3494 |
$timestamp = gmmktime( $date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1] ); |
0 | 3495 |
$timestamp -= $offset; |
3496 |
||
9 | 3497 |
return gmdate( 'Y-m-d H:i:s', $timestamp ); |
3498 |
||
3499 |
} elseif ( $timezone == 'user' ) { |
|
3500 |
return preg_replace( '#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string ); |
|
0 | 3501 |
} |
3502 |
} |
|
3503 |
||
3504 |
/** |
|
3505 |
* Strips out all characters that are not allowable in an email. |
|
3506 |
* |
|
3507 |
* @since 1.5.0 |
|
3508 |
* |
|
3509 |
* @param string $email Email address to filter. |
|
3510 |
* @return string Filtered email address. |
|
3511 |
*/ |
|
3512 |
function sanitize_email( $email ) { |
|
3513 |
// Test for the minimum length the email can be |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3514 |
if ( strlen( $email ) < 6 ) { |
5 | 3515 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3516 |
* Filters a sanitized email address. |
5 | 3517 |
* |
3518 |
* This filter is evaluated under several contexts, including 'email_too_short', |
|
3519 |
* 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
|
3520 |
* 'domain_no_periods', 'domain_no_valid_subs', or no context. |
|
3521 |
* |
|
3522 |
* @since 2.8.0 |
|
3523 |
* |
|
9 | 3524 |
* @param string $sanitized_email The sanitized email address. |
3525 |
* @param string $email The email address, as provided to sanitize_email(). |
|
3526 |
* @param string|null $message A message to pass to the user. null if email is sanitized. |
|
5 | 3527 |
*/ |
0 | 3528 |
return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); |
3529 |
} |
|
3530 |
||
3531 |
// Test for an @ character after the first position |
|
3532 |
if ( strpos( $email, '@', 1 ) === false ) { |
|
5 | 3533 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3534 |
return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); |
3535 |
} |
|
3536 |
||
3537 |
// Split out the local and domain parts |
|
3538 |
list( $local, $domain ) = explode( '@', $email, 2 ); |
|
3539 |
||
3540 |
// LOCAL PART |
|
3541 |
// Test for invalid characters |
|
3542 |
$local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); |
|
3543 |
if ( '' === $local ) { |
|
5 | 3544 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3545 |
return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' ); |
3546 |
} |
|
3547 |
||
3548 |
// DOMAIN PART |
|
3549 |
// Test for sequences of periods |
|
3550 |
$domain = preg_replace( '/\.{2,}/', '', $domain ); |
|
3551 |
if ( '' === $domain ) { |
|
5 | 3552 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3553 |
return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); |
3554 |
} |
|
3555 |
||
3556 |
// Test for leading and trailing periods and whitespace |
|
3557 |
$domain = trim( $domain, " \t\n\r\0\x0B." ); |
|
3558 |
if ( '' === $domain ) { |
|
5 | 3559 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3560 |
return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); |
3561 |
} |
|
3562 |
||
3563 |
// Split the domain into subs |
|
3564 |
$subs = explode( '.', $domain ); |
|
3565 |
||
3566 |
// Assume the domain will have at least two subs |
|
3567 |
if ( 2 > count( $subs ) ) { |
|
5 | 3568 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3569 |
return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); |
3570 |
} |
|
3571 |
||
3572 |
// Create an array that will contain valid subs |
|
3573 |
$new_subs = array(); |
|
3574 |
||
3575 |
// Loop through each sub |
|
3576 |
foreach ( $subs as $sub ) { |
|
3577 |
// Test for leading and trailing hyphens |
|
3578 |
$sub = trim( $sub, " \t\n\r\0\x0B-" ); |
|
3579 |
||
3580 |
// Test for invalid characters |
|
3581 |
$sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub ); |
|
3582 |
||
3583 |
// If there's anything left, add it to the valid subs |
|
3584 |
if ( '' !== $sub ) { |
|
3585 |
$new_subs[] = $sub; |
|
3586 |
} |
|
3587 |
} |
|
3588 |
||
3589 |
// If there aren't 2 or more valid subs |
|
3590 |
if ( 2 > count( $new_subs ) ) { |
|
5 | 3591 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3592 |
return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); |
3593 |
} |
|
3594 |
||
3595 |
// Join valid subs into the new domain |
|
3596 |
$domain = join( '.', $new_subs ); |
|
3597 |
||
3598 |
// Put the email back together |
|
9 | 3599 |
$sanitized_email = $local . '@' . $domain; |
0 | 3600 |
|
3601 |
// Congratulations your email made it! |
|
5 | 3602 |
/** This filter is documented in wp-includes/formatting.php */ |
9 | 3603 |
return apply_filters( 'sanitize_email', $sanitized_email, $email, null ); |
0 | 3604 |
} |
3605 |
||
3606 |
/** |
|
3607 |
* Determines the difference between two timestamps. |
|
3608 |
* |
|
3609 |
* The difference is returned in a human readable format such as "1 hour", |
|
3610 |
* "5 mins", "2 days". |
|
3611 |
* |
|
3612 |
* @since 1.5.0 |
|
3613 |
* |
|
3614 |
* @param int $from Unix timestamp from which the difference begins. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3615 |
* @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set. |
0 | 3616 |
* @return string Human readable time difference. |
3617 |
*/ |
|
3618 |
function human_time_diff( $from, $to = '' ) { |
|
5 | 3619 |
if ( empty( $to ) ) { |
0 | 3620 |
$to = time(); |
5 | 3621 |
} |
0 | 3622 |
|
3623 |
$diff = (int) abs( $to - $from ); |
|
3624 |
||
3625 |
if ( $diff < HOUR_IN_SECONDS ) { |
|
3626 |
$mins = round( $diff / MINUTE_IN_SECONDS ); |
|
9 | 3627 |
if ( $mins <= 1 ) { |
0 | 3628 |
$mins = 1; |
9 | 3629 |
} |
3630 |
/* translators: Time difference between two dates, in minutes (min=minute). %s: Number of minutes */ |
|
0 | 3631 |
$since = sprintf( _n( '%s min', '%s mins', $mins ), $mins ); |
3632 |
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) { |
|
3633 |
$hours = round( $diff / HOUR_IN_SECONDS ); |
|
9 | 3634 |
if ( $hours <= 1 ) { |
0 | 3635 |
$hours = 1; |
9 | 3636 |
} |
3637 |
/* translators: Time difference between two dates, in hours. %s: Number of hours */ |
|
0 | 3638 |
$since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours ); |
3639 |
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) { |
|
3640 |
$days = round( $diff / DAY_IN_SECONDS ); |
|
9 | 3641 |
if ( $days <= 1 ) { |
0 | 3642 |
$days = 1; |
9 | 3643 |
} |
3644 |
/* translators: Time difference between two dates, in days. %s: Number of days */ |
|
0 | 3645 |
$since = sprintf( _n( '%s day', '%s days', $days ), $days ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3646 |
} elseif ( $diff < MONTH_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) { |
0 | 3647 |
$weeks = round( $diff / WEEK_IN_SECONDS ); |
9 | 3648 |
if ( $weeks <= 1 ) { |
0 | 3649 |
$weeks = 1; |
9 | 3650 |
} |
3651 |
/* translators: Time difference between two dates, in weeks. %s: Number of weeks */ |
|
0 | 3652 |
$since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3653 |
} elseif ( $diff < YEAR_IN_SECONDS && $diff >= MONTH_IN_SECONDS ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3654 |
$months = round( $diff / MONTH_IN_SECONDS ); |
9 | 3655 |
if ( $months <= 1 ) { |
0 | 3656 |
$months = 1; |
9 | 3657 |
} |
3658 |
/* translators: Time difference between two dates, in months. %s: Number of months */ |
|
0 | 3659 |
$since = sprintf( _n( '%s month', '%s months', $months ), $months ); |
3660 |
} elseif ( $diff >= YEAR_IN_SECONDS ) { |
|
3661 |
$years = round( $diff / YEAR_IN_SECONDS ); |
|
9 | 3662 |
if ( $years <= 1 ) { |
0 | 3663 |
$years = 1; |
9 | 3664 |
} |
3665 |
/* translators: Time difference between two dates, in years. %s: Number of years */ |
|
0 | 3666 |
$since = sprintf( _n( '%s year', '%s years', $years ), $years ); |
3667 |
} |
|
3668 |
||
5 | 3669 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3670 |
* Filters the human readable difference between two timestamps. |
5 | 3671 |
* |
3672 |
* @since 4.0.0 |
|
3673 |
* |
|
3674 |
* @param string $since The difference in human readable text. |
|
3675 |
* @param int $diff The difference in seconds. |
|
3676 |
* @param int $from Unix timestamp from which the difference begins. |
|
3677 |
* @param int $to Unix timestamp to end the time difference. |
|
3678 |
*/ |
|
3679 |
return apply_filters( 'human_time_diff', $since, $diff, $from, $to ); |
|
0 | 3680 |
} |
3681 |
||
3682 |
/** |
|
3683 |
* Generates an excerpt from the content, if needed. |
|
3684 |
* |
|
3685 |
* The excerpt word amount will be 55 words and if the amount is greater than |
|
3686 |
* that, then the string ' […]' will be appended to the excerpt. If the string |
|
3687 |
* is less than 55 words, then the content will be returned as is. |
|
3688 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3689 |
* The 55 word limit can be modified by plugins/themes using the {@see 'excerpt_length'} filter |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3690 |
* The ' […]' string can be modified by plugins/themes using the {@see 'excerpt_more'} filter |
0 | 3691 |
* |
3692 |
* @since 1.5.0 |
|
9 | 3693 |
* @since 5.2.0 Added the `$post` parameter. |
3694 |
* |
|
3695 |
* @param string $text Optional. The excerpt. If set to empty, an excerpt is generated. |
|
3696 |
* @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default is null. |
|
0 | 3697 |
* @return string The excerpt. |
3698 |
*/ |
|
9 | 3699 |
function wp_trim_excerpt( $text = '', $post = null ) { |
0 | 3700 |
$raw_excerpt = $text; |
3701 |
if ( '' == $text ) { |
|
9 | 3702 |
$post = get_post( $post ); |
3703 |
$text = get_the_content( '', false, $post ); |
|
0 | 3704 |
|
3705 |
$text = strip_shortcodes( $text ); |
|
9 | 3706 |
$text = excerpt_remove_blocks( $text ); |
0 | 3707 |
|
5 | 3708 |
/** This filter is documented in wp-includes/post-template.php */ |
3709 |
$text = apply_filters( 'the_content', $text ); |
|
9 | 3710 |
$text = str_replace( ']]>', ']]>', $text ); |
5 | 3711 |
|
3712 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3713 |
* Filters the number of words in an excerpt. |
5 | 3714 |
* |
3715 |
* @since 2.7.0 |
|
3716 |
* |
|
3717 |
* @param int $number The number of words. Default 55. |
|
3718 |
*/ |
|
3719 |
$excerpt_length = apply_filters( 'excerpt_length', 55 ); |
|
3720 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3721 |
* Filters the string in the "more" link displayed after a trimmed excerpt. |
5 | 3722 |
* |
3723 |
* @since 2.9.0 |
|
3724 |
* |
|
3725 |
* @param string $more_string The string shown within the more link. |
|
3726 |
*/ |
|
3727 |
$excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' ); |
|
9 | 3728 |
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); |
0 | 3729 |
} |
5 | 3730 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3731 |
* Filters the trimmed excerpt string. |
5 | 3732 |
* |
3733 |
* @since 2.8.0 |
|
3734 |
* |
|
3735 |
* @param string $text The trimmed text. |
|
3736 |
* @param string $raw_excerpt The text prior to trimming. |
|
3737 |
*/ |
|
3738 |
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt ); |
|
0 | 3739 |
} |
3740 |
||
3741 |
/** |
|
3742 |
* Trims text to a certain number of words. |
|
3743 |
* |
|
3744 |
* This function is localized. For languages that count 'words' by the individual |
|
3745 |
* character (such as East Asian languages), the $num_words argument will apply |
|
3746 |
* to the number of individual characters. |
|
3747 |
* |
|
3748 |
* @since 3.3.0 |
|
3749 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3750 |
* @param string $text Text to trim. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3751 |
* @param int $num_words Number of words. Default 55. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3752 |
* @param string $more Optional. What to append if $text needs to be trimmed. Default '…'. |
0 | 3753 |
* @return string Trimmed text. |
3754 |
*/ |
|
3755 |
function wp_trim_words( $text, $num_words = 55, $more = null ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3756 |
if ( null === $more ) { |
0 | 3757 |
$more = __( '…' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3758 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3759 |
|
0 | 3760 |
$original_text = $text; |
9 | 3761 |
$text = wp_strip_all_tags( $text ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3762 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3763 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3764 |
* translators: If your word count is based on single characters (e.g. East Asian characters), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3765 |
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3766 |
* Do not translate into your own language. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3767 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3768 |
if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
0 | 3769 |
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
3770 |
preg_match_all( '/./u', $text, $words_array ); |
|
3771 |
$words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
9 | 3772 |
$sep = ''; |
0 | 3773 |
} else { |
3774 |
$words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
9 | 3775 |
$sep = ' '; |
0 | 3776 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3777 |
|
0 | 3778 |
if ( count( $words_array ) > $num_words ) { |
3779 |
array_pop( $words_array ); |
|
3780 |
$text = implode( $sep, $words_array ); |
|
3781 |
$text = $text . $more; |
|
3782 |
} else { |
|
3783 |
$text = implode( $sep, $words_array ); |
|
3784 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3785 |
|
5 | 3786 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3787 |
* Filters the text content after words have been trimmed. |
5 | 3788 |
* |
3789 |
* @since 3.3.0 |
|
3790 |
* |
|
3791 |
* @param string $text The trimmed text. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3792 |
* @param int $num_words The number of words to trim the text to. Default 55. |
5 | 3793 |
* @param string $more An optional string to append to the end of the trimmed text, e.g. …. |
3794 |
* @param string $original_text The text before it was trimmed. |
|
3795 |
*/ |
|
0 | 3796 |
return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
3797 |
} |
|
3798 |
||
3799 |
/** |
|
3800 |
* Converts named entities into numbered entities. |
|
3801 |
* |
|
3802 |
* @since 1.5.1 |
|
3803 |
* |
|
3804 |
* @param string $text The text within which entities will be converted. |
|
3805 |
* @return string Text with converted entities. |
|
3806 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3807 |
function ent2ncr( $text ) { |
0 | 3808 |
|
5 | 3809 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3810 |
* Filters text before named entities are converted into numbered entities. |
5 | 3811 |
* |
3812 |
* A non-null string must be returned for the filter to be evaluated. |
|
3813 |
* |
|
3814 |
* @since 3.3.0 |
|
3815 |
* |
|
3816 |
* @param null $converted_text The text to be converted. Default null. |
|
3817 |
* @param string $text The text prior to entity conversion. |
|
3818 |
*/ |
|
0 | 3819 |
$filtered = apply_filters( 'pre_ent2ncr', null, $text ); |
9 | 3820 |
if ( null !== $filtered ) { |
0 | 3821 |
return $filtered; |
9 | 3822 |
} |
0 | 3823 |
|
3824 |
$to_ncr = array( |
|
9 | 3825 |
'"' => '"', |
3826 |
'&' => '&', |
|
3827 |
'<' => '<', |
|
3828 |
'>' => '>', |
|
3829 |
'|' => '|', |
|
3830 |
' ' => ' ', |
|
3831 |
'¡' => '¡', |
|
3832 |
'¢' => '¢', |
|
3833 |
'£' => '£', |
|
3834 |
'¤' => '¤', |
|
3835 |
'¥' => '¥', |
|
3836 |
'¦' => '¦', |
|
3837 |
'&brkbar;' => '¦', |
|
3838 |
'§' => '§', |
|
3839 |
'¨' => '¨', |
|
3840 |
'¨' => '¨', |
|
3841 |
'©' => '©', |
|
3842 |
'ª' => 'ª', |
|
3843 |
'«' => '«', |
|
3844 |
'¬' => '¬', |
|
3845 |
'­' => '­', |
|
3846 |
'®' => '®', |
|
3847 |
'¯' => '¯', |
|
3848 |
'&hibar;' => '¯', |
|
3849 |
'°' => '°', |
|
3850 |
'±' => '±', |
|
3851 |
'²' => '²', |
|
3852 |
'³' => '³', |
|
3853 |
'´' => '´', |
|
3854 |
'µ' => 'µ', |
|
3855 |
'¶' => '¶', |
|
3856 |
'·' => '·', |
|
3857 |
'¸' => '¸', |
|
3858 |
'¹' => '¹', |
|
3859 |
'º' => 'º', |
|
3860 |
'»' => '»', |
|
3861 |
'¼' => '¼', |
|
3862 |
'½' => '½', |
|
3863 |
'¾' => '¾', |
|
3864 |
'¿' => '¿', |
|
3865 |
'À' => 'À', |
|
3866 |
'Á' => 'Á', |
|
3867 |
'Â' => 'Â', |
|
3868 |
'Ã' => 'Ã', |
|
3869 |
'Ä' => 'Ä', |
|
3870 |
'Å' => 'Å', |
|
3871 |
'Æ' => 'Æ', |
|
3872 |
'Ç' => 'Ç', |
|
3873 |
'È' => 'È', |
|
3874 |
'É' => 'É', |
|
3875 |
'Ê' => 'Ê', |
|
3876 |
'Ë' => 'Ë', |
|
3877 |
'Ì' => 'Ì', |
|
3878 |
'Í' => 'Í', |
|
3879 |
'Î' => 'Î', |
|
3880 |
'Ï' => 'Ï', |
|
3881 |
'Ð' => 'Ð', |
|
3882 |
'Ñ' => 'Ñ', |
|
3883 |
'Ò' => 'Ò', |
|
3884 |
'Ó' => 'Ó', |
|
3885 |
'Ô' => 'Ô', |
|
3886 |
'Õ' => 'Õ', |
|
3887 |
'Ö' => 'Ö', |
|
3888 |
'×' => '×', |
|
3889 |
'Ø' => 'Ø', |
|
3890 |
'Ù' => 'Ù', |
|
3891 |
'Ú' => 'Ú', |
|
3892 |
'Û' => 'Û', |
|
3893 |
'Ü' => 'Ü', |
|
3894 |
'Ý' => 'Ý', |
|
3895 |
'Þ' => 'Þ', |
|
3896 |
'ß' => 'ß', |
|
3897 |
'à' => 'à', |
|
3898 |
'á' => 'á', |
|
3899 |
'â' => 'â', |
|
3900 |
'ã' => 'ã', |
|
3901 |
'ä' => 'ä', |
|
3902 |
'å' => 'å', |
|
3903 |
'æ' => 'æ', |
|
3904 |
'ç' => 'ç', |
|
3905 |
'è' => 'è', |
|
3906 |
'é' => 'é', |
|
3907 |
'ê' => 'ê', |
|
3908 |
'ë' => 'ë', |
|
3909 |
'ì' => 'ì', |
|
3910 |
'í' => 'í', |
|
3911 |
'î' => 'î', |
|
3912 |
'ï' => 'ï', |
|
3913 |
'ð' => 'ð', |
|
3914 |
'ñ' => 'ñ', |
|
3915 |
'ò' => 'ò', |
|
3916 |
'ó' => 'ó', |
|
3917 |
'ô' => 'ô', |
|
3918 |
'õ' => 'õ', |
|
3919 |
'ö' => 'ö', |
|
3920 |
'÷' => '÷', |
|
3921 |
'ø' => 'ø', |
|
3922 |
'ù' => 'ù', |
|
3923 |
'ú' => 'ú', |
|
3924 |
'û' => 'û', |
|
3925 |
'ü' => 'ü', |
|
3926 |
'ý' => 'ý', |
|
3927 |
'þ' => 'þ', |
|
3928 |
'ÿ' => 'ÿ', |
|
3929 |
'Œ' => 'Œ', |
|
3930 |
'œ' => 'œ', |
|
3931 |
'Š' => 'Š', |
|
3932 |
'š' => 'š', |
|
3933 |
'Ÿ' => 'Ÿ', |
|
3934 |
'ƒ' => 'ƒ', |
|
3935 |
'ˆ' => 'ˆ', |
|
3936 |
'˜' => '˜', |
|
3937 |
'Α' => 'Α', |
|
3938 |
'Β' => 'Β', |
|
3939 |
'Γ' => 'Γ', |
|
3940 |
'Δ' => 'Δ', |
|
3941 |
'Ε' => 'Ε', |
|
3942 |
'Ζ' => 'Ζ', |
|
3943 |
'Η' => 'Η', |
|
3944 |
'Θ' => 'Θ', |
|
3945 |
'Ι' => 'Ι', |
|
3946 |
'Κ' => 'Κ', |
|
3947 |
'Λ' => 'Λ', |
|
3948 |
'Μ' => 'Μ', |
|
3949 |
'Ν' => 'Ν', |
|
3950 |
'Ξ' => 'Ξ', |
|
3951 |
'Ο' => 'Ο', |
|
3952 |
'Π' => 'Π', |
|
3953 |
'Ρ' => 'Ρ', |
|
3954 |
'Σ' => 'Σ', |
|
3955 |
'Τ' => 'Τ', |
|
3956 |
'Υ' => 'Υ', |
|
3957 |
'Φ' => 'Φ', |
|
3958 |
'Χ' => 'Χ', |
|
3959 |
'Ψ' => 'Ψ', |
|
3960 |
'Ω' => 'Ω', |
|
3961 |
'α' => 'α', |
|
3962 |
'β' => 'β', |
|
3963 |
'γ' => 'γ', |
|
3964 |
'δ' => 'δ', |
|
3965 |
'ε' => 'ε', |
|
3966 |
'ζ' => 'ζ', |
|
3967 |
'η' => 'η', |
|
3968 |
'θ' => 'θ', |
|
3969 |
'ι' => 'ι', |
|
3970 |
'κ' => 'κ', |
|
3971 |
'λ' => 'λ', |
|
3972 |
'μ' => 'μ', |
|
3973 |
'ν' => 'ν', |
|
3974 |
'ξ' => 'ξ', |
|
3975 |
'ο' => 'ο', |
|
3976 |
'π' => 'π', |
|
3977 |
'ρ' => 'ρ', |
|
3978 |
'ς' => 'ς', |
|
3979 |
'σ' => 'σ', |
|
3980 |
'τ' => 'τ', |
|
3981 |
'υ' => 'υ', |
|
3982 |
'φ' => 'φ', |
|
3983 |
'χ' => 'χ', |
|
3984 |
'ψ' => 'ψ', |
|
3985 |
'ω' => 'ω', |
|
0 | 3986 |
'ϑ' => 'ϑ', |
9 | 3987 |
'ϒ' => 'ϒ', |
3988 |
'ϖ' => 'ϖ', |
|
3989 |
' ' => ' ', |
|
3990 |
' ' => ' ', |
|
3991 |
' ' => ' ', |
|
3992 |
'‌' => '‌', |
|
3993 |
'‍' => '‍', |
|
3994 |
'‎' => '‎', |
|
3995 |
'‏' => '‏', |
|
3996 |
'–' => '–', |
|
3997 |
'—' => '—', |
|
3998 |
'‘' => '‘', |
|
3999 |
'’' => '’', |
|
4000 |
'‚' => '‚', |
|
4001 |
'“' => '“', |
|
4002 |
'”' => '”', |
|
4003 |
'„' => '„', |
|
4004 |
'†' => '†', |
|
4005 |
'‡' => '‡', |
|
4006 |
'•' => '•', |
|
4007 |
'…' => '…', |
|
4008 |
'‰' => '‰', |
|
4009 |
'′' => '′', |
|
4010 |
'″' => '″', |
|
4011 |
'‹' => '‹', |
|
4012 |
'›' => '›', |
|
4013 |
'‾' => '‾', |
|
4014 |
'⁄' => '⁄', |
|
4015 |
'€' => '€', |
|
4016 |
'ℑ' => 'ℑ', |
|
4017 |
'℘' => '℘', |
|
4018 |
'ℜ' => 'ℜ', |
|
4019 |
'™' => '™', |
|
4020 |
'ℵ' => 'ℵ', |
|
4021 |
'↵' => '↵', |
|
4022 |
'⇐' => '⇐', |
|
4023 |
'⇑' => '⇑', |
|
4024 |
'⇒' => '⇒', |
|
4025 |
'⇓' => '⇓', |
|
4026 |
'⇔' => '⇔', |
|
4027 |
'∀' => '∀', |
|
4028 |
'∂' => '∂', |
|
4029 |
'∃' => '∃', |
|
4030 |
'∅' => '∅', |
|
4031 |
'∇' => '∇', |
|
4032 |
'∈' => '∈', |
|
4033 |
'∉' => '∉', |
|
4034 |
'∋' => '∋', |
|
4035 |
'∏' => '∏', |
|
4036 |
'∑' => '∑', |
|
4037 |
'−' => '−', |
|
4038 |
'∗' => '∗', |
|
4039 |
'√' => '√', |
|
4040 |
'∝' => '∝', |
|
4041 |
'∞' => '∞', |
|
4042 |
'∠' => '∠', |
|
4043 |
'∧' => '∧', |
|
4044 |
'∨' => '∨', |
|
4045 |
'∩' => '∩', |
|
4046 |
'∪' => '∪', |
|
4047 |
'∫' => '∫', |
|
4048 |
'∴' => '∴', |
|
4049 |
'∼' => '∼', |
|
4050 |
'≅' => '≅', |
|
4051 |
'≈' => '≈', |
|
4052 |
'≠' => '≠', |
|
4053 |
'≡' => '≡', |
|
4054 |
'≤' => '≤', |
|
4055 |
'≥' => '≥', |
|
4056 |
'⊂' => '⊂', |
|
4057 |
'⊃' => '⊃', |
|
4058 |
'⊄' => '⊄', |
|
4059 |
'⊆' => '⊆', |
|
4060 |
'⊇' => '⊇', |
|
4061 |
'⊕' => '⊕', |
|
4062 |
'⊗' => '⊗', |
|
4063 |
'⊥' => '⊥', |
|
4064 |
'⋅' => '⋅', |
|
4065 |
'⌈' => '⌈', |
|
4066 |
'⌉' => '⌉', |
|
4067 |
'⌊' => '⌊', |
|
4068 |
'⌋' => '⌋', |
|
4069 |
'⟨' => '〈', |
|
4070 |
'⟩' => '〉', |
|
4071 |
'←' => '←', |
|
4072 |
'↑' => '↑', |
|
4073 |
'→' => '→', |
|
4074 |
'↓' => '↓', |
|
4075 |
'↔' => '↔', |
|
4076 |
'◊' => '◊', |
|
4077 |
'♠' => '♠', |
|
4078 |
'♣' => '♣', |
|
4079 |
'♥' => '♥', |
|
4080 |
'♦' => '♦', |
|
0 | 4081 |
); |
4082 |
||
9 | 4083 |
return str_replace( array_keys( $to_ncr ), array_values( $to_ncr ), $text ); |
0 | 4084 |
} |
4085 |
||
4086 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4087 |
* Formats text for the editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4088 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4089 |
* Generally the browsers treat everything inside a textarea as text, but |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4090 |
* it is still a good idea to HTML entity encode `<`, `>` and `&` in the content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4091 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4092 |
* The filter {@see 'format_for_editor'} is applied here. If `$text` is empty the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4093 |
* filter will be applied to an empty string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4094 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4095 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4096 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4097 |
* @see _WP_Editors::editor() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4098 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4099 |
* @param string $text The text to be formatted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4100 |
* @param string $default_editor The default editor for the current user. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4101 |
* It is usually either 'html' or 'tinymce'. |
0 | 4102 |
* @return string The formatted text after filter is applied. |
4103 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4104 |
function format_for_editor( $text, $default_editor = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4105 |
if ( $text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4106 |
$text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) ); |
5 | 4107 |
} |
0 | 4108 |
|
5 | 4109 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4110 |
* Filters the text after it is formatted for the editor. |
5 | 4111 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4112 |
* @since 4.3.0 |
5 | 4113 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4114 |
* @param string $text The formatted text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4115 |
* @param string $default_editor The default editor for the current user. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4116 |
* It is usually either 'html' or 'tinymce'. |
5 | 4117 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4118 |
return apply_filters( 'format_for_editor', $text, $default_editor ); |
0 | 4119 |
} |
4120 |
||
4121 |
/** |
|
4122 |
* Perform a deep string replace operation to ensure the values in $search are no longer present |
|
4123 |
* |
|
4124 |
* Repeats the replacement operation until it no longer replaces anything so as to remove "nested" values |
|
4125 |
* e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that |
|
4126 |
* str_replace would return |
|
4127 |
* |
|
4128 |
* @since 2.8.1 |
|
4129 |
* @access private |
|
4130 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4131 |
* @param string|array $search The value being searched for, otherwise known as the needle. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4132 |
* An array may be used to designate multiple needles. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4133 |
* @param string $subject The string being searched and replaced on, otherwise known as the haystack. |
9 | 4134 |
* @return string The string with the replaced values. |
0 | 4135 |
*/ |
4136 |
function _deep_replace( $search, $subject ) { |
|
4137 |
$subject = (string) $subject; |
|
4138 |
||
4139 |
$count = 1; |
|
4140 |
while ( $count ) { |
|
4141 |
$subject = str_replace( $search, '', $subject, $count ); |
|
4142 |
} |
|
4143 |
||
4144 |
return $subject; |
|
4145 |
} |
|
4146 |
||
4147 |
/** |
|
4148 |
* Escapes data for use in a MySQL query. |
|
4149 |
* |
|
4150 |
* Usually you should prepare queries using wpdb::prepare(). |
|
4151 |
* Sometimes, spot-escaping is required or useful. One example |
|
4152 |
* is preparing an array for use in an IN clause. |
|
4153 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4154 |
* NOTE: Since 4.8.3, '%' characters will be replaced with a placeholder string, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4155 |
* this prevents certain SQLi attacks from taking place. This change in behaviour |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4156 |
* may cause issues for code that expects the return value of esc_sql() to be useable |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4157 |
* for other purposes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4158 |
* |
0 | 4159 |
* @since 2.8.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4160 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4161 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4162 |
* |
0 | 4163 |
* @param string|array $data Unescaped data |
4164 |
* @return string|array Escaped data |
|
4165 |
*/ |
|
4166 |
function esc_sql( $data ) { |
|
4167 |
global $wpdb; |
|
4168 |
return $wpdb->_escape( $data ); |
|
4169 |
} |
|
4170 |
||
4171 |
/** |
|
4172 |
* Checks and cleans a URL. |
|
4173 |
* |
|
4174 |
* A number of characters are removed from the URL. If the URL is for displaying |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4175 |
* (the default behaviour) ampersands are also replaced. The {@see 'clean_url'} filter |
0 | 4176 |
* is applied to the returned cleaned URL. |
4177 |
* |
|
4178 |
* @since 2.8.0 |
|
4179 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4180 |
* @param string $url The URL to be cleaned. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4181 |
* @param array $protocols Optional. An array of acceptable protocols. |
9 | 4182 |
* Defaults to return value of wp_allowed_protocols() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4183 |
* @param string $_context Private. Use esc_url_raw() for database usage. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4184 |
* @return string The cleaned $url after the {@see 'clean_url'} filter is applied. |
0 | 4185 |
*/ |
4186 |
function esc_url( $url, $protocols = null, $_context = 'display' ) { |
|
4187 |
$original_url = $url; |
|
4188 |
||
9 | 4189 |
if ( '' == $url ) { |
0 | 4190 |
return $url; |
9 | 4191 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4192 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4193 |
$url = str_replace( ' ', '%20', $url ); |
9 | 4194 |
$url = preg_replace( '|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4195 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4196 |
if ( '' === $url ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4197 |
return $url; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4198 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4199 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4200 |
if ( 0 !== stripos( $url, 'mailto:' ) ) { |
9 | 4201 |
$strip = array( '%0d', '%0a', '%0D', '%0A' ); |
4202 |
$url = _deep_replace( $strip, $url ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4203 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4204 |
|
9 | 4205 |
$url = str_replace( ';//', '://', $url ); |
0 | 4206 |
/* If the URL doesn't appear to contain a scheme, we |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4207 |
* presume it needs http:// prepended (unless a relative |
0 | 4208 |
* link starting with /, # or ? or a php file). |
4209 |
*/ |
|
9 | 4210 |
if ( strpos( $url, ':' ) === false && ! in_array( $url[0], array( '/', '#', '?' ) ) && |
4211 |
! preg_match( '/^[a-z0-9-]+?\.php/i', $url ) ) { |
|
0 | 4212 |
$url = 'http://' . $url; |
9 | 4213 |
} |
0 | 4214 |
|
4215 |
// Replace ampersands and single quotes only when displaying. |
|
4216 |
if ( 'display' == $_context ) { |
|
4217 |
$url = wp_kses_normalize_entities( $url ); |
|
4218 |
$url = str_replace( '&', '&', $url ); |
|
4219 |
$url = str_replace( "'", ''', $url ); |
|
4220 |
} |
|
4221 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4222 |
if ( ( false !== strpos( $url, '[' ) ) || ( false !== strpos( $url, ']' ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4223 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4224 |
$parsed = wp_parse_url( $url ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4225 |
$front = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4226 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4227 |
if ( isset( $parsed['scheme'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4228 |
$front .= $parsed['scheme'] . '://'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4229 |
} elseif ( '/' === $url[0] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4230 |
$front .= '//'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4231 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4232 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4233 |
if ( isset( $parsed['user'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4234 |
$front .= $parsed['user']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4235 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4236 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4237 |
if ( isset( $parsed['pass'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4238 |
$front .= ':' . $parsed['pass']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4239 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4240 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4241 |
if ( isset( $parsed['user'] ) || isset( $parsed['pass'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4242 |
$front .= '@'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4243 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4244 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4245 |
if ( isset( $parsed['host'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4246 |
$front .= $parsed['host']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4247 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4248 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4249 |
if ( isset( $parsed['port'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4250 |
$front .= ':' . $parsed['port']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4251 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4252 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4253 |
$end_dirty = str_replace( $front, '', $url ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4254 |
$end_clean = str_replace( array( '[', ']' ), array( '%5B', '%5D' ), $end_dirty ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4255 |
$url = str_replace( $end_dirty, $end_clean, $url ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4256 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4257 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4258 |
|
0 | 4259 |
if ( '/' === $url[0] ) { |
4260 |
$good_protocol_url = $url; |
|
4261 |
} else { |
|
9 | 4262 |
if ( ! is_array( $protocols ) ) { |
0 | 4263 |
$protocols = wp_allowed_protocols(); |
9 | 4264 |
} |
0 | 4265 |
$good_protocol_url = wp_kses_bad_protocol( $url, $protocols ); |
9 | 4266 |
if ( strtolower( $good_protocol_url ) != strtolower( $url ) ) { |
0 | 4267 |
return ''; |
9 | 4268 |
} |
0 | 4269 |
} |
4270 |
||
5 | 4271 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4272 |
* Filters a string cleaned and escaped for output as a URL. |
5 | 4273 |
* |
4274 |
* @since 2.3.0 |
|
4275 |
* |
|
4276 |
* @param string $good_protocol_url The cleaned URL to be returned. |
|
4277 |
* @param string $original_url The URL prior to cleaning. |
|
4278 |
* @param string $_context If 'display', replace ampersands and single quotes only. |
|
4279 |
*/ |
|
4280 |
return apply_filters( 'clean_url', $good_protocol_url, $original_url, $_context ); |
|
0 | 4281 |
} |
4282 |
||
4283 |
/** |
|
4284 |
* Performs esc_url() for database usage. |
|
4285 |
* |
|
4286 |
* @since 2.8.0 |
|
4287 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4288 |
* @param string $url The URL to be cleaned. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4289 |
* @param array $protocols An array of acceptable protocols. |
0 | 4290 |
* @return string The cleaned URL. |
4291 |
*/ |
|
4292 |
function esc_url_raw( $url, $protocols = null ) { |
|
4293 |
return esc_url( $url, $protocols, 'db' ); |
|
4294 |
} |
|
4295 |
||
4296 |
/** |
|
4297 |
* Convert entities, while preserving already-encoded entities. |
|
4298 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4299 |
* @link https://secure.php.net/htmlentities Borrowed from the PHP Manual user notes. |
0 | 4300 |
* |
4301 |
* @since 1.2.2 |
|
4302 |
* |
|
4303 |
* @param string $myHTML The text to be converted. |
|
4304 |
* @return string Converted text. |
|
4305 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4306 |
function htmlentities2( $myHTML ) { |
9 | 4307 |
$translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES ); |
4308 |
$translation_table[ chr( 38 ) ] = '&'; |
|
4309 |
return preg_replace( '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', strtr( $myHTML, $translation_table ) ); |
|
0 | 4310 |
} |
4311 |
||
4312 |
/** |
|
4313 |
* Escape single quotes, htmlspecialchar " < > &, and fix line endings. |
|
4314 |
* |
|
4315 |
* Escapes text strings for echoing in JS. It is intended to be used for inline JS |
|
4316 |
* (in a tag attribute, for example onclick="..."). Note that the strings have to |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4317 |
* be in single quotes. The {@see 'js_escape'} filter is also applied here. |
0 | 4318 |
* |
4319 |
* @since 2.8.0 |
|
4320 |
* |
|
4321 |
* @param string $text The text to be escaped. |
|
4322 |
* @return string Escaped text. |
|
4323 |
*/ |
|
4324 |
function esc_js( $text ) { |
|
4325 |
$safe_text = wp_check_invalid_utf8( $text ); |
|
4326 |
$safe_text = _wp_specialchars( $safe_text, ENT_COMPAT ); |
|
4327 |
$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) ); |
|
4328 |
$safe_text = str_replace( "\r", '', $safe_text ); |
|
4329 |
$safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) ); |
|
5 | 4330 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4331 |
* Filters a string cleaned and escaped for output in JavaScript. |
5 | 4332 |
* |
4333 |
* Text passed to esc_js() is stripped of invalid or special characters, |
|
4334 |
* and properly slashed for output. |
|
4335 |
* |
|
4336 |
* @since 2.0.6 |
|
4337 |
* |
|
4338 |
* @param string $safe_text The text after it has been escaped. |
|
9 | 4339 |
* @param string $text The text prior to being escaped. |
5 | 4340 |
*/ |
0 | 4341 |
return apply_filters( 'js_escape', $safe_text, $text ); |
4342 |
} |
|
4343 |
||
4344 |
/** |
|
4345 |
* Escaping for HTML blocks. |
|
4346 |
* |
|
4347 |
* @since 2.8.0 |
|
4348 |
* |
|
4349 |
* @param string $text |
|
4350 |
* @return string |
|
4351 |
*/ |
|
4352 |
function esc_html( $text ) { |
|
4353 |
$safe_text = wp_check_invalid_utf8( $text ); |
|
4354 |
$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); |
|
5 | 4355 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4356 |
* Filters a string cleaned and escaped for output in HTML. |
5 | 4357 |
* |
4358 |
* Text passed to esc_html() is stripped of invalid or special characters |
|
4359 |
* before output. |
|
4360 |
* |
|
4361 |
* @since 2.8.0 |
|
4362 |
* |
|
4363 |
* @param string $safe_text The text after it has been escaped. |
|
9 | 4364 |
* @param string $text The text prior to being escaped. |
5 | 4365 |
*/ |
0 | 4366 |
return apply_filters( 'esc_html', $safe_text, $text ); |
4367 |
} |
|
4368 |
||
4369 |
/** |
|
4370 |
* Escaping for HTML attributes. |
|
4371 |
* |
|
4372 |
* @since 2.8.0 |
|
4373 |
* |
|
4374 |
* @param string $text |
|
4375 |
* @return string |
|
4376 |
*/ |
|
4377 |
function esc_attr( $text ) { |
|
4378 |
$safe_text = wp_check_invalid_utf8( $text ); |
|
4379 |
$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); |
|
5 | 4380 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4381 |
* Filters a string cleaned and escaped for output in an HTML attribute. |
5 | 4382 |
* |
4383 |
* Text passed to esc_attr() is stripped of invalid or special characters |
|
4384 |
* before output. |
|
4385 |
* |
|
4386 |
* @since 2.0.6 |
|
4387 |
* |
|
4388 |
* @param string $safe_text The text after it has been escaped. |
|
9 | 4389 |
* @param string $text The text prior to being escaped. |
5 | 4390 |
*/ |
0 | 4391 |
return apply_filters( 'attribute_escape', $safe_text, $text ); |
4392 |
} |
|
4393 |
||
4394 |
/** |
|
4395 |
* Escaping for textarea values. |
|
4396 |
* |
|
4397 |
* @since 3.1.0 |
|
4398 |
* |
|
4399 |
* @param string $text |
|
4400 |
* @return string |
|
4401 |
*/ |
|
4402 |
function esc_textarea( $text ) { |
|
4403 |
$safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( 'blog_charset' ) ); |
|
5 | 4404 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4405 |
* Filters a string cleaned and escaped for output in a textarea element. |
5 | 4406 |
* |
4407 |
* @since 3.1.0 |
|
4408 |
* |
|
4409 |
* @param string $safe_text The text after it has been escaped. |
|
9 | 4410 |
* @param string $text The text prior to being escaped. |
5 | 4411 |
*/ |
0 | 4412 |
return apply_filters( 'esc_textarea', $safe_text, $text ); |
4413 |
} |
|
4414 |
||
4415 |
/** |
|
4416 |
* Escape an HTML tag name. |
|
4417 |
* |
|
4418 |
* @since 2.5.0 |
|
4419 |
* |
|
4420 |
* @param string $tag_name |
|
4421 |
* @return string |
|
4422 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4423 |
function tag_escape( $tag_name ) { |
9 | 4424 |
$safe_tag = strtolower( preg_replace( '/[^a-zA-Z0-9_:]/', '', $tag_name ) ); |
5 | 4425 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4426 |
* Filters a string cleaned and escaped for output as an HTML tag. |
5 | 4427 |
* |
4428 |
* @since 2.8.0 |
|
4429 |
* |
|
4430 |
* @param string $safe_tag The tag name after it has been escaped. |
|
9 | 4431 |
* @param string $tag_name The text before it was escaped. |
5 | 4432 |
*/ |
4433 |
return apply_filters( 'tag_escape', $safe_tag, $tag_name ); |
|
0 | 4434 |
} |
4435 |
||
4436 |
/** |
|
4437 |
* Convert full URL paths to absolute paths. |
|
4438 |
* |
|
4439 |
* Removes the http or https protocols and the domain. Keeps the path '/' at the |
|
4440 |
* beginning, so it isn't a true relative link, but from the web root base. |
|
4441 |
* |
|
4442 |
* @since 2.1.0 |
|
5 | 4443 |
* @since 4.1.0 Support was added for relative URLs. |
0 | 4444 |
* |
4445 |
* @param string $link Full URL path. |
|
4446 |
* @return string Absolute path. |
|
4447 |
*/ |
|
4448 |
function wp_make_link_relative( $link ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4449 |
return preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', $link ); |
0 | 4450 |
} |
4451 |
||
4452 |
/** |
|
4453 |
* Sanitises various option values based on the nature of the option. |
|
4454 |
* |
|
4455 |
* This is basically a switch statement which will pass $value through a number |
|
4456 |
* of functions depending on the $option. |
|
4457 |
* |
|
4458 |
* @since 2.0.5 |
|
4459 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4460 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4461 |
* |
0 | 4462 |
* @param string $option The name of the option. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4463 |
* @param string $value The unsanitised value. |
0 | 4464 |
* @return string Sanitized value. |
4465 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4466 |
function sanitize_option( $option, $value ) { |
5 | 4467 |
global $wpdb; |
0 | 4468 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4469 |
$original_value = $value; |
9 | 4470 |
$error = ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4471 |
|
0 | 4472 |
switch ( $option ) { |
9 | 4473 |
case 'admin_email': |
4474 |
case 'new_admin_email': |
|
5 | 4475 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4476 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4477 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4478 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4479 |
$value = sanitize_email( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4480 |
if ( ! is_email( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4481 |
$error = __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4482 |
} |
0 | 4483 |
} |
4484 |
break; |
|
4485 |
||
4486 |
case 'thumbnail_size_w': |
|
4487 |
case 'thumbnail_size_h': |
|
4488 |
case 'medium_size_w': |
|
4489 |
case 'medium_size_h': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4490 |
case 'medium_large_size_w': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4491 |
case 'medium_large_size_h': |
0 | 4492 |
case 'large_size_w': |
4493 |
case 'large_size_h': |
|
4494 |
case 'mailserver_port': |
|
4495 |
case 'comment_max_links': |
|
4496 |
case 'page_on_front': |
|
4497 |
case 'page_for_posts': |
|
4498 |
case 'rss_excerpt_length': |
|
4499 |
case 'default_category': |
|
4500 |
case 'default_email_category': |
|
4501 |
case 'default_link_category': |
|
4502 |
case 'close_comments_days_old': |
|
4503 |
case 'comments_per_page': |
|
4504 |
case 'thread_comments_depth': |
|
4505 |
case 'users_can_register': |
|
4506 |
case 'start_of_week': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4507 |
case 'site_icon': |
0 | 4508 |
$value = absint( $value ); |
4509 |
break; |
|
4510 |
||
4511 |
case 'posts_per_page': |
|
4512 |
case 'posts_per_rss': |
|
4513 |
$value = (int) $value; |
|
9 | 4514 |
if ( empty( $value ) ) { |
0 | 4515 |
$value = 1; |
9 | 4516 |
} |
4517 |
if ( $value < -1 ) { |
|
4518 |
$value = abs( $value ); |
|
4519 |
} |
|
0 | 4520 |
break; |
4521 |
||
4522 |
case 'default_ping_status': |
|
4523 |
case 'default_comment_status': |
|
4524 |
// Options that if not there have 0 value but need to be something like "closed" |
|
9 | 4525 |
if ( $value == '0' || $value == '' ) { |
0 | 4526 |
$value = 'closed'; |
9 | 4527 |
} |
0 | 4528 |
break; |
4529 |
||
4530 |
case 'blogdescription': |
|
4531 |
case 'blogname': |
|
5 | 4532 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4533 |
if ( $value !== $original_value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4534 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', wp_encode_emoji( $original_value ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4535 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4536 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4537 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4538 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4539 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4540 |
$value = esc_html( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4541 |
} |
0 | 4542 |
break; |
4543 |
||
4544 |
case 'blog_charset': |
|
9 | 4545 |
$value = preg_replace( '/[^a-zA-Z0-9_-]/', '', $value ); // strips slashes |
0 | 4546 |
break; |
4547 |
||
4548 |
case 'blog_public': |
|
4549 |
// This is the value if the settings checkbox is not checked on POST. Don't rely on this. |
|
9 | 4550 |
if ( null === $value ) { |
0 | 4551 |
$value = 1; |
9 | 4552 |
} else { |
0 | 4553 |
$value = intval( $value ); |
9 | 4554 |
} |
0 | 4555 |
break; |
4556 |
||
4557 |
case 'date_format': |
|
4558 |
case 'time_format': |
|
4559 |
case 'mailserver_url': |
|
4560 |
case 'mailserver_login': |
|
4561 |
case 'mailserver_pass': |
|
4562 |
case 'upload_path': |
|
5 | 4563 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4564 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4565 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4566 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4567 |
$value = strip_tags( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4568 |
$value = wp_kses_data( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4569 |
} |
0 | 4570 |
break; |
4571 |
||
4572 |
case 'ping_sites': |
|
4573 |
$value = explode( "\n", $value ); |
|
4574 |
$value = array_filter( array_map( 'trim', $value ) ); |
|
4575 |
$value = array_filter( array_map( 'esc_url_raw', $value ) ); |
|
4576 |
$value = implode( "\n", $value ); |
|
4577 |
break; |
|
4578 |
||
4579 |
case 'gmt_offset': |
|
9 | 4580 |
$value = preg_replace( '/[^0-9:.-]/', '', $value ); // strips slashes |
0 | 4581 |
break; |
4582 |
||
4583 |
case 'siteurl': |
|
5 | 4584 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4585 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4586 |
$error = $value->get_error_message(); |
0 | 4587 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4588 |
if ( preg_match( '#http(s?)://(.+)#i', $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4589 |
$value = esc_url_raw( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4590 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4591 |
$error = __( 'The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4592 |
} |
0 | 4593 |
} |
4594 |
break; |
|
4595 |
||
4596 |
case 'home': |
|
5 | 4597 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4598 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4599 |
$error = $value->get_error_message(); |
0 | 4600 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4601 |
if ( preg_match( '#http(s?)://(.+)#i', $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4602 |
$value = esc_url_raw( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4603 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4604 |
$error = __( 'The Site address you entered did not appear to be a valid URL. Please enter a valid URL.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4605 |
} |
0 | 4606 |
} |
4607 |
break; |
|
4608 |
||
4609 |
case 'WPLANG': |
|
4610 |
$allowed = get_available_languages(); |
|
5 | 4611 |
if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG ) { |
4612 |
$allowed[] = WPLANG; |
|
4613 |
} |
|
4614 |
if ( ! in_array( $value, $allowed ) && ! empty( $value ) ) { |
|
0 | 4615 |
$value = get_option( $option ); |
5 | 4616 |
} |
0 | 4617 |
break; |
4618 |
||
4619 |
case 'illegal_names': |
|
5 | 4620 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4621 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4622 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4623 |
} else { |
9 | 4624 |
if ( ! is_array( $value ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4625 |
$value = explode( ' ', $value ); |
9 | 4626 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4627 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4628 |
$value = array_values( array_filter( array_map( 'trim', $value ) ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4629 |
|
9 | 4630 |
if ( ! $value ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4631 |
$value = ''; |
9 | 4632 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4633 |
} |
0 | 4634 |
break; |
4635 |
||
4636 |
case 'limited_email_domains': |
|
4637 |
case 'banned_email_domains': |
|
5 | 4638 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4639 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4640 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4641 |
} else { |
9 | 4642 |
if ( ! is_array( $value ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4643 |
$value = explode( "\n", $value ); |
9 | 4644 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4645 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4646 |
$domains = array_values( array_filter( array_map( 'trim', $value ) ) ); |
9 | 4647 |
$value = array(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4648 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4649 |
foreach ( $domains as $domain ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4650 |
if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4651 |
$value[] = $domain; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4652 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4653 |
} |
9 | 4654 |
if ( ! $value ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4655 |
$value = ''; |
9 | 4656 |
} |
0 | 4657 |
} |
4658 |
break; |
|
4659 |
||
4660 |
case 'timezone_string': |
|
4661 |
$allowed_zones = timezone_identifiers_list(); |
|
4662 |
if ( ! in_array( $value, $allowed_zones ) && ! empty( $value ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4663 |
$error = __( 'The timezone you have entered is not valid. Please select a valid timezone.' ); |
0 | 4664 |
} |
4665 |
break; |
|
4666 |
||
4667 |
case 'permalink_structure': |
|
4668 |
case 'category_base': |
|
4669 |
case 'tag_base': |
|
5 | 4670 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4671 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4672 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4673 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4674 |
$value = esc_url_raw( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4675 |
$value = str_replace( 'http://', '', $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4676 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4677 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4678 |
if ( 'permalink_structure' === $option && '' !== $value && ! preg_match( '/%[^\/%]+%/', $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4679 |
$error = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4680 |
/* translators: %s: Codex URL */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4681 |
__( 'A structure tag is required when using custom permalinks. <a href="%s">Learn more</a>' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4682 |
__( 'https://codex.wordpress.org/Using_Permalinks#Choosing_your_permalink_structure' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4683 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4684 |
} |
0 | 4685 |
break; |
4686 |
||
9 | 4687 |
case 'default_role': |
4688 |
if ( ! get_role( $value ) && get_role( 'subscriber' ) ) { |
|
0 | 4689 |
$value = 'subscriber'; |
9 | 4690 |
} |
0 | 4691 |
break; |
5 | 4692 |
|
4693 |
case 'moderation_keys': |
|
4694 |
case 'blacklist_keys': |
|
4695 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4696 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4697 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4698 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4699 |
$value = explode( "\n", $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4700 |
$value = array_filter( array_map( 'trim', $value ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4701 |
$value = array_unique( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4702 |
$value = implode( "\n", $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4703 |
} |
5 | 4704 |
break; |
0 | 4705 |
} |
4706 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4707 |
if ( ! empty( $error ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4708 |
$value = get_option( $option ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4709 |
if ( function_exists( 'add_settings_error' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4710 |
add_settings_error( $option, "invalid_{$option}", $error ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4711 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4712 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4713 |
|
5 | 4714 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4715 |
* Filters an option value following sanitization. |
5 | 4716 |
* |
4717 |
* @since 2.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4718 |
* @since 4.3.0 Added the `$original_value` parameter. |
5 | 4719 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4720 |
* @param string $value The sanitized option value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4721 |
* @param string $option The option name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4722 |
* @param string $original_value The original value passed to the function. |
5 | 4723 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4724 |
return apply_filters( "sanitize_option_{$option}", $value, $option, $original_value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4725 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4726 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4727 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4728 |
* Maps a function to all non-iterable elements of an array or an object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4729 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4730 |
* This is similar to `array_walk_recursive()` but acts upon objects too. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4731 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4732 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4733 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4734 |
* @param mixed $value The array, object, or scalar. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4735 |
* @param callable $callback The function to map onto $value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4736 |
* @return mixed The value with the callback applied to all non-arrays and non-objects inside it. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4737 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4738 |
function map_deep( $value, $callback ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4739 |
if ( is_array( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4740 |
foreach ( $value as $index => $item ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4741 |
$value[ $index ] = map_deep( $item, $callback ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4742 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4743 |
} elseif ( is_object( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4744 |
$object_vars = get_object_vars( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4745 |
foreach ( $object_vars as $property_name => $property_value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4746 |
$value->$property_name = map_deep( $property_value, $callback ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4747 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4748 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4749 |
$value = call_user_func( $callback, $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4750 |
} |
0 | 4751 |
|
4752 |
return $value; |
|
4753 |
} |
|
4754 |
||
4755 |
/** |
|
4756 |
* Parses a string into variables to be stored in an array. |
|
4757 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4758 |
* Uses {@link https://secure.php.net/parse_str parse_str()} and stripslashes if |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4759 |
* {@link https://secure.php.net/magic_quotes magic_quotes_gpc} is on. |
0 | 4760 |
* |
4761 |
* @since 2.2.1 |
|
4762 |
* |
|
4763 |
* @param string $string The string to be parsed. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4764 |
* @param array $array Variables will be stored in this array. |
0 | 4765 |
*/ |
4766 |
function wp_parse_str( $string, &$array ) { |
|
4767 |
parse_str( $string, $array ); |
|
9 | 4768 |
if ( get_magic_quotes_gpc() ) { |
0 | 4769 |
$array = stripslashes_deep( $array ); |
9 | 4770 |
} |
5 | 4771 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4772 |
* Filters the array of variables derived from a parsed string. |
5 | 4773 |
* |
4774 |
* @since 2.3.0 |
|
4775 |
* |
|
4776 |
* @param array $array The array populated with variables. |
|
4777 |
*/ |
|
0 | 4778 |
$array = apply_filters( 'wp_parse_str', $array ); |
4779 |
} |
|
4780 |
||
4781 |
/** |
|
4782 |
* Convert lone less than signs. |
|
4783 |
* |
|
4784 |
* KSES already converts lone greater than signs. |
|
4785 |
* |
|
4786 |
* @since 2.3.0 |
|
4787 |
* |
|
4788 |
* @param string $text Text to be converted. |
|
4789 |
* @return string Converted text. |
|
4790 |
*/ |
|
4791 |
function wp_pre_kses_less_than( $text ) { |
|
9 | 4792 |
return preg_replace_callback( '%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text ); |
0 | 4793 |
} |
4794 |
||
4795 |
/** |
|
4796 |
* Callback function used by preg_replace. |
|
4797 |
* |
|
4798 |
* @since 2.3.0 |
|
4799 |
* |
|
4800 |
* @param array $matches Populated by matches to preg_replace. |
|
4801 |
* @return string The text returned after esc_html if needed. |
|
4802 |
*/ |
|
4803 |
function wp_pre_kses_less_than_callback( $matches ) { |
|
9 | 4804 |
if ( false === strpos( $matches[0], '>' ) ) { |
4805 |
return esc_html( $matches[0] ); |
|
4806 |
} |
|
0 | 4807 |
return $matches[0]; |
4808 |
} |
|
4809 |
||
4810 |
/** |
|
4811 |
* WordPress implementation of PHP sprintf() with filters. |
|
4812 |
* |
|
4813 |
* @since 2.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4814 |
* @link https://secure.php.net/sprintf |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4815 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4816 |
* @param string $pattern The string which formatted args are inserted. |
5 | 4817 |
* @param mixed $args ,... Arguments to be formatted into the $pattern string. |
0 | 4818 |
* @return string The formatted string. |
4819 |
*/ |
|
4820 |
function wp_sprintf( $pattern ) { |
|
9 | 4821 |
$args = func_get_args(); |
4822 |
$len = strlen( $pattern ); |
|
4823 |
$start = 0; |
|
4824 |
$result = ''; |
|
0 | 4825 |
$arg_index = 0; |
4826 |
while ( $len > $start ) { |
|
4827 |
// Last character: append and break |
|
9 | 4828 |
if ( strlen( $pattern ) - 1 == $start ) { |
4829 |
$result .= substr( $pattern, -1 ); |
|
0 | 4830 |
break; |
4831 |
} |
|
4832 |
||
4833 |
// Literal %: append and continue |
|
9 | 4834 |
if ( substr( $pattern, $start, 2 ) == '%%' ) { |
4835 |
$start += 2; |
|
0 | 4836 |
$result .= '%'; |
4837 |
continue; |
|
4838 |
} |
|
4839 |
||
4840 |
// Get fragment before next % |
|
9 | 4841 |
$end = strpos( $pattern, '%', $start + 1 ); |
4842 |
if ( false === $end ) { |
|
0 | 4843 |
$end = $len; |
9 | 4844 |
} |
4845 |
$fragment = substr( $pattern, $start, $end - $start ); |
|
0 | 4846 |
|
4847 |
// Fragment has a specifier |
|
9 | 4848 |
if ( $pattern[ $start ] == '%' ) { |
0 | 4849 |
// Find numbered arguments or take the next one in order |
9 | 4850 |
if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) { |
4851 |
$arg = isset( $args[ $matches[1] ] ) ? $args[ $matches[1] ] : ''; |
|
4852 |
$fragment = str_replace( "%{$matches[1]}$", '%', $fragment ); |
|
0 | 4853 |
} else { |
4854 |
++$arg_index; |
|
9 | 4855 |
$arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : ''; |
0 | 4856 |
} |
4857 |
||
5 | 4858 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4859 |
* Filters a fragment from the pattern passed to wp_sprintf(). |
5 | 4860 |
* |
4861 |
* If the fragment is unchanged, then sprintf() will be run on the fragment. |
|
4862 |
* |
|
4863 |
* @since 2.5.0 |
|
4864 |
* |
|
4865 |
* @param string $fragment A fragment from the pattern. |
|
4866 |
* @param string $arg The argument. |
|
4867 |
*/ |
|
0 | 4868 |
$_fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); |
9 | 4869 |
if ( $_fragment != $fragment ) { |
0 | 4870 |
$fragment = $_fragment; |
9 | 4871 |
} else { |
4872 |
$fragment = sprintf( $fragment, strval( $arg ) ); |
|
4873 |
} |
|
0 | 4874 |
} |
4875 |
||
4876 |
// Append to result and move to next fragment |
|
4877 |
$result .= $fragment; |
|
9 | 4878 |
$start = $end; |
0 | 4879 |
} |
4880 |
return $result; |
|
4881 |
} |
|
4882 |
||
4883 |
/** |
|
4884 |
* Localize list items before the rest of the content. |
|
4885 |
* |
|
4886 |
* The '%l' must be at the first characters can then contain the rest of the |
|
4887 |
* content. The list items will have ', ', ', and', and ' and ' added depending |
|
4888 |
* on the amount of list items in the $args parameter. |
|
4889 |
* |
|
4890 |
* @since 2.5.0 |
|
4891 |
* |
|
4892 |
* @param string $pattern Content containing '%l' at the beginning. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4893 |
* @param array $args List items to prepend to the content and replace '%l'. |
0 | 4894 |
* @return string Localized list items and rest of the content. |
4895 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4896 |
function wp_sprintf_l( $pattern, $args ) { |
0 | 4897 |
// Not a match |
9 | 4898 |
if ( substr( $pattern, 0, 2 ) != '%l' ) { |
0 | 4899 |
return $pattern; |
9 | 4900 |
} |
0 | 4901 |
|
4902 |
// Nothing to work with |
|
9 | 4903 |
if ( empty( $args ) ) { |
0 | 4904 |
return ''; |
9 | 4905 |
} |
0 | 4906 |
|
5 | 4907 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4908 |
* Filters the translated delimiters used by wp_sprintf_l(). |
5 | 4909 |
* Placeholders (%s) are included to assist translators and then |
4910 |
* removed before the array of strings reaches the filter. |
|
4911 |
* |
|
4912 |
* Please note: Ampersands and entities should be avoided here. |
|
4913 |
* |
|
4914 |
* @since 2.5.0 |
|
4915 |
* |
|
4916 |
* @param array $delimiters An array of translated delimiters. |
|
4917 |
*/ |
|
9 | 4918 |
$l = apply_filters( |
4919 |
'wp_sprintf_l', |
|
4920 |
array( |
|
4921 |
/* translators: used to join items in a list with more than 2 items */ |
|
4922 |
'between' => sprintf( __( '%1$s, %2$s' ), '', '' ), |
|
4923 |
/* translators: used to join last two items in a list with more than 2 times */ |
|
4924 |
'between_last_two' => sprintf( __( '%1$s, and %2$s' ), '', '' ), |
|
4925 |
/* translators: used to join items in a list with only 2 items */ |
|
4926 |
'between_only_two' => sprintf( __( '%1$s and %2$s' ), '', '' ), |
|
4927 |
) |
|
4928 |
); |
|
4929 |
||
4930 |
$args = (array) $args; |
|
4931 |
$result = array_shift( $args ); |
|
4932 |
if ( count( $args ) == 1 ) { |
|
4933 |
$result .= $l['between_only_two'] . array_shift( $args ); |
|
4934 |
} |
|
0 | 4935 |
// Loop when more than two args |
9 | 4936 |
$i = count( $args ); |
0 | 4937 |
while ( $i ) { |
9 | 4938 |
$arg = array_shift( $args ); |
0 | 4939 |
$i--; |
9 | 4940 |
if ( 0 == $i ) { |
0 | 4941 |
$result .= $l['between_last_two'] . $arg; |
9 | 4942 |
} else { |
0 | 4943 |
$result .= $l['between'] . $arg; |
9 | 4944 |
} |
0 | 4945 |
} |
9 | 4946 |
return $result . substr( $pattern, 2 ); |
0 | 4947 |
} |
4948 |
||
4949 |
/** |
|
4950 |
* Safely extracts not more than the first $count characters from html string. |
|
4951 |
* |
|
4952 |
* UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* |
|
4953 |
* be counted as one character. For example & will be counted as 4, < as |
|
4954 |
* 3, etc. |
|
4955 |
* |
|
4956 |
* @since 2.5.0 |
|
4957 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4958 |
* @param string $str String to get the excerpt from. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4959 |
* @param int $count Maximum number of characters to take. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4960 |
* @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string. |
0 | 4961 |
* @return string The excerpt. |
4962 |
*/ |
|
4963 |
function wp_html_excerpt( $str, $count, $more = null ) { |
|
9 | 4964 |
if ( null === $more ) { |
0 | 4965 |
$more = ''; |
9 | 4966 |
} |
4967 |
$str = wp_strip_all_tags( $str, true ); |
|
0 | 4968 |
$excerpt = mb_substr( $str, 0, $count ); |
4969 |
// remove part of an entity at the end |
|
4970 |
$excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt ); |
|
9 | 4971 |
if ( $str != $excerpt ) { |
0 | 4972 |
$excerpt = trim( $excerpt ) . $more; |
9 | 4973 |
} |
0 | 4974 |
return $excerpt; |
4975 |
} |
|
4976 |
||
4977 |
/** |
|
4978 |
* Add a Base url to relative links in passed content. |
|
4979 |
* |
|
4980 |
* By default it supports the 'src' and 'href' attributes. However this can be |
|
4981 |
* changed via the 3rd param. |
|
4982 |
* |
|
4983 |
* @since 2.7.0 |
|
4984 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4985 |
* @global string $_links_add_base |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4986 |
* |
0 | 4987 |
* @param string $content String to search for links in. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4988 |
* @param string $base The base URL to prefix to links. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4989 |
* @param array $attrs The attributes which should be processed. |
0 | 4990 |
* @return string The processed content. |
4991 |
*/ |
|
9 | 4992 |
function links_add_base_url( $content, $base, $attrs = array( 'src', 'href' ) ) { |
0 | 4993 |
global $_links_add_base; |
4994 |
$_links_add_base = $base; |
|
9 | 4995 |
$attrs = implode( '|', (array) $attrs ); |
0 | 4996 |
return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content ); |
4997 |
} |
|
4998 |
||
4999 |
/** |
|
5000 |
* Callback to add a base url to relative links in passed content. |
|
5001 |
* |
|
5002 |
* @since 2.7.0 |
|
5003 |
* @access private |
|
5004 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5005 |
* @global string $_links_add_base |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5006 |
* |
0 | 5007 |
* @param string $m The matched link. |
5008 |
* @return string The processed link. |
|
5009 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5010 |
function _links_add_base( $m ) { |
0 | 5011 |
global $_links_add_base; |
5012 |
//1 = attribute name 2 = quotation mark 3 = URL |
|
5013 |
return $m[1] . '=' . $m[2] . |
|
5014 |
( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols() ) ? |
|
5015 |
$m[3] : |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5016 |
WP_Http::make_absolute_url( $m[3], $_links_add_base ) |
5 | 5017 |
) |
0 | 5018 |
. $m[2]; |
5019 |
} |
|
5020 |
||
5021 |
/** |
|
5022 |
* Adds a Target attribute to all links in passed content. |
|
5023 |
* |
|
5 | 5024 |
* This function by default only applies to `<a>` tags, however this can be |
0 | 5025 |
* modified by the 3rd param. |
5026 |
* |
|
5 | 5027 |
* *NOTE:* Any current target attributed will be stripped and replaced. |
0 | 5028 |
* |
5029 |
* @since 2.7.0 |
|
5030 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5031 |
* @global string $_links_add_target |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5032 |
* |
0 | 5033 |
* @param string $content String to search for links in. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5034 |
* @param string $target The Target to add to the links. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5035 |
* @param array $tags An array of tags to apply to. |
0 | 5036 |
* @return string The processed content. |
5037 |
*/ |
|
9 | 5038 |
function links_add_target( $content, $target = '_blank', $tags = array( 'a' ) ) { |
0 | 5039 |
global $_links_add_target; |
5040 |
$_links_add_target = $target; |
|
9 | 5041 |
$tags = implode( '|', (array) $tags ); |
5 | 5042 |
return preg_replace_callback( "!<($tags)([^>]*)>!i", '_links_add_target', $content ); |
0 | 5043 |
} |
5044 |
||
5045 |
/** |
|
5046 |
* Callback to add a target attribute to all links in passed content. |
|
5047 |
* |
|
5048 |
* @since 2.7.0 |
|
5049 |
* @access private |
|
5050 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5051 |
* @global string $_links_add_target |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5052 |
* |
0 | 5053 |
* @param string $m The matched link. |
5054 |
* @return string The processed link. |
|
5055 |
*/ |
|
5056 |
function _links_add_target( $m ) { |
|
5057 |
global $_links_add_target; |
|
9 | 5058 |
$tag = $m[1]; |
5059 |
$link = preg_replace( '|( target=([\'"])(.*?)\2)|i', '', $m[2] ); |
|
0 | 5060 |
return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">'; |
5061 |
} |
|
5062 |
||
5063 |
/** |
|
5064 |
* Normalize EOL characters and strip duplicate whitespace. |
|
5065 |
* |
|
5066 |
* @since 2.7.0 |
|
5067 |
* |
|
5068 |
* @param string $str The string to normalize. |
|
5069 |
* @return string The normalized string. |
|
5070 |
*/ |
|
5071 |
function normalize_whitespace( $str ) { |
|
9 | 5072 |
$str = trim( $str ); |
5073 |
$str = str_replace( "\r", "\n", $str ); |
|
5074 |
$str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str ); |
|
0 | 5075 |
return $str; |
5076 |
} |
|
5077 |
||
5078 |
/** |
|
5079 |
* Properly strip all HTML tags including script and style |
|
5080 |
* |
|
5 | 5081 |
* This differs from strip_tags() because it removes the contents of |
5082 |
* the `<script>` and `<style>` tags. E.g. `strip_tags( '<script>something</script>' )` |
|
5083 |
* will return 'something'. wp_strip_all_tags will return '' |
|
5084 |
* |
|
0 | 5085 |
* @since 2.9.0 |
5086 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5087 |
* @param string $string String containing HTML tags |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5088 |
* @param bool $remove_breaks Optional. Whether to remove left over line breaks and white space chars |
0 | 5089 |
* @return string The processed string. |
5090 |
*/ |
|
9 | 5091 |
function wp_strip_all_tags( $string, $remove_breaks = false ) { |
0 | 5092 |
$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string ); |
9 | 5093 |
$string = strip_tags( $string ); |
5094 |
||
5095 |
if ( $remove_breaks ) { |
|
5096 |
$string = preg_replace( '/[\r\n\t ]+/', ' ', $string ); |
|
5097 |
} |
|
0 | 5098 |
|
5099 |
return trim( $string ); |
|
5100 |
} |
|
5101 |
||
5102 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5103 |
* Sanitizes a string from user input or from the database. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5104 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5105 |
* - Checks for invalid UTF-8, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5106 |
* - Converts single `<` characters to entities |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5107 |
* - Strips all tags |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5108 |
* - Removes line breaks, tabs, and extra whitespace |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5109 |
* - Strips octets |
0 | 5110 |
* |
5111 |
* @since 2.9.0 |
|
5112 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5113 |
* @see sanitize_textarea_field() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5114 |
* @see wp_check_invalid_utf8() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5115 |
* @see wp_strip_all_tags() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5116 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5117 |
* @param string $str String to sanitize. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5118 |
* @return string Sanitized string. |
0 | 5119 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5120 |
function sanitize_text_field( $str ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5121 |
$filtered = _sanitize_text_fields( $str, false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5122 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5123 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5124 |
* Filters a sanitized text field string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5125 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5126 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5127 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5128 |
* @param string $filtered The sanitized string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5129 |
* @param string $str The string prior to being sanitized. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5130 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5131 |
return apply_filters( 'sanitize_text_field', $filtered, $str ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5132 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5133 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5134 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5135 |
* Sanitizes a multiline string from user input or from the database. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5136 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5137 |
* The function is like sanitize_text_field(), but preserves |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5138 |
* new lines (\n) and other whitespace, which are legitimate |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5139 |
* input in textarea elements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5140 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5141 |
* @see sanitize_text_field() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5142 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5143 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5144 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5145 |
* @param string $str String to sanitize. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5146 |
* @return string Sanitized string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5147 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5148 |
function sanitize_textarea_field( $str ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5149 |
$filtered = _sanitize_text_fields( $str, true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5150 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5151 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5152 |
* Filters a sanitized textarea field string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5153 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5154 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5155 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5156 |
* @param string $filtered The sanitized string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5157 |
* @param string $str The string prior to being sanitized. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5158 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5159 |
return apply_filters( 'sanitize_textarea_field', $filtered, $str ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5160 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5161 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5162 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5163 |
* Internal helper function to sanitize a string from user input or from the db |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5164 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5165 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5166 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5167 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5168 |
* @param string $str String to sanitize. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5169 |
* @param bool $keep_newlines optional Whether to keep newlines. Default: false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5170 |
* @return string Sanitized string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5171 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5172 |
function _sanitize_text_fields( $str, $keep_newlines = false ) { |
9 | 5173 |
if ( is_object( $str ) || is_array( $str ) ) { |
5174 |
return ''; |
|
5175 |
} |
|
5176 |
||
5177 |
$str = (string) $str; |
|
5178 |
||
0 | 5179 |
$filtered = wp_check_invalid_utf8( $str ); |
5180 |
||
9 | 5181 |
if ( strpos( $filtered, '<' ) !== false ) { |
0 | 5182 |
$filtered = wp_pre_kses_less_than( $filtered ); |
5183 |
// This will strip extra whitespace for us. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5184 |
$filtered = wp_strip_all_tags( $filtered, false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5185 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5186 |
// Use html entities in a special case to make sure no later |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5187 |
// newline stripping stage could lead to a functional tag |
9 | 5188 |
$filtered = str_replace( "<\n", "<\n", $filtered ); |
0 | 5189 |
} |
5190 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5191 |
if ( ! $keep_newlines ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5192 |
$filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5193 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5194 |
$filtered = trim( $filtered ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5195 |
|
0 | 5196 |
$found = false; |
9 | 5197 |
while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $match ) ) { |
5198 |
$filtered = str_replace( $match[0], '', $filtered ); |
|
5199 |
$found = true; |
|
0 | 5200 |
} |
5201 |
||
5202 |
if ( $found ) { |
|
5203 |
// Strip out the whitespace that may now exist after removing the octets. |
|
9 | 5204 |
$filtered = trim( preg_replace( '/ +/', ' ', $filtered ) ); |
0 | 5205 |
} |
5206 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5207 |
return $filtered; |
0 | 5208 |
} |
5209 |
||
5210 |
/** |
|
5211 |
* i18n friendly version of basename() |
|
5212 |
* |
|
5213 |
* @since 3.1.0 |
|
5214 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5215 |
* @param string $path A path. |
0 | 5216 |
* @param string $suffix If the filename ends in suffix this will also be cut off. |
5217 |
* @return string |
|
5218 |
*/ |
|
5219 |
function wp_basename( $path, $suffix = '' ) { |
|
5220 |
return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) ); |
|
5221 |
} |
|
5222 |
||
9 | 5223 |
// phpcs:disable WordPress.WP.CapitalPDangit.Misspelled, WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid -- 8-) |
0 | 5224 |
/** |
5225 |
* Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence). |
|
5226 |
* |
|
5227 |
* Violating our coding standards for a good function name. |
|
5228 |
* |
|
5229 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5230 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5231 |
* @staticvar string|false $dblq |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5232 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5233 |
* @param string $text The text to be modified. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5234 |
* @return string The modified text. |
0 | 5235 |
*/ |
5236 |
function capital_P_dangit( $text ) { |
|
5237 |
// Simple replacement for titles |
|
5 | 5238 |
$current_filter = current_filter(); |
9 | 5239 |
if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) { |
0 | 5240 |
return str_replace( 'Wordpress', 'WordPress', $text ); |
9 | 5241 |
} |
0 | 5242 |
// Still here? Use the more judicious replacement |
5243 |
static $dblq = false; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5244 |
if ( false === $dblq ) { |
0 | 5245 |
$dblq = _x( '“', 'opening curly double quote' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5246 |
} |
0 | 5247 |
return str_replace( |
5248 |
array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ), |
|
5249 |
array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ), |
|
9 | 5250 |
$text |
5251 |
); |
|
0 | 5252 |
} |
9 | 5253 |
// phpcs:enable |
0 | 5254 |
|
5255 |
/** |
|
5256 |
* Sanitize a mime type |
|
5257 |
* |
|
5258 |
* @since 3.1.3 |
|
5259 |
* |
|
5260 |
* @param string $mime_type Mime type |
|
5261 |
* @return string Sanitized mime type |
|
5262 |
*/ |
|
5263 |
function sanitize_mime_type( $mime_type ) { |
|
5264 |
$sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type ); |
|
5 | 5265 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5266 |
* Filters a mime type following sanitization. |
5 | 5267 |
* |
5268 |
* @since 3.1.3 |
|
5269 |
* |
|
5270 |
* @param string $sani_mime_type The sanitized mime type. |
|
5271 |
* @param string $mime_type The mime type prior to sanitization. |
|
5272 |
*/ |
|
0 | 5273 |
return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type ); |
5274 |
} |
|
5275 |
||
5276 |
/** |
|
5277 |
* Sanitize space or carriage return separated URLs that are used to send trackbacks. |
|
5278 |
* |
|
5279 |
* @since 3.4.0 |
|
5280 |
* |
|
5281 |
* @param string $to_ping Space or carriage return separated URLs |
|
5282 |
* @return string URLs starting with the http or https protocol, separated by a carriage return. |
|
5283 |
*/ |
|
5284 |
function sanitize_trackback_urls( $to_ping ) { |
|
5285 |
$urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY ); |
|
5286 |
foreach ( $urls_to_ping as $k => $url ) { |
|
9 | 5287 |
if ( ! preg_match( '#^https?://.#i', $url ) ) { |
5288 |
unset( $urls_to_ping[ $k ] ); |
|
5289 |
} |
|
0 | 5290 |
} |
5291 |
$urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping ); |
|
5292 |
$urls_to_ping = implode( "\n", $urls_to_ping ); |
|
5 | 5293 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5294 |
* Filters a list of trackback URLs following sanitization. |
5 | 5295 |
* |
5296 |
* The string returned here consists of a space or carriage return-delimited list |
|
5297 |
* of trackback URLs. |
|
5298 |
* |
|
5299 |
* @since 3.4.0 |
|
5300 |
* |
|
5301 |
* @param string $urls_to_ping Sanitized space or carriage return separated URLs. |
|
5302 |
* @param string $to_ping Space or carriage return separated URLs before sanitization. |
|
5303 |
*/ |
|
0 | 5304 |
return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping ); |
5305 |
} |
|
5306 |
||
5307 |
/** |
|
5308 |
* Add slashes to a string or array of strings. |
|
5309 |
* |
|
5310 |
* This should be used when preparing data for core API that expects slashed data. |
|
5311 |
* This should not be used to escape data going directly into an SQL query. |
|
5312 |
* |
|
5313 |
* @since 3.6.0 |
|
5314 |
* |
|
5315 |
* @param string|array $value String or array of strings to slash. |
|
5316 |
* @return string|array Slashed $value |
|
5317 |
*/ |
|
5318 |
function wp_slash( $value ) { |
|
5319 |
if ( is_array( $value ) ) { |
|
5320 |
foreach ( $value as $k => $v ) { |
|
5321 |
if ( is_array( $v ) ) { |
|
9 | 5322 |
$value[ $k ] = wp_slash( $v ); |
0 | 5323 |
} else { |
9 | 5324 |
$value[ $k ] = addslashes( $v ); |
0 | 5325 |
} |
5326 |
} |
|
5327 |
} else { |
|
5328 |
$value = addslashes( $value ); |
|
5329 |
} |
|
5330 |
||
5331 |
return $value; |
|
5332 |
} |
|
5333 |
||
5334 |
/** |
|
5335 |
* Remove slashes from a string or array of strings. |
|
5336 |
* |
|
5337 |
* This should be used to remove slashes from data passed to core API that |
|
5338 |
* expects data to be unslashed. |
|
5339 |
* |
|
5340 |
* @since 3.6.0 |
|
5341 |
* |
|
5342 |
* @param string|array $value String or array of strings to unslash. |
|
5343 |
* @return string|array Unslashed $value |
|
5344 |
*/ |
|
5345 |
function wp_unslash( $value ) { |
|
5346 |
return stripslashes_deep( $value ); |
|
5347 |
} |
|
5348 |
||
5349 |
/** |
|
5350 |
* Extract and return the first URL from passed content. |
|
5351 |
* |
|
5352 |
* @since 3.6.0 |
|
5353 |
* |
|
5354 |
* @param string $content A string which might contain a URL. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5355 |
* @return string|false The found URL. |
0 | 5356 |
*/ |
5357 |
function get_url_in_content( $content ) { |
|
5 | 5358 |
if ( empty( $content ) ) { |
5359 |
return false; |
|
5360 |
} |
|
5361 |
||
5362 |
if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) { |
|
0 | 5363 |
return esc_url_raw( $matches[2] ); |
5 | 5364 |
} |
0 | 5365 |
|
5366 |
return false; |
|
5367 |
} |
|
5 | 5368 |
|
5369 |
/** |
|
5370 |
* Returns the regexp for common whitespace characters. |
|
5371 |
* |
|
5372 |
* By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp. |
|
5373 |
* This is designed to replace the PCRE \s sequence. In ticket #22692, that |
|
5374 |
* sequence was found to be unreliable due to random inclusion of the A0 byte. |
|
5375 |
* |
|
5376 |
* @since 4.0.0 |
|
5377 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5378 |
* @staticvar string $spaces |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5379 |
* |
5 | 5380 |
* @return string The spaces regexp. |
5381 |
*/ |
|
5382 |
function wp_spaces_regexp() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5383 |
static $spaces = ''; |
5 | 5384 |
|
5385 |
if ( empty( $spaces ) ) { |
|
5386 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5387 |
* Filters the regexp for common whitespace characters. |
5 | 5388 |
* |
5389 |
* This string is substituted for the \s sequence as needed in regular |
|
5390 |
* expressions. For websites not written in English, different characters |
|
5391 |
* may represent whitespace. For websites not encoded in UTF-8, the 0xC2 0xA0 |
|
5392 |
* sequence may not be in use. |
|
5393 |
* |
|
5394 |
* @since 4.0.0 |
|
5395 |
* |
|
5396 |
* @param string $spaces Regexp pattern for matching common whitespace characters. |
|
5397 |
*/ |
|
5398 |
$spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0| ' ); |
|
5399 |
} |
|
5400 |
||
5401 |
return $spaces; |
|
5402 |
} |
|
5403 |
||
5404 |
/** |
|
5405 |
* Print the important emoji-related styles. |
|
5406 |
* |
|
5407 |
* @since 4.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5408 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5409 |
* @staticvar bool $printed |
5 | 5410 |
*/ |
5411 |
function print_emoji_styles() { |
|
5412 |
static $printed = false; |
|
5413 |
||
5414 |
if ( $printed ) { |
|
5415 |
return; |
|
5416 |
} |
|
5417 |
||
5418 |
$printed = true; |
|
9 | 5419 |
?> |
5 | 5420 |
<style type="text/css"> |
5421 |
img.wp-smiley, |
|
5422 |
img.emoji { |
|
5423 |
display: inline !important; |
|
5424 |
border: none !important; |
|
5425 |
box-shadow: none !important; |
|
5426 |
height: 1em !important; |
|
5427 |
width: 1em !important; |
|
5428 |
margin: 0 .07em !important; |
|
5429 |
vertical-align: -0.1em !important; |
|
5430 |
background: none !important; |
|
5431 |
padding: 0 !important; |
|
5432 |
} |
|
5433 |
</style> |
|
9 | 5434 |
<?php |
5 | 5435 |
} |
5436 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5437 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5438 |
* Print the inline Emoji detection script if it is not already printed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5439 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5440 |
* @since 4.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5441 |
* @staticvar bool $printed |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5442 |
*/ |
5 | 5443 |
function print_emoji_detection_script() { |
5444 |
static $printed = false; |
|
5445 |
||
5446 |
if ( $printed ) { |
|
5447 |
return; |
|
5448 |
} |
|
5449 |
||
5450 |
$printed = true; |
|
5451 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5452 |
_print_emoji_detection_script(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5453 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5454 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5455 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5456 |
* Prints inline Emoji dection script |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5457 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5458 |
* @ignore |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5459 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5460 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5461 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5462 |
function _print_emoji_detection_script() { |
5 | 5463 |
$settings = array( |
5464 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5465 |
* Filters the URL where emoji png images are hosted. |
5 | 5466 |
* |
5467 |
* @since 4.2.0 |
|
5468 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5469 |
* @param string The emoji base URL for png images. |
5 | 5470 |
*/ |
9 | 5471 |
'baseUrl' => apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/12.0.0-1/72x72/' ), |
5 | 5472 |
|
5473 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5474 |
* Filters the extension of the emoji png files. |
5 | 5475 |
* |
5476 |
* @since 4.2.0 |
|
5477 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5478 |
* @param string The emoji extension for png files. Default .png. |
5 | 5479 |
*/ |
9 | 5480 |
'ext' => apply_filters( 'emoji_ext', '.png' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5481 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5482 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5483 |
* Filters the URL where emoji SVG images are hosted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5484 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5485 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5486 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5487 |
* @param string The emoji base URL for svg images. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5488 |
*/ |
9 | 5489 |
'svgUrl' => apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/12.0.0-1/svg/' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5490 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5491 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5492 |
* Filters the extension of the emoji SVG files. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5493 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5494 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5495 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5496 |
* @param string The emoji extension for svg files. Default .svg. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5497 |
*/ |
9 | 5498 |
'svgExt' => apply_filters( 'emoji_svg_ext', '.svg' ), |
5 | 5499 |
); |
5500 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5501 |
$version = 'ver=' . get_bloginfo( 'version' ); |
5 | 5502 |
|
5503 |
if ( SCRIPT_DEBUG ) { |
|
5504 |
$settings['source'] = array( |
|
5505 |
/** This filter is documented in wp-includes/class.wp-scripts.php */ |
|
5506 |
'wpemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji.js?$version" ), 'wpemoji' ), |
|
5507 |
/** This filter is documented in wp-includes/class.wp-scripts.php */ |
|
5508 |
'twemoji' => apply_filters( 'script_loader_src', includes_url( "js/twemoji.js?$version" ), 'twemoji' ), |
|
5509 |
); |
|
5510 |
||
5511 |
?> |
|
5512 |
<script type="text/javascript"> |
|
5513 |
window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; |
|
9 | 5514 |
<?php readfile( ABSPATH . WPINC . '/js/wp-emoji-loader.js' ); ?> |
5 | 5515 |
</script> |
5516 |
<?php |
|
5517 |
} else { |
|
5518 |
$settings['source'] = array( |
|
5519 |
/** This filter is documented in wp-includes/class.wp-scripts.php */ |
|
5520 |
'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ), |
|
5521 |
); |
|
5522 |
||
5523 |
/* |
|
5524 |
* If you're looking at a src version of this file, you'll see an "include" |
|
5525 |
* statement below. This is used by the `grunt build` process to directly |
|
5526 |
* include a minified version of wp-emoji-loader.js, instead of using the |
|
5527 |
* readfile() method from above. |
|
5528 |
* |
|
5529 |
* If you're looking at a build version of this file, you'll see a string of |
|
5530 |
* minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG |
|
5531 |
* and edit wp-emoji-loader.js directly. |
|
5532 |
*/ |
|
5533 |
?> |
|
5534 |
<script type="text/javascript"> |
|
5535 |
window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; |
|
9 | 5536 |
!function(a,b,c){function d(a,b){var c=String.fromCharCode;l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,a),0,0);var d=k.toDataURL();l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,b),0,0);var e=k.toDataURL();return d===e}function e(a){var b;if(!l||!l.fillText)return!1;switch(l.textBaseline="top",l.font="600 32px Arial",a){case"flag":return!(b=d([55356,56826,55356,56819],[55356,56826,8203,55356,56819]))&&(b=d([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]),!b);case"emoji":return b=d([55357,56424,55356,57342,8205,55358,56605,8205,55357,56424,55356,57340],[55357,56424,55356,57342,8203,55358,56605,8203,55357,56424,55356,57340]),!b}return!1}function f(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var g,h,i,j,k=b.createElement("canvas"),l=k.getContext&&k.getContext("2d");for(j=Array("flag","emoji"),c.supports={everything:!0,everythingExceptFlag:!0},i=0;i<j.length;i++)c.supports[j[i]]=e(j[i]),c.supports.everything=c.supports.everything&&c.supports[j[i]],"flag"!==j[i]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[j[i]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(h=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",h,!1),a.addEventListener("load",h,!1)):(a.attachEvent("onload",h),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),g=c.source||{},g.concatemoji?f(g.concatemoji):g.wpemoji&&g.twemoji&&(f(g.twemoji),f(g.wpemoji)))}(window,document,window._wpemojiSettings); |
5 | 5537 |
</script> |
5538 |
<?php |
|
5539 |
} |
|
5540 |
} |
|
5541 |
||
5542 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5543 |
* Convert emoji characters to their equivalent HTML entity. |
5 | 5544 |
* |
5545 |
* This allows us to store emoji in a DB using the utf8 character set. |
|
5546 |
* |
|
5547 |
* @since 4.2.0 |
|
5548 |
* |
|
5549 |
* @param string $content The content to encode. |
|
5550 |
* @return string The encoded content. |
|
5551 |
*/ |
|
5552 |
function wp_encode_emoji( $content ) { |
|
9 | 5553 |
$emoji = _wp_emoji_list( 'partials' ); |
5554 |
$compat = version_compare( phpversion(), '5.4', '<' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5555 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5556 |
foreach ( $emoji as $emojum ) { |
9 | 5557 |
if ( $compat ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5558 |
$emoji_char = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5559 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5560 |
$emoji_char = html_entity_decode( $emojum ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5561 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5562 |
if ( false !== strpos( $content, $emoji_char ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5563 |
$content = preg_replace( "/$emoji_char/", $emojum, $content ); |
5 | 5564 |
} |
5565 |
} |
|
5566 |
||
5567 |
return $content; |
|
5568 |
} |
|
5569 |
||
5570 |
/** |
|
5571 |
* Convert emoji to a static img element. |
|
5572 |
* |
|
5573 |
* @since 4.2.0 |
|
5574 |
* |
|
5575 |
* @param string $text The content to encode. |
|
5576 |
* @return string The encoded content. |
|
5577 |
*/ |
|
5578 |
function wp_staticize_emoji( $text ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5579 |
if ( false === strpos( $text, '&#x' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5580 |
if ( ( function_exists( 'mb_check_encoding' ) && mb_check_encoding( $text, 'ASCII' ) ) || ! preg_match( '/[^\x00-\x7F]/', $text ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5581 |
// The text doesn't contain anything that might be emoji, so we can return early. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5582 |
return $text; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5583 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5584 |
$encoded_text = wp_encode_emoji( $text ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5585 |
if ( $encoded_text === $text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5586 |
return $encoded_text; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5587 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5588 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5589 |
$text = $encoded_text; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5590 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5591 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5592 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5593 |
$emoji = _wp_emoji_list( 'entities' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5594 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5595 |
// Quickly narrow down the list of emoji that might be in the text and need replacing. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5596 |
$possible_emoji = array(); |
9 | 5597 |
$compat = version_compare( phpversion(), '5.4', '<' ); |
5598 |
foreach ( $emoji as $emojum ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5599 |
if ( false !== strpos( $text, $emojum ) ) { |
9 | 5600 |
if ( $compat ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5601 |
$possible_emoji[ $emojum ] = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5602 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5603 |
$possible_emoji[ $emojum ] = html_entity_decode( $emojum ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5604 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5605 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5606 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5607 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5608 |
if ( ! $possible_emoji ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5609 |
return $text; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5610 |
} |
5 | 5611 |
|
5612 |
/** This filter is documented in wp-includes/formatting.php */ |
|
9 | 5613 |
$cdn_url = apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/12.0.0-1/72x72/' ); |
5 | 5614 |
|
5615 |
/** This filter is documented in wp-includes/formatting.php */ |
|
5616 |
$ext = apply_filters( 'emoji_ext', '.png' ); |
|
5617 |
||
5618 |
$output = ''; |
|
5619 |
/* |
|
5620 |
* HTML loop taken from smiley function, which was taken from texturize function. |
|
5621 |
* It'll never be consolidated. |
|
5622 |
* |
|
5623 |
* First, capture the tags as well as in between. |
|
5624 |
*/ |
|
5625 |
$textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
|
9 | 5626 |
$stop = count( $textarr ); |
5 | 5627 |
|
5628 |
// Ignore processing of specific tags. |
|
9 | 5629 |
$tags_to_ignore = 'code|pre|style|script|textarea'; |
5 | 5630 |
$ignore_block_element = ''; |
5631 |
||
5632 |
for ( $i = 0; $i < $stop; $i++ ) { |
|
9 | 5633 |
$content = $textarr[ $i ]; |
5 | 5634 |
|
5635 |
// If we're in an ignore block, wait until we find its closing tag. |
|
9 | 5636 |
if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) { |
5 | 5637 |
$ignore_block_element = $matches[1]; |
5638 |
} |
|
5639 |
||
5640 |
// If it's not a tag and not in ignore block. |
|
9 | 5641 |
if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] && false !== strpos( $content, '&#x' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5642 |
foreach ( $possible_emoji as $emojum => $emoji_char ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5643 |
if ( false === strpos( $content, $emojum ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5644 |
continue; |
5 | 5645 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5646 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5647 |
$file = str_replace( ';&#x', '-', $emojum ); |
9 | 5648 |
$file = str_replace( array( '&#x', ';' ), '', $file ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5649 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5650 |
$entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $file . $ext, $emoji_char ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5651 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5652 |
$content = str_replace( $emojum, $entity, $content ); |
5 | 5653 |
} |
5654 |
} |
|
5655 |
||
5656 |
// Did we exit ignore block. |
|
9 | 5657 |
if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) { |
5 | 5658 |
$ignore_block_element = ''; |
5659 |
} |
|
5660 |
||
5661 |
$output .= $content; |
|
5662 |
} |
|
5663 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5664 |
// Finally, remove any stray U+FE0F characters |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5665 |
$output = str_replace( '️', '', $output ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5666 |
|
5 | 5667 |
return $output; |
5668 |
} |
|
5669 |
||
5670 |
/** |
|
5671 |
* Convert emoji in emails into static images. |
|
5672 |
* |
|
5673 |
* @since 4.2.0 |
|
5674 |
* |
|
5675 |
* @param array $mail The email data array. |
|
5676 |
* @return array The email data array, with emoji in the message staticized. |
|
5677 |
*/ |
|
5678 |
function wp_staticize_emoji_for_email( $mail ) { |
|
5679 |
if ( ! isset( $mail['message'] ) ) { |
|
5680 |
return $mail; |
|
5681 |
} |
|
5682 |
||
5683 |
/* |
|
5684 |
* We can only transform the emoji into images if it's a text/html email. |
|
5685 |
* To do that, here's a cut down version of the same process that happens |
|
5686 |
* in wp_mail() - get the Content-Type from the headers, if there is one, |
|
5687 |
* then pass it through the wp_mail_content_type filter, in case a plugin |
|
5688 |
* is handling changing the Content-Type. |
|
5689 |
*/ |
|
5690 |
$headers = array(); |
|
5691 |
if ( isset( $mail['headers'] ) ) { |
|
5692 |
if ( is_array( $mail['headers'] ) ) { |
|
5693 |
$headers = $mail['headers']; |
|
5694 |
} else { |
|
5695 |
$headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) ); |
|
5696 |
} |
|
5697 |
} |
|
5698 |
||
5699 |
foreach ( $headers as $header ) { |
|
9 | 5700 |
if ( strpos( $header, ':' ) === false ) { |
5 | 5701 |
continue; |
5702 |
} |
|
5703 |
||
5704 |
// Explode them out. |
|
5705 |
list( $name, $content ) = explode( ':', trim( $header ), 2 ); |
|
5706 |
||
5707 |
// Cleanup crew. |
|
9 | 5708 |
$name = trim( $name ); |
5 | 5709 |
$content = trim( $content ); |
5710 |
||
5711 |
if ( 'content-type' === strtolower( $name ) ) { |
|
5712 |
if ( strpos( $content, ';' ) !== false ) { |
|
5713 |
list( $type, $charset ) = explode( ';', $content ); |
|
9 | 5714 |
$content_type = trim( $type ); |
5 | 5715 |
} else { |
5716 |
$content_type = trim( $content ); |
|
5717 |
} |
|
5718 |
break; |
|
5719 |
} |
|
5720 |
} |
|
5721 |
||
5722 |
// Set Content-Type if we don't have a content-type from the input headers. |
|
5723 |
if ( ! isset( $content_type ) ) { |
|
5724 |
$content_type = 'text/plain'; |
|
5725 |
} |
|
5726 |
||
5727 |
/** This filter is documented in wp-includes/pluggable.php */ |
|
5728 |
$content_type = apply_filters( 'wp_mail_content_type', $content_type ); |
|
5729 |
||
5730 |
if ( 'text/html' === $content_type ) { |
|
5731 |
$mail['message'] = wp_staticize_emoji( $mail['message'] ); |
|
5732 |
} |
|
5733 |
||
5734 |
return $mail; |
|
5735 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5736 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5737 |
/** |
9 | 5738 |
* Returns arrays of emoji data. |
5739 |
* |
|
5740 |
* These arrays are automatically built from the regex in twemoji.js - if they need to be updated, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5741 |
* you should update the regex there, then run the `grunt precommit:emoji` job. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5742 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5743 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5744 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5745 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5746 |
* @param string $type Optional. Which array type to return. Accepts 'partials' or 'entities', default 'entities'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5747 |
* @return array An array to match all emoji that WordPress recognises. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5748 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5749 |
function _wp_emoji_list( $type = 'entities' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5750 |
// Do not remove the START/END comments - they're used to find where to insert the arrays. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5751 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5752 |
// START: emoji arrays |
9 | 5753 |
$entities = array( '👨‍❤️‍💋‍👨', '👩‍❤️‍💋‍👩', '👩‍❤️‍💋‍👨', '🏴󠁧󠁢󠁥󠁮󠁧󠁿', '🏴󠁧󠁢󠁳󠁣󠁴󠁿', '🏴󠁧󠁢󠁷󠁬󠁳󠁿', '🧑🏿‍🤝‍🧑🏻', '🧑🏾‍🤝‍🧑🏾', '🧑🏾‍🤝‍🧑🏽', '🧑🏾‍🤝‍🧑🏼', '🧑🏾‍🤝‍🧑🏻', '🧑🏽‍🤝‍🧑🏽', '🧑🏽‍🤝‍🧑🏼', '🧑🏽‍🤝‍🧑🏻', '🧑🏼‍🤝‍🧑🏼', '🧑🏼‍🤝‍🧑🏻', '🧑🏻‍🤝‍🧑🏻', '👩🏾‍🤝‍👩🏽', '🧑🏿‍🤝‍🧑🏿', '🧑🏿‍🤝‍🧑🏾', '👨🏼‍🤝‍👨🏻', '🧑🏿‍🤝‍🧑🏽', '🧑🏿‍🤝‍🧑🏼', '👩🏻‍🤝‍👨🏼', '👩🏻‍🤝‍👨🏽', '👩🏻‍🤝‍👨🏾', '👩🏻‍🤝‍👨🏿', '👨🏿‍🤝‍👨🏾', '👨🏿‍🤝‍👨🏽', '👨🏿‍🤝‍👨🏼', '👨🏿‍🤝‍👨🏻', '👩🏼‍🤝‍👨🏻', '👩🏼‍🤝‍👨🏽', '👨🏽‍🤝‍👨🏻', '👨🏽‍🤝‍👨🏼', '👩🏿‍🤝‍👩🏾', '👩🏿‍🤝‍👩🏽', '👩🏿‍🤝‍👩🏼', '👩🏿‍🤝‍👩🏻', '👩🏿‍🤝‍👨🏾', '👩🏿‍🤝‍👨🏽', '👩🏿‍🤝‍👨🏼', '👩🏿‍🤝‍👨🏻', '👩🏼‍🤝‍👨🏾', '👩🏾‍🤝‍👩🏼', '👩🏾‍🤝‍👩🏻', '👩🏾‍🤝‍👨🏿', '👩🏾‍🤝‍👨🏽', '👩🏾‍🤝‍👨🏼', '👨🏾‍🤝‍👨🏻', '👨🏾‍🤝‍👨🏼', '👨🏾‍🤝‍👨🏽', '👩🏾‍🤝‍👨🏻', '👩🏽‍🤝‍👩🏼', '👩🏽‍🤝‍👩🏻', '👩🏽‍🤝‍👨🏿', '👩🏽‍🤝‍👨🏾', '👩🏽‍🤝‍👨🏼', '👩🏽‍🤝‍👨🏻', '👩🏼‍🤝‍👩🏻', '👩🏼‍🤝‍👨🏿', '👨‍👨‍👧‍👦', '👩‍👩‍👧‍👦', '👩‍👩‍👧‍👧', '👨‍👨‍👦‍👦', '👩‍👩‍👦‍👦', '👨‍👨‍👧‍👧', '👨‍👩‍👦‍👦', '👨‍👩‍👧‍👦', '👨‍👩‍👧‍👧', '👨‍❤️‍👨', '👩‍❤️‍👨', '👩‍❤️‍👩', '👩‍👦‍👦', '👩‍👩‍👦', '👨‍👨‍👦', '👩‍👧‍👦', '👩‍👧‍👧', '👨‍👨‍👧', '👩‍👩‍👧', '👨‍👩‍👦', '🧑‍🤝‍🧑', '👨‍👦‍👦', '👨‍👩‍👧', '👨‍👧‍👦', '👨‍👧‍👧', '🧗🏽‍♀️', '🧗🏼‍♂️', '🧗🏼‍♀️', '🧗🏻‍♂️', '🧗🏻‍♀️', '👷🏿‍♀️', '💆🏻‍♀️', '🧖🏿‍♂️', '🧖🏿‍♀️', '🧖🏾‍♂️', '🧖🏾‍♀️', '🧖🏽‍♂️', '🧖🏽‍♀️', '🧖🏼‍♂️', '🧖🏼‍♀️', '🧖🏻‍♂️', '🧖🏻‍♀️', '💁🏿‍♀️', '💁🏾‍♂️', '💁🏾‍♀️', '💁🏽‍♂️', '💁🏽‍♀️', '💁🏼‍♂️', '💁🏼‍♀️', '💂🏻‍♀️', '🧝🏿‍♂️', '🧝🏿‍♀️', '🧝🏾‍♂️', '🧝🏾‍♀️', '🧝🏽‍♂️', '🧝🏽‍♀️', '🧝🏼‍♂️', '🧝🏼‍♀️', '👷🏾‍♂️', '👷🏾‍♀️', '🧏🏿‍♂️', '🧏🏿‍♀️', '🧏🏾‍♂️', '🧏🏾‍♀️', '🧏🏽‍♂️', '🧏🏽‍♀️', '🧏🏼‍♂️', '🧏🏼‍♀️', '🧏🏻‍♂️', '🧏🏻‍♀️', '💆🏻‍♂️', '👷🏽‍♂️', '🧎🏿‍♂️', '🧎🏿‍♀️', '🧎🏾‍♂️', '🧎🏾‍♀️', '🧎🏽‍♂️', '🧎🏽‍♀️', '🧎🏼‍♂️', '🧎🏼‍♀️', '🧎🏻‍♂️', '🧎🏻‍♀️', '👷🏽‍♀️', '💆🏼‍♀️', '🧍🏿‍♂️', '🧍🏿‍♀️', '🧍🏾‍♂️', '🧍🏾‍♀️', '🧍🏽‍♂️', '🧍🏽‍♀️', '🧍🏼‍♂️', '🧍🏼‍♀️', '🧍🏻‍♂️', '🧍🏻‍♀️', '👷🏼‍♂️', '👷🏼‍♀️', '🦹🏿‍♂️', '🦹🏿‍♀️', '🦹🏾‍♂️', '🦹🏾‍♀️', '🦹🏽‍♂️', '🦹🏽‍♀️', '🦹🏼‍♂️', '🦹🏼‍♀️', '🦹🏻‍♂️', '🦹🏻‍♀️', '💆🏼‍♂️', '👷🏻‍♂️', '🦸🏿‍♂️', '🦸🏿‍♀️', '🦸🏾‍♂️', '🦸🏾‍♀️', '🦸🏽‍♂️', '🦸🏽‍♀️', '🦸🏼‍♂️', '🦸🏼‍♀️', '🦸🏻‍♂️', '🦸🏻‍♀️', '👷🏻‍♀️', '💆🏽‍♀️', '🤾🏿‍♂️', '🤾🏿‍♀️', '🤾🏾‍♂️', '🤾🏾‍♀️', '🤾🏽‍♂️', '🤾🏽‍♀️', '🤾🏼‍♂️', '🤾🏼‍♀️', '🤾🏻‍♂️', '🤾🏻‍♀️', '💆🏽‍♂️', '💆🏾‍♀️', '🤽🏿‍♂️', '🤽🏿‍♀️', '🤽🏾‍♂️', '🤽🏾‍♀️', '🤽🏽‍♂️', '🤽🏽‍♀️', '🤽🏼‍♂️', '🤽🏼‍♀️', '🤽🏻‍♂️', '🤽🏻‍♀️', '💆🏾‍♂️', '💆🏿‍♀️', '💆🏿‍♂️', '💇🏻‍♀️', '🤹🏿‍♂️', '🤹🏿‍♀️', '🤹🏾‍♂️', '🤹🏾‍♀️', '🤹🏽‍♂️', '🤹🏽‍♀️', '🤹🏼‍♂️', '🤹🏼‍♀️', '🤹🏻‍♂️', '🤹🏻‍♀️', '💇🏻‍♂️', '💇🏼‍♀️', '🤸🏿‍♂️', '🤸🏿‍♀️', '🤸🏾‍♂️', '🤸🏾‍♀️', '🤸🏽‍♂️', '🤸🏽‍♀️', '🤸🏼‍♂️', '🤸🏼‍♀️', '🤸🏻‍♂️', '🤸🏻‍♀️', '💇🏼‍♂️', '💇🏽‍♀️', '🤷🏿‍♂️', '🤷🏿‍♀️', '🤷🏾‍♂️', '🤷🏾‍♀️', '🤷🏽‍♂️', '🤷🏽‍♀️', '🤷🏼‍♂️', '🤷🏼‍♀️', '🤷🏻‍♂️', '🤷🏻‍♀️', '💇🏽‍♂️', '💇🏾‍♀️', '🤵🏿‍♂️', '🤵🏿‍♀️', '🤵🏾‍♂️', '🤵🏾‍♀️', '🤵🏽‍♂️', '🤵🏽‍♀️', '🤵🏼‍♂️', '🤵🏼‍♀️', '🤵🏻‍♂️', '🤵🏻‍♀️', '💇🏾‍♂️', '👳🏿‍♂️', '🤦🏿‍♂️', '🤦🏿‍♀️', '🤦🏾‍♂️', '🏃🏻‍♀️', '🏃🏻‍♂️', '🤦🏾‍♀️', '🏃🏼‍♀️', '🏃🏼‍♂️', '🤦🏽‍♂️', '🏃🏽‍♀️', '🏃🏽‍♂️', '🤦🏽‍♀️', '🏃🏾‍♀️', '🏃🏾‍♂️', '🤦🏼‍♂️', '🏃🏿‍♀️', '🏃🏿‍♂️', '🤦🏼‍♀️', '👳🏿‍♀️', '💇🏿‍♀️', '🏄🏻‍♀️', '🏄🏻‍♂️', '🤦🏻‍♂️', '🏄🏼‍♀️', '🏄🏼‍♂️', '🤦🏻‍♀️', '🏄🏽‍♀️', '🏄🏽‍♂️', '💁🏿‍♂️', '🏄🏾‍♀️', '🏄🏾‍♂️', '👳🏾‍♀️', '🏄🏿‍♀️', '🏄🏿‍♂️', '🚶🏿‍♂️', '💇🏿‍♂️', '👳🏽‍♂️', '🚶🏿‍♀️', '🚶🏾‍♂️', '🚶🏾‍♀️', '🚶🏽‍♂️', '🚶🏽‍♀️', '🏊🏻‍♀️', '🏊🏻‍♂️', '🚶🏼‍♂️', '🏊🏼‍♀️', '🏊🏼‍♂️', '🚶🏼‍♀️', '🏊🏽‍♀️', '🏊🏽‍♂️', '🚶🏻‍♂️', '🏊🏾‍♀️', '🏊🏾‍♂️', '🚶🏻‍♀️', '🏊🏿‍♀️', '🏊🏿‍♂️', '👳🏽‍♀️', '👳🏼‍♂️', '👳🏼‍♀️', '🏋🏻‍♀️', '🏋🏻‍♂️', '👳🏻‍♂️', '🏋🏼‍♀️', '🏋🏼‍♂️', '🚵🏿‍♂️', '🏋🏽‍♀️', '🏋🏽‍♂️', '🚵🏿‍♀️', '🏋🏾‍♀️', '🏋🏾‍♂️', '🚵🏾‍♂️', '🏋🏿‍♀️', '🏋🏿‍♂️', '🚵🏾‍♀️', '🏌🏻‍♀️', '🏌🏻‍♂️', '🚵🏽‍♂️', '🏌🏼‍♀️', '🏌🏼‍♂️', '🚵🏽‍♀️', '🏌🏽‍♀️', '🏌🏽‍♂️', '🚵🏼‍♂️', '🏌🏾‍♀️', '🏌🏾‍♂️', '🚵🏼‍♀️', '🏌🏿‍♀️', '🏌🏿‍♂️', '🚵🏻‍♂️', '👳🏻‍♀️', '🕴🏻‍♀️', '🧝🏻‍♂️', '🧝🏻‍♀️', '💁🏻‍♂️', '🚵🏻‍♀️', '🕴🏻‍♂️', '🕴🏼‍♀️', '🚴🏿‍♂️', '🚴🏿‍♀️', '🚴🏾‍♂️', '🚴🏾‍♀️', '🚴🏽‍♂️', '🚴🏽‍♀️', '🚴🏼‍♂️', '🚴🏼‍♀️', '🚴🏻‍♂️', '🚴🏻‍♀️', '🕴🏼‍♂️', '🕴🏽‍♀️', '🚣🏿‍♂️', '🚣🏿‍♀️', '🚣🏾‍♂️', '🚣🏾‍♀️', '🚣🏽‍♂️', '🚣🏽‍♀️', '🚣🏼‍♂️', '🚣🏼‍♀️', '🚣🏻‍♂️', '🚣🏻‍♀️', '🕴🏽‍♂️', '👱🏿‍♂️', '🙎🏿‍♂️', '🙎🏿‍♀️', '🙎🏾‍♂️', '🙎🏾‍♀️', '🙎🏽‍♂️', '🙎🏽‍♀️', '🙎🏼‍♂️', '🙎🏼‍♀️', '🙎🏻‍♂️', '🙎🏻‍♀️', '👱🏿‍♀️', '🕴🏾‍♀️', '🙍🏿‍♂️', '🙍🏿‍♀️', '🙍🏾‍♂️', '🙍🏾‍♀️', '🙍🏽‍♂️', '🙍🏽‍♀️', '🙍🏼‍♂️', '🙍🏼‍♀️', '🙍🏻‍♂️', '🙍🏻‍♀️', '👱🏾‍♂️', '👱🏾‍♀️', '🙋🏿‍♂️', '🙋🏿‍♀️', '🙋🏾‍♂️', '🙋🏾‍♀️', '🙋🏽‍♂️', '🙋🏽‍♀️', '🙋🏼‍♂️', '🙋🏼‍♀️', '🙋🏻‍♂️', '🙋🏻‍♀️', '🕴🏾‍♂️', '👱🏽‍♂️', '🙇🏿‍♂️', '🙇🏿‍♀️', '🙇🏾‍♂️', '🙇🏾‍♀️', '🙇🏽‍♂️', '🙇🏽‍♀️', '🙇🏼‍♂️', '🙇🏼‍♀️', '🙇🏻‍♂️', '🙇🏻‍♀️', '👱🏽‍♀️', '🕴🏿‍♀️', '👱🏼‍♂️', '👱🏼‍♀️', '🕴🏿‍♂️', '👱🏻‍♂️', '👱🏻‍♀️', '🕵🏻‍♀️', '🕵🏻‍♂️', '🕵🏼‍♀️', '🕵🏼‍♂️', '👮🏿‍♂️', '👮🏿‍♀️', '🕵🏽‍♀️', '👮🏾‍♂️', '👮🏾‍♀️', '🕵🏽‍♂️', '👮🏽‍♂️', '👮🏽‍♀️', '👨🏻‍⚕️', '👨🏻‍⚖️', '👨🏻‍✈️', '🙆🏿‍♂️', '🕵🏾‍♀️', '👮🏼‍♂️', '👮🏼‍♀️', '🕵🏾‍♂️', '👮🏻‍♂️', '👮🏻‍♀️', '🕵🏿‍♀️', '🕵🏿‍♂️', '🙅🏻‍♀️', '🙅🏻‍♂️', '🙅🏼‍♀️', '💁🏻‍♀️', '🙅🏼‍♂️', '🙅🏽‍♀️', '🙅🏽‍♂️', '🙅🏾‍♀️', '🙅🏾‍♂️', '🙅🏿‍♀️', '🙅🏿‍♂️', '👨🏼‍⚕️', '👨🏼‍⚖️', '👨🏼‍✈️', '🙆🏿‍♀️', '🧜🏿‍♂️', '🧜🏿‍♀️', '🧜🏾‍♂️', '🧜🏾‍♀️', '🧜🏽‍♂️', '🧜🏽‍♀️', '🧜🏼‍♂️', '🧜🏼‍♀️', '🧜🏻‍♂️', '🧜🏻‍♀️', '💂🏻‍♂️', '💂🏼‍♀️', '👩🏿‍✈️', '🧛🏿‍♂️', '🧛🏿‍♀️', '👩🏿‍⚖️', '👩🏿‍⚕️', '🧛🏾‍♂️', '🧛🏾‍♀️', '🧛🏽‍♂️', '🧛🏽‍♀️', '🧛🏼‍♂️', '👨🏽‍⚕️', '👨🏽‍⚖️', '👨🏽‍✈️', '🙆🏾‍♂️', '🧛🏼‍♀️', '🧛🏻‍♂️', '🧛🏻‍♀️', '🙆🏻‍♀️', '👩🏾‍✈️', '👩🏾‍⚖️', '👩🏾‍⚕️', '💂🏼‍♂️', '💂🏽‍♀️', '🧚🏿‍♂️', '🧚🏿‍♀️', '🧚🏾‍♂️', '🧚🏾‍♀️', '🧚🏽‍♂️', '🧚🏽‍♀️', '🧚🏼‍♂️', '🧚🏼‍♀️', '🙆🏻‍♂️', '👩🏽‍✈️', '👩🏽‍⚖️', '👩🏽‍⚕️', '🧚🏻‍♂️', '🧚🏻‍♀️', '👨🏾‍⚕️', '👨🏾‍⚖️', '👨🏾‍✈️', '🙆🏾‍♀️', '💂🏽‍♂️', '💂🏾‍♀️', '🧙🏿‍♂️', '🧙🏿‍♀️', '🙆🏼‍♀️', '👩🏼‍✈️', '👩🏼‍⚖️', '👩🏼‍⚕️', '🧙🏾‍♂️', '🧙🏾‍♀️', '🧙🏽‍♂️', '🧙🏽‍♀️', '🧙🏼‍♂️', '🧙🏼‍♀️', '🧙🏻‍♂️', '🧙🏻‍♀️', '💂🏾‍♂️', '🙆🏼‍♂️', '👩🏻‍✈️', '👩🏻‍⚖️', '👩🏻‍⚕️', '💂🏿‍♀️', '🧘🏿‍♂️', '🧘🏿‍♀️', '👨🏿‍⚕️', '👨🏿‍⚖️', '👨🏿‍✈️', '🙆🏽‍♂️', '🧘🏾‍♂️', '🧘🏾‍♀️', '🧘🏽‍♂️', '🧘🏽‍♀️', '🧘🏼‍♂️', '🧘🏼‍♀️', '🧘🏻‍♂️', '🧘🏻‍♀️', '💂🏿‍♂️', '👷🏿‍♂️', '🧗🏿‍♂️', '🧗🏿‍♀️', '🧗🏾‍♂️', '🙆🏽‍♀️', '🧗🏾‍♀️', '🧗🏽‍♂️', '👳🏾‍♂️', '⛹🏼‍♂️', '🕴️‍♀️', '🕴️‍♂️', '⛹🏾‍♂️', '⛹🏿‍♀️', '⛹🏿‍♂️', '⛹🏼‍♀️', '🏌️‍♀️', '🏌️‍♂️', '⛹🏽‍♀️', '⛹🏻‍♂️', '🕵️‍♀️', '🕵️‍♂️', '⛹🏻‍♀️', '⛹🏽‍♂️', '⛹🏾‍♀️', '🏋️‍♀️', '🏋️‍♂️', '⛹️‍♀️', '⛹️‍♂️', '👨🏽‍🚒', '👩🏻‍🍳', '👩🏻‍🎓', '👩🏻‍🎤', '👩🏻‍🎨', '👩🏻‍🏫', '👩🏻‍🏭', '👩🏻‍💻', '👩🏻‍💼', '👩🏻‍🔧', '👩🏻‍🔬', '👩🏻‍🚀', '👩🏻‍🚒', '👨🏻‍🏫', '👨🏿‍🦽', '👨🏿‍🦼', '👨🏿‍🦳', '👩🏻‍🦯', '👩🏻‍🦰', '👩🏻‍🦱', '👩🏻‍🦲', '👩🏻‍🦳', '👩🏻‍🦼', '👩🏻‍🦽', '👨🏿‍🦲', '👨🏿‍🦱', '👨🏿‍🦰', '👨🏿‍🦯', '👩🏼‍🌾', '👩🏼‍🍳', '👩🏼‍🎓', '👩🏼‍🎤', '👩🏼‍🎨', '👩🏼‍🏫', '👩🏼‍🏭', '👩🏼‍💻', '👩🏼‍💼', '👩🏼‍🔧', '👩🏼‍🔬', '👩🏼‍🚀', '👩🏼‍🚒', '👨🏿‍🚒', '👨🏿‍🚀', '👨🏿‍🔬', '👨🏿‍🔧', '👨🏿‍💼', '👩🏼‍🦯', '👩🏼‍🦰', '👩🏼‍🦱', '👩🏼‍🦲', '👩🏼‍🦳', '👩🏼‍🦼', '👩🏼‍🦽', '👨🏿‍💻', '👨🏿‍🏭', '👨🏿‍🏫', '👨🏿‍🎨', '👩🏽‍🌾', '👩🏽‍🍳', '👩🏽‍🎓', '👩🏽‍🎤', '👩🏽‍🎨', '👩🏽‍🏫', '👩🏽‍🏭', '👩🏽‍💻', '👩🏽‍💼', '👩🏽‍🔧', '👩🏽‍🔬', '👩🏽‍🚀', '👩🏽‍🚒', '👨🏿‍🎤', '👨🏿‍🎓', '👨🏿‍🍳', '👨🏿‍🌾', '👨🏾‍🦽', '👨🏾‍🦼', '👩🏽‍🦯', '👩🏽‍🦰', '👩🏽‍🦱', '👩🏽‍🦲', '👩🏽‍🦳', '👩🏽‍🦼', '👩🏽‍🦽', '👨🏾‍🦳', '👨🏾‍🦲', '👨🏾‍🦱', '👨🏾‍🦰', '👩🏾‍🌾', '👩🏾‍🍳', '👩🏾‍🎓', '👩🏾‍🎤', '👩🏾‍🎨', '👩🏾‍🏫', '👩🏾‍🏭', '👩🏾‍💻', '👩🏾‍💼', '👩🏾‍🔧', '👩🏾‍🔬', '👩🏾‍🚀', '👩🏾‍🚒', '👨🏾‍🦯', '👨🏾‍🚒', '👨🏾‍🚀', '👨🏾‍🔬', '👨🏾‍🔧', '👨🏾‍💼', '👨🏾‍💻', '👩🏾‍🦯', '👩🏾‍🦰', '👩🏾‍🦱', '👩🏾‍🦲', '👩🏾‍🦳', '👩🏾‍🦼', '👩🏾‍🦽', '👨🏾‍🏭', '👨🏾‍🏫', '👨🏾‍🎨', '👨🏾‍🎤', '👩🏿‍🌾', '👩🏿‍🍳', '👩🏿‍🎓', '👩🏿‍🎤', '👩🏿‍🎨', '👩🏿‍🏫', '👩🏿‍🏭', '👩🏿‍💻', '👩🏿‍💼', '👩🏿‍🔧', '👩🏿‍🔬', '👩🏿‍🚀', '👩🏿‍🚒', '👨🏾‍🎓', '👨🏾‍🍳', '👨🏾‍🌾', '👨🏽‍🦽', '👨🏽‍🦼', '👨🏽‍🦳', '👨🏽‍🦲', '👨🏽‍🦱', '👩🏿‍🦯', '👩🏿‍🦰', '👩🏿‍🦱', '👩🏿‍🦲', '👩🏿‍🦳', '👩🏿‍🦼', '👩🏿‍🦽', '👨🏽‍🦰', '👨🏽‍🦯', '👩🏻‍🌾', '👨🏻‍🌾', '👨🏽‍🚀', '👨🏽‍🔬', '👨🏽‍🔧', '👨🏽‍💼', '👨🏽‍💻', '👨🏽‍🏭', '👨🏽‍🏫', '👨🏽‍🎨', '👨🏻‍🍳', '👨🏻‍🎓', '👨🏻‍🎤', '👨🏽‍🎤', '👨🏽‍🎓', '👨🏽‍🍳', '👨🏽‍🌾', '👨🏻‍🎨', '👨🏼‍🦽', '👨🏼‍🦼', '👨🏼‍🦳', '👨🏼‍🦲', '👨🏼‍🦱', '👨🏼‍🦰', '👨🏼‍🦯', '👨🏼‍🚒', '👨🏼‍🚀', '👨🏼‍🔬', '👨🏼‍🔧', '👨🏼‍💼', '👨🏼‍💻', '👨🏼‍🏭', '👨🏼‍🏫', '👨🏼‍🎨', '👨🏼‍🎤', '👨🏼‍🎓', '👨🏼‍🍳', '👨🏼‍🌾', '👨🏻‍🦽', '👨🏻‍🦼', '👨🏻‍🦳', '👨🏻‍🦲', '👨🏻‍🦱', '👨🏻‍🦰', '👨🏻‍🦯', '👨🏻‍🚒', '👨🏻‍🚀', '👨🏻‍🏭', '👨🏻‍💻', '👨🏻‍💼', '👨🏻‍🔧', '👨🏻‍🔬', '🏳️‍🌈', '🤹‍♀️', '👮‍♂️', '👮‍♀️', '🙅‍♀️', '👩‍✈️', '👩‍⚖️', '👩‍⚕️', '🙅‍♂️', '🙆‍♀️', '🙆‍♂️', '🙇‍♀️', '🙇‍♂️', '🙋‍♀️', '🙋‍♂️', '🙍‍♀️', '🙍‍♂️', '🙎‍♀️', '🙎‍♂️', '👱‍♀️', '👱‍♂️', '🚣‍♀️', '🚣‍♂️', '🚴‍♀️', '🚴‍♂️', '🏴‍☠️', '👯‍♂️', '🚵‍♀️', '💇‍♂️', '🏊‍♂️', '🏊‍♀️', '💇‍♀️', '🚵‍♂️', '🏄‍♂️', '🏄‍♀️', '🚶‍♀️', '🚶‍♂️', '🏃‍♂️', '🏃‍♀️', '🤦‍♀️', '🤦‍♂️', '👳‍♀️', '👳‍♂️', '🤵‍♀️', '🤵‍♂️', '🤷‍♀️', '🤷‍♂️', '🤸‍♀️', '🤸‍♂️', '👯‍♀️', '💆‍♂️', '💆‍♀️', '🤹‍♂️', '🤼‍♀️', '🤼‍♂️', '🤽‍♀️', '🤽‍♂️', '🤾‍♀️', '🤾‍♂️', '🦸‍♀️', '🦸‍♂️', '🦹‍♀️', '🦹‍♂️', '🧍‍♀️', '🧍‍♂️', '🧎‍♀️', '🧎‍♂️', '🧏‍♀️', '🧏‍♂️', '🧖‍♀️', '🧖‍♂️', '🧗‍♀️', '💂‍♂️', '👷‍♀️', '👷‍♂️', '💂‍♀️', '🧗‍♂️', '🧘‍♀️', '🧘‍♂️', '🧙‍♀️', '🧙‍♂️', '🧚‍♀️', '🧚‍♂️', '🧛‍♀️', '🧛‍♂️', '🧜‍♀️', '🧜‍♂️', '🧝‍♀️', '🧝‍♂️', '🧞‍♀️', '💁‍♂️', '🧞‍♂️', '🧟‍♀️', '💁‍♀️', '🧟‍♂️', '👨‍⚖️', '👨‍⚕️', '👨‍✈️', '👨‍🦳', '👨‍🦼', '👨‍🦽', '👨‍👧', '👨‍🌾', '👨‍🍳', '👨‍🎓', '👨‍🎤', '👨‍🎨', '👨‍🏫', '👨‍🏭', '🐕‍🦺', '👨‍👦', '👁‍🗨', '👩‍🌾', '👩‍🍳', '👩‍🎓', '👩‍🎤', '👩‍🎨', '👩‍🏫', '👩‍🏭', '👨‍💻', '👩‍👦', '👨‍💼', '👨‍🔧', '👩‍👧', '👨‍🔬', '👨‍🚀', '👨‍🚒', '👨‍🦯', '👨‍🦰', '👩‍💻', '👩‍💼', '👩‍🔧', '👩‍🔬', '👩‍🚀', '👩‍🚒', '👩‍🦯', '👩‍🦰', '👩‍🦱', '👩‍🦲', '👩‍🦳', '👩‍🦼', '👩‍🦽', '👨‍🦱', '👨‍🦲', '🎅🏽', '💁🏾', '💁🏽', '💁🏼', '💁🏻', '👼🏿', '💂🏻', '👼🏾', '👼🏽', '💂🏼', '👼🏼', '👼🏻', '💂🏽', '👸🏿', '👸🏾', '💂🏾', '👸🏽', '👸🏼', '💂🏿', '👸🏻', '👷🏿', '💃🏻', '💃🏼', '💃🏽', '💃🏾', '💃🏿', '💅🏻', '💅🏼', '💅🏽', '💅🏾', '💅🏿', '👷🏾', '👷🏽', '💆🏻', '👷🏼', '👷🏻', '💆🏼', '👶🏿', '👶🏾', '💆🏽', '👶🏽', '👶🏼', '💆🏾', '👶🏻', '👵🏿', '💆🏿', '👵🏾', '👵🏽', '👵🏼', '👵🏻', '💇🏻', '👴🏿', '👴🏾', '💇🏼', '👴🏽', '👴🏼', '💇🏽', '👴🏻', '👳🏿', '💇🏾', '👳🏾', '👳🏽', '💇🏿', '👳🏼', '👳🏻', '💪🏻', '💪🏼', '💪🏽', '💪🏾', '💪🏿', '👲🏿', '👲🏾', '🕴🏻', '👲🏽', '👲🏼', '🕴🏼', '👲🏻', '👱🏿', '🕴🏽', '👱🏾', '👱🏽', '🕴🏾', '👱🏼', '👱🏻', '🕴🏿', '👰🏿', '👰🏾', '👰🏽', '👰🏼', '🕵🏻', '👰🏻', '👮🏿', '🕵🏼', '👮🏾', '👮🏽', '🕵🏽', '👮🏼', '👮🏻', '🕵🏾', '👭🏿', '👭🏾', '🕵🏿', '👭🏽', '👭🏼', '🕺🏻', '🕺🏼', '🕺🏽', '🕺🏾', '🕺🏿', '🖐🏻', '🖐🏼', '🖐🏽', '🖐🏾', '🖐🏿', '🖕🏻', '🖕🏼', '🖕🏽', '🖕🏾', '🖕🏿', '🖖🏻', '🖖🏼', '🖖🏽', '🖖🏾', '🖖🏿', '👭🏻', '👬🏿', '🙅🏻', '👬🏾', '👬🏽', '🙅🏼', '👬🏼', '👬🏻', '🙅🏽', '👫🏿', '👫🏾', '🙅🏾', '👫🏽', '👫🏼', '🙅🏿', '👫🏻', '👩🏿', '👩🏾', '👩🏽', '🙆🏻', '👩🏼', '👩🏻', '🙆🏼', '🇦🇨', '👨🏿', '🙆🏽', '👨🏾', '👨🏽', '🙆🏾', '👨🏼', '👨🏻', '🙆🏿', '👧🏿', '👧🏾', '👧🏽', '👧🏼', '🙇🏻', '👧🏻', '👦🏿', '🙇🏼', '👦🏾', '👦🏽', '🙇🏽', '👦🏼', '👦🏻', '🙇🏾', '👐🏿', '👐🏾', '🙇🏿', '👐🏽', '👐🏼', '👐🏻', '👏🏿', '🙋🏻', '👏🏾', '👏🏽', '🙋🏼', '👏🏼', '👏🏻', '🙋🏽', '👎🏿', '👎🏾', '🙋🏾', '👎🏽', '👎🏼', '🙋🏿', '👎🏻', '👍🏿', '🙌🏻', '🙌🏼', '🙌🏽', '🙌🏾', '🙌🏿', '👍🏾', '👍🏽', '🙍🏻', '👍🏼', '👍🏻', '🙍🏼', '👌🏿', '👌🏾', '🙍🏽', '👌🏽', '👌🏼', '🙍🏾', '👌🏻', '👋🏿', '🙍🏿', '👋🏾', '👋🏽', '👋🏼', '👋🏻', '🙎🏻', '👊🏿', '👊🏾', '🙎🏼', '👊🏽', '👊🏼', '🙎🏽', '👊🏻', '👉🏿', '🙎🏾', '👉🏾', '👉🏽', '🙎🏿', '👉🏼', '👉🏻', '🙏🏻', '🙏🏼', '🙏🏽', '🙏🏾', '🙏🏿', '👈🏿', '👈🏾', '🚣🏻', '👈🏽', '👈🏼', '🚣🏼', '👈🏻', '👇🏿', '🚣🏽', '👇🏾', '👇🏽', '🚣🏾', '👇🏼', '👇🏻', '🚣🏿', '👆🏿', '👆🏾', '👆🏽', '👆🏼', '🚴🏻', '👆🏻', '👃🏿', '🚴🏼', '👃🏾', '👃🏽', '🚴🏽', '👃🏼', '👃🏻', '🚴🏾', '👂🏿', '👂🏾', '🚴🏿', '👂🏽', '👂🏼', '👂🏻', '🏌🏿', '🚵🏻', '🏌🏾', '🏌🏽', '🚵🏼', '🏌🏼', '🏌🏻', '🚵🏽', '🏋🏿', '🏋🏾', '🚵🏾', '🏋🏽', '🏋🏼', '🚵🏿', '🏋🏻', '🏊🏿', '🏊🏾', '🏊🏽', '🚶🏻', '🏊🏼', '🏊🏻', '🚶🏼', '🏇🏿', '🏇🏾', '🚶🏽', '🏇🏽', '🏇🏼', '🚶🏾', '🏇🏻', '🏄🏿', '🚶🏿', '🏄🏾', '🏄🏽', '🛀🏻', '🛀🏼', '🛀🏽', '🛀🏾', '🛀🏿', '🛌🏻', '🛌🏼', '🛌🏽', '🛌🏾', '🛌🏿', '🤏🏻', '🤏🏼', '🤏🏽', '🤏🏾', '🤏🏿', '🤘🏻', '🤘🏼', '🤘🏽', '🤘🏾', '🤘🏿', '🤙🏻', '🤙🏼', '🤙🏽', '🤙🏾', '🤙🏿', '🤚🏻', '🤚🏼', '🤚🏽', '🤚🏾', '🤚🏿', '🤛🏻', '🤛🏼', '🤛🏽', '🤛🏾', '🤛🏿', '🤜🏻', '🤜🏼', '🤜🏽', '🤜🏾', '🤜🏿', '🤞🏻', '🤞🏼', '🤞🏽', '🤞🏾', '🤞🏿', '🤟🏻', '🤟🏼', '🤟🏽', '🤟🏾', '🤟🏿', '🏄🏼', '🏄🏻', '🤦🏻', '🏃🏿', '🏃🏾', '🤦🏼', '🏃🏽', '🏃🏼', '🤦🏽', '🏃🏻', '🏂🏿', '🤦🏾', '🏂🏾', '🏂🏽', '🤦🏿', '🏂🏼', '🏂🏻', '🤰🏻', '🤰🏼', '🤰🏽', '🤰🏾', '🤰🏿', '🤱🏻', '🤱🏼', '🤱🏽', '🤱🏾', '🤱🏿', '🤲🏻', '🤲🏼', '🤲🏽', '🤲🏾', '🤲🏿', '🤳🏻', '🤳🏼', '🤳🏽', '🤳🏾', '🤳🏿', '🤴🏻', '🤴🏼', '🤴🏽', '🤴🏾', '🤴🏿', '🎅🏿', '🎅🏾', '🤵🏻', '💁🏿', '🎅🏼', '🤵🏼', '🎅🏻', '🇿🇼', '🤵🏽', '🇿🇲', '🇿🇦', '🤵🏾', '🇾🇹', '🇾🇪', '🤵🏿', '🇽🇰', '🇼🇸', '🤶🏻', '🤶🏼', '🤶🏽', '🤶🏾', '🤶🏿', '🇼🇫', '🇻🇺', '🤷🏻', '🇻🇳', '🇻🇮', '🤷🏼', '🇻🇬', '🇻🇪', '🤷🏽', '🇻🇨', '🇻🇦', '🤷🏾', '🇺🇿', '🇺🇾', '🤷🏿', '🇺🇸', '🇺🇳', '🇺🇲', '🇺🇬', '🤸🏻', '🇺🇦', '🇹🇿', '🤸🏼', '🇹🇼', '🇹🇻', '🤸🏽', '🇹🇹', '🇹🇷', '🤸🏾', '🇹🇴', '🇹🇳', '🤸🏿', '🇹🇲', '🇹🇱', '🇹🇰', '🇹🇯', '🤹🏻', '🇹🇭', '🇹🇬', '🤹🏼', '🇹🇫', '🇹🇩', '🤹🏽', '🇹🇨', '🇹🇦', '🤹🏾', '🇸🇿', '🇸🇾', '🤹🏿', '🇸🇽', '🇸🇻', '🇸🇹', '🇸🇸', '🇸🇷', '🇸🇴', '🤽🏻', '🇸🇳', '🇸🇲', '🤽🏼', '🇸🇱', '🇸🇰', '🤽🏽', '🇸🇯', '🇸🇮', '🤽🏾', '🇸🇭', '🇸🇬', '🤽🏿', '🇸🇪', '🇸🇩', '🇸🇨', '🇸🇧', '🤾🏻', '🇸🇦', '🇷🇼', '🤾🏼', '🇷🇺', '🇷🇸', '🤾🏽', '🇷🇴', '🇷🇪', '🤾🏾', '🇶🇦', '🇵🇾', '🤾🏿', '🇵🇼', '🇵🇹', '🦵🏻', '🦵🏼', '🦵🏽', '🦵🏾', '🦵🏿', '🦶🏻', '🦶🏼', '🦶🏽', '🦶🏾', '🦶🏿', '🇵🇸', '🇵🇷', '🦸🏻', '🇵🇳', '🇵🇲', '🦸🏼', '🇵🇱', '🇵🇰', '🦸🏽', '🇵🇭', '🇵🇬', '🦸🏾', '🇵🇫', '🇵🇪', '🦸🏿', '🇵🇦', '🇴🇲', '🇳🇿', '🇳🇺', '🦹🏻', '🇳🇷', '🇳🇵', '🦹🏼', '🇳🇴', '🇳🇱', '🦹🏽', '🇳🇮', '🇳🇬', '🦹🏾', '🇳🇫', '🇳🇪', '🦹🏿', '🇳🇨', '🇳🇦', '🦻🏻', '🦻🏼', '🦻🏽', '🦻🏾', '🦻🏿', '🇲🇿', '🇲🇾', '🧍🏻', '🇲🇽', '🇲🇼', '🧍🏼', '🇲🇻', '🇲🇺', '🧍🏽', '🇲🇹', '🇲🇸', '🧍🏾', '🇲🇷', '🇲🇶', '🧍🏿', '🇲🇵', '🇲🇴', '🇲🇳', '🇲🇲', '🧎🏻', '🇲🇱', '🇲🇰', '🧎🏼', '🇲🇭', '🇲🇬', '🧎🏽', '🇲🇫', '🇲🇪', '🧎🏾', '🇲🇩', '🇲🇨', '🧎🏿', '🇲🇦', '🇱🇾', '🇱🇻', '🇱🇺', '🧏🏻', '🇱🇹', '🇱🇸', '🧏🏼', '🇱🇷', '🇱🇰', '🧏🏽', '🇱🇮', '🇱🇨', '🧏🏾', '🇱🇧', '🇱🇦', '🧏🏿', '🇰🇿', '🇰🇾', '🇰🇼', '🧑🏻', '🇰🇷', '🇰🇵', '🧑🏼', '🇰🇳', '🇰🇲', '🇰🇮', '🧑🏽', '🇰🇭', '🇰🇬', '🇰🇪', '🇯🇵', '🧑🏾', '🇯🇴', '🇯🇲', '🇯🇪', '🇮🇹', '🇮🇸', '🧑🏿', '🇮🇷', '🧒🏻', '🧒🏼', '🧒🏽', '🧒🏾', '🧒🏿', '🧓🏻', '🧓🏼', '🧓🏽', '🧓🏾', '🧓🏿', '🧔🏻', '🧔🏼', '🧔🏽', '🧔🏾', '🧔🏿', '🧕🏻', '🧕🏼', '🧕🏽', '🧕🏾', '🧕🏿', '🇮🇶', '🇮🇴', '🧖🏻', '🇮🇳', '🇮🇲', '🧖🏼', '🇮🇱', '🇮🇪', '🧖🏽', '🇮🇩', '🇮🇨', '🧖🏾', '🇭🇺', '🇭🇹', '🧖🏿', '🇭🇷', '🇭🇳', '🇭🇲', '🇭🇰', '🧗🏻', '🇬🇾', '🇬🇼', '🧗🏼', '🇬🇺', '🇬🇹', '🧗🏽', '🇬🇸', '🇬🇷', '🧗🏾', '🇬🇶', '🇬🇵', '🧗🏿', '🇬🇳', '🇬🇲', '🇬🇱', '🇬🇮', '🧘🏻', '🇬🇭', '🇬🇬', '🧘🏼', '🇬🇫', '🇬🇪', '🧘🏽', '🇬🇩', '🇬🇧', '🧘🏾', '🇬🇦', '🇫🇷', '🧘🏿', '🇫🇴', '🇫🇲', '🇫🇰', '🇫🇯', '🧙🏻', '🇫🇮', '🇪🇺', '🧙🏼', '🇪🇹', '🇪🇸', '🧙🏽', '🇪🇷', '🇪🇭', '🧙🏾', '🇪🇬', '🇪🇪', '🧙🏿', '🇪🇨', '🇪🇦', '🇩🇿', '🇩🇴', '🧚🏻', '🇩🇲', '🇩🇰', '🧚🏼', '🇩🇯', '🇩🇬', '🧚🏽', '🇩🇪', '🇨🇿', '🧚🏾', '🇨🇾', '🇨🇽', '🧚🏿', '🇨🇼', '🇨🇻', '🇨🇺', '🇨🇷', '🧛🏻', '🇨🇵', '🇨🇴', '🧛🏼', '🇨🇳', '🇨🇲', '🧛🏽', '🇨🇱', '🇨🇰', '🧛🏾', '🇨🇮', '🇨🇭', '🧛🏿', '🇨🇬', '🇨🇫', '🇨🇩', '🇨🇨', '🧜🏻', '🇨🇦', '🇧🇿', '🧜🏼', '🇧🇾', '🇧🇼', '🧜🏽', '🇧🇻', '🇧🇹', '🧜🏾', '🇧🇸', '🇧🇷', '🧜🏿', '🇧🇶', '🇧🇴', '🇧🇳', '🇧🇲', '🧝🏻', '🇧🇱', '🇧🇯', '🧝🏼', '🇧🇮', '🇧🇭', '🧝🏽', '🇧🇬', '🇧🇫', '🧝🏾', '🇧🇪', '🇧🇩', '🧝🏿', '🇧🇧', '🇧🇦', '🇦🇿', '🇦🇽', '🇦🇼', '🇦🇺', '🇦🇹', '🇦🇸', '🇦🇷', '🇦🇶', '🇦🇴', '🇦🇲', '🇦🇱', '🇦🇮', '🇦🇬', '🇦🇫', '🇦🇪', '🇦🇩', '✍🏿', '⛹🏻', '✍🏾', '✍🏽', '✍🏼', '✍🏻', '✌🏿', '✌🏾', '✌🏽', '✌🏼', '✌🏻', '✋🏿', '✋🏾', '✋🏽', '✋🏼', '✋🏻', '✊🏿', '✊🏾', '✊🏽', '✊🏼', '✊🏻', '⛷🏽', '⛷🏾', '⛹🏿', '☝🏿', '☝🏾', '⛹🏾', '☝🏽', '☝🏼', '⛹🏽', '☝🏻', '⛷🏿', '⛹🏼', '⛷🏻', '⛷🏼', '4⃣', '#⃣', '0⃣', '1⃣', '2⃣', '3⃣', '*⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🏌', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '🙃', '🙄', '🏮', '🏯', '🏰', '🌭', '🏳', '🌮', '🌯', '🌰', '🌱', '🏴', '🏵', '🏷', '🏸', '🏹', '🏺', '🏻', '🏼', '🙅', '🏽', '🏾', '🏿', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '🐉', '🐊', '🐋', '🐌', '🐍', '🙆', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🌲', '🐕', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🙇', '🙈', '🙉', '🙊', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🙋', '🐯', '🐰', '🐱', '🐲', '🐳', '🙌', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '🐼', '🐽', '🐾', '🐿', '👀', '🌳', '👁', '🌴', '🌵', '🙍', '🌶', '🌷', '🌸', '👂', '🌹', '🌺', '🌻', '🌼', '🌽', '👃', '👄', '👅', '🌾', '🌿', '🍀', '🍁', '🍂', '🙎', '👆', '🍃', '🍄', '🍅', '🍆', '🙏', '🚀', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚒', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🍇', '👇', '🍈', '🍉', '🍊', '🍋', '🍌', '👈', '🍍', '🍎', '🍏', '🍐', '🍑', '👉', '🍒', '🍓', '🍔', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🍕', '🍖', '👊', '🍗', '🍘', '🍙', '🍚', '🍛', '👋', '🍜', '🍝', '🍞', '🍟', '🍠', '👌', '🍡', '🍢', '🚴', '🍣', '🍤', '🍥', '👍', '🍦', '👩', '👪', '🍧', '🍨', '🍩', '🍪', '👎', '👫', '🍫', '🍬', '🍭', '🍮', '🚵', '🍯', '👬', '👏', '🍰', '🍱', '🍲', '🍳', '👭', '🍴', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '👘', '👙', '👚', '👛', '👜', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '👝', '👞', '👟', '👮', '👠', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟩', '🟪', '🟫', '🤍', '🤎', '👡', '👯', '👢', '👣', '👤', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '👥', '🍵', '👰', '🍶', '🍷', '🤘', '🍸', '🍹', '👦', '🍺', '🍻', '🤙', '🍼', '🍽', '🍾', '👧', '🍿', '🤚', '🎀', '🎁', '🎂', '🎃', '🎄', '🤛', '👱', '🇵', '🅾', '🇶', '🇲', '🤜', '🤝', '🅿', '👲', '🎅', '🎆', '🎇', '🤞', '🎈', '🎉', '🎊', '🎋', '🎌', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '👳', '🎙', '🎚', '🎛', '🎞', '🎟', '👴', '🎠', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🎡', '🎢', '🎣', '🎤', '👵', '🤰', '🎥', '🎦', '🎧', '🎨', '🎩', '🤱', '👶', '🎪', '🎫', '🎬', '🎭', '🤲', '🎮', '🎯', '🎰', '🎱', '🎲', '🤳', '🎳', '🎴', '🎵', '🎶', '🎷', '🤴', '🎸', '🎹', '🎺', '👷', '🎻', '🎼', '🎽', '🎾', '🎿', '👸', '👹', '👺', '👻', '🏀', '🏁', '🇧', '🇮', '🤵', '🇪', '👼', '👽', '👾', '👿', '🤶', '💀', '🇷', '🇱', '🏂', '🆎', '🆑', '🇨', '🇹', '🇯', '🆒', '🇬', '🆓', '🇳', '🆔', '🇴', '🇺', '🇫', '🤷', '🆕', '💁', '🆖', '🆗', '🇭', '🏃', '🆘', '🇩', '🇻', '🇰', '🆙', '🇼', '🆚', '🇽', '🇸', '🀄', '🇾', '🤸', '🇦', '🅰', '💂', '🅱', '🇿', '🈁', '🈂', '🏄', '💃', '💄', '🏅', '🏆', '🈚', '🈯', '🈲', '💅', '🈳', '🤹', '🤺', '🈴', '🏇', '🤼', '🏈', '🏉', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '💆', '🌄', '🌅', '🤽', '🌆', '🌇', '🌈', '🏊', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '💇', '💈', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥳', '🥴', '🥵', '🥶', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦮', '🦯', '🦰', '🦱', '🦲', '🦳', '🦴', '💉', '💊', '💋', '💌', '💍', '🦵', '💎', '💏', '💐', '💑', '💒', '🦶', '🦷', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '🦸', '💤', '💥', '💦', '💧', '💨', '💩', '🌔', '🌕', '🌖', '🌗', '🌘', '💪', '💫', '💬', '💭', '💮', '💯', '🦹', '🦺', '💰', '💱', '💲', '💳', '💴', '🦻', '🦼', '🦽', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '💵', '💶', '💷', '💸', '💹', '💺', '💻', '💼', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '🧍', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '🧎', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '🧏', '🧐', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '🧑', '📽', '📿', '🔀', '🔁', '🔂', '🧒', '🔃', '🔄', '🔅', '🔆', '🔇', '🧓', '🔈', '🔉', '🔊', '🔋', '🔌', '🧔', '🔍', '🔎', '🔏', '🔐', '🔑', '🧕', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🧖', '🔣', '🔤', '🔥', '🔦', '🔧', '🔨', '🔩', '🔪', '🔫', '🔬', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🧗', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🧘', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🧙', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🌙', '🏋', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🧚', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🕴', '👨', '🌫', '🌬', '🃏', '🏍', '🏎', '🏏', '🧛', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🕵', '🕶', '🕷', '🕸', '🕹', '🏚', '🏛', '🧜', '🏜', '🏝', '🏞', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🏟', '🏠', '🏡', '🏢', '🏣', '🖐', '🏤', '🏥', '🧝', '🏦', '🏧', '🧞', '🏨', '🖕', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩰', '🩱', '🩲', '🩳', '🩸', '🩹', '🩺', '🪀', '🪁', '🪂', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '🏩', '🏪', '🏫', '🏬', '🏭', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗨', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '▫', '☦', '☮', '☯', '☸', '☹', '☺', '♀', '♂', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚕', '⚖', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '☣', '☢', '☠', '☝', '☘', '⛷', '⛸', '☕', '☔', '☑', '☎', '☄', '☃', '☂', '☁', '☀', '◾', '◽', '◼', '◻', '◀', '▶', '☪', '▪', '⛹', '⛺', '⛽', '✂', '✅', '✈', '✉', 'Ⓜ', '⏺', '⏹', '⏸', '⏳', '✊', '⏲', '⏱', '⏰', '⏯', '⏮', '✋', '⏭', '⏬', '⏫', '⏪', '⏩', '✌', '⏏', '⌨', '⌛', '⌚', '↪', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❄', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '❤', '➕', '➖', '➗', '➡', '➰', '➿', '⤴', '⤵', '↩', '⬅', '⬆', '⬇', '⬛', '⬜', '⭐', '⭕', '↙', '〰', '〽', '↘', '↗', '㊗', '㊙', '↖', '↕', '↔', 'ℹ', '™', '⁉', '‼', '' ); |
5754 |
$partials = array( '🀄', '🃏', '🅰', '🅱', '🅾', '🅿', '🆎', '🆑', '🆒', '🆓', '🆔', '🆕', '🆖', '🆗', '🆘', '🆙', '🆚', '🇦', '🇨', '🇩', '🇪', '🇫', '🇬', '🇮', '🇱', '🇲', '🇴', '🇶', '🇷', '🇸', '🇹', '🇺', '🇼', '🇽', '🇿', '🇧', '🇭', '🇯', '🇳', '🇻', '🇾', '🇰', '🇵', '🈁', '🈂', '🈚', '🈯', '🈲', '🈳', '🈴', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '🌄', '🌅', '🌆', '🌇', '🌈', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘', '🌙', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🌫', '🌬', '🌭', '🌮', '🌯', '🌰', '🌱', '🌲', '🌳', '🌴', '🌵', '🌶', '🌷', '🌸', '🌹', '🌺', '🌻', '🌼', '🌽', '🌾', '🌿', '🍀', '🍁', '🍂', '🍃', '🍄', '🍅', '🍆', '🍇', '🍈', '🍉', '🍊', '🍋', '🍌', '🍍', '🍎', '🍏', '🍐', '🍑', '🍒', '🍓', '🍔', '🍕', '🍖', '🍗', '🍘', '🍙', '🍚', '🍛', '🍜', '🍝', '🍞', '🍟', '🍠', '🍡', '🍢', '🍣', '🍤', '🍥', '🍦', '🍧', '🍨', '🍩', '🍪', '🍫', '🍬', '🍭', '🍮', '🍯', '🍰', '🍱', '🍲', '🍳', '🍴', '🍵', '🍶', '🍷', '🍸', '🍹', '🍺', '🍻', '🍼', '🍽', '🍾', '🍿', '🎀', '🎁', '🎂', '🎃', '🎄', '🎅', '🏻', '🏼', '🏽', '🏾', '🏿', '🎆', '🎇', '🎈', '🎉', '🎊', '🎋', '🎌', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '🎙', '🎚', '🎛', '🎞', '🎟', '🎠', '🎡', '🎢', '🎣', '🎤', '🎥', '🎦', '🎧', '🎨', '🎩', '🎪', '🎫', '🎬', '🎭', '🎮', '🎯', '🎰', '🎱', '🎲', '🎳', '🎴', '🎵', '🎶', '🎷', '🎸', '🎹', '🎺', '🎻', '🎼', '🎽', '🎾', '🎿', '🏀', '🏁', '🏂', '🏃', '‍', '♀', '️', '♂', '🏄', '🏅', '🏆', '🏇', '🏈', '🏉', '🏊', '🏋', '🏌', '🏍', '🏎', '🏏', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🏚', '🏛', '🏜', '🏝', '🏞', '🏟', '🏠', '🏡', '🏢', '🏣', '🏤', '🏥', '🏦', '🏧', '🏨', '🏩', '🏪', '🏫', '🏬', '🏭', '🏮', '🏯', '🏰', '🏳', '🏴', '☠', '󠁧', '󠁢', '󠁥', '󠁮', '󠁿', '󠁳', '󠁣', '󠁴', '󠁷', '󠁬', '🏵', '🏷', '🏸', '🏹', '🏺', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '🐉', '🐊', '🐋', '🐌', '🐍', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🐕', '🦺', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🐯', '🐰', '🐱', '🐲', '🐳', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '🐼', '🐽', '🐾', '🐿', '👀', '👁', '🗨', '👂', '👃', '👄', '👅', '👆', '👇', '👈', '👉', '👊', '👋', '👌', '👍', '👎', '👏', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '👘', '👙', '👚', '👛', '👜', '👝', '👞', '👟', '👠', '👡', '👢', '👣', '👤', '👥', '👦', '👧', '👨', '💻', '💼', '🔧', '🔬', '🚀', '🚒', '🦯', '🦰', '🦱', '🦲', '🦳', '🦼', '🦽', '⚕', '⚖', '✈', '🤝', '👩', '❤', '💋', '👪', '👫', '👬', '👭', '👮', '👯', '👰', '👱', '👲', '👳', '👴', '👵', '👶', '👷', '👸', '👹', '👺', '👻', '👼', '👽', '👾', '👿', '💀', '💁', '💂', '💃', '💄', '💅', '💆', '💇', '💈', '💉', '💊', '💌', '💍', '💎', '💏', '💐', '💑', '💒', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '💤', '💥', '💦', '💧', '💨', '💩', '💪', '💫', '💬', '💭', '💮', '💯', '💰', '💱', '💲', '💳', '💴', '💵', '💶', '💷', '💸', '💹', '💺', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '📽', '📿', '🔀', '🔁', '🔂', '🔃', '🔄', '🔅', '🔆', '🔇', '🔈', '🔉', '🔊', '🔋', '🔌', '🔍', '🔎', '🔏', '🔐', '🔑', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🔣', '🔤', '🔥', '🔦', '🔨', '🔩', '🔪', '🔫', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🕴', '🕵', '🕶', '🕷', '🕸', '🕹', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🖐', '🖕', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '🙃', '🙄', '🙅', '🙆', '🙇', '🙈', '🙉', '🙊', '🙋', '🙌', '🙍', '🙎', '🙏', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🚴', '🚵', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟩', '🟪', '🟫', '🤍', '🤎', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '🤘', '🤙', '🤚', '🤛', '🤜', '🤞', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🤰', '🤱', '🤲', '🤳', '🤴', '🤵', '🤶', '🤷', '🤸', '🤹', '🤺', '🤼', '🤽', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥳', '🥴', '🥵', '🥶', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦮', '🦴', '🦵', '🦶', '🦷', '🦸', '🦹', '🦻', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '🧍', '🧎', '🧏', '🧐', '🧑', '🧒', '🧓', '🧔', '🧕', '🧖', '🧗', '🧘', '🧙', '🧚', '🧛', '🧜', '🧝', '🧞', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩰', '🩱', '🩲', '🩳', '🩸', '🩹', '🩺', '🪀', '🪁', '🪂', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '‼', '⁉', '™', 'ℹ', '↔', '↕', '↖', '↗', '↘', '↙', '↩', '↪', '⃣', '⌚', '⌛', '⌨', '⏏', '⏩', '⏪', '⏫', '⏬', '⏭', '⏮', '⏯', '⏰', '⏱', '⏲', '⏳', '⏸', '⏹', '⏺', 'Ⓜ', '▪', '▫', '▶', '◀', '◻', '◼', '◽', '◾', '☀', '☁', '☂', '☃', '☄', '☎', '☑', '☔', '☕', '☘', '☝', '☢', '☣', '☦', '☪', '☮', '☯', '☸', '☹', '☺', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '⛷', '⛸', '⛹', '⛺', '⛽', '✂', '✅', '✉', '✊', '✋', '✌', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❄', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '➕', '➖', '➗', '➡', '➰', '➿', '⤴', '⤵', '⬅', '⬆', '⬇', '⬛', '⬜', '⭐', '⭕', '〰', '〽', '㊗', '㊙', '' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5755 |
// END: emoji arrays |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5756 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5757 |
if ( 'entities' === $type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5758 |
return $entities; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5759 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5760 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5761 |
return $partials; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5762 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5763 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5764 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5765 |
* Shorten a URL, to be used as link text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5766 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5767 |
* @since 1.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5768 |
* @since 4.4.0 Moved to wp-includes/formatting.php from wp-admin/includes/misc.php and added $length param. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5769 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5770 |
* @param string $url URL to shorten. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5771 |
* @param int $length Optional. Maximum length of the shortened URL. Default 35 characters. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5772 |
* @return string Shortened URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5773 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5774 |
function url_shorten( $url, $length = 35 ) { |
9 | 5775 |
$stripped = str_replace( array( 'https://', 'http://', 'www.' ), '', $url ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5776 |
$short_url = untrailingslashit( $stripped ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5777 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5778 |
if ( strlen( $short_url ) > $length ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5779 |
$short_url = substr( $short_url, 0, $length - 3 ) . '…'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5780 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5781 |
return $short_url; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5782 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5783 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5784 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5785 |
* Sanitizes a hex color. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5786 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5787 |
* Returns either '', a 3 or 6 digit hex color (with #), or nothing. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5788 |
* For sanitizing values without a #, see sanitize_hex_color_no_hash(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5789 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5790 |
* @since 3.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5791 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5792 |
* @param string $color |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5793 |
* @return string|void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5794 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5795 |
function sanitize_hex_color( $color ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5796 |
if ( '' === $color ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5797 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5798 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5799 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5800 |
// 3 or 6 hex digits, or the empty string. |
9 | 5801 |
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5802 |
return $color; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5803 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5804 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5805 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5806 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5807 |
* Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5808 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5809 |
* Saving hex colors without a hash puts the burden of adding the hash on the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5810 |
* UI, which makes it difficult to use or upgrade to other color types such as |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5811 |
* rgba, hsl, rgb, and html color names. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5812 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5813 |
* Returns either '', a 3 or 6 digit hex color (without a #), or null. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5814 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5815 |
* @since 3.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5816 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5817 |
* @param string $color |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5818 |
* @return string|null |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5819 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5820 |
function sanitize_hex_color_no_hash( $color ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5821 |
$color = ltrim( $color, '#' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5822 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5823 |
if ( '' === $color ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5824 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5825 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5826 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5827 |
return sanitize_hex_color( '#' . $color ) ? $color : null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5828 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5829 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5830 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5831 |
* Ensures that any hex color is properly hashed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5832 |
* Otherwise, returns value untouched. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5833 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5834 |
* This method should only be necessary if using sanitize_hex_color_no_hash(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5835 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5836 |
* @since 3.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5837 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5838 |
* @param string $color |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5839 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5840 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5841 |
function maybe_hash_hex_color( $color ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5842 |
if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5843 |
return '#' . $unhashed; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5844 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5845 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5846 |
return $color; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5847 |
} |