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,
|
---|
14 | *
|
---|
15 | * 'cause today's effort makes it worth tomorrow's "holiday" ...
|
---|
16 | *
|
---|
17 | * Becomes:
|
---|
18 | *
|
---|
19 | * ’cause today’s effort makes it worth tomorrow’s “holiday” …
|
---|
20 | *
|
---|
21 | * Code within certain html blocks are skipped.
|
---|
22 | *
|
---|
23 | * Do not use this function before the {@see 'init'} action hook; everything will break.
|
---|
24 | *
|
---|
25 | * @since 0.71
|
---|
26 | *
|
---|
27 | * @global array $wp_cockneyreplace Array of formatted entities for certain common phrases
|
---|
28 | * @global array $shortcode_tags
|
---|
29 | * @staticvar array $static_characters
|
---|
30 | * @staticvar array $static_replacements
|
---|
31 | * @staticvar array $dynamic_characters
|
---|
32 | * @staticvar array $dynamic_replacements
|
---|
33 | * @staticvar array $default_no_texturize_tags
|
---|
34 | * @staticvar array $default_no_texturize_shortcodes
|
---|
35 | * @staticvar bool $run_texturize
|
---|
36 | * @staticvar string $apos
|
---|
37 | * @staticvar string $prime
|
---|
38 | * @staticvar string $double_prime
|
---|
39 | * @staticvar string $opening_quote
|
---|
40 | * @staticvar string $closing_quote
|
---|
41 | * @staticvar string $opening_single_quote
|
---|
42 | * @staticvar string $closing_single_quote
|
---|
43 | * @staticvar string $open_q_flag
|
---|
44 | * @staticvar string $open_sq_flag
|
---|
45 | * @staticvar string $apos_flag
|
---|
46 | *
|
---|
47 | * @param string $text The text to be formatted
|
---|
48 | * @param bool $reset Set to true for unit testing. Translated patterns will reset.
|
---|
49 | * @return string The string replaced with html entities
|
---|
50 | */
|
---|
51 | function wptexturize( $text, $reset = false ) {
|
---|
52 | global $wp_cockneyreplace, $shortcode_tags;
|
---|
53 | static $static_characters = null,
|
---|
54 | $static_replacements = null,
|
---|
55 | $dynamic_characters = null,
|
---|
56 | $dynamic_replacements = null,
|
---|
57 | $default_no_texturize_tags = null,
|
---|
58 | $default_no_texturize_shortcodes = null,
|
---|
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-->';
|
---|
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 | /**
|
---|
79 | * Filters whether to skip running wptexturize().
|
---|
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 |
|
---|
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 |
|
---|
120 | $default_no_texturize_tags = array( 'pre', 'code', 'kbd', 'style', 'script', 'tt' );
|
---|
121 | $default_no_texturize_shortcodes = array( 'code' );
|
---|
122 |
|
---|
123 | // if a plugin has provided an autocorrect array, use it
|
---|
124 | if ( isset( $wp_cockneyreplace ) ) {
|
---|
125 | $cockney = array_keys( $wp_cockneyreplace );
|
---|
126 | $cockneyreplace = array_values( $wp_cockneyreplace );
|
---|
127 | } else {
|
---|
128 | /* translators: This is a comma-separated list of words that defy the syntax of quotations in normal use,
|
---|
129 | * for example... 'We do not have enough words yet' ... is a typical quoted phrase. But when we write
|
---|
130 | * lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes.
|
---|
131 | */
|
---|
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 | );
|
---|
147 | }
|
---|
148 |
|
---|
149 | $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney );
|
---|
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.
|
---|
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();
|
---|
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 ) {
|
---|
169 | $dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_single_quote;
|
---|
170 | }
|
---|
171 | if ( "'" !== $apos || '"' !== $closing_quote ) {
|
---|
172 | $dynamic[ '/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_quote;
|
---|
173 | }
|
---|
174 |
|
---|
175 | // '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0.
|
---|
176 | if ( "'" !== $apos ) {
|
---|
177 | $dynamic['/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/'] = $apos_flag;
|
---|
178 | }
|
---|
179 |
|
---|
180 | // Quoted Numbers like '0.42'
|
---|
181 | if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) {
|
---|
182 | $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $open_sq_flag . '$1' . $closing_single_quote;
|
---|
183 | }
|
---|
184 |
|
---|
185 | // Single quote at start, or preceded by (, {, <, [, ", -, or spaces.
|
---|
186 | if ( "'" !== $opening_single_quote ) {
|
---|
187 | $dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $open_sq_flag;
|
---|
188 | }
|
---|
189 |
|
---|
190 | // Apostrophe in a word. No spaces, double apostrophes, or other punctuation.
|
---|
191 | if ( "'" !== $apos ) {
|
---|
192 | $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos_flag;
|
---|
193 | }
|
---|
194 |
|
---|
195 | $dynamic_characters['apos'] = array_keys( $dynamic );
|
---|
196 | $dynamic_replacements['apos'] = array_values( $dynamic );
|
---|
197 | $dynamic = array();
|
---|
198 |
|
---|
199 | // Quoted Numbers like "42"
|
---|
200 | if ( '"' !== $opening_quote && '"' !== $closing_quote ) {
|
---|
201 | $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $open_q_flag . '$1' . $closing_quote;
|
---|
202 | }
|
---|
203 |
|
---|
204 | // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces.
|
---|
205 | if ( '"' !== $opening_quote ) {
|
---|
206 | $dynamic[ '/(?<=\A|[([{\-]|<|' . $spaces . ')"(?!' . $spaces . ')/' ] = $open_q_flag;
|
---|
207 | }
|
---|
208 |
|
---|
209 | $dynamic_characters['quote'] = array_keys( $dynamic );
|
---|
210 | $dynamic_replacements['quote'] = array_values( $dynamic );
|
---|
211 | $dynamic = array();
|
---|
212 |
|
---|
213 | // Dashes and spaces
|
---|
214 | $dynamic['/---/'] = $em_dash;
|
---|
215 | $dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash;
|
---|
216 | $dynamic['/(?<!xn)--/'] = $en_dash;
|
---|
217 | $dynamic[ '/(?<=^|' . $spaces . ')-(?=$|' . $spaces . ')/' ] = $en_dash;
|
---|
218 |
|
---|
219 | $dynamic_characters['dash'] = array_keys( $dynamic );
|
---|
220 | $dynamic_replacements['dash'] = array_values( $dynamic );
|
---|
221 | }
|
---|
222 |
|
---|
223 | // Must do this every time in case plugins use these filters in a context sensitive manner
|
---|
224 | /**
|
---|
225 | * Filters the list of HTML elements not to texturize.
|
---|
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 | /**
|
---|
233 | * Filters the list of shortcodes not to texturize.
|
---|
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 );
|
---|
240 |
|
---|
241 | $no_texturize_tags_stack = array();
|
---|
242 | $no_texturize_shortcodes_stack = array();
|
---|
243 |
|
---|
244 | // Look for shortcodes and HTML elements.
|
---|
245 |
|
---|
246 | preg_match_all( '@\[/?([^<>&/\[\]\x00-\x20=]++)@', $text, $matches );
|
---|
247 | $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
|
---|
248 | $found_shortcodes = ! empty( $tagnames );
|
---|
249 | $shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : '';
|
---|
250 | $regex = _get_wptexturize_split_regex( $shortcode_regex );
|
---|
251 |
|
---|
252 | $textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
|
---|
253 |
|
---|
254 | foreach ( $textarr as &$curl ) {
|
---|
255 | // Only call _wptexturize_pushpop_element if $curl is a delimiter.
|
---|
256 | $first = $curl[0];
|
---|
257 | if ( '<' === $first ) {
|
---|
258 | if ( '<!--' === substr( $curl, 0, 4 ) ) {
|
---|
259 | // This is an HTML comment delimiter.
|
---|
260 | continue;
|
---|
261 | } else {
|
---|
262 | // This is an HTML element delimiter.
|
---|
263 |
|
---|
264 | // Replace each & with & unless it already looks like an entity.
|
---|
265 | $curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl );
|
---|
266 |
|
---|
267 | _wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags );
|
---|
268 | }
|
---|
269 | } elseif ( '' === trim( $curl ) ) {
|
---|
270 | // This is a newline between delimiters. Performance improves when we check this.
|
---|
271 | continue;
|
---|
272 |
|
---|
273 | } elseif ( '[' === $first && $found_shortcodes && 1 === preg_match( '/^' . $shortcode_regex . '$/', $curl ) ) {
|
---|
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 );
|
---|
290 | $curl = wptexturize_primes( $curl, "'", $prime, $open_sq_flag, $closing_single_quote );
|
---|
291 | $curl = str_replace( $apos_flag, $apos, $curl );
|
---|
292 | $curl = str_replace( $open_sq_flag, $opening_single_quote, $curl );
|
---|
293 | }
|
---|
294 | if ( false !== strpos( $curl, '"' ) ) {
|
---|
295 | $curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl );
|
---|
296 | $curl = wptexturize_primes( $curl, '"', $double_prime, $open_q_flag, $closing_quote );
|
---|
297 | $curl = str_replace( $open_q_flag, $opening_quote, $curl );
|
---|
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 | }
|
---|
308 |
|
---|
309 | // Replace each & with & unless it already looks like an entity.
|
---|
310 | $curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl );
|
---|
311 | }
|
---|
312 | }
|
---|
313 |
|
---|
314 | return implode( '', $textarr );
|
---|
315 | }
|
---|
316 |
|
---|
317 | /**
|
---|
318 | * Implements a logic tree to determine whether or not "7'." represents seven feet,
|
---|
319 | * then converts the special char into either a prime char or a closing quote char.
|
---|
320 | *
|
---|
321 | * @since 4.3.0
|
---|
322 | *
|
---|
323 | * @param string $haystack The plain text to be searched.
|
---|
324 | * @param string $needle The character to search for such as ' or ".
|
---|
325 | * @param string $prime The prime char to use for replacement.
|
---|
326 | * @param string $open_quote The opening quote char. Opening quote replacement must be
|
---|
327 | * accomplished already.
|
---|
328 | * @param string $close_quote The closing quote char to use for replacement.
|
---|
329 | * @return string The $haystack value after primes and quotes replacements.
|
---|
330 | */
|
---|
331 | function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quote ) {
|
---|
332 | $spaces = wp_spaces_regexp();
|
---|
333 | $flag = '<!--wp-prime-or-quote-->';
|
---|
334 | $quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|>|" . $spaces . ')/';
|
---|
335 | $prime_pattern = "/(?<=\\d)$needle/";
|
---|
336 | $flag_after_digit = "/(?<=\\d)$flag/";
|
---|
337 | $flag_no_digit = "/(?<!\\d)$flag/";
|
---|
338 |
|
---|
339 | $sentences = explode( $open_quote, $haystack );
|
---|
340 |
|
---|
341 | foreach ( $sentences as $key => &$sentence ) {
|
---|
342 | if ( false === strpos( $sentence, $needle ) ) {
|
---|
343 | continue;
|
---|
344 | } elseif ( 0 !== $key && 0 === substr_count( $sentence, $close_quote ) ) {
|
---|
345 | $sentence = preg_replace( $quote_pattern, $flag, $sentence, -1, $count );
|
---|
346 | if ( $count > 1 ) {
|
---|
347 | // This sentence appears to have multiple closing quotes. Attempt Vulcan logic.
|
---|
348 | $sentence = preg_replace( $flag_no_digit, $close_quote, $sentence, -1, $count2 );
|
---|
349 | if ( 0 === $count2 ) {
|
---|
350 | // Try looking for a quote followed by a period.
|
---|
351 | $count2 = substr_count( $sentence, "$flag." );
|
---|
352 | if ( $count2 > 0 ) {
|
---|
353 | // Assume the rightmost quote-period match is the end of quotation.
|
---|
354 | $pos = strrpos( $sentence, "$flag." );
|
---|
355 | } else {
|
---|
356 | // When all else fails, make the rightmost candidate a closing quote.
|
---|
357 | // This is most likely to be problematic in the context of bug #18549.
|
---|
358 | $pos = strrpos( $sentence, $flag );
|
---|
359 | }
|
---|
360 | $sentence = substr_replace( $sentence, $close_quote, $pos, strlen( $flag ) );
|
---|
361 | }
|
---|
362 | // Use conventional replacement on any remaining primes and quotes.
|
---|
363 | $sentence = preg_replace( $prime_pattern, $prime, $sentence );
|
---|
364 | $sentence = preg_replace( $flag_after_digit, $prime, $sentence );
|
---|
365 | $sentence = str_replace( $flag, $close_quote, $sentence );
|
---|
366 | } elseif ( 1 == $count ) {
|
---|
367 | // Found only one closing quote candidate, so give it priority over primes.
|
---|
368 | $sentence = str_replace( $flag, $close_quote, $sentence );
|
---|
369 | $sentence = preg_replace( $prime_pattern, $prime, $sentence );
|
---|
370 | } else {
|
---|
371 | // No closing quotes found. Just run primes pattern.
|
---|
372 | $sentence = preg_replace( $prime_pattern, $prime, $sentence );
|
---|
373 | }
|
---|
374 | } else {
|
---|
375 | $sentence = preg_replace( $prime_pattern, $prime, $sentence );
|
---|
376 | $sentence = preg_replace( $quote_pattern, $close_quote, $sentence );
|
---|
377 | }
|
---|
378 | if ( '"' == $needle && false !== strpos( $sentence, '"' ) ) {
|
---|
379 | $sentence = str_replace( '"', $close_quote, $sentence );
|
---|
380 | }
|
---|
381 | }
|
---|
382 |
|
---|
383 | return implode( $open_quote, $sentences );
|
---|
384 | }
|
---|
385 |
|
---|
386 | /**
|
---|
387 | * Search for disabled element tags. Push element to stack on tag open and pop
|
---|
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>.
|
---|
392 | *
|
---|
393 | * @since 2.9.0
|
---|
394 | * @access private
|
---|
395 | *
|
---|
396 | * @param string $text Text to check. Must be a tag like `<html>` or `[shortcode]`.
|
---|
397 | * @param array $stack List of open tag elements.
|
---|
398 | * @param array $disabled_elements The tag names to match against. Spaces are not allowed in tag names.
|
---|
399 | */
|
---|
400 | function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) {
|
---|
401 | // Is it an opening tag or closing tag?
|
---|
402 | if ( isset( $text[1] ) && '/' !== $text[1] ) {
|
---|
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 ) {
|
---|
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 |
|
---|
433 | array_push( $stack, $tag );
|
---|
434 | } elseif ( end( $stack ) == $tag ) {
|
---|
435 | array_pop( $stack );
|
---|
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
|
---|
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'.
|
---|
446 | *
|
---|
447 | * @since 0.71
|
---|
448 | *
|
---|
449 | * @param string $pee The text which has to be formatted.
|
---|
450 | * @param bool $br Optional. If set, this will convert all remaining line-breaks
|
---|
451 | * after paragraphing. Default true.
|
---|
452 | * @return string Text which has been converted into correct paragraph tags.
|
---|
453 | */
|
---|
454 | function wpautop( $pee, $br = true ) {
|
---|
455 | $pre_tags = array();
|
---|
456 |
|
---|
457 | if ( trim( $pee ) === '' ) {
|
---|
458 | return '';
|
---|
459 | }
|
---|
460 |
|
---|
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 | */
|
---|
468 | if ( strpos( $pee, '<pre' ) !== false ) {
|
---|
469 | $pee_parts = explode( '</pre>', $pee );
|
---|
470 | $last_pee = array_pop( $pee_parts );
|
---|
471 | $pee = '';
|
---|
472 | $i = 0;
|
---|
473 |
|
---|
474 | foreach ( $pee_parts as $pee_part ) {
|
---|
475 | $start = strpos( $pee_part, '<pre' );
|
---|
476 |
|
---|
477 | // Malformed html?
|
---|
478 | if ( $start === false ) {
|
---|
479 | $pee .= $pee_part;
|
---|
480 | continue;
|
---|
481 | }
|
---|
482 |
|
---|
483 | $name = "<pre wp-pre-tag-$i></pre>";
|
---|
484 | $pre_tags[ $name ] = substr( $pee_part, $start ) . '</pre>';
|
---|
485 |
|
---|
486 | $pee .= substr( $pee_part, 0, $start ) . $name;
|
---|
487 | $i++;
|
---|
488 | }
|
---|
489 |
|
---|
490 | $pee .= $last_pee;
|
---|
491 | }
|
---|
492 | // Change multiple <br>s into two line breaks, which will turn into paragraphs.
|
---|
493 | $pee = preg_replace( '|<br\s*/?>\s*<br\s*/?>|', "\n\n", $pee );
|
---|
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 |
|
---|
497 | // Add a double line break above block-level opening tags.
|
---|
498 | $pee = preg_replace( '!(<' . $allblocks . '[\s/>])!', "\n\n$1", $pee );
|
---|
499 |
|
---|
500 | // Add a double line break below block-level closing tags.
|
---|
501 | $pee = preg_replace( '!(</' . $allblocks . '>)!', "$1\n\n", $pee );
|
---|
502 |
|
---|
503 | // Standardize newline characters to "\n".
|
---|
504 | $pee = str_replace( array( "\r\n", "\r" ), "\n", $pee );
|
---|
505 |
|
---|
506 | // Find newlines in all elements and add placeholders.
|
---|
507 | $pee = wp_replace_in_html_tags( $pee, array( "\n" => ' <!-- wpnl --> ' ) );
|
---|
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 );
|
---|
523 | }
|
---|
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 |
|
---|
535 | // Collapse line breaks before and after <figcaption> elements.
|
---|
536 | if ( strpos( $pee, '<figcaption' ) !== false ) {
|
---|
537 | $pee = preg_replace( '|\s*(<figcaption[^>]*>)|', '$1', $pee );
|
---|
538 | $pee = preg_replace( '|</figcaption>\s*|', '</figcaption>', $pee );
|
---|
539 | }
|
---|
540 |
|
---|
541 | // Remove more than two contiguous line breaks.
|
---|
542 | $pee = preg_replace( "/\n\n+/", "\n\n", $pee );
|
---|
543 |
|
---|
544 | // Split up the contents into an array of strings, separated by double line breaks.
|
---|
545 | $pees = preg_split( '/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY );
|
---|
546 |
|
---|
547 | // Reset $pee prior to rebuilding.
|
---|
548 | $pee = '';
|
---|
549 |
|
---|
550 | // Rebuild the content as a string, wrapping every bit with a <p>.
|
---|
551 | foreach ( $pees as $tinkle ) {
|
---|
552 | $pee .= '<p>' . trim( $tinkle, "\n" ) . "</p>\n";
|
---|
553 | }
|
---|
554 |
|
---|
555 | // Under certain strange conditions it could create a P of entirely whitespace.
|
---|
556 | $pee = preg_replace( '|<p>\s*</p>|', '', $pee );
|
---|
557 |
|
---|
558 | // Add a closing <p> inside <div>, <address>, or <form> tag if missing.
|
---|
559 | $pee = preg_replace( '!<p>([^<]+)</(div|address|form)>!', '<p>$1</p></$2>', $pee );
|
---|
560 |
|
---|
561 | // If an opening or closing block element tag is wrapped in a <p>, unwrap it.
|
---|
562 | $pee = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', '$1', $pee );
|
---|
563 |
|
---|
564 | // In some cases <li> may get wrapped in <p>, fix them.
|
---|
565 | $pee = preg_replace( '|<p>(<li.+?)</p>|', '$1', $pee );
|
---|
566 |
|
---|
567 | // If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>.
|
---|
568 | $pee = preg_replace( '|<p><blockquote([^>]*)>|i', '<blockquote$1><p>', $pee );
|
---|
569 | $pee = str_replace( '</blockquote></p>', '</p></blockquote>', $pee );
|
---|
570 |
|
---|
571 | // If an opening or closing block element tag is preceded by an opening <p> tag, remove it.
|
---|
572 | $pee = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)!', '$1', $pee );
|
---|
573 |
|
---|
574 | // If an opening or closing block element tag is followed by a closing <p> tag, remove it.
|
---|
575 | $pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*</p>!', '$1', $pee );
|
---|
576 |
|
---|
577 | // Optionally insert line breaks.
|
---|
578 | if ( $br ) {
|
---|
579 | // Replace newlines that shouldn't be touched with a placeholder.
|
---|
580 | $pee = preg_replace_callback( '/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee );
|
---|
581 |
|
---|
582 | // Normalize <br>
|
---|
583 | $pee = str_replace( array( '<br>', '<br/>' ), '<br />', $pee );
|
---|
584 |
|
---|
585 | // Replace any new line characters that aren't preceded by a <br /> with a <br />.
|
---|
586 | $pee = preg_replace( '|(?<!<br />)\s*\n|', "<br />\n", $pee );
|
---|
587 |
|
---|
588 | // Replace newline placeholders with newlines.
|
---|
589 | $pee = str_replace( '<WPPreserveNewline />', "\n", $pee );
|
---|
590 | }
|
---|
591 |
|
---|
592 | // If a <br /> tag is after an opening or closing block tag, remove it.
|
---|
593 | $pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*<br />!', '$1', $pee );
|
---|
594 |
|
---|
595 | // If a <br /> tag is before a subset of opening or closing block tags, remove it.
|
---|
596 | $pee = preg_replace( '!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee );
|
---|
597 | $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
|
---|
598 |
|
---|
599 | // Replace placeholder <pre> tags with their original content.
|
---|
600 | if ( ! empty( $pre_tags ) ) {
|
---|
601 | $pee = str_replace( array_keys( $pre_tags ), array_values( $pre_tags ), $pee );
|
---|
602 | }
|
---|
603 |
|
---|
604 | // Restore newlines in all elements.
|
---|
605 | if ( false !== strpos( $pee, '<!-- wpnl -->' ) ) {
|
---|
606 | $pee = str_replace( array( ' <!-- wpnl --> ', '<!-- wpnl -->' ), "\n", $pee );
|
---|
607 | }
|
---|
608 |
|
---|
609 | return $pee;
|
---|
610 | }
|
---|
611 |
|
---|
612 | /**
|
---|
613 | * Separate HTML elements and comments from the text.
|
---|
614 | *
|
---|
615 | * @since 4.2.4
|
---|
616 | *
|
---|
617 | * @param string $input The text which has to be formatted.
|
---|
618 | * @return array The formatted text.
|
---|
619 | */
|
---|
620 | function wp_html_split( $input ) {
|
---|
621 | return preg_split( get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE );
|
---|
622 | }
|
---|
623 |
|
---|
624 | /**
|
---|
625 | * Retrieve the regular expression for an HTML element.
|
---|
626 | *
|
---|
627 | * @since 4.4.0
|
---|
628 | *
|
---|
629 | * @staticvar string $regex
|
---|
630 | *
|
---|
631 | * @return string The regular expression
|
---|
632 | */
|
---|
633 | function get_html_split_regex() {
|
---|
634 | static $regex;
|
---|
635 |
|
---|
636 | if ( ! isset( $regex ) ) {
|
---|
637 | // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation
|
---|
638 | $comments =
|
---|
639 | '!' // Start of comment, after the <.
|
---|
640 | . '(?:' // Unroll the loop: Consume everything until --> is found.
|
---|
641 | . '-(?!->)' // Dash not followed by end of comment.
|
---|
642 | . '[^\-]*+' // Consume non-dashes.
|
---|
643 | . ')*+' // Loop possessively.
|
---|
644 | . '(?:-->)?'; // End of comment. If not found, match all input.
|
---|
645 |
|
---|
646 | $cdata =
|
---|
647 | '!\[CDATA\[' // Start of comment, after the <.
|
---|
648 | . '[^\]]*+' // Consume non-].
|
---|
649 | . '(?:' // Unroll the loop: Consume everything until ]]> is found.
|
---|
650 | . '](?!]>)' // One ] not followed by end of comment.
|
---|
651 | . '[^\]]*+' // Consume non-].
|
---|
652 | . ')*+' // Loop possessively.
|
---|
653 | . '(?:]]>)?'; // End of comment. If not found, match all input.
|
---|
654 |
|
---|
655 | $escaped =
|
---|
656 | '(?=' // Is the element escaped?
|
---|
657 | . '!--'
|
---|
658 | . '|'
|
---|
659 | . '!\[CDATA\['
|
---|
660 | . ')'
|
---|
661 | . '(?(?=!-)' // If yes, which type?
|
---|
662 | . $comments
|
---|
663 | . '|'
|
---|
664 | . $cdata
|
---|
665 | . ')';
|
---|
666 |
|
---|
667 | $regex =
|
---|
668 | '/(' // Capture the entire match.
|
---|
669 | . '<' // Find start of element.
|
---|
670 | . '(?' // Conditional expression follows.
|
---|
671 | . $escaped // Find end of escaped element.
|
---|
672 | . '|' // ... else ...
|
---|
673 | . '[^>]*>?' // Find end of normal element.
|
---|
674 | . ')'
|
---|
675 | . ')/';
|
---|
676 | // phpcs:enable
|
---|
677 | }
|
---|
678 |
|
---|
679 | return $regex;
|
---|
680 | }
|
---|
681 |
|
---|
682 | /**
|
---|
683 | * Retrieve the combined regular expression for HTML and shortcodes.
|
---|
684 | *
|
---|
685 | * @access private
|
---|
686 | * @ignore
|
---|
687 | * @internal This function will be removed in 4.5.0 per Shortcode API Roadmap.
|
---|
688 | * @since 4.4.0
|
---|
689 | *
|
---|
690 | * @staticvar string $html_regex
|
---|
691 | *
|
---|
692 | * @param string $shortcode_regex The result from _get_wptexturize_shortcode_regex(). Optional.
|
---|
693 | * @return string The regular expression
|
---|
694 | */
|
---|
695 | function _get_wptexturize_split_regex( $shortcode_regex = '' ) {
|
---|
696 | static $html_regex;
|
---|
697 |
|
---|
698 | if ( ! isset( $html_regex ) ) {
|
---|
699 | // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation
|
---|
700 | $comment_regex =
|
---|
701 | '!' // Start of comment, after the <.
|
---|
702 | . '(?:' // Unroll the loop: Consume everything until --> is found.
|
---|
703 | . '-(?!->)' // Dash not followed by end of comment.
|
---|
704 | . '[^\-]*+' // Consume non-dashes.
|
---|
705 | . ')*+' // Loop possessively.
|
---|
706 | . '(?:-->)?'; // End of comment. If not found, match all input.
|
---|
707 |
|
---|
708 | $html_regex = // Needs replaced with wp_html_split() per Shortcode API Roadmap.
|
---|
709 | '<' // Find start of element.
|
---|
710 | . '(?(?=!--)' // Is this a comment?
|
---|
711 | . $comment_regex // Find end of comment.
|
---|
712 | . '|'
|
---|
713 | . '[^>]*>?' // Find end of element. If not found, match all input.
|
---|
714 | . ')';
|
---|
715 | // phpcs:enable
|
---|
716 | }
|
---|
717 |
|
---|
718 | if ( empty( $shortcode_regex ) ) {
|
---|
719 | $regex = '/(' . $html_regex . ')/';
|
---|
720 | } else {
|
---|
721 | $regex = '/(' . $html_regex . '|' . $shortcode_regex . ')/';
|
---|
722 | }
|
---|
723 |
|
---|
724 | return $regex;
|
---|
725 | }
|
---|
726 |
|
---|
727 | /**
|
---|
728 | * Retrieve the regular expression for shortcodes.
|
---|
729 | *
|
---|
730 | * @access private
|
---|
731 | * @ignore
|
---|
732 | * @internal This function will be removed in 4.5.0 per Shortcode API Roadmap.
|
---|
733 | * @since 4.4.0
|
---|
734 | *
|
---|
735 | * @param array $tagnames List of shortcodes to find.
|
---|
736 | * @return string The regular expression
|
---|
737 | */
|
---|
738 | function _get_wptexturize_shortcode_regex( $tagnames ) {
|
---|
739 | $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
|
---|
740 | $tagregexp = "(?:$tagregexp)(?=[\\s\\]\\/])"; // Excerpt of get_shortcode_regex().
|
---|
741 | // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation
|
---|
742 | $regex =
|
---|
743 | '\[' // Find start of shortcode.
|
---|
744 | . '[\/\[]?' // Shortcodes may begin with [/ or [[
|
---|
745 | . $tagregexp // Only match registered shortcodes, because performance.
|
---|
746 | . '(?:'
|
---|
747 | . '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical.
|
---|
748 | . '|'
|
---|
749 | . '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >.
|
---|
750 | . ')*+' // Possessive critical.
|
---|
751 | . '\]' // Find end of shortcode.
|
---|
752 | . '\]?'; // Shortcodes may end with ]]
|
---|
753 | // phpcs:enable
|
---|
754 |
|
---|
755 | return $regex;
|
---|
756 | }
|
---|
757 |
|
---|
758 | /**
|
---|
759 | * Replace characters or phrases within HTML elements only.
|
---|
760 | *
|
---|
761 | * @since 4.2.3
|
---|
762 | *
|
---|
763 | * @param string $haystack The text which has to be formatted.
|
---|
764 | * @param array $replace_pairs In the form array('from' => 'to', ...).
|
---|
765 | * @return string The formatted text.
|
---|
766 | */
|
---|
767 | function wp_replace_in_html_tags( $haystack, $replace_pairs ) {
|
---|
768 | // Find all elements.
|
---|
769 | $textarr = wp_html_split( $haystack );
|
---|
770 | $changed = false;
|
---|
771 |
|
---|
772 | // Optimize when searching for one item.
|
---|
773 | if ( 1 === count( $replace_pairs ) ) {
|
---|
774 | // Extract $needle and $replace.
|
---|
775 | foreach ( $replace_pairs as $needle => $replace ) {
|
---|
776 | }
|
---|
777 |
|
---|
778 | // Loop through delimiters (elements) only.
|
---|
779 | for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) {
|
---|
780 | if ( false !== strpos( $textarr[ $i ], $needle ) ) {
|
---|
781 | $textarr[ $i ] = str_replace( $needle, $replace, $textarr[ $i ] );
|
---|
782 | $changed = true;
|
---|
783 | }
|
---|
784 | }
|
---|
785 | } else {
|
---|
786 | // Extract all $needles.
|
---|
787 | $needles = array_keys( $replace_pairs );
|
---|
788 |
|
---|
789 | // Loop through delimiters (elements) only.
|
---|
790 | for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) {
|
---|
791 | foreach ( $needles as $needle ) {
|
---|
792 | if ( false !== strpos( $textarr[ $i ], $needle ) ) {
|
---|
793 | $textarr[ $i ] = strtr( $textarr[ $i ], $replace_pairs );
|
---|
794 | $changed = true;
|
---|
795 | // After one strtr() break out of the foreach loop and look at next element.
|
---|
796 | break;
|
---|
797 | }
|
---|
798 | }
|
---|
799 | }
|
---|
800 | }
|
---|
801 |
|
---|
802 | if ( $changed ) {
|
---|
803 | $haystack = implode( $textarr );
|
---|
804 | }
|
---|
805 |
|
---|
806 | return $haystack;
|
---|
807 | }
|
---|
808 |
|
---|
809 | /**
|
---|
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 ) {
|
---|
819 | return str_replace( "\n", '<WPPreserveNewline />', $matches[0] );
|
---|
820 | }
|
---|
821 |
|
---|
822 | /**
|
---|
823 | * Don't auto-p wrap shortcodes that stand alone
|
---|
824 | *
|
---|
825 | * Ensures that shortcodes are not wrapped in `<p>...</p>`.
|
---|
826 | *
|
---|
827 | * @since 2.9.0
|
---|
828 | *
|
---|
829 | * @global array $shortcode_tags
|
---|
830 | *
|
---|
831 | * @param string $pee The content.
|
---|
832 | * @return string The filtered content.
|
---|
833 | */
|
---|
834 | function shortcode_unautop( $pee ) {
|
---|
835 | global $shortcode_tags;
|
---|
836 |
|
---|
837 | if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) {
|
---|
838 | return $pee;
|
---|
839 | }
|
---|
840 |
|
---|
841 | $tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) );
|
---|
842 | $spaces = wp_spaces_regexp();
|
---|
843 |
|
---|
844 | // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation
|
---|
845 | $pattern =
|
---|
846 | '/'
|
---|
847 | . '<p>' // Opening paragraph
|
---|
848 | . '(?:' . $spaces . ')*+' // Optional leading whitespace
|
---|
849 | . '(' // 1: The shortcode
|
---|
850 | . '\\[' // Opening bracket
|
---|
851 | . "($tagregexp)" // 2: Shortcode name
|
---|
852 | . '(?![\\w-])' // Not followed by word character or hyphen
|
---|
853 | // Unroll the loop: Inside the opening shortcode tag
|
---|
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 | . ')'
|
---|
873 | . '(?:' . $spaces . ')*+' // optional trailing whitespace
|
---|
874 | . '<\\/p>' // closing paragraph
|
---|
875 | . '/';
|
---|
876 | // phpcs:enable
|
---|
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 | */
|
---|
893 | function seems_utf8( $str ) {
|
---|
894 | mbstring_binary_safe_encoding();
|
---|
895 | $length = strlen( $str );
|
---|
896 | reset_mbstring_encoding();
|
---|
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 ) ) {
|
---|
916 | return false;
|
---|
917 | }
|
---|
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 | *
|
---|
934 | * @staticvar string $_charset
|
---|
935 | *
|
---|
936 | * @param string $string The text which is to be encoded.
|
---|
937 | * @param int|string $quote_style Optional. Converts double quotes if set to ENT_COMPAT,
|
---|
938 | * both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES.
|
---|
939 | * Also compatible with old values; converting single quotes if set to 'single',
|
---|
940 | * double if set to 'double' or both if otherwise set.
|
---|
941 | * Default is ENT_NOQUOTES.
|
---|
942 | * @param string $charset Optional. The character encoding of the string. Default is false.
|
---|
943 | * @param bool $double_encode Optional. Whether to encode existing html entities. Default is false.
|
---|
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 |
|
---|
949 | if ( 0 === strlen( $string ) ) {
|
---|
950 | return '';
|
---|
951 | }
|
---|
952 |
|
---|
953 | // Don't bother if there are no specialchars - saves some processing
|
---|
954 | if ( ! preg_match( '/[&<>"\']/', $string ) ) {
|
---|
955 | return $string;
|
---|
956 | }
|
---|
957 |
|
---|
958 | // Account for the previous behaviour of the function when the $quote_style is not an accepted value
|
---|
959 | if ( empty( $quote_style ) ) {
|
---|
960 | $quote_style = ENT_NOQUOTES;
|
---|
961 | } elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
|
---|
962 | $quote_style = ENT_QUOTES;
|
---|
963 | }
|
---|
964 |
|
---|
965 | // Store the site charset as a static to avoid multiple calls to wp_load_alloptions()
|
---|
966 | if ( ! $charset ) {
|
---|
967 | static $_charset = null;
|
---|
968 | if ( ! isset( $_charset ) ) {
|
---|
969 | $alloptions = wp_load_alloptions();
|
---|
970 | $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';
|
---|
971 | }
|
---|
972 | $charset = $_charset;
|
---|
973 | }
|
---|
974 |
|
---|
975 | if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) {
|
---|
976 | $charset = 'UTF-8';
|
---|
977 | }
|
---|
978 |
|
---|
979 | $_quote_style = $quote_style;
|
---|
980 |
|
---|
981 | if ( $quote_style === 'double' ) {
|
---|
982 | $quote_style = ENT_COMPAT;
|
---|
983 | $_quote_style = ENT_COMPAT;
|
---|
984 | } elseif ( $quote_style === 'single' ) {
|
---|
985 | $quote_style = ENT_NOQUOTES;
|
---|
986 | }
|
---|
987 |
|
---|
988 | if ( ! $double_encode ) {
|
---|
989 | // Guarantee every &entity; is valid, convert &garbage; into &garbage;
|
---|
990 | // This is required for PHP < 5.4.0 because ENT_HTML401 flag is unavailable.
|
---|
991 | $string = wp_kses_normalize_entities( $string );
|
---|
992 | }
|
---|
993 |
|
---|
994 | $string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode );
|
---|
995 |
|
---|
996 | // Back-compat.
|
---|
997 | if ( 'single' === $_quote_style ) {
|
---|
998 | $string = str_replace( "'", ''', $string );
|
---|
999 | }
|
---|
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 | *
|
---|
1014 | * @param string $string The text which is to be decoded.
|
---|
1015 | * @param string|int $quote_style Optional. Converts double quotes if set to ENT_COMPAT,
|
---|
1016 | * both single and double if set to ENT_QUOTES or
|
---|
1017 | * none if set to ENT_NOQUOTES.
|
---|
1018 | * Also compatible with old _wp_specialchars() values;
|
---|
1019 | * converting single quotes if set to 'single',
|
---|
1020 | * double if set to 'double' or both if otherwise set.
|
---|
1021 | * Default is ENT_NOQUOTES.
|
---|
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;
|
---|
1039 | } elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
|
---|
1040 | $quote_style = ENT_QUOTES;
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 | // More complete than get_html_translation_table( HTML_SPECIALCHARS )
|
---|
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 | );
|
---|
1076 |
|
---|
1077 | if ( $quote_style === ENT_QUOTES ) {
|
---|
1078 | $translation = array_merge( $single, $double, $others );
|
---|
1079 | $translation_preg = array_merge( $single_preg, $double_preg, $others_preg );
|
---|
1080 | } elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {
|
---|
1081 | $translation = array_merge( $double, $others );
|
---|
1082 | $translation_preg = array_merge( $double_preg, $others_preg );
|
---|
1083 | } elseif ( $quote_style === 'single' ) {
|
---|
1084 | $translation = array_merge( $single, $others );
|
---|
1085 | $translation_preg = array_merge( $single_preg, $others_preg );
|
---|
1086 | } elseif ( $quote_style === ENT_NOQUOTES ) {
|
---|
1087 | $translation = $others;
|
---|
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 | *
|
---|
1103 | * @staticvar bool $is_utf8
|
---|
1104 | * @staticvar bool $utf8_pcre
|
---|
1105 | *
|
---|
1106 | * @param string $string The text which is to be checked.
|
---|
1107 | * @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
|
---|
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()
|
---|
1118 | static $is_utf8 = null;
|
---|
1119 | if ( ! isset( $is_utf8 ) ) {
|
---|
1120 | $is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) );
|
---|
1121 | }
|
---|
1122 | if ( ! $is_utf8 ) {
|
---|
1123 | return $string;
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 | // Check for support for utf8 in the installed PCRE library once and store the result in a static
|
---|
1127 | static $utf8_pcre = null;
|
---|
1128 | if ( ! isset( $utf8_pcre ) ) {
|
---|
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
|
---|
1132 | if ( ! $utf8_pcre ) {
|
---|
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
|
---|
1155 | * @param int $length Max length of the string
|
---|
1156 | * @return string String with Unicode encoded for URI.
|
---|
1157 | */
|
---|
1158 | function utf8_uri_encode( $utf8_string, $length = 0 ) {
|
---|
1159 | $unicode = '';
|
---|
1160 | $values = array();
|
---|
1161 | $num_octets = 1;
|
---|
1162 | $unicode_length = 0;
|
---|
1163 |
|
---|
1164 | mbstring_binary_safe_encoding();
|
---|
1165 | $string_length = strlen( $utf8_string );
|
---|
1166 | reset_mbstring_encoding();
|
---|
1167 |
|
---|
1168 | for ( $i = 0; $i < $string_length; $i++ ) {
|
---|
1169 |
|
---|
1170 | $value = ord( $utf8_string[ $i ] );
|
---|
1171 |
|
---|
1172 | if ( $value < 128 ) {
|
---|
1173 | if ( $length && ( $unicode_length >= $length ) ) {
|
---|
1174 | break;
|
---|
1175 | }
|
---|
1176 | $unicode .= chr( $value );
|
---|
1177 | $unicode_length++;
|
---|
1178 | } else {
|
---|
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 | }
|
---|
1188 |
|
---|
1189 | $values[] = $value;
|
---|
1190 |
|
---|
1191 | if ( $length && ( $unicode_length + ( $num_octets * 3 ) ) > $length ) {
|
---|
1192 | break;
|
---|
1193 | }
|
---|
1194 | if ( count( $values ) == $num_octets ) {
|
---|
1195 | for ( $j = 0; $j < $num_octets; $j++ ) {
|
---|
1196 | $unicode .= '%' . dechex( $values[ $j ] );
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 | $unicode_length += $num_octets * 3;
|
---|
1200 |
|
---|
1201 | $values = array();
|
---|
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 | *
|
---|
1215 | * **Accent characters converted:**
|
---|
1216 | *
|
---|
1217 | * Currency signs:
|
---|
1218 | *
|
---|
1219 | * | Code | Glyph | Replacement | Description |
|
---|
1220 | * | -------- | ----- | ----------- | ------------------- |
|
---|
1221 | * | U+00A3 | £ | (empty) | British Pound sign |
|
---|
1222 | * | U+20AC | ⬠| E | Euro sign |
|
---|
1223 | *
|
---|
1224 | * Decompositions for Latin-1 Supplement:
|
---|
1225 | *
|
---|
1226 | * | Code | Glyph | Replacement | Description |
|
---|
1227 | * | ------- | ----- | ----------- | -------------------------------------- |
|
---|
1228 | * | U+00AA | ª | a | Feminine ordinal indicator |
|
---|
1229 | * | U+00BA | º | o | Masculine ordinal indicator |
|
---|
1230 | * | U+00C0 | Ã | A | Latin capital letter A with grave |
|
---|
1231 | * | U+00C1 | Ã | A | Latin capital letter A with acute |
|
---|
1232 | * | U+00C2 | Ã | A | Latin capital letter A with circumflex |
|
---|
1233 | * | U+00C3 | Ã | A | Latin capital letter A with tilde |
|
---|
1234 | * | U+00C4 | Ã | A | Latin capital letter A with diaeresis |
|
---|
1235 | * | U+00C5 | Ã
|
---|
1236 | | A | Latin capital letter A with ring above |
|
---|
1237 | * | U+00C6 | Ã | AE | Latin capital letter AE |
|
---|
1238 | * | U+00C7 | Ã | C | Latin capital letter C with cedilla |
|
---|
1239 | * | U+00C8 | Ã | E | Latin capital letter E with grave |
|
---|
1240 | * | U+00C9 | Ã | E | Latin capital letter E with acute |
|
---|
1241 | * | U+00CA | Ã | E | Latin capital letter E with circumflex |
|
---|
1242 | * | U+00CB | Ã | E | Latin capital letter E with diaeresis |
|
---|
1243 | * | U+00CC | Ã | I | Latin capital letter I with grave |
|
---|
1244 | * | U+00CD | Ã | I | Latin capital letter I with acute |
|
---|
1245 | * | U+00CE | Ã | I | Latin capital letter I with circumflex |
|
---|
1246 | * | U+00CF | Ã | I | Latin capital letter I with diaeresis |
|
---|
1247 | * | U+00D0 | Ã | D | Latin capital letter Eth |
|
---|
1248 | * | U+00D1 | Ã | N | Latin capital letter N with tilde |
|
---|
1249 | * | U+00D2 | Ã | O | Latin capital letter O with grave |
|
---|
1250 | * | U+00D3 | Ã | O | Latin capital letter O with acute |
|
---|
1251 | * | U+00D4 | Ã | O | Latin capital letter O with circumflex |
|
---|
1252 | * | U+00D5 | Ã | O | Latin capital letter O with tilde |
|
---|
1253 | * | U+00D6 | Ã | O | Latin capital letter O with diaeresis |
|
---|
1254 | * | U+00D8 | Ã | O | Latin capital letter O with stroke |
|
---|
1255 | * | U+00D9 | Ã | U | Latin capital letter U with grave |
|
---|
1256 | * | U+00DA | Ã | U | Latin capital letter U with acute |
|
---|
1257 | * | U+00DB | Ã | U | Latin capital letter U with circumflex |
|
---|
1258 | * | U+00DC | Ã | U | Latin capital letter U with diaeresis |
|
---|
1259 | * | U+00DD | Ã | Y | Latin capital letter Y with acute |
|
---|
1260 | * | U+00DE | Ã | TH | Latin capital letter Thorn |
|
---|
1261 | * | U+00DF | Ã | s | Latin small letter sharp s |
|
---|
1262 | * | U+00E0 | Ã | a | Latin small letter a with grave |
|
---|
1263 | * | U+00E1 | á | a | Latin small letter a with acute |
|
---|
1264 | * | U+00E2 | â | a | Latin small letter a with circumflex |
|
---|
1265 | * | U+00E3 | ã | a | Latin small letter a with tilde |
|
---|
1266 | * | U+00E4 | ä | a | Latin small letter a with diaeresis |
|
---|
1267 | * | U+00E5 | å | a | Latin small letter a with ring above |
|
---|
1268 | * | U+00E6 | æ | ae | Latin small letter ae |
|
---|
1269 | * | U+00E7 | ç | c | Latin small letter c with cedilla |
|
---|
1270 | * | U+00E8 | è | e | Latin small letter e with grave |
|
---|
1271 | * | U+00E9 | é | e | Latin small letter e with acute |
|
---|
1272 | * | U+00EA | ê | e | Latin small letter e with circumflex |
|
---|
1273 | * | U+00EB | ë | e | Latin small letter e with diaeresis |
|
---|
1274 | * | U+00EC | ì | i | Latin small letter i with grave |
|
---|
1275 | * | U+00ED | Ã | i | Latin small letter i with acute |
|
---|
1276 | * | U+00EE | î | i | Latin small letter i with circumflex |
|
---|
1277 | * | U+00EF | ï | i | Latin small letter i with diaeresis |
|
---|
1278 | * | U+00F0 | ð | d | Latin small letter Eth |
|
---|
1279 | * | U+00F1 | ñ | n | Latin small letter n with tilde |
|
---|
1280 | * | U+00F2 | ò | o | Latin small letter o with grave |
|
---|
1281 | * | U+00F3 | ó | o | Latin small letter o with acute |
|
---|
1282 | * | U+00F4 | ô | o | Latin small letter o with circumflex |
|
---|
1283 | * | U+00F5 | õ | o | Latin small letter o with tilde |
|
---|
1284 | * | U+00F6 | ö | o | Latin small letter o with diaeresis |
|
---|
1285 | * | U+00F8 | ø | o | Latin small letter o with stroke |
|
---|
1286 | * | U+00F9 | ù | u | Latin small letter u with grave |
|
---|
1287 | * | U+00FA | ú | u | Latin small letter u with acute |
|
---|
1288 | * | U+00FB | û | u | Latin small letter u with circumflex |
|
---|
1289 | * | U+00FC | ü | u | Latin small letter u with diaeresis |
|
---|
1290 | * | U+00FD | ý | y | Latin small letter y with acute |
|
---|
1291 | * | U+00FE | þ | th | Latin small letter Thorn |
|
---|
1292 | * | U+00FF | ÿ | y | Latin small letter y with diaeresis |
|
---|
1293 | *
|
---|
1294 | * Decompositions for Latin Extended-A:
|
---|
1295 | *
|
---|
1296 | * | Code | Glyph | Replacement | Description |
|
---|
1297 | * | ------- | ----- | ----------- | ------------------------------------------------- |
|
---|
1298 | * | U+0100 | Ä | A | Latin capital letter A with macron |
|
---|
1299 | * | U+0101 | Ä | a | Latin small letter a with macron |
|
---|
1300 | * | U+0102 | Ä | A | Latin capital letter A with breve |
|
---|
1301 | * | U+0103 | Ä | a | Latin small letter a with breve |
|
---|
1302 | * | U+0104 | Ä | A | Latin capital letter A with ogonek |
|
---|
1303 | * | U+0105 | Ä
|
---|
1304 | | a | Latin small letter a with ogonek |
|
---|
1305 | * | U+01006 | Ä | C | Latin capital letter C with acute |
|
---|
1306 | * | U+0107 | Ä | c | Latin small letter c with acute |
|
---|
1307 | * | U+0108 | Ä | C | Latin capital letter C with circumflex |
|
---|
1308 | * | U+0109 | Ä | c | Latin small letter c with circumflex |
|
---|
1309 | * | U+010A | Ä | C | Latin capital letter C with dot above |
|
---|
1310 | * | U+010B | Ä | c | Latin small letter c with dot above |
|
---|
1311 | * | U+010C | Ä | C | Latin capital letter C with caron |
|
---|
1312 | * | U+010D | Ä | c | Latin small letter c with caron |
|
---|
1313 | * | U+010E | Ä | D | Latin capital letter D with caron |
|
---|
1314 | * | U+010F | Ä | d | Latin small letter d with caron |
|
---|
1315 | * | U+0110 | Ä | D | Latin capital letter D with stroke |
|
---|
1316 | * | U+0111 | Ä | d | Latin small letter d with stroke |
|
---|
1317 | * | U+0112 | Ä | E | Latin capital letter E with macron |
|
---|
1318 | * | U+0113 | Ä | e | Latin small letter e with macron |
|
---|
1319 | * | U+0114 | Ä | E | Latin capital letter E with breve |
|
---|
1320 | * | U+0115 | Ä | e | Latin small letter e with breve |
|
---|
1321 | * | U+0116 | Ä | E | Latin capital letter E with dot above |
|
---|
1322 | * | U+0117 | Ä | e | Latin small letter e with dot above |
|
---|
1323 | * | U+0118 | Ä | E | Latin capital letter E with ogonek |
|
---|
1324 | * | U+0119 | Ä | e | Latin small letter e with ogonek |
|
---|
1325 | * | U+011A | Ä | E | Latin capital letter E with caron |
|
---|
1326 | * | U+011B | Ä | e | Latin small letter e with caron |
|
---|
1327 | * | U+011C | Ä | G | Latin capital letter G with circumflex |
|
---|
1328 | * | U+011D | Ä | g | Latin small letter g with circumflex |
|
---|
1329 | * | U+011E | Ä | G | Latin capital letter G with breve |
|
---|
1330 | * | U+011F | Ä | g | Latin small letter g with breve |
|
---|
1331 | * | U+0120 | Ä | G | Latin capital letter G with dot above |
|
---|
1332 | * | U+0121 | Ä¡ | g | Latin small letter g with dot above |
|
---|
1333 | * | U+0122 | Ģ | G | Latin capital letter G with cedilla |
|
---|
1334 | * | U+0123 | ģ | g | Latin small letter g with cedilla |
|
---|
1335 | * | U+0124 | Ĥ | H | Latin capital letter H with circumflex |
|
---|
1336 | * | U+0125 | ĥ | h | Latin small letter h with circumflex |
|
---|
1337 | * | U+0126 | Ħ | H | Latin capital letter H with stroke |
|
---|
1338 | * | U+0127 | ħ | h | Latin small letter h with stroke |
|
---|
1339 | * | U+0128 | Ĩ | I | Latin capital letter I with tilde |
|
---|
1340 | * | U+0129 | Ä© | i | Latin small letter i with tilde |
|
---|
1341 | * | U+012A | Ī | I | Latin capital letter I with macron |
|
---|
1342 | * | U+012B | Ä« | i | Latin small letter i with macron |
|
---|
1343 | * | U+012C | Ĭ | I | Latin capital letter I with breve |
|
---|
1344 | * | U+012D | Ä | i | Latin small letter i with breve |
|
---|
1345 | * | U+012E | Ä® | I | Latin capital letter I with ogonek |
|
---|
1346 | * | U+012F | į | i | Latin small letter i with ogonek |
|
---|
1347 | * | U+0130 | İ | I | Latin capital letter I with dot above |
|
---|
1348 | * | U+0131 | ı | i | Latin small letter dotless i |
|
---|
1349 | * | U+0132 | IJ | IJ | Latin capital ligature IJ |
|
---|
1350 | * | U+0133 | ij | ij | Latin small ligature ij |
|
---|
1351 | * | U+0134 | Ä´ | J | Latin capital letter J with circumflex |
|
---|
1352 | * | U+0135 | ĵ | j | Latin small letter j with circumflex |
|
---|
1353 | * | U+0136 | Ķ | K | Latin capital letter K with cedilla |
|
---|
1354 | * | U+0137 | Ä· | k | Latin small letter k with cedilla |
|
---|
1355 | * | U+0138 | ĸ | k | Latin small letter Kra |
|
---|
1356 | * | U+0139 | Ĺ | L | Latin capital letter L with acute |
|
---|
1357 | * | U+013A | ĺ | l | Latin small letter l with acute |
|
---|
1358 | * | U+013B | Ä» | L | Latin capital letter L with cedilla |
|
---|
1359 | * | U+013C | ļ | l | Latin small letter l with cedilla |
|
---|
1360 | * | U+013D | Ľ | L | Latin capital letter L with caron |
|
---|
1361 | * | U+013E | ľ | l | Latin small letter l with caron |
|
---|
1362 | * | U+013F | Ä¿ | L | Latin capital letter L with middle dot |
|
---|
1363 | * | U+0140 | Å | l | Latin small letter l with middle dot |
|
---|
1364 | * | U+0141 | Å | L | Latin capital letter L with stroke |
|
---|
1365 | * | U+0142 | Å | l | Latin small letter l with stroke |
|
---|
1366 | * | U+0143 | Å | N | Latin capital letter N with acute |
|
---|
1367 | * | U+0144 | Å | n | Latin small letter N with acute |
|
---|
1368 | * | U+0145 | Å
|
---|
1369 | | N | Latin capital letter N with cedilla |
|
---|
1370 | * | U+0146 | Å | n | Latin small letter n with cedilla |
|
---|
1371 | * | U+0147 | Å | N | Latin capital letter N with caron |
|
---|
1372 | * | U+0148 | Å | n | Latin small letter n with caron |
|
---|
1373 | * | U+0149 | Å | n | Latin small letter n preceded by apostrophe |
|
---|
1374 | * | U+014A | Å | N | Latin capital letter Eng |
|
---|
1375 | * | U+014B | Å | n | Latin small letter Eng |
|
---|
1376 | * | U+014C | Å | O | Latin capital letter O with macron |
|
---|
1377 | * | U+014D | Å | o | Latin small letter o with macron |
|
---|
1378 | * | U+014E | Å | O | Latin capital letter O with breve |
|
---|
1379 | * | U+014F | Å | o | Latin small letter o with breve |
|
---|
1380 | * | U+0150 | Å | O | Latin capital letter O with double acute |
|
---|
1381 | * | U+0151 | Å | o | Latin small letter o with double acute |
|
---|
1382 | * | U+0152 | Å | OE | Latin capital ligature OE |
|
---|
1383 | * | U+0153 | Å | oe | Latin small ligature oe |
|
---|
1384 | * | U+0154 | Å | R | Latin capital letter R with acute |
|
---|
1385 | * | U+0155 | Å | r | Latin small letter r with acute |
|
---|
1386 | * | U+0156 | Å | R | Latin capital letter R with cedilla |
|
---|
1387 | * | U+0157 | Å | r | Latin small letter r with cedilla |
|
---|
1388 | * | U+0158 | Å | R | Latin capital letter R with caron |
|
---|
1389 | * | U+0159 | Å | r | Latin small letter r with caron |
|
---|
1390 | * | U+015A | Å | S | Latin capital letter S with acute |
|
---|
1391 | * | U+015B | Å | s | Latin small letter s with acute |
|
---|
1392 | * | U+015C | Å | S | Latin capital letter S with circumflex |
|
---|
1393 | * | U+015D | Å | s | Latin small letter s with circumflex |
|
---|
1394 | * | U+015E | Å | S | Latin capital letter S with cedilla |
|
---|
1395 | * | U+015F | Å | s | Latin small letter s with cedilla |
|
---|
1396 | * | U+0160 | Å | S | Latin capital letter S with caron |
|
---|
1397 | * | U+0161 | Å¡ | s | Latin small letter s with caron |
|
---|
1398 | * | U+0162 | Ţ | T | Latin capital letter T with cedilla |
|
---|
1399 | * | U+0163 | ţ | t | Latin small letter t with cedilla |
|
---|
1400 | * | U+0164 | Ť | T | Latin capital letter T with caron |
|
---|
1401 | * | U+0165 | ť | t | Latin small letter t with caron |
|
---|
1402 | * | U+0166 | Ŧ | T | Latin capital letter T with stroke |
|
---|
1403 | * | U+0167 | ŧ | t | Latin small letter t with stroke |
|
---|
1404 | * | U+0168 | Ũ | U | Latin capital letter U with tilde |
|
---|
1405 | * | U+0169 | Å© | u | Latin small letter u with tilde |
|
---|
1406 | * | U+016A | Ū | U | Latin capital letter U with macron |
|
---|
1407 | * | U+016B | Å« | u | Latin small letter u with macron |
|
---|
1408 | * | U+016C | Ŭ | U | Latin capital letter U with breve |
|
---|
1409 | * | U+016D | Å | u | Latin small letter u with breve |
|
---|
1410 | * | U+016E | Å® | U | Latin capital letter U with ring above |
|
---|
1411 | * | U+016F | ů | u | Latin small letter u with ring above |
|
---|
1412 | * | U+0170 | Ű | U | Latin capital letter U with double acute |
|
---|
1413 | * | U+0171 | ű | u | Latin small letter u with double acute |
|
---|
1414 | * | U+0172 | Ų | U | Latin capital letter U with ogonek |
|
---|
1415 | * | U+0173 | ų | u | Latin small letter u with ogonek |
|
---|
1416 | * | U+0174 | Å´ | W | Latin capital letter W with circumflex |
|
---|
1417 | * | U+0175 | ŵ | w | Latin small letter w with circumflex |
|
---|
1418 | * | U+0176 | Ŷ | Y | Latin capital letter Y with circumflex |
|
---|
1419 | * | U+0177 | Å· | y | Latin small letter y with circumflex |
|
---|
1420 | * | U+0178 | Ÿ | Y | Latin capital letter Y with diaeresis |
|
---|
1421 | * | U+0179 | Ź | Z | Latin capital letter Z with acute |
|
---|
1422 | * | U+017A | ź | z | Latin small letter z with acute |
|
---|
1423 | * | U+017B | Å» | Z | Latin capital letter Z with dot above |
|
---|
1424 | * | U+017C | ż | z | Latin small letter z with dot above |
|
---|
1425 | * | U+017D | Ž | Z | Latin capital letter Z with caron |
|
---|
1426 | * | U+017E | ž | z | Latin small letter z with caron |
|
---|
1427 | * | U+017F | Å¿ | s | Latin small letter long s |
|
---|
1428 | * | U+01A0 | Æ | O | Latin capital letter O with horn |
|
---|
1429 | * | U+01A1 | Æ¡ | o | Latin small letter o with horn |
|
---|
1430 | * | U+01AF | Ư | U | Latin capital letter U with horn |
|
---|
1431 | * | U+01B0 | ư | u | Latin small letter u with horn |
|
---|
1432 | * | U+01CD | Ç | A | Latin capital letter A with caron |
|
---|
1433 | * | U+01CE | Ç | a | Latin small letter a with caron |
|
---|
1434 | * | U+01CF | Ç | I | Latin capital letter I with caron |
|
---|
1435 | * | U+01D0 | Ç | i | Latin small letter i with caron |
|
---|
1436 | * | U+01D1 | Ç | O | Latin capital letter O with caron |
|
---|
1437 | * | U+01D2 | Ç | o | Latin small letter o with caron |
|
---|
1438 | * | U+01D3 | Ç | U | Latin capital letter U with caron |
|
---|
1439 | * | U+01D4 | Ç | u | Latin small letter u with caron |
|
---|
1440 | * | U+01D5 | Ç | U | Latin capital letter U with diaeresis and macron |
|
---|
1441 | * | U+01D6 | Ç | u | Latin small letter u with diaeresis and macron |
|
---|
1442 | * | U+01D7 | Ç | U | Latin capital letter U with diaeresis and acute |
|
---|
1443 | * | U+01D8 | Ç | u | Latin small letter u with diaeresis and acute |
|
---|
1444 | * | U+01D9 | Ç | U | Latin capital letter U with diaeresis and caron |
|
---|
1445 | * | U+01DA | Ç | u | Latin small letter u with diaeresis and caron |
|
---|
1446 | * | U+01DB | Ç | U | Latin capital letter U with diaeresis and grave |
|
---|
1447 | * | U+01DC | Ç | u | Latin small letter u with diaeresis and grave |
|
---|
1448 | *
|
---|
1449 | * Decompositions for Latin Extended-B:
|
---|
1450 | *
|
---|
1451 | * | Code | Glyph | Replacement | Description |
|
---|
1452 | * | -------- | ----- | ----------- | ----------------------------------------- |
|
---|
1453 | * | U+0218 | È | S | Latin capital letter S with comma below |
|
---|
1454 | * | U+0219 | È | s | Latin small letter s with comma below |
|
---|
1455 | * | U+021A | È | T | Latin capital letter T with comma below |
|
---|
1456 | * | U+021B | È | t | Latin small letter t with comma below |
|
---|
1457 | *
|
---|
1458 | * Vowels with diacritic (Chinese, Hanyu Pinyin):
|
---|
1459 | *
|
---|
1460 | * | Code | Glyph | Replacement | Description |
|
---|
1461 | * | -------- | ----- | ----------- | ----------------------------------------------------- |
|
---|
1462 | * | U+0251 | É | a | Latin small letter alpha |
|
---|
1463 | * | U+1EA0 | Ạ| A | Latin capital letter A with dot below |
|
---|
1464 | * | U+1EA1 | ạ | a | Latin small letter a with dot below |
|
---|
1465 | * | U+1EA2 | Ả | A | Latin capital letter A with hook above |
|
---|
1466 | * | U+1EA3 | ả | a | Latin small letter a with hook above |
|
---|
1467 | * | U+1EA4 | Ấ | A | Latin capital letter A with circumflex and acute |
|
---|
1468 | * | U+1EA5 | ấ | a | Latin small letter a with circumflex and acute |
|
---|
1469 | * | U+1EA6 | Ầ | A | Latin capital letter A with circumflex and grave |
|
---|
1470 | * | U+1EA7 | ầ | a | Latin small letter a with circumflex and grave |
|
---|
1471 | * | U+1EA8 | Ẩ | A | Latin capital letter A with circumflex and hook above |
|
---|
1472 | * | U+1EA9 | ẩ | a | Latin small letter a with circumflex and hook above |
|
---|
1473 | * | U+1EAA | Ẫ | A | Latin capital letter A with circumflex and tilde |
|
---|
1474 | * | U+1EAB | ẫ | a | Latin small letter a with circumflex and tilde |
|
---|
1475 | * | U+1EA6 | Ậ | A | Latin capital letter A with circumflex and dot below |
|
---|
1476 | * | U+1EAD | Ạ| a | Latin small letter a with circumflex and dot below |
|
---|
1477 | * | U+1EAE | Ắ | A | Latin capital letter A with breve and acute |
|
---|
1478 | * | U+1EAF | ắ | a | Latin small letter a with breve and acute |
|
---|
1479 | * | U+1EB0 | Ằ | A | Latin capital letter A with breve and grave |
|
---|
1480 | * | U+1EB1 | ằ | a | Latin small letter a with breve and grave |
|
---|
1481 | * | U+1EB2 | Ẳ | A | Latin capital letter A with breve and hook above |
|
---|
1482 | * | U+1EB3 | ẳ | a | Latin small letter a with breve and hook above |
|
---|
1483 | * | U+1EB4 | Ẵ | A | Latin capital letter A with breve and tilde |
|
---|
1484 | * | U+1EB5 | ẵ | a | Latin small letter a with breve and tilde |
|
---|
1485 | * | U+1EB6 | Ặ | A | Latin capital letter A with breve and dot below |
|
---|
1486 | * | U+1EB7 | ặ | a | Latin small letter a with breve and dot below |
|
---|
1487 | * | U+1EB8 | Ẹ | E | Latin capital letter E with dot below |
|
---|
1488 | * | U+1EB9 | ẹ | e | Latin small letter e with dot below |
|
---|
1489 | * | U+1EBA | Ẻ | E | Latin capital letter E with hook above |
|
---|
1490 | * | U+1EBB | ẻ | e | Latin small letter e with hook above |
|
---|
1491 | * | U+1EBC | Ẽ | E | Latin capital letter E with tilde |
|
---|
1492 | * | U+1EBD | ẽ | e | Latin small letter e with tilde |
|
---|
1493 | * | U+1EBE | Ế | E | Latin capital letter E with circumflex and acute |
|
---|
1494 | * | U+1EBF | ế | e | Latin small letter e with circumflex and acute |
|
---|
1495 | * | U+1EC0 | á» | E | Latin capital letter E with circumflex and grave |
|
---|
1496 | * | U+1EC1 | á» | e | Latin small letter e with circumflex and grave |
|
---|
1497 | * | U+1EC2 | á» | E | Latin capital letter E with circumflex and hook above |
|
---|
1498 | * | U+1EC3 | á» | e | Latin small letter e with circumflex and hook above |
|
---|
1499 | * | U+1EC4 | á» | E | Latin capital letter E with circumflex and tilde |
|
---|
1500 | * | U+1EC5 | á»
|
---|
1501 | | e | Latin small letter e with circumflex and tilde |
|
---|
1502 | * | U+1EC6 | á» | E | Latin capital letter E with circumflex and dot below |
|
---|
1503 | * | U+1EC7 | á» | e | Latin small letter e with circumflex and dot below |
|
---|
1504 | * | U+1EC8 | á» | I | Latin capital letter I with hook above |
|
---|
1505 | * | U+1EC9 | á» | i | Latin small letter i with hook above |
|
---|
1506 | * | U+1ECA | á» | I | Latin capital letter I with dot below |
|
---|
1507 | * | U+1ECB | á» | i | Latin small letter i with dot below |
|
---|
1508 | * | U+1ECC | á» | O | Latin capital letter O with dot below |
|
---|
1509 | * | U+1ECD | á» | o | Latin small letter o with dot below |
|
---|
1510 | * | U+1ECE | á» | O | Latin capital letter O with hook above |
|
---|
1511 | * | U+1ECF | á» | o | Latin small letter o with hook above |
|
---|
1512 | * | U+1ED0 | á» | O | Latin capital letter O with circumflex and acute |
|
---|
1513 | * | U+1ED1 | á» | o | Latin small letter o with circumflex and acute |
|
---|
1514 | * | U+1ED2 | á» | O | Latin capital letter O with circumflex and grave |
|
---|
1515 | * | U+1ED3 | á» | o | Latin small letter o with circumflex and grave |
|
---|
1516 | * | U+1ED4 | á» | O | Latin capital letter O with circumflex and hook above |
|
---|
1517 | * | U+1ED5 | á» | o | Latin small letter o with circumflex and hook above |
|
---|
1518 | * | U+1ED6 | á» | O | Latin capital letter O with circumflex and tilde |
|
---|
1519 | * | U+1ED7 | á» | o | Latin small letter o with circumflex and tilde |
|
---|
1520 | * | U+1ED8 | á» | O | Latin capital letter O with circumflex and dot below |
|
---|
1521 | * | U+1ED9 | á» | o | Latin small letter o with circumflex and dot below |
|
---|
1522 | * | U+1EDA | á» | O | Latin capital letter O with horn and acute |
|
---|
1523 | * | U+1EDB | á» | o | Latin small letter o with horn and acute |
|
---|
1524 | * | U+1EDC | á» | O | Latin capital letter O with horn and grave |
|
---|
1525 | * | U+1EDD | á» | o | Latin small letter o with horn and grave |
|
---|
1526 | * | U+1EDE | á» | O | Latin capital letter O with horn and hook above |
|
---|
1527 | * | U+1EDF | á» | o | Latin small letter o with horn and hook above |
|
---|
1528 | * | U+1EE0 | á» | O | Latin capital letter O with horn and tilde |
|
---|
1529 | * | U+1EE1 | ỡ | o | Latin small letter o with horn and tilde |
|
---|
1530 | * | U+1EE2 | Ợ | O | Latin capital letter O with horn and dot below |
|
---|
1531 | * | U+1EE3 | ợ | o | Latin small letter o with horn and dot below |
|
---|
1532 | * | U+1EE4 | Ụ | U | Latin capital letter U with dot below |
|
---|
1533 | * | U+1EE5 | ụ | u | Latin small letter u with dot below |
|
---|
1534 | * | U+1EE6 | Ủ | U | Latin capital letter U with hook above |
|
---|
1535 | * | U+1EE7 | á»§ | u | Latin small letter u with hook above |
|
---|
1536 | * | U+1EE8 | Ứ | U | Latin capital letter U with horn and acute |
|
---|
1537 | * | U+1EE9 | ứ | u | Latin small letter u with horn and acute |
|
---|
1538 | * | U+1EEA | Ừ | U | Latin capital letter U with horn and grave |
|
---|
1539 | * | U+1EEB | ừ | u | Latin small letter u with horn and grave |
|
---|
1540 | * | U+1EEC | Ử | U | Latin capital letter U with horn and hook above |
|
---|
1541 | * | U+1EED | á» | u | Latin small letter u with horn and hook above |
|
---|
1542 | * | U+1EEE | á»® | U | Latin capital letter U with horn and tilde |
|
---|
1543 | * | U+1EEF | ữ | u | Latin small letter u with horn and tilde |
|
---|
1544 | * | U+1EF0 | á»° | U | Latin capital letter U with horn and dot below |
|
---|
1545 | * | U+1EF1 | á»± | u | Latin small letter u with horn and dot below |
|
---|
1546 | * | U+1EF2 | Ỳ | Y | Latin capital letter Y with grave |
|
---|
1547 | * | U+1EF3 | ỳ | y | Latin small letter y with grave |
|
---|
1548 | * | U+1EF4 | á»´ | Y | Latin capital letter Y with dot below |
|
---|
1549 | * | U+1EF5 | ỵ | y | Latin small letter y with dot below |
|
---|
1550 | * | U+1EF6 | á»¶ | Y | Latin capital letter Y with hook above |
|
---|
1551 | * | U+1EF7 | á»· | y | Latin small letter y with hook above |
|
---|
1552 | * | U+1EF8 | Ỹ | Y | Latin capital letter Y with tilde |
|
---|
1553 | * | U+1EF9 | ỹ | y | Latin small letter y with tilde |
|
---|
1554 | *
|
---|
1555 | * German (`de_DE`), German formal (`de_DE_formal`), German (Switzerland) formal (`de_CH`),
|
---|
1556 | * and German (Switzerland) informal (`de_CH_informal`) locales:
|
---|
1557 | *
|
---|
1558 | * | Code | Glyph | Replacement | Description |
|
---|
1559 | * | -------- | ----- | ----------- | --------------------------------------- |
|
---|
1560 | * | U+00C4 | Ã | Ae | Latin capital letter A with diaeresis |
|
---|
1561 | * | U+00E4 | ä | ae | Latin small letter a with diaeresis |
|
---|
1562 | * | U+00D6 | Ã | Oe | Latin capital letter O with diaeresis |
|
---|
1563 | * | U+00F6 | ö | oe | Latin small letter o with diaeresis |
|
---|
1564 | * | U+00DC | Ã | Ue | Latin capital letter U with diaeresis |
|
---|
1565 | * | U+00FC | ü | ue | Latin small letter u with diaeresis |
|
---|
1566 | * | U+00DF | Ã | ss | Latin small letter sharp s |
|
---|
1567 | *
|
---|
1568 | * Danish (`da_DK`) locale:
|
---|
1569 | *
|
---|
1570 | * | Code | Glyph | Replacement | Description |
|
---|
1571 | * | -------- | ----- | ----------- | --------------------------------------- |
|
---|
1572 | * | U+00C6 | Ã | Ae | Latin capital letter AE |
|
---|
1573 | * | U+00E6 | æ | ae | Latin small letter ae |
|
---|
1574 | * | U+00D8 | Ã | Oe | Latin capital letter O with stroke |
|
---|
1575 | * | U+00F8 | ø | oe | Latin small letter o with stroke |
|
---|
1576 | * | U+00C5 | Ã
|
---|
1577 | | Aa | Latin capital letter A with ring above |
|
---|
1578 | * | U+00E5 | å | aa | Latin small letter a with ring above |
|
---|
1579 | *
|
---|
1580 | * Catalan (`ca`) locale:
|
---|
1581 | *
|
---|
1582 | * | Code | Glyph | Replacement | Description |
|
---|
1583 | * | -------- | ----- | ----------- | --------------------------------------- |
|
---|
1584 | * | U+00B7 | l·l | ll | Flown dot (between two Ls) |
|
---|
1585 | *
|
---|
1586 | * Serbian (`sr_RS`) and Bosnian (`bs_BA`) locales:
|
---|
1587 | *
|
---|
1588 | * | Code | Glyph | Replacement | Description |
|
---|
1589 | * | -------- | ----- | ----------- | --------------------------------------- |
|
---|
1590 | * | U+0110 | Ä | DJ | Latin capital letter D with stroke |
|
---|
1591 | * | U+0111 | Ä | dj | Latin small letter d with stroke |
|
---|
1592 | *
|
---|
1593 | * @since 1.2.1
|
---|
1594 | * @since 4.6.0 Added locale support for `de_CH`, `de_CH_informal`, and `ca`.
|
---|
1595 | * @since 4.7.0 Added locale support for `sr_RS`.
|
---|
1596 | * @since 4.8.0 Added locale support for `bs_BA`.
|
---|
1597 | *
|
---|
1598 | * @param string $string Text that might have accent characters
|
---|
1599 | * @return string Filtered string with replaced "nice" characters.
|
---|
1600 | */
|
---|
1601 | function remove_accents( $string ) {
|
---|
1602 | if ( ! preg_match( '/[\x80-\xff]/', $string ) ) {
|
---|
1603 | return $string;
|
---|
1604 | }
|
---|
1605 |
|
---|
1606 | if ( seems_utf8( $string ) ) {
|
---|
1607 | $chars = array(
|
---|
1608 | // Decompositions for Latin-1 Supplement
|
---|
1609 | 'ª' => 'a',
|
---|
1610 | 'º' => 'o',
|
---|
1611 | 'Ã' => 'A',
|
---|
1612 | 'Ã' => 'A',
|
---|
1613 | 'Ã' => 'A',
|
---|
1614 | 'Ã' => 'A',
|
---|
1615 | 'Ã' => 'A',
|
---|
1616 | 'Ã
|
---|
1617 | ' => 'A',
|
---|
1618 | 'Ã' => 'AE',
|
---|
1619 | 'Ã' => 'C',
|
---|
1620 | 'Ã' => 'E',
|
---|
1621 | 'Ã' => 'E',
|
---|
1622 | 'Ã' => 'E',
|
---|
1623 | 'Ã' => 'E',
|
---|
1624 | 'Ã' => 'I',
|
---|
1625 | 'Ã' => 'I',
|
---|
1626 | 'Ã' => 'I',
|
---|
1627 | 'Ã' => 'I',
|
---|
1628 | 'Ã' => 'D',
|
---|
1629 | 'Ã' => 'N',
|
---|
1630 | 'Ã' => 'O',
|
---|
1631 | 'Ã' => 'O',
|
---|
1632 | 'Ã' => 'O',
|
---|
1633 | 'Ã' => 'O',
|
---|
1634 | 'Ã' => 'O',
|
---|
1635 | 'Ã' => 'U',
|
---|
1636 | 'Ã' => 'U',
|
---|
1637 | 'Ã' => 'U',
|
---|
1638 | 'Ã' => 'U',
|
---|
1639 | 'Ã' => 'Y',
|
---|
1640 | 'Ã' => 'TH',
|
---|
1641 | 'Ã' => 's',
|
---|
1642 | 'Ã ' => 'a',
|
---|
1643 | 'á' => 'a',
|
---|
1644 | 'â' => 'a',
|
---|
1645 | 'ã' => 'a',
|
---|
1646 | 'ä' => 'a',
|
---|
1647 | 'Ã¥' => 'a',
|
---|
1648 | 'æ' => 'ae',
|
---|
1649 | 'ç' => 'c',
|
---|
1650 | 'è' => 'e',
|
---|
1651 | 'é' => 'e',
|
---|
1652 | 'ê' => 'e',
|
---|
1653 | 'ë' => 'e',
|
---|
1654 | 'ì' => 'i',
|
---|
1655 | 'Ã' => 'i',
|
---|
1656 | 'î' => 'i',
|
---|
1657 | 'ï' => 'i',
|
---|
1658 | 'ð' => 'd',
|
---|
1659 | 'ñ' => 'n',
|
---|
1660 | 'ò' => 'o',
|
---|
1661 | 'ó' => 'o',
|
---|
1662 | 'ô' => 'o',
|
---|
1663 | 'õ' => 'o',
|
---|
1664 | 'ö' => 'o',
|
---|
1665 | 'ø' => 'o',
|
---|
1666 | 'ù' => 'u',
|
---|
1667 | 'ú' => 'u',
|
---|
1668 | 'û' => 'u',
|
---|
1669 | 'ü' => 'u',
|
---|
1670 | 'ý' => 'y',
|
---|
1671 | 'þ' => 'th',
|
---|
1672 | 'ÿ' => 'y',
|
---|
1673 | 'Ã' => 'O',
|
---|
1674 | // Decompositions for Latin Extended-A
|
---|
1675 | 'Ä' => 'A',
|
---|
1676 | 'Ä' => 'a',
|
---|
1677 | 'Ä' => 'A',
|
---|
1678 | 'Ä' => 'a',
|
---|
1679 | 'Ä' => 'A',
|
---|
1680 | 'Ä
|
---|
1681 | ' => 'a',
|
---|
1682 | 'Ä' => 'C',
|
---|
1683 | 'Ä' => 'c',
|
---|
1684 | 'Ä' => 'C',
|
---|
1685 | 'Ä' => 'c',
|
---|
1686 | 'Ä' => 'C',
|
---|
1687 | 'Ä' => 'c',
|
---|
1688 | 'Ä' => 'C',
|
---|
1689 | 'Ä' => 'c',
|
---|
1690 | 'Ä' => 'D',
|
---|
1691 | 'Ä' => 'd',
|
---|
1692 | 'Ä' => 'D',
|
---|
1693 | 'Ä' => 'd',
|
---|
1694 | 'Ä' => 'E',
|
---|
1695 | 'Ä' => 'e',
|
---|
1696 | 'Ä' => 'E',
|
---|
1697 | 'Ä' => 'e',
|
---|
1698 | 'Ä' => 'E',
|
---|
1699 | 'Ä' => 'e',
|
---|
1700 | 'Ä' => 'E',
|
---|
1701 | 'Ä' => 'e',
|
---|
1702 | 'Ä' => 'E',
|
---|
1703 | 'Ä' => 'e',
|
---|
1704 | 'Ä' => 'G',
|
---|
1705 | 'Ä' => 'g',
|
---|
1706 | 'Ä' => 'G',
|
---|
1707 | 'Ä' => 'g',
|
---|
1708 | 'Ä ' => 'G',
|
---|
1709 | 'Ä¡' => 'g',
|
---|
1710 | 'Ä¢' => 'G',
|
---|
1711 | 'Ä£' => 'g',
|
---|
1712 | 'Ĥ' => 'H',
|
---|
1713 | 'Ä¥' => 'h',
|
---|
1714 | 'Ħ' => 'H',
|
---|
1715 | 'ħ' => 'h',
|
---|
1716 | 'Ĩ' => 'I',
|
---|
1717 | 'Ä©' => 'i',
|
---|
1718 | 'Ī' => 'I',
|
---|
1719 | 'Ä«' => 'i',
|
---|
1720 | 'Ĭ' => 'I',
|
---|
1721 | 'Ä' => 'i',
|
---|
1722 | 'Ä®' => 'I',
|
---|
1723 | 'į' => 'i',
|
---|
1724 | 'İ' => 'I',
|
---|
1725 | 'ı' => 'i',
|
---|
1726 | 'IJ' => 'IJ',
|
---|
1727 | 'ij' => 'ij',
|
---|
1728 | 'Ä´' => 'J',
|
---|
1729 | 'ĵ' => 'j',
|
---|
1730 | 'Ķ' => 'K',
|
---|
1731 | 'Ä·' => 'k',
|
---|
1732 | 'ĸ' => 'k',
|
---|
1733 | 'Ĺ' => 'L',
|
---|
1734 | 'ĺ' => 'l',
|
---|
1735 | 'Ä»' => 'L',
|
---|
1736 | 'ļ' => 'l',
|
---|
1737 | 'Ľ' => 'L',
|
---|
1738 | 'ľ' => 'l',
|
---|
1739 | 'Ä¿' => 'L',
|
---|
1740 | 'Å' => 'l',
|
---|
1741 | 'Å' => 'L',
|
---|
1742 | 'Å' => 'l',
|
---|
1743 | 'Å' => 'N',
|
---|
1744 | 'Å' => 'n',
|
---|
1745 | 'Å
|
---|
1746 | ' => 'N',
|
---|
1747 | 'Å' => 'n',
|
---|
1748 | 'Å' => 'N',
|
---|
1749 | 'Å' => 'n',
|
---|
1750 | 'Å' => 'n',
|
---|
1751 | 'Å' => 'N',
|
---|
1752 | 'Å' => 'n',
|
---|
1753 | 'Å' => 'O',
|
---|
1754 | 'Å' => 'o',
|
---|
1755 | 'Å' => 'O',
|
---|
1756 | 'Å' => 'o',
|
---|
1757 | 'Å' => 'O',
|
---|
1758 | 'Å' => 'o',
|
---|
1759 | 'Å' => 'OE',
|
---|
1760 | 'Å' => 'oe',
|
---|
1761 | 'Å' => 'R',
|
---|
1762 | 'Å' => 'r',
|
---|
1763 | 'Å' => 'R',
|
---|
1764 | 'Å' => 'r',
|
---|
1765 | 'Å' => 'R',
|
---|
1766 | 'Å' => 'r',
|
---|
1767 | 'Å' => 'S',
|
---|
1768 | 'Å' => 's',
|
---|
1769 | 'Å' => 'S',
|
---|
1770 | 'Å' => 's',
|
---|
1771 | 'Å' => 'S',
|
---|
1772 | 'Å' => 's',
|
---|
1773 | 'Å ' => 'S',
|
---|
1774 | 'Å¡' => 's',
|
---|
1775 | 'Å¢' => 'T',
|
---|
1776 | 'Å£' => 't',
|
---|
1777 | 'Ť' => 'T',
|
---|
1778 | 'Å¥' => 't',
|
---|
1779 | 'Ŧ' => 'T',
|
---|
1780 | 'ŧ' => 't',
|
---|
1781 | 'Ũ' => 'U',
|
---|
1782 | 'Å©' => 'u',
|
---|
1783 | 'Ū' => 'U',
|
---|
1784 | 'Å«' => 'u',
|
---|
1785 | 'Ŭ' => 'U',
|
---|
1786 | 'Å' => 'u',
|
---|
1787 | 'Å®' => 'U',
|
---|
1788 | 'ů' => 'u',
|
---|
1789 | 'Ű' => 'U',
|
---|
1790 | 'ű' => 'u',
|
---|
1791 | 'Ų' => 'U',
|
---|
1792 | 'ų' => 'u',
|
---|
1793 | 'Å´' => 'W',
|
---|
1794 | 'ŵ' => 'w',
|
---|
1795 | 'Ŷ' => 'Y',
|
---|
1796 | 'Å·' => 'y',
|
---|
1797 | 'Ÿ' => 'Y',
|
---|
1798 | 'Ź' => 'Z',
|
---|
1799 | 'ź' => 'z',
|
---|
1800 | 'Å»' => 'Z',
|
---|
1801 | 'ż' => 'z',
|
---|
1802 | 'Ž' => 'Z',
|
---|
1803 | 'ž' => 'z',
|
---|
1804 | 'Å¿' => 's',
|
---|
1805 | // Decompositions for Latin Extended-B
|
---|
1806 | 'È' => 'S',
|
---|
1807 | 'È' => 's',
|
---|
1808 | 'È' => 'T',
|
---|
1809 | 'È' => 't',
|
---|
1810 | // Euro Sign
|
---|
1811 | 'â¬' => 'E',
|
---|
1812 | // GBP (Pound) Sign
|
---|
1813 | '£' => '',
|
---|
1814 | // Vowels with diacritic (Vietnamese)
|
---|
1815 | // unmarked
|
---|
1816 | 'Æ ' => 'O',
|
---|
1817 | 'Æ¡' => 'o',
|
---|
1818 | 'Ư' => 'U',
|
---|
1819 | 'ư' => 'u',
|
---|
1820 | // grave accent
|
---|
1821 | 'Ầ' => 'A',
|
---|
1822 | 'ầ' => 'a',
|
---|
1823 | 'Ằ' => 'A',
|
---|
1824 | 'ằ' => 'a',
|
---|
1825 | 'á»' => 'E',
|
---|
1826 | 'á»' => 'e',
|
---|
1827 | 'á»' => 'O',
|
---|
1828 | 'á»' => 'o',
|
---|
1829 | 'á»' => 'O',
|
---|
1830 | 'á»' => 'o',
|
---|
1831 | 'Ừ' => 'U',
|
---|
1832 | 'ừ' => 'u',
|
---|
1833 | 'Ỳ' => 'Y',
|
---|
1834 | 'ỳ' => 'y',
|
---|
1835 | // hook
|
---|
1836 | 'Ả' => 'A',
|
---|
1837 | 'ả' => 'a',
|
---|
1838 | 'Ẩ' => 'A',
|
---|
1839 | 'ẩ' => 'a',
|
---|
1840 | 'Ẳ' => 'A',
|
---|
1841 | 'ẳ' => 'a',
|
---|
1842 | 'Ẻ' => 'E',
|
---|
1843 | 'ẻ' => 'e',
|
---|
1844 | 'á»' => 'E',
|
---|
1845 | 'á»' => 'e',
|
---|
1846 | 'á»' => 'I',
|
---|
1847 | 'á»' => 'i',
|
---|
1848 | 'á»' => 'O',
|
---|
1849 | 'á»' => 'o',
|
---|
1850 | 'á»' => 'O',
|
---|
1851 | 'á»' => 'o',
|
---|
1852 | 'á»' => 'O',
|
---|
1853 | 'á»' => 'o',
|
---|
1854 | 'Ủ' => 'U',
|
---|
1855 | 'á»§' => 'u',
|
---|
1856 | 'Ử' => 'U',
|
---|
1857 | 'á»' => 'u',
|
---|
1858 | 'á»¶' => 'Y',
|
---|
1859 | 'á»·' => 'y',
|
---|
1860 | // tilde
|
---|
1861 | 'Ẫ' => 'A',
|
---|
1862 | 'ẫ' => 'a',
|
---|
1863 | 'Ẵ' => 'A',
|
---|
1864 | 'ẵ' => 'a',
|
---|
1865 | 'Ẽ' => 'E',
|
---|
1866 | 'ẽ' => 'e',
|
---|
1867 | 'á»' => 'E',
|
---|
1868 | 'á»
|
---|
1869 | ' => 'e',
|
---|
1870 | 'á»' => 'O',
|
---|
1871 | 'á»' => 'o',
|
---|
1872 | 'á» ' => 'O',
|
---|
1873 | 'ỡ' => 'o',
|
---|
1874 | 'á»®' => 'U',
|
---|
1875 | 'ữ' => 'u',
|
---|
1876 | 'Ỹ' => 'Y',
|
---|
1877 | 'ỹ' => 'y',
|
---|
1878 | // acute accent
|
---|
1879 | 'Ấ' => 'A',
|
---|
1880 | 'ấ' => 'a',
|
---|
1881 | 'Ắ' => 'A',
|
---|
1882 | 'ắ' => 'a',
|
---|
1883 | 'Ế' => 'E',
|
---|
1884 | 'ế' => 'e',
|
---|
1885 | 'á»' => 'O',
|
---|
1886 | 'á»' => 'o',
|
---|
1887 | 'á»' => 'O',
|
---|
1888 | 'á»' => 'o',
|
---|
1889 | 'Ứ' => 'U',
|
---|
1890 | 'ứ' => 'u',
|
---|
1891 | // dot below
|
---|
1892 | 'Ạ' => 'A',
|
---|
1893 | 'ạ' => 'a',
|
---|
1894 | 'Ậ' => 'A',
|
---|
1895 | 'áº' => 'a',
|
---|
1896 | 'Ặ' => 'A',
|
---|
1897 | 'ặ' => 'a',
|
---|
1898 | 'Ẹ' => 'E',
|
---|
1899 | 'ẹ' => 'e',
|
---|
1900 | 'á»' => 'E',
|
---|
1901 | 'á»' => 'e',
|
---|
1902 | 'á»' => 'I',
|
---|
1903 | 'á»' => 'i',
|
---|
1904 | 'á»' => 'O',
|
---|
1905 | 'á»' => 'o',
|
---|
1906 | 'á»' => 'O',
|
---|
1907 | 'á»' => 'o',
|
---|
1908 | 'Ợ' => 'O',
|
---|
1909 | 'ợ' => 'o',
|
---|
1910 | 'Ụ' => 'U',
|
---|
1911 | 'ụ' => 'u',
|
---|
1912 | 'á»°' => 'U',
|
---|
1913 | 'á»±' => 'u',
|
---|
1914 | 'á»´' => 'Y',
|
---|
1915 | 'ỵ' => 'y',
|
---|
1916 | // Vowels with diacritic (Chinese, Hanyu Pinyin)
|
---|
1917 | 'É' => 'a',
|
---|
1918 | // macron
|
---|
1919 | 'Ç' => 'U',
|
---|
1920 | 'Ç' => 'u',
|
---|
1921 | // acute accent
|
---|
1922 | 'Ç' => 'U',
|
---|
1923 | 'Ç' => 'u',
|
---|
1924 | // caron
|
---|
1925 | 'Ç' => 'A',
|
---|
1926 | 'Ç' => 'a',
|
---|
1927 | 'Ç' => 'I',
|
---|
1928 | 'Ç' => 'i',
|
---|
1929 | 'Ç' => 'O',
|
---|
1930 | 'Ç' => 'o',
|
---|
1931 | 'Ç' => 'U',
|
---|
1932 | 'Ç' => 'u',
|
---|
1933 | 'Ç' => 'U',
|
---|
1934 | 'Ç' => 'u',
|
---|
1935 | // grave accent
|
---|
1936 | 'Ç' => 'U',
|
---|
1937 | 'Ç' => 'u',
|
---|
1938 | );
|
---|
1939 |
|
---|
1940 | // Used for locale-specific rules
|
---|
1941 | $locale = get_locale();
|
---|
1942 |
|
---|
1943 | if ( 'de_DE' == $locale || 'de_DE_formal' == $locale || 'de_CH' == $locale || 'de_CH_informal' == $locale ) {
|
---|
1944 | $chars['Ã'] = 'Ae';
|
---|
1945 | $chars['ä'] = 'ae';
|
---|
1946 | $chars['Ã'] = 'Oe';
|
---|
1947 | $chars['ö'] = 'oe';
|
---|
1948 | $chars['Ã'] = 'Ue';
|
---|
1949 | $chars['ü'] = 'ue';
|
---|
1950 | $chars['Ã'] = 'ss';
|
---|
1951 | } elseif ( 'da_DK' === $locale ) {
|
---|
1952 | $chars['Ã'] = 'Ae';
|
---|
1953 | $chars['æ'] = 'ae';
|
---|
1954 | $chars['Ã'] = 'Oe';
|
---|
1955 | $chars['ø'] = 'oe';
|
---|
1956 | $chars['Ã
|
---|
1957 | '] = 'Aa';
|
---|
1958 | $chars['Ã¥'] = 'aa';
|
---|
1959 | } elseif ( 'ca' === $locale ) {
|
---|
1960 | $chars['l·l'] = 'll';
|
---|
1961 | } elseif ( 'sr_RS' === $locale || 'bs_BA' === $locale ) {
|
---|
1962 | $chars['Ä'] = 'DJ';
|
---|
1963 | $chars['Ä'] = 'dj';
|
---|
1964 | }
|
---|
1965 |
|
---|
1966 | $string = strtr( $string, $chars );
|
---|
1967 | } else {
|
---|
1968 | $chars = array();
|
---|
1969 | // Assume ISO-8859-1 if not UTF-8
|
---|
1970 | $chars['in'] = "\x80\x83\x8a\x8e\x9a\x9e"
|
---|
1971 | . "\x9f\xa2\xa5\xb5\xc0\xc1\xc2"
|
---|
1972 | . "\xc3\xc4\xc5\xc7\xc8\xc9\xca"
|
---|
1973 | . "\xcb\xcc\xcd\xce\xcf\xd1\xd2"
|
---|
1974 | . "\xd3\xd4\xd5\xd6\xd8\xd9\xda"
|
---|
1975 | . "\xdb\xdc\xdd\xe0\xe1\xe2\xe3"
|
---|
1976 | . "\xe4\xe5\xe7\xe8\xe9\xea\xeb"
|
---|
1977 | . "\xec\xed\xee\xef\xf1\xf2\xf3"
|
---|
1978 | . "\xf4\xf5\xf6\xf8\xf9\xfa\xfb"
|
---|
1979 | . "\xfc\xfd\xff";
|
---|
1980 |
|
---|
1981 | $chars['out'] = 'EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy';
|
---|
1982 |
|
---|
1983 | $string = strtr( $string, $chars['in'], $chars['out'] );
|
---|
1984 | $double_chars = array();
|
---|
1985 | $double_chars['in'] = array( "\x8c", "\x9c", "\xc6", "\xd0", "\xde", "\xdf", "\xe6", "\xf0", "\xfe" );
|
---|
1986 | $double_chars['out'] = array( 'OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th' );
|
---|
1987 | $string = str_replace( $double_chars['in'], $double_chars['out'], $string );
|
---|
1988 | }
|
---|
1989 |
|
---|
1990 | return $string;
|
---|
1991 | }
|
---|
1992 |
|
---|
1993 | /**
|
---|
1994 | * Sanitizes a filename, replacing whitespace with dashes.
|
---|
1995 | *
|
---|
1996 | * Removes special characters that are illegal in filenames on certain
|
---|
1997 | * operating systems and special characters requiring special escaping
|
---|
1998 | * to manipulate at the command line. Replaces spaces and consecutive
|
---|
1999 | * dashes with a single dash. Trims period, dash and underscore from beginning
|
---|
2000 | * and end of filename. It is not guaranteed that this function will return a
|
---|
2001 | * filename that is allowed to be uploaded.
|
---|
2002 | *
|
---|
2003 | * @since 2.1.0
|
---|
2004 | *
|
---|
2005 | * @param string $filename The filename to be sanitized
|
---|
2006 | * @return string The sanitized filename
|
---|
2007 | */
|
---|
2008 | function sanitize_file_name( $filename ) {
|
---|
2009 | $filename_raw = $filename;
|
---|
2010 | $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', chr( 0 ) );
|
---|
2011 | /**
|
---|
2012 | * Filters the list of characters to remove from a filename.
|
---|
2013 | *
|
---|
2014 | * @since 2.8.0
|
---|
2015 | *
|
---|
2016 | * @param array $special_chars Characters to remove.
|
---|
2017 | * @param string $filename_raw Filename as it was passed into sanitize_file_name().
|
---|
2018 | */
|
---|
2019 | $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
|
---|
2020 | $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );
|
---|
2021 | $filename = str_replace( $special_chars, '', $filename );
|
---|
2022 | $filename = str_replace( array( '%20', '+' ), '-', $filename );
|
---|
2023 | $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
|
---|
2024 | $filename = trim( $filename, '.-_' );
|
---|
2025 |
|
---|
2026 | if ( false === strpos( $filename, '.' ) ) {
|
---|
2027 | $mime_types = wp_get_mime_types();
|
---|
2028 | $filetype = wp_check_filetype( 'test.' . $filename, $mime_types );
|
---|
2029 | if ( $filetype['ext'] === $filename ) {
|
---|
2030 | $filename = 'unnamed-file.' . $filetype['ext'];
|
---|
2031 | }
|
---|
2032 | }
|
---|
2033 |
|
---|
2034 | // Split the filename into a base and extension[s]
|
---|
2035 | $parts = explode( '.', $filename );
|
---|
2036 |
|
---|
2037 | // Return if only one extension
|
---|
2038 | if ( count( $parts ) <= 2 ) {
|
---|
2039 | /**
|
---|
2040 | * Filters a sanitized filename string.
|
---|
2041 | *
|
---|
2042 | * @since 2.8.0
|
---|
2043 | *
|
---|
2044 | * @param string $filename Sanitized filename.
|
---|
2045 | * @param string $filename_raw The filename prior to sanitization.
|
---|
2046 | */
|
---|
2047 | return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
|
---|
2048 | }
|
---|
2049 |
|
---|
2050 | // Process multiple extensions
|
---|
2051 | $filename = array_shift( $parts );
|
---|
2052 | $extension = array_pop( $parts );
|
---|
2053 | $mimes = get_allowed_mime_types();
|
---|
2054 |
|
---|
2055 | /*
|
---|
2056 | * Loop over any intermediate extensions. Postfix them with a trailing underscore
|
---|
2057 | * if they are a 2 - 5 character long alpha string not in the extension whitelist.
|
---|
2058 | */
|
---|
2059 | foreach ( (array) $parts as $part ) {
|
---|
2060 | $filename .= '.' . $part;
|
---|
2061 |
|
---|
2062 | if ( preg_match( '/^[a-zA-Z]{2,5}\d?$/', $part ) ) {
|
---|
2063 | $allowed = false;
|
---|
2064 | foreach ( $mimes as $ext_preg => $mime_match ) {
|
---|
2065 | $ext_preg = '!^(' . $ext_preg . ')$!i';
|
---|
2066 | if ( preg_match( $ext_preg, $part ) ) {
|
---|
2067 | $allowed = true;
|
---|
2068 | break;
|
---|
2069 | }
|
---|
2070 | }
|
---|
2071 | if ( ! $allowed ) {
|
---|
2072 | $filename .= '_';
|
---|
2073 | }
|
---|
2074 | }
|
---|
2075 | }
|
---|
2076 | $filename .= '.' . $extension;
|
---|
2077 | /** This filter is documented in wp-includes/formatting.php */
|
---|
2078 | return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
|
---|
2079 | }
|
---|
2080 |
|
---|
2081 | /**
|
---|
2082 | * Sanitizes a username, stripping out unsafe characters.
|
---|
2083 | *
|
---|
2084 | * Removes tags, octets, entities, and if strict is enabled, will only keep
|
---|
2085 | * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
|
---|
2086 | * raw username (the username in the parameter), and the value of $strict as
|
---|
2087 | * parameters for the {@see 'sanitize_user'} filter.
|
---|
2088 | *
|
---|
2089 | * @since 2.0.0
|
---|
2090 | *
|
---|
2091 | * @param string $username The username to be sanitized.
|
---|
2092 | * @param bool $strict If set limits $username to specific characters. Default false.
|
---|
2093 | * @return string The sanitized username, after passing through filters.
|
---|
2094 | */
|
---|
2095 | function sanitize_user( $username, $strict = false ) {
|
---|
2096 | $raw_username = $username;
|
---|
2097 | $username = wp_strip_all_tags( $username );
|
---|
2098 | $username = remove_accents( $username );
|
---|
2099 | // Kill octets
|
---|
2100 | $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
|
---|
2101 | $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities
|
---|
2102 |
|
---|
2103 | // If strict, reduce to ASCII for max portability.
|
---|
2104 | if ( $strict ) {
|
---|
2105 | $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );
|
---|
2106 | }
|
---|
2107 |
|
---|
2108 | $username = trim( $username );
|
---|
2109 | // Consolidate contiguous whitespace
|
---|
2110 | $username = preg_replace( '|\s+|', ' ', $username );
|
---|
2111 |
|
---|
2112 | /**
|
---|
2113 | * Filters a sanitized username string.
|
---|
2114 | *
|
---|
2115 | * @since 2.0.1
|
---|
2116 | *
|
---|
2117 | * @param string $username Sanitized username.
|
---|
2118 | * @param string $raw_username The username prior to sanitization.
|
---|
2119 | * @param bool $strict Whether to limit the sanitization to specific characters. Default false.
|
---|
2120 | */
|
---|
2121 | return apply_filters( 'sanitize_user', $username, $raw_username, $strict );
|
---|
2122 | }
|
---|
2123 |
|
---|
2124 | /**
|
---|
2125 | * Sanitizes a string key.
|
---|
2126 | *
|
---|
2127 | * Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed.
|
---|
2128 | *
|
---|
2129 | * @since 3.0.0
|
---|
2130 | *
|
---|
2131 | * @param string $key String key
|
---|
2132 | * @return string Sanitized key
|
---|
2133 | */
|
---|
2134 | function sanitize_key( $key ) {
|
---|
2135 | $raw_key = $key;
|
---|
2136 | $key = strtolower( $key );
|
---|
2137 | $key = preg_replace( '/[^a-z0-9_\-]/', '', $key );
|
---|
2138 |
|
---|
2139 | /**
|
---|
2140 | * Filters a sanitized key string.
|
---|
2141 | *
|
---|
2142 | * @since 3.0.0
|
---|
2143 | *
|
---|
2144 | * @param string $key Sanitized key.
|
---|
2145 | * @param string $raw_key The key prior to sanitization.
|
---|
2146 | */
|
---|
2147 | return apply_filters( 'sanitize_key', $key, $raw_key );
|
---|
2148 | }
|
---|
2149 |
|
---|
2150 | /**
|
---|
2151 | * Sanitizes a title, or returns a fallback title.
|
---|
2152 | *
|
---|
2153 | * Specifically, HTML and PHP tags are stripped. Further actions can be added
|
---|
2154 | * via the plugin API. If $title is empty and $fallback_title is set, the latter
|
---|
2155 | * will be used.
|
---|
2156 | *
|
---|
2157 | * @since 1.0.0
|
---|
2158 | *
|
---|
2159 | * @param string $title The string to be sanitized.
|
---|
2160 | * @param string $fallback_title Optional. A title to use if $title is empty.
|
---|
2161 | * @param string $context Optional. The operation for which the string is sanitized
|
---|
2162 | * @return string The sanitized string.
|
---|
2163 | */
|
---|
2164 | function sanitize_title( $title, $fallback_title = '', $context = 'save' ) {
|
---|
2165 | $raw_title = $title;
|
---|
2166 |
|
---|
2167 | if ( 'save' == $context ) {
|
---|
2168 | $title = remove_accents( $title );
|
---|
2169 | }
|
---|
2170 |
|
---|
2171 | /**
|
---|
2172 | * Filters a sanitized title string.
|
---|
2173 | *
|
---|
2174 | * @since 1.2.0
|
---|
2175 | *
|
---|
2176 | * @param string $title Sanitized title.
|
---|
2177 | * @param string $raw_title The title prior to sanitization.
|
---|
2178 | * @param string $context The context for which the title is being sanitized.
|
---|
2179 | */
|
---|
2180 | $title = apply_filters( 'sanitize_title', $title, $raw_title, $context );
|
---|
2181 |
|
---|
2182 | if ( '' === $title || false === $title ) {
|
---|
2183 | $title = $fallback_title;
|
---|
2184 | }
|
---|
2185 |
|
---|
2186 | return $title;
|
---|
2187 | }
|
---|
2188 |
|
---|
2189 | /**
|
---|
2190 | * Sanitizes a title with the 'query' context.
|
---|
2191 | *
|
---|
2192 | * Used for querying the database for a value from URL.
|
---|
2193 | *
|
---|
2194 | * @since 3.1.0
|
---|
2195 | *
|
---|
2196 | * @param string $title The string to be sanitized.
|
---|
2197 | * @return string The sanitized string.
|
---|
2198 | */
|
---|
2199 | function sanitize_title_for_query( $title ) {
|
---|
2200 | return sanitize_title( $title, '', 'query' );
|
---|
2201 | }
|
---|
2202 |
|
---|
2203 | /**
|
---|
2204 | * Sanitizes a title, replacing whitespace and a few other characters with dashes.
|
---|
2205 | *
|
---|
2206 | * Limits the output to alphanumeric characters, underscore (_) and dash (-).
|
---|
2207 | * Whitespace becomes a dash.
|
---|
2208 | *
|
---|
2209 | * @since 1.2.0
|
---|
2210 | *
|
---|
2211 | * @param string $title The title to be sanitized.
|
---|
2212 | * @param string $raw_title Optional. Not used.
|
---|
2213 | * @param string $context Optional. The operation for which the string is sanitized.
|
---|
2214 | * @return string The sanitized title.
|
---|
2215 | */
|
---|
2216 | function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) {
|
---|
2217 | $title = strip_tags( $title );
|
---|
2218 | // Preserve escaped octets.
|
---|
2219 | $title = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title );
|
---|
2220 | // Remove percent signs that are not part of an octet.
|
---|
2221 | $title = str_replace( '%', '', $title );
|
---|
2222 | // Restore octets.
|
---|
2223 | $title = preg_replace( '|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title );
|
---|
2224 |
|
---|
2225 | if ( seems_utf8( $title ) ) {
|
---|
2226 | if ( function_exists( 'mb_strtolower' ) ) {
|
---|
2227 | $title = mb_strtolower( $title, 'UTF-8' );
|
---|
2228 | }
|
---|
2229 | $title = utf8_uri_encode( $title, 200 );
|
---|
2230 | }
|
---|
2231 |
|
---|
2232 | $title = strtolower( $title );
|
---|
2233 |
|
---|
2234 | if ( 'save' == $context ) {
|
---|
2235 | // Convert nbsp, ndash and mdash to hyphens
|
---|
2236 | $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );
|
---|
2237 | // Convert nbsp, ndash and mdash HTML entities to hyphens
|
---|
2238 | $title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title );
|
---|
2239 | // Convert forward slash to hyphen
|
---|
2240 | $title = str_replace( '/', '-', $title );
|
---|
2241 |
|
---|
2242 | // Strip these characters entirely
|
---|
2243 | $title = str_replace(
|
---|
2244 | array(
|
---|
2245 | // soft hyphens
|
---|
2246 | '%c2%ad',
|
---|
2247 | // iexcl and iquest
|
---|
2248 | '%c2%a1',
|
---|
2249 | '%c2%bf',
|
---|
2250 | // angle quotes
|
---|
2251 | '%c2%ab',
|
---|
2252 | '%c2%bb',
|
---|
2253 | '%e2%80%b9',
|
---|
2254 | '%e2%80%ba',
|
---|
2255 | // curly quotes
|
---|
2256 | '%e2%80%98',
|
---|
2257 | '%e2%80%99',
|
---|
2258 | '%e2%80%9c',
|
---|
2259 | '%e2%80%9d',
|
---|
2260 | '%e2%80%9a',
|
---|
2261 | '%e2%80%9b',
|
---|
2262 | '%e2%80%9e',
|
---|
2263 | '%e2%80%9f',
|
---|
2264 | // copy, reg, deg, hellip and trade
|
---|
2265 | '%c2%a9',
|
---|
2266 | '%c2%ae',
|
---|
2267 | '%c2%b0',
|
---|
2268 | '%e2%80%a6',
|
---|
2269 | '%e2%84%a2',
|
---|
2270 | // acute accents
|
---|
2271 | '%c2%b4',
|
---|
2272 | '%cb%8a',
|
---|
2273 | '%cc%81',
|
---|
2274 | '%cd%81',
|
---|
2275 | // grave accent, macron, caron
|
---|
2276 | '%cc%80',
|
---|
2277 | '%cc%84',
|
---|
2278 | '%cc%8c',
|
---|
2279 | ),
|
---|
2280 | '',
|
---|
2281 | $title
|
---|
2282 | );
|
---|
2283 |
|
---|
2284 | // Convert times to x
|
---|
2285 | $title = str_replace( '%c3%97', 'x', $title );
|
---|
2286 | }
|
---|
2287 |
|
---|
2288 | $title = preg_replace( '/&.+?;/', '', $title ); // kill entities
|
---|
2289 | $title = str_replace( '.', '-', $title );
|
---|
2290 |
|
---|
2291 | $title = preg_replace( '/[^%a-z0-9 _-]/', '', $title );
|
---|
2292 | $title = preg_replace( '/\s+/', '-', $title );
|
---|
2293 | $title = preg_replace( '|-+|', '-', $title );
|
---|
2294 | $title = trim( $title, '-' );
|
---|
2295 |
|
---|
2296 | return $title;
|
---|
2297 | }
|
---|
2298 |
|
---|
2299 | /**
|
---|
2300 | * Ensures a string is a valid SQL 'order by' clause.
|
---|
2301 | *
|
---|
2302 | * Accepts one or more columns, with or without a sort order (ASC / DESC).
|
---|
2303 | * e.g. 'column_1', 'column_1, column_2', 'column_1 ASC, column_2 DESC' etc.
|
---|
2304 | *
|
---|
2305 | * Also accepts 'RAND()'.
|
---|
2306 | *
|
---|
2307 | * @since 2.5.1
|
---|
2308 | *
|
---|
2309 | * @param string $orderby Order by clause to be validated.
|
---|
2310 | * @return string|false Returns $orderby if valid, false otherwise.
|
---|
2311 | */
|
---|
2312 | function sanitize_sql_orderby( $orderby ) {
|
---|
2313 | 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 ) ) {
|
---|
2314 | return $orderby;
|
---|
2315 | }
|
---|
2316 | return false;
|
---|
2317 | }
|
---|
2318 |
|
---|
2319 | /**
|
---|
2320 | * Sanitizes an HTML classname to ensure it only contains valid characters.
|
---|
2321 | *
|
---|
2322 | * Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty
|
---|
2323 | * string then it will return the alternative value supplied.
|
---|
2324 | *
|
---|
2325 | * @todo Expand to support the full range of CDATA that a class attribute can contain.
|
---|
2326 | *
|
---|
2327 | * @since 2.8.0
|
---|
2328 | *
|
---|
2329 | * @param string $class The classname to be sanitized
|
---|
2330 | * @param string $fallback Optional. The value to return if the sanitization ends up as an empty string.
|
---|
2331 | * Defaults to an empty string.
|
---|
2332 | * @return string The sanitized value
|
---|
2333 | */
|
---|
2334 | function sanitize_html_class( $class, $fallback = '' ) {
|
---|
2335 | //Strip out any % encoded octets
|
---|
2336 | $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class );
|
---|
2337 |
|
---|
2338 | //Limit to A-Z,a-z,0-9,_,-
|
---|
2339 | $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized );
|
---|
2340 |
|
---|
2341 | if ( '' == $sanitized && $fallback ) {
|
---|
2342 | return sanitize_html_class( $fallback );
|
---|
2343 | }
|
---|
2344 | /**
|
---|
2345 | * Filters a sanitized HTML class string.
|
---|
2346 | *
|
---|
2347 | * @since 2.8.0
|
---|
2348 | *
|
---|
2349 | * @param string $sanitized The sanitized HTML class.
|
---|
2350 | * @param string $class HTML class before sanitization.
|
---|
2351 | * @param string $fallback The fallback string.
|
---|
2352 | */
|
---|
2353 | return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );
|
---|
2354 | }
|
---|
2355 |
|
---|
2356 | /**
|
---|
2357 | * Converts lone & characters into `&` (a.k.a. `&`)
|
---|
2358 | *
|
---|
2359 | * @since 0.71
|
---|
2360 | *
|
---|
2361 | * @param string $content String of characters to be converted.
|
---|
2362 | * @param string $deprecated Not used.
|
---|
2363 | * @return string Converted string.
|
---|
2364 | */
|
---|
2365 | function convert_chars( $content, $deprecated = '' ) {
|
---|
2366 | if ( ! empty( $deprecated ) ) {
|
---|
2367 | _deprecated_argument( __FUNCTION__, '0.71' );
|
---|
2368 | }
|
---|
2369 |
|
---|
2370 | if ( strpos( $content, '&' ) !== false ) {
|
---|
2371 | $content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content );
|
---|
2372 | }
|
---|
2373 |
|
---|
2374 | return $content;
|
---|
2375 | }
|
---|
2376 |
|
---|
2377 | /**
|
---|
2378 | * Converts invalid Unicode references range to valid range.
|
---|
2379 | *
|
---|
2380 | * @since 4.3.0
|
---|
2381 | *
|
---|
2382 | * @param string $content String with entities that need converting.
|
---|
2383 | * @return string Converted string.
|
---|
2384 | */
|
---|
2385 | function convert_invalid_entities( $content ) {
|
---|
2386 | $wp_htmltranswinuni = array(
|
---|
2387 | '€' => '€', // the Euro sign
|
---|
2388 | '' => '',
|
---|
2389 | '‚' => '‚', // these are Windows CP1252 specific characters
|
---|
2390 | 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers
|
---|
2391 | '„' => '„',
|
---|
2392 | '…' => '…',
|
---|
2393 | '†' => '†',
|
---|
2394 | '‡' => '‡',
|
---|
2395 | 'ˆ' => 'ˆ',
|
---|
2396 | '‰' => '‰',
|
---|
2397 | 'Š' => 'Š',
|
---|
2398 | '‹' => '‹',
|
---|
2399 | 'Œ' => 'Œ',
|
---|
2400 | '' => '',
|
---|
2401 | 'Ž' => 'Ž',
|
---|
2402 | '' => '',
|
---|
2403 | '' => '',
|
---|
2404 | '‘' => '‘',
|
---|
2405 | '’' => '’',
|
---|
2406 | '“' => '“',
|
---|
2407 | '”' => '”',
|
---|
2408 | '•' => '•',
|
---|
2409 | '–' => '–',
|
---|
2410 | '—' => '—',
|
---|
2411 | '˜' => '˜',
|
---|
2412 | '™' => '™',
|
---|
2413 | 'š' => 'š',
|
---|
2414 | '›' => '›',
|
---|
2415 | 'œ' => 'œ',
|
---|
2416 | '' => '',
|
---|
2417 | 'ž' => 'ž',
|
---|
2418 | 'Ÿ' => 'Ÿ',
|
---|
2419 | );
|
---|
2420 |
|
---|
2421 | if ( strpos( $content, '' ) !== false ) {
|
---|
2422 | $content = strtr( $content, $wp_htmltranswinuni );
|
---|
2423 | }
|
---|
2424 |
|
---|
2425 | return $content;
|
---|
2426 | }
|
---|
2427 |
|
---|
2428 | /**
|
---|
2429 | * Balances tags if forced to, or if the 'use_balanceTags' option is set to true.
|
---|
2430 | *
|
---|
2431 | * @since 0.71
|
---|
2432 | *
|
---|
2433 | * @param string $text Text to be balanced
|
---|
2434 | * @param bool $force If true, forces balancing, ignoring the value of the option. Default false.
|
---|
2435 | * @return string Balanced text
|
---|
2436 | */
|
---|
2437 | function balanceTags( $text, $force = false ) {
|
---|
2438 | if ( $force || get_option( 'use_balanceTags' ) == 1 ) {
|
---|
2439 | return force_balance_tags( $text );
|
---|
2440 | } else {
|
---|
2441 | return $text;
|
---|
2442 | }
|
---|
2443 | }
|
---|
2444 |
|
---|
2445 | /**
|
---|
2446 | * Balances tags of string using a modified stack.
|
---|
2447 | *
|
---|
2448 | * @since 2.0.4
|
---|
2449 | *
|
---|
2450 | * @author Leonard Lin <leonard@acm.org>
|
---|
2451 | * @license GPL
|
---|
2452 | * @copyright November 4, 2001
|
---|
2453 | * @version 1.1
|
---|
2454 | * @todo Make better - change loop condition to $text in 1.2
|
---|
2455 | * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004
|
---|
2456 | * 1.1 Fixed handling of append/stack pop order of end text
|
---|
2457 | * Added Cleaning Hooks
|
---|
2458 | * 1.0 First Version
|
---|
2459 | *
|
---|
2460 | * @param string $text Text to be balanced.
|
---|
2461 | * @return string Balanced text.
|
---|
2462 | */
|
---|
2463 | function force_balance_tags( $text ) {
|
---|
2464 | $tagstack = array();
|
---|
2465 | $stacksize = 0;
|
---|
2466 | $tagqueue = '';
|
---|
2467 | $newtext = '';
|
---|
2468 | // Known single-entity/self-closing tags
|
---|
2469 | $single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' );
|
---|
2470 | // Tags that can be immediately nested within themselves
|
---|
2471 | $nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' );
|
---|
2472 |
|
---|
2473 | // WP bug fix for comments - in case you REALLY meant to type '< !--'
|
---|
2474 | $text = str_replace( '< !--', '< !--', $text );
|
---|
2475 | // WP bug fix for LOVE <3 (and other situations with '<' before a number)
|
---|
2476 | $text = preg_replace( '#<([0-9]{1})#', '<$1', $text );
|
---|
2477 |
|
---|
2478 | while ( preg_match( '/<(\/?[\w:]*)\s*([^>]*)>/', $text, $regex ) ) {
|
---|
2479 | $newtext .= $tagqueue;
|
---|
2480 |
|
---|
2481 | $i = strpos( $text, $regex[0] );
|
---|
2482 | $l = strlen( $regex[0] );
|
---|
2483 |
|
---|
2484 | // clear the shifter
|
---|
2485 | $tagqueue = '';
|
---|
2486 | // Pop or Push
|
---|
2487 | if ( isset( $regex[1][0] ) && '/' == $regex[1][0] ) { // End Tag
|
---|
2488 | $tag = strtolower( substr( $regex[1], 1 ) );
|
---|
2489 | // if too many closing tags
|
---|
2490 | if ( $stacksize <= 0 ) {
|
---|
2491 | $tag = '';
|
---|
2492 | // or close to be safe $tag = '/' . $tag;
|
---|
2493 |
|
---|
2494 | // if stacktop value = tag close value then pop
|
---|
2495 | } elseif ( $tagstack[ $stacksize - 1 ] == $tag ) { // found closing tag
|
---|
2496 | $tag = '</' . $tag . '>'; // Close Tag
|
---|
2497 | // Pop
|
---|
2498 | array_pop( $tagstack );
|
---|
2499 | $stacksize--;
|
---|
2500 | } else { // closing tag not at top, search for it
|
---|
2501 | for ( $j = $stacksize - 1; $j >= 0; $j-- ) {
|
---|
2502 | if ( $tagstack[ $j ] == $tag ) {
|
---|
2503 | // add tag to tagqueue
|
---|
2504 | for ( $k = $stacksize - 1; $k >= $j; $k-- ) {
|
---|
2505 | $tagqueue .= '</' . array_pop( $tagstack ) . '>';
|
---|
2506 | $stacksize--;
|
---|
2507 | }
|
---|
2508 | break;
|
---|
2509 | }
|
---|
2510 | }
|
---|
2511 | $tag = '';
|
---|
2512 | }
|
---|
2513 | } else { // Begin Tag
|
---|
2514 | $tag = strtolower( $regex[1] );
|
---|
2515 |
|
---|
2516 | // Tag Cleaning
|
---|
2517 |
|
---|
2518 | // If it's an empty tag "< >", do nothing
|
---|
2519 | if ( '' == $tag ) {
|
---|
2520 | // do nothing
|
---|
2521 | } elseif ( substr( $regex[2], -1 ) == '/' ) { // ElseIf it presents itself as a self-closing tag...
|
---|
2522 | // ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and
|
---|
2523 | // immediately close it with a closing tag (the tag will encapsulate no text as a result)
|
---|
2524 | if ( ! in_array( $tag, $single_tags ) ) {
|
---|
2525 | $regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag";
|
---|
2526 | }
|
---|
2527 | } elseif ( in_array( $tag, $single_tags ) ) { // ElseIf it's a known single-entity tag but it doesn't close itself, do so
|
---|
2528 | $regex[2] .= '/';
|
---|
2529 | } else { // Else it's not a single-entity tag
|
---|
2530 | // If the top of the stack is the same as the tag we want to push, close previous tag
|
---|
2531 | if ( $stacksize > 0 && ! in_array( $tag, $nestable_tags ) && $tagstack[ $stacksize - 1 ] == $tag ) {
|
---|
2532 | $tagqueue = '</' . array_pop( $tagstack ) . '>';
|
---|
2533 | $stacksize--;
|
---|
2534 | }
|
---|
2535 | $stacksize = array_push( $tagstack, $tag );
|
---|
2536 | }
|
---|
2537 |
|
---|
2538 | // Attributes
|
---|
2539 | $attributes = $regex[2];
|
---|
2540 | if ( ! empty( $attributes ) && $attributes[0] != '>' ) {
|
---|
2541 | $attributes = ' ' . $attributes;
|
---|
2542 | }
|
---|
2543 |
|
---|
2544 | $tag = '<' . $tag . $attributes . '>';
|
---|
2545 | //If already queuing a close tag, then put this tag on, too
|
---|
2546 | if ( ! empty( $tagqueue ) ) {
|
---|
2547 | $tagqueue .= $tag;
|
---|
2548 | $tag = '';
|
---|
2549 | }
|
---|
2550 | }
|
---|
2551 | $newtext .= substr( $text, 0, $i ) . $tag;
|
---|
2552 | $text = substr( $text, $i + $l );
|
---|
2553 | }
|
---|
2554 |
|
---|
2555 | // Clear Tag Queue
|
---|
2556 | $newtext .= $tagqueue;
|
---|
2557 |
|
---|
2558 | // Add Remaining text
|
---|
2559 | $newtext .= $text;
|
---|
2560 |
|
---|
2561 | // Empty Stack
|
---|
2562 | while ( $x = array_pop( $tagstack ) ) {
|
---|
2563 | $newtext .= '</' . $x . '>'; // Add remaining tags to close
|
---|
2564 | }
|
---|
2565 |
|
---|
2566 | // WP fix for the bug with HTML comments
|
---|
2567 | $newtext = str_replace( '< !--', '<!--', $newtext );
|
---|
2568 | $newtext = str_replace( '< !--', '< !--', $newtext );
|
---|
2569 |
|
---|
2570 | return $newtext;
|
---|
2571 | }
|
---|
2572 |
|
---|
2573 | /**
|
---|
2574 | * Acts on text which is about to be edited.
|
---|
2575 | *
|
---|
2576 | * The $content is run through esc_textarea(), which uses htmlspecialchars()
|
---|
2577 | * to convert special characters to HTML entities. If `$richedit` is set to true,
|
---|
2578 | * it is simply a holder for the {@see 'format_to_edit'} filter.
|
---|
2579 | *
|
---|
2580 | * @since 0.71
|
---|
2581 | * @since 4.4.0 The `$richedit` parameter was renamed to `$rich_text` for clarity.
|
---|
2582 | *
|
---|
2583 | * @param string $content The text about to be edited.
|
---|
2584 | * @param bool $rich_text Optional. Whether `$content` should be considered rich text,
|
---|
2585 | * in which case it would not be passed through esc_textarea().
|
---|
2586 | * Default false.
|
---|
2587 | * @return string The text after the filter (and possibly htmlspecialchars()) has been run.
|
---|
2588 | */
|
---|
2589 | function format_to_edit( $content, $rich_text = false ) {
|
---|
2590 | /**
|
---|
2591 | * Filters the text to be formatted for editing.
|
---|
2592 | *
|
---|
2593 | * @since 1.2.0
|
---|
2594 | *
|
---|
2595 | * @param string $content The text, prior to formatting for editing.
|
---|
2596 | */
|
---|
2597 | $content = apply_filters( 'format_to_edit', $content );
|
---|
2598 | if ( ! $rich_text ) {
|
---|
2599 | $content = esc_textarea( $content );
|
---|
2600 | }
|
---|
2601 | return $content;
|
---|
2602 | }
|
---|
2603 |
|
---|
2604 | /**
|
---|
2605 | * Add leading zeros when necessary.
|
---|
2606 | *
|
---|
2607 | * If you set the threshold to '4' and the number is '10', then you will get
|
---|
2608 | * back '0010'. If you set the threshold to '4' and the number is '5000', then you
|
---|
2609 | * will get back '5000'.
|
---|
2610 | *
|
---|
2611 | * Uses sprintf to append the amount of zeros based on the $threshold parameter
|
---|
2612 | * and the size of the number. If the number is large enough, then no zeros will
|
---|
2613 | * be appended.
|
---|
2614 | *
|
---|
2615 | * @since 0.71
|
---|
2616 | *
|
---|
2617 | * @param int $number Number to append zeros to if not greater than threshold.
|
---|
2618 | * @param int $threshold Digit places number needs to be to not have zeros added.
|
---|
2619 | * @return string Adds leading zeros to number if needed.
|
---|
2620 | */
|
---|
2621 | function zeroise( $number, $threshold ) {
|
---|
2622 | return sprintf( '%0' . $threshold . 's', $number );
|
---|
2623 | }
|
---|
2624 |
|
---|
2625 | /**
|
---|
2626 | * Adds backslashes before letters and before a number at the start of a string.
|
---|
2627 | *
|
---|
2628 | * @since 0.71
|
---|
2629 | *
|
---|
2630 | * @param string $string Value to which backslashes will be added.
|
---|
2631 | * @return string String with backslashes inserted.
|
---|
2632 | */
|
---|
2633 | function backslashit( $string ) {
|
---|
2634 | if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) {
|
---|
2635 | $string = '\\\\' . $string;
|
---|
2636 | }
|
---|
2637 | return addcslashes( $string, 'A..Za..z' );
|
---|
2638 | }
|
---|
2639 |
|
---|
2640 | /**
|
---|
2641 | * Appends a trailing slash.
|
---|
2642 | *
|
---|
2643 | * Will remove trailing forward and backslashes if it exists already before adding
|
---|
2644 | * a trailing forward slash. This prevents double slashing a string or path.
|
---|
2645 | *
|
---|
2646 | * The primary use of this is for paths and thus should be used for paths. It is
|
---|
2647 | * not restricted to paths and offers no specific path support.
|
---|
2648 | *
|
---|
2649 | * @since 1.2.0
|
---|
2650 | *
|
---|
2651 | * @param string $string What to add the trailing slash to.
|
---|
2652 | * @return string String with trailing slash added.
|
---|
2653 | */
|
---|
2654 | function trailingslashit( $string ) {
|
---|
2655 | return untrailingslashit( $string ) . '/';
|
---|
2656 | }
|
---|
2657 |
|
---|
2658 | /**
|
---|
2659 | * Removes trailing forward slashes and backslashes if they exist.
|
---|
2660 | *
|
---|
2661 | * The primary use of this is for paths and thus should be used for paths. It is
|
---|
2662 | * not restricted to paths and offers no specific path support.
|
---|
2663 | *
|
---|
2664 | * @since 2.2.0
|
---|
2665 | *
|
---|
2666 | * @param string $string What to remove the trailing slashes from.
|
---|
2667 | * @return string String without the trailing slashes.
|
---|
2668 | */
|
---|
2669 | function untrailingslashit( $string ) {
|
---|
2670 | return rtrim( $string, '/\\' );
|
---|
2671 | }
|
---|
2672 |
|
---|
2673 | /**
|
---|
2674 | * Adds slashes to escape strings.
|
---|
2675 | *
|
---|
2676 | * Slashes will first be removed if magic_quotes_gpc is set, see {@link
|
---|
2677 | * https://secure.php.net/magic_quotes} for more details.
|
---|
2678 | *
|
---|
2679 | * @since 0.71
|
---|
2680 | *
|
---|
2681 | * @param string $gpc The string returned from HTTP request data.
|
---|
2682 | * @return string Returns a string escaped with slashes.
|
---|
2683 | */
|
---|
2684 | function addslashes_gpc( $gpc ) {
|
---|
2685 | if ( get_magic_quotes_gpc() ) {
|
---|
2686 | $gpc = stripslashes( $gpc );
|
---|
2687 | }
|
---|
2688 |
|
---|
2689 | return wp_slash( $gpc );
|
---|
2690 | }
|
---|
2691 |
|
---|
2692 | /**
|
---|
2693 | * Navigates through an array, object, or scalar, and removes slashes from the values.
|
---|
2694 | *
|
---|
2695 | * @since 2.0.0
|
---|
2696 | *
|
---|
2697 | * @param mixed $value The value to be stripped.
|
---|
2698 | * @return mixed Stripped value.
|
---|
2699 | */
|
---|
2700 | function stripslashes_deep( $value ) {
|
---|
2701 | return map_deep( $value, 'stripslashes_from_strings_only' );
|
---|
2702 | }
|
---|
2703 |
|
---|
2704 | /**
|
---|
2705 | * Callback function for `stripslashes_deep()` which strips slashes from strings.
|
---|
2706 | *
|
---|
2707 | * @since 4.4.0
|
---|
2708 | *
|
---|
2709 | * @param mixed $value The array or string to be stripped.
|
---|
2710 | * @return mixed $value The stripped value.
|
---|
2711 | */
|
---|
2712 | function stripslashes_from_strings_only( $value ) {
|
---|
2713 | return is_string( $value ) ? stripslashes( $value ) : $value;
|
---|
2714 | }
|
---|
2715 |
|
---|
2716 | /**
|
---|
2717 | * Navigates through an array, object, or scalar, and encodes the values to be used in a URL.
|
---|
2718 | *
|
---|
2719 | * @since 2.2.0
|
---|
2720 | *
|
---|
2721 | * @param mixed $value The array or string to be encoded.
|
---|
2722 | * @return mixed $value The encoded value.
|
---|
2723 | */
|
---|
2724 | function urlencode_deep( $value ) {
|
---|
2725 | return map_deep( $value, 'urlencode' );
|
---|
2726 | }
|
---|
2727 |
|
---|
2728 | /**
|
---|
2729 | * Navigates through an array, object, or scalar, and raw-encodes the values to be used in a URL.
|
---|
2730 | *
|
---|
2731 | * @since 3.4.0
|
---|
2732 | *
|
---|
2733 | * @param mixed $value The array or string to be encoded.
|
---|
2734 | * @return mixed $value The encoded value.
|
---|
2735 | */
|
---|
2736 | function rawurlencode_deep( $value ) {
|
---|
2737 | return map_deep( $value, 'rawurlencode' );
|
---|
2738 | }
|
---|
2739 |
|
---|
2740 | /**
|
---|
2741 | * Navigates through an array, object, or scalar, and decodes URL-encoded values
|
---|
2742 | *
|
---|
2743 | * @since 4.4.0
|
---|
2744 | *
|
---|
2745 | * @param mixed $value The array or string to be decoded.
|
---|
2746 | * @return mixed $value The decoded value.
|
---|
2747 | */
|
---|
2748 | function urldecode_deep( $value ) {
|
---|
2749 | return map_deep( $value, 'urldecode' );
|
---|
2750 | }
|
---|
2751 |
|
---|
2752 | /**
|
---|
2753 | * Converts email addresses characters to HTML entities to block spam bots.
|
---|
2754 | *
|
---|
2755 | * @since 0.71
|
---|
2756 | *
|
---|
2757 | * @param string $email_address Email address.
|
---|
2758 | * @param int $hex_encoding Optional. Set to 1 to enable hex encoding.
|
---|
2759 | * @return string Converted email address.
|
---|
2760 | */
|
---|
2761 | function antispambot( $email_address, $hex_encoding = 0 ) {
|
---|
2762 | $email_no_spam_address = '';
|
---|
2763 | for ( $i = 0, $len = strlen( $email_address ); $i < $len; $i++ ) {
|
---|
2764 | $j = rand( 0, 1 + $hex_encoding );
|
---|
2765 | if ( $j == 0 ) {
|
---|
2766 | $email_no_spam_address .= '&#' . ord( $email_address[ $i ] ) . ';';
|
---|
2767 | } elseif ( $j == 1 ) {
|
---|
2768 | $email_no_spam_address .= $email_address[ $i ];
|
---|
2769 | } elseif ( $j == 2 ) {
|
---|
2770 | $email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[ $i ] ) ), 2 );
|
---|
2771 | }
|
---|
2772 | }
|
---|
2773 |
|
---|
2774 | return str_replace( '@', '@', $email_no_spam_address );
|
---|
2775 | }
|
---|
2776 |
|
---|
2777 | /**
|
---|
2778 | * Callback to convert URI match to HTML A element.
|
---|
2779 | *
|
---|
2780 | * This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable().
|
---|
2781 | *
|
---|
2782 | * @since 2.3.2
|
---|
2783 | * @access private
|
---|
2784 | *
|
---|
2785 | * @param array $matches Single Regex Match.
|
---|
2786 | * @return string HTML A element with URI address.
|
---|
2787 | */
|
---|
2788 | function _make_url_clickable_cb( $matches ) {
|
---|
2789 | $url = $matches[2];
|
---|
2790 |
|
---|
2791 | if ( ')' == $matches[3] && strpos( $url, '(' ) ) {
|
---|
2792 | // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL.
|
---|
2793 | // Then we can let the parenthesis balancer do its thing below.
|
---|
2794 | $url .= $matches[3];
|
---|
2795 | $suffix = '';
|
---|
2796 | } else {
|
---|
2797 | $suffix = $matches[3];
|
---|
2798 | }
|
---|
2799 |
|
---|
2800 | // Include parentheses in the URL only if paired
|
---|
2801 | while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
|
---|
2802 | $suffix = strrchr( $url, ')' ) . $suffix;
|
---|
2803 | $url = substr( $url, 0, strrpos( $url, ')' ) );
|
---|
2804 | }
|
---|
2805 |
|
---|
2806 | $url = esc_url( $url );
|
---|
2807 | if ( empty( $url ) ) {
|
---|
2808 | return $matches[0];
|
---|
2809 | }
|
---|
2810 |
|
---|
2811 | return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
|
---|
2812 | }
|
---|
2813 |
|
---|
2814 | /**
|
---|
2815 | * Callback to convert URL match to HTML A element.
|
---|
2816 | *
|
---|
2817 | * This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable().
|
---|
2818 | *
|
---|
2819 | * @since 2.3.2
|
---|
2820 | * @access private
|
---|
2821 | *
|
---|
2822 | * @param array $matches Single Regex Match.
|
---|
2823 | * @return string HTML A element with URL address.
|
---|
2824 | */
|
---|
2825 | function _make_web_ftp_clickable_cb( $matches ) {
|
---|
2826 | $ret = '';
|
---|
2827 | $dest = $matches[2];
|
---|
2828 | $dest = 'http://' . $dest;
|
---|
2829 |
|
---|
2830 | // removed trailing [.,;:)] from URL
|
---|
2831 | if ( in_array( substr( $dest, -1 ), array( '.', ',', ';', ':', ')' ) ) === true ) {
|
---|
2832 | $ret = substr( $dest, -1 );
|
---|
2833 | $dest = substr( $dest, 0, strlen( $dest ) - 1 );
|
---|
2834 | }
|
---|
2835 |
|
---|
2836 | $dest = esc_url( $dest );
|
---|
2837 | if ( empty( $dest ) ) {
|
---|
2838 | return $matches[0];
|
---|
2839 | }
|
---|
2840 |
|
---|
2841 | return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
|
---|
2842 | }
|
---|
2843 |
|
---|
2844 | /**
|
---|
2845 | * Callback to convert email address match to HTML A element.
|
---|
2846 | *
|
---|
2847 | * This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable().
|
---|
2848 | *
|
---|
2849 | * @since 2.3.2
|
---|
2850 | * @access private
|
---|
2851 | *
|
---|
2852 | * @param array $matches Single Regex Match.
|
---|
2853 | * @return string HTML A element with email address.
|
---|
2854 | */
|
---|
2855 | function _make_email_clickable_cb( $matches ) {
|
---|
2856 | $email = $matches[2] . '@' . $matches[3];
|
---|
2857 | return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
|
---|
2858 | }
|
---|
2859 |
|
---|
2860 | /**
|
---|
2861 | * Convert plaintext URI to HTML links.
|
---|
2862 | *
|
---|
2863 | * Converts URI, www and ftp, and email addresses. Finishes by fixing links
|
---|
2864 | * within links.
|
---|
2865 | *
|
---|
2866 | * @since 0.71
|
---|
2867 | *
|
---|
2868 | * @param string $text Content to convert URIs.
|
---|
2869 | * @return string Content with converted URIs.
|
---|
2870 | */
|
---|
2871 | function make_clickable( $text ) {
|
---|
2872 | $r = '';
|
---|
2873 | $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags
|
---|
2874 | $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
|
---|
2875 | foreach ( $textarr as $piece ) {
|
---|
2876 |
|
---|
2877 | 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 ) ) {
|
---|
2878 | $nested_code_pre++;
|
---|
2879 | } elseif ( $nested_code_pre && ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) || '</script>' === strtolower( $piece ) || '</style>' === strtolower( $piece ) ) ) {
|
---|
2880 | $nested_code_pre--;
|
---|
2881 | }
|
---|
2882 |
|
---|
2883 | if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
|
---|
2884 | $r .= $piece;
|
---|
2885 | continue;
|
---|
2886 | }
|
---|
2887 |
|
---|
2888 | // Long strings might contain expensive edge cases ...
|
---|
2889 | if ( 10000 < strlen( $piece ) ) {
|
---|
2890 | // ... break it up
|
---|
2891 | foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses
|
---|
2892 | if ( 2101 < strlen( $chunk ) ) {
|
---|
2893 | $r .= $chunk; // Too big, no whitespace: bail.
|
---|
2894 | } else {
|
---|
2895 | $r .= make_clickable( $chunk );
|
---|
2896 | }
|
---|
2897 | }
|
---|
2898 | } else {
|
---|
2899 | $ret = " $piece "; // Pad with whitespace to simplify the regexes
|
---|
2900 |
|
---|
2901 | $url_clickable = '~
|
---|
2902 | ([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation
|
---|
2903 | ( # 2: URL
|
---|
2904 | [\\w]{1,20}+:// # Scheme and hier-part prefix
|
---|
2905 | (?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long
|
---|
2906 | [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character
|
---|
2907 | (?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character
|
---|
2908 | [\'.,;:!?)] # Punctuation URL character
|
---|
2909 | [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character
|
---|
2910 | )*
|
---|
2911 | )
|
---|
2912 | (\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing)
|
---|
2913 | ~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.
|
---|
2914 | // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
|
---|
2915 |
|
---|
2916 | $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );
|
---|
2917 |
|
---|
2918 | $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
|
---|
2919 | $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
|
---|
2920 |
|
---|
2921 | $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
|
---|
2922 | $r .= $ret;
|
---|
2923 | }
|
---|
2924 | }
|
---|
2925 |
|
---|
2926 | // Cleanup of accidental links within links
|
---|
2927 | return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', '$1$3</a>', $r );
|
---|
2928 | }
|
---|
2929 |
|
---|
2930 | /**
|
---|
2931 | * Breaks a string into chunks by splitting at whitespace characters.
|
---|
2932 | * The length of each returned chunk is as close to the specified length goal as possible,
|
---|
2933 | * with the caveat that each chunk includes its trailing delimiter.
|
---|
2934 | * Chunks longer than the goal are guaranteed to not have any inner whitespace.
|
---|
2935 | *
|
---|
2936 | * Joining the returned chunks with empty delimiters reconstructs the input string losslessly.
|
---|
2937 | *
|
---|
2938 | * Input string must have no null characters (or eventual transformations on output chunks must not care about null characters)
|
---|
2939 | *
|
---|
2940 | * _split_str_by_whitespace( "1234 67890 1234 67890a cd 1234 890 123456789 1234567890a 45678 1 3 5 7 90 ", 10 ) ==
|
---|
2941 | * array (
|
---|
2942 | * 0 => '1234 67890 ', // 11 characters: Perfect split
|
---|
2943 | * 1 => '1234 ', // 5 characters: '1234 67890a' was too long
|
---|
2944 | * 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long
|
---|
2945 | * 3 => '1234 890 ', // 11 characters: Perfect split
|
---|
2946 | * 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long
|
---|
2947 | * 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split
|
---|
2948 | * 6 => ' 45678 ', // 11 characters: Perfect split
|
---|
2949 | * 7 => '1 3 5 7 90 ', // 11 characters: End of $string
|
---|
2950 | * );
|
---|
2951 | *
|
---|
2952 | * @since 3.4.0
|
---|
2953 | * @access private
|
---|
2954 | *
|
---|
2955 | * @param string $string The string to split.
|
---|
2956 | * @param int $goal The desired chunk length.
|
---|
2957 | * @return array Numeric array of chunks.
|
---|
2958 | */
|
---|
2959 | function _split_str_by_whitespace( $string, $goal ) {
|
---|
2960 | $chunks = array();
|
---|
2961 |
|
---|
2962 | $string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" );
|
---|
2963 |
|
---|
2964 | while ( $goal < strlen( $string_nullspace ) ) {
|
---|
2965 | $pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" );
|
---|
2966 |
|
---|
2967 | if ( false === $pos ) {
|
---|
2968 | $pos = strpos( $string_nullspace, "\000", $goal + 1 );
|
---|
2969 | if ( false === $pos ) {
|
---|
2970 | break;
|
---|
2971 | }
|
---|
2972 | }
|
---|
2973 |
|
---|
2974 | $chunks[] = substr( $string, 0, $pos + 1 );
|
---|
2975 | $string = substr( $string, $pos + 1 );
|
---|
2976 | $string_nullspace = substr( $string_nullspace, $pos + 1 );
|
---|
2977 | }
|
---|
2978 |
|
---|
2979 | if ( $string ) {
|
---|
2980 | $chunks[] = $string;
|
---|
2981 | }
|
---|
2982 |
|
---|
2983 | return $chunks;
|
---|
2984 | }
|
---|
2985 |
|
---|
2986 | /**
|
---|
2987 | * Adds rel nofollow string to all HTML A elements in content.
|
---|
2988 | *
|
---|
2989 | * @since 1.5.0
|
---|
2990 | *
|
---|
2991 | * @param string $text Content that may contain HTML A elements.
|
---|
2992 | * @return string Converted content.
|
---|
2993 | */
|
---|
2994 | function wp_rel_nofollow( $text ) {
|
---|
2995 | // This is a pre save filter, so text is already escaped.
|
---|
2996 | $text = stripslashes( $text );
|
---|
2997 | $text = preg_replace_callback( '|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text );
|
---|
2998 | return wp_slash( $text );
|
---|
2999 | }
|
---|
3000 |
|
---|
3001 | /**
|
---|
3002 | * Callback to add rel=nofollow string to HTML A element.
|
---|
3003 | *
|
---|
3004 | * Will remove already existing rel="nofollow" and rel='nofollow' from the
|
---|
3005 | * string to prevent from invalidating (X)HTML.
|
---|
3006 | *
|
---|
3007 | * @since 2.3.0
|
---|
3008 | *
|
---|
3009 | * @param array $matches Single Match
|
---|
3010 | * @return string HTML A Element with rel nofollow.
|
---|
3011 | */
|
---|
3012 | function wp_rel_nofollow_callback( $matches ) {
|
---|
3013 | $text = $matches[1];
|
---|
3014 | $atts = shortcode_parse_atts( $matches[1] );
|
---|
3015 | $rel = 'nofollow';
|
---|
3016 |
|
---|
3017 | if ( ! empty( $atts['href'] ) ) {
|
---|
3018 | if ( in_array( strtolower( wp_parse_url( $atts['href'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) {
|
---|
3019 | if ( strtolower( wp_parse_url( $atts['href'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) {
|
---|
3020 | return "<a $text>";
|
---|
3021 | }
|
---|
3022 | }
|
---|
3023 | }
|
---|
3024 |
|
---|
3025 | if ( ! empty( $atts['rel'] ) ) {
|
---|
3026 | $parts = array_map( 'trim', explode( ' ', $atts['rel'] ) );
|
---|
3027 | if ( false === array_search( 'nofollow', $parts ) ) {
|
---|
3028 | $parts[] = 'nofollow';
|
---|
3029 | }
|
---|
3030 | $rel = implode( ' ', $parts );
|
---|
3031 | unset( $atts['rel'] );
|
---|
3032 |
|
---|
3033 | $html = '';
|
---|
3034 | foreach ( $atts as $name => $value ) {
|
---|
3035 | $html .= "{$name}=\"" . esc_attr( $value ) . '" ';
|
---|
3036 | }
|
---|
3037 | $text = trim( $html );
|
---|
3038 | }
|
---|
3039 | return "<a $text rel=\"" . esc_attr( $rel ) . '">';
|
---|
3040 | }
|
---|
3041 |
|
---|
3042 | /**
|
---|
3043 | * Adds rel noreferrer and noopener to all HTML A elements that have a target.
|
---|
3044 | *
|
---|
3045 | * @since 5.1.0
|
---|
3046 | *
|
---|
3047 | * @param string $text Content that may contain HTML A elements.
|
---|
3048 | * @return string Converted content.
|
---|
3049 | */
|
---|
3050 | function wp_targeted_link_rel( $text ) {
|
---|
3051 | // Don't run (more expensive) regex if no links with targets.
|
---|
3052 | if ( stripos( $text, 'target' ) !== false && stripos( $text, '<a ' ) !== false ) {
|
---|
3053 | $text = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $text );
|
---|
3054 | }
|
---|
3055 |
|
---|
3056 | return $text;
|
---|
3057 | }
|
---|
3058 |
|
---|
3059 | /**
|
---|
3060 | * Callback to add rel="noreferrer noopener" string to HTML A element.
|
---|
3061 | *
|
---|
3062 | * Will not duplicate existing noreferrer and noopener values
|
---|
3063 | * to prevent from invalidating the HTML.
|
---|
3064 | *
|
---|
3065 | * @since 5.1.0
|
---|
3066 | *
|
---|
3067 | * @param array $matches Single Match
|
---|
3068 | * @return string HTML A Element with rel noreferrer noopener in addition to any existing values
|
---|
3069 | */
|
---|
3070 | function wp_targeted_link_rel_callback( $matches ) {
|
---|
3071 | $link_html = $matches[1];
|
---|
3072 | $rel_match = array();
|
---|
3073 |
|
---|
3074 | /**
|
---|
3075 | * Filters the rel values that are added to links with `target` attribute.
|
---|
3076 | *
|
---|
3077 | * @since 5.1.0
|
---|
3078 | *
|
---|
3079 | * @param string The rel values.
|
---|
3080 | * @param string $link_html The matched content of the link tag including all HTML attributes.
|
---|
3081 | */
|
---|
3082 | $rel = apply_filters( 'wp_targeted_link_rel', 'noopener noreferrer', $link_html );
|
---|
3083 |
|
---|
3084 | // Avoid additional regex if the filter removes rel values.
|
---|
3085 | if ( ! $rel ) {
|
---|
3086 | return "<a $link_html>";
|
---|
3087 | }
|
---|
3088 |
|
---|
3089 | // Value with delimiters, spaces around are optional.
|
---|
3090 | $attr_regex = '|rel\s*=\s*?(\\\\{0,1}["\'])(.*?)\\1|i';
|
---|
3091 | preg_match( $attr_regex, $link_html, $rel_match );
|
---|
3092 |
|
---|
3093 | if ( empty( $rel_match[0] ) ) {
|
---|
3094 | // No delimiters, try with a single value and spaces, because `rel = va"lue` is totally fine...
|
---|
3095 | $attr_regex = '|rel\s*=(\s*)([^\s]*)|i';
|
---|
3096 | preg_match( $attr_regex, $link_html, $rel_match );
|
---|
3097 | }
|
---|
3098 |
|
---|
3099 | if ( ! empty( $rel_match[0] ) ) {
|
---|
3100 | $parts = preg_split( '|\s+|', strtolower( $rel_match[2] ) );
|
---|
3101 | $parts = array_map( 'esc_attr', $parts );
|
---|
3102 | $needed = explode( ' ', $rel );
|
---|
3103 | $parts = array_unique( array_merge( $parts, $needed ) );
|
---|
3104 | $delimiter = trim( $rel_match[1] ) ? $rel_match[1] : '"';
|
---|
3105 | $rel = 'rel=' . $delimiter . trim( implode( ' ', $parts ) ) . $delimiter;
|
---|
3106 | $link_html = str_replace( $rel_match[0], $rel, $link_html );
|
---|
3107 | } elseif ( preg_match( '|target\s*=\s*?\\\\"|', $link_html ) ) {
|
---|
3108 | $link_html .= " rel=\\\"$rel\\\"";
|
---|
3109 | } elseif ( preg_match( '#(target|href)\s*=\s*?\'#', $link_html ) ) {
|
---|
3110 | $link_html .= " rel='$rel'";
|
---|
3111 | } else {
|
---|
3112 | $link_html .= " rel=\"$rel\"";
|
---|
3113 | }
|
---|
3114 |
|
---|
3115 | return "<a $link_html>";
|
---|
3116 | }
|
---|
3117 |
|
---|
3118 | /**
|
---|
3119 | * Adds all filters modifying the rel attribute of targeted links.
|
---|
3120 | *
|
---|
3121 | * @since 5.1.0
|
---|
3122 | */
|
---|
3123 | function wp_init_targeted_link_rel_filters() {
|
---|
3124 | $filters = array(
|
---|
3125 | 'title_save_pre',
|
---|
3126 | 'content_save_pre',
|
---|
3127 | 'excerpt_save_pre',
|
---|
3128 | 'content_filtered_save_pre',
|
---|
3129 | 'pre_comment_content',
|
---|
3130 | 'pre_term_description',
|
---|
3131 | 'pre_link_description',
|
---|
3132 | 'pre_link_notes',
|
---|
3133 | 'pre_user_description',
|
---|
3134 | );
|
---|
3135 |
|
---|
3136 | foreach ( $filters as $filter ) {
|
---|
3137 | add_filter( $filter, 'wp_targeted_link_rel' );
|
---|
3138 | };
|
---|
3139 | }
|
---|
3140 |
|
---|
3141 | /**
|
---|
3142 | * Removes all filters modifying the rel attribute of targeted links.
|
---|
3143 | *
|
---|
3144 | * @since 5.1.0
|
---|
3145 | */
|
---|
3146 | function wp_remove_targeted_link_rel_filters() {
|
---|
3147 | $filters = array(
|
---|
3148 | 'title_save_pre',
|
---|
3149 | 'content_save_pre',
|
---|
3150 | 'excerpt_save_pre',
|
---|
3151 | 'content_filtered_save_pre',
|
---|
3152 | 'pre_comment_content',
|
---|
3153 | 'pre_term_description',
|
---|
3154 | 'pre_link_description',
|
---|
3155 | 'pre_link_notes',
|
---|
3156 | 'pre_user_description',
|
---|
3157 | );
|
---|
3158 |
|
---|
3159 | foreach ( $filters as $filter ) {
|
---|
3160 | remove_filter( $filter, 'wp_targeted_link_rel' );
|
---|
3161 | };
|
---|
3162 | }
|
---|
3163 |
|
---|
3164 | /**
|
---|
3165 | * Convert one smiley code to the icon graphic file equivalent.
|
---|
3166 | *
|
---|
3167 | * Callback handler for convert_smilies().
|
---|
3168 | *
|
---|
3169 | * Looks up one smiley code in the $wpsmiliestrans global array and returns an
|
---|
3170 | * `<img>` string for that smiley.
|
---|
3171 | *
|
---|
3172 | * @since 2.8.0
|
---|
3173 | *
|
---|
3174 | * @global array $wpsmiliestrans
|
---|
3175 | *
|
---|
3176 | * @param array $matches Single match. Smiley code to convert to image.
|
---|
3177 | * @return string Image string for smiley.
|
---|
3178 | */
|
---|
3179 | function translate_smiley( $matches ) {
|
---|
3180 | global $wpsmiliestrans;
|
---|
3181 |
|
---|
3182 | if ( count( $matches ) == 0 ) {
|
---|
3183 | return '';
|
---|
3184 | }
|
---|
3185 |
|
---|
3186 | $smiley = trim( reset( $matches ) );
|
---|
3187 | $img = $wpsmiliestrans[ $smiley ];
|
---|
3188 |
|
---|
3189 | $matches = array();
|
---|
3190 | $ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false;
|
---|
3191 | $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
|
---|
3192 |
|
---|
3193 | // Don't convert smilies that aren't images - they're probably emoji.
|
---|
3194 | if ( ! in_array( $ext, $image_exts ) ) {
|
---|
3195 | return $img;
|
---|
3196 | }
|
---|
3197 |
|
---|
3198 | /**
|
---|
3199 | * Filters the Smiley image URL before it's used in the image element.
|
---|
3200 | *
|
---|
3201 | * @since 2.9.0
|
---|
3202 | *
|
---|
3203 | * @param string $smiley_url URL for the smiley image.
|
---|
3204 | * @param string $img Filename for the smiley image.
|
---|
3205 | * @param string $site_url Site URL, as returned by site_url().
|
---|
3206 | */
|
---|
3207 | $src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() );
|
---|
3208 |
|
---|
3209 | return sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', esc_url( $src_url ), esc_attr( $smiley ) );
|
---|
3210 | }
|
---|
3211 |
|
---|
3212 | /**
|
---|
3213 | * Convert text equivalent of smilies to images.
|
---|
3214 | *
|
---|
3215 | * Will only convert smilies if the option 'use_smilies' is true and the global
|
---|
3216 | * used in the function isn't empty.
|
---|
3217 | *
|
---|
3218 | * @since 0.71
|
---|
3219 | *
|
---|
3220 | * @global string|array $wp_smiliessearch
|
---|
3221 | *
|
---|
3222 | * @param string $text Content to convert smilies from text.
|
---|
3223 | * @return string Converted content with text smilies replaced with images.
|
---|
3224 | */
|
---|
3225 | function convert_smilies( $text ) {
|
---|
3226 | global $wp_smiliessearch;
|
---|
3227 | $output = '';
|
---|
3228 | if ( get_option( 'use_smilies' ) && ! empty( $wp_smiliessearch ) ) {
|
---|
3229 | // HTML loop taken from texturize function, could possible be consolidated
|
---|
3230 | $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between
|
---|
3231 | $stop = count( $textarr );// loop stuff
|
---|
3232 |
|
---|
3233 | // Ignore proessing of specific tags
|
---|
3234 | $tags_to_ignore = 'code|pre|style|script|textarea';
|
---|
3235 | $ignore_block_element = '';
|
---|
3236 |
|
---|
3237 | for ( $i = 0; $i < $stop; $i++ ) {
|
---|
3238 | $content = $textarr[ $i ];
|
---|
3239 |
|
---|
3240 | // If we're in an ignore block, wait until we find its closing tag
|
---|
3241 | if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) {
|
---|
3242 | $ignore_block_element = $matches[1];
|
---|
3243 | }
|
---|
3244 |
|
---|
3245 | // If it's not a tag and not in ignore block
|
---|
3246 | if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) {
|
---|
3247 | $content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content );
|
---|
3248 | }
|
---|
3249 |
|
---|
3250 | // did we exit ignore block
|
---|
3251 | if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) {
|
---|
3252 | $ignore_block_element = '';
|
---|
3253 | }
|
---|
3254 |
|
---|
3255 | $output .= $content;
|
---|
3256 | }
|
---|
3257 | } else {
|
---|
3258 | // return default text.
|
---|
3259 | $output = $text;
|
---|
3260 | }
|
---|
3261 | return $output;
|
---|
3262 | }
|
---|
3263 |
|
---|
3264 | /**
|
---|
3265 | * Verifies that an email is valid.
|
---|
3266 | *
|
---|
3267 | * Does not grok i18n domains. Not RFC compliant.
|
---|
3268 | *
|
---|
3269 | * @since 0.71
|
---|
3270 | *
|
---|
3271 | * @param string $email Email address to verify.
|
---|
3272 | * @param bool $deprecated Deprecated.
|
---|
3273 | * @return string|bool Either false or the valid email address.
|
---|
3274 | */
|
---|
3275 | function is_email( $email, $deprecated = false ) {
|
---|
3276 | if ( ! empty( $deprecated ) ) {
|
---|
3277 | _deprecated_argument( __FUNCTION__, '3.0.0' );
|
---|
3278 | }
|
---|
3279 |
|
---|
3280 | // Test for the minimum length the email can be
|
---|
3281 | if ( strlen( $email ) < 6 ) {
|
---|
3282 | /**
|
---|
3283 | * Filters whether an email address is valid.
|
---|
3284 | *
|
---|
3285 | * This filter is evaluated under several different contexts, such as 'email_too_short',
|
---|
3286 | * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits',
|
---|
3287 | * 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context.
|
---|
3288 | *
|
---|
3289 | * @since 2.8.0
|
---|
3290 | *
|
---|
3291 | * @param bool $is_email Whether the email address has passed the is_email() checks. Default false.
|
---|
3292 | * @param string $email The email address being checked.
|
---|
3293 | * @param string $context Context under which the email was tested.
|
---|
3294 | */
|
---|
3295 | return apply_filters( 'is_email', false, $email, 'email_too_short' );
|
---|
3296 | }
|
---|
3297 |
|
---|
3298 | // Test for an @ character after the first position
|
---|
3299 | if ( strpos( $email, '@', 1 ) === false ) {
|
---|
3300 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3301 | return apply_filters( 'is_email', false, $email, 'email_no_at' );
|
---|
3302 | }
|
---|
3303 |
|
---|
3304 | // Split out the local and domain parts
|
---|
3305 | list( $local, $domain ) = explode( '@', $email, 2 );
|
---|
3306 |
|
---|
3307 | // LOCAL PART
|
---|
3308 | // Test for invalid characters
|
---|
3309 | if ( ! preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) {
|
---|
3310 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3311 | return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
|
---|
3312 | }
|
---|
3313 |
|
---|
3314 | // DOMAIN PART
|
---|
3315 | // Test for sequences of periods
|
---|
3316 | if ( preg_match( '/\.{2,}/', $domain ) ) {
|
---|
3317 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3318 | return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
|
---|
3319 | }
|
---|
3320 |
|
---|
3321 | // Test for leading and trailing periods and whitespace
|
---|
3322 | if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) {
|
---|
3323 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3324 | return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
|
---|
3325 | }
|
---|
3326 |
|
---|
3327 | // Split the domain into subs
|
---|
3328 | $subs = explode( '.', $domain );
|
---|
3329 |
|
---|
3330 | // Assume the domain will have at least two subs
|
---|
3331 | if ( 2 > count( $subs ) ) {
|
---|
3332 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3333 | return apply_filters( 'is_email', false, $email, 'domain_no_periods' );
|
---|
3334 | }
|
---|
3335 |
|
---|
3336 | // Loop through each sub
|
---|
3337 | foreach ( $subs as $sub ) {
|
---|
3338 | // Test for leading and trailing hyphens and whitespace
|
---|
3339 | if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) {
|
---|
3340 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3341 | return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
|
---|
3342 | }
|
---|
3343 |
|
---|
3344 | // Test for invalid characters
|
---|
3345 | if ( ! preg_match( '/^[a-z0-9-]+$/i', $sub ) ) {
|
---|
3346 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3347 | return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );
|
---|
3348 | }
|
---|
3349 | }
|
---|
3350 |
|
---|
3351 | // Congratulations your email made it!
|
---|
3352 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3353 | return apply_filters( 'is_email', $email, $email, null );
|
---|
3354 | }
|
---|
3355 |
|
---|
3356 | /**
|
---|
3357 | * Convert to ASCII from email subjects.
|
---|
3358 | *
|
---|
3359 | * @since 1.2.0
|
---|
3360 | *
|
---|
3361 | * @param string $string Subject line
|
---|
3362 | * @return string Converted string to ASCII
|
---|
3363 | */
|
---|
3364 | function wp_iso_descrambler( $string ) {
|
---|
3365 | /* this may only work with iso-8859-1, I'm afraid */
|
---|
3366 | if ( ! preg_match( '#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches ) ) {
|
---|
3367 | return $string;
|
---|
3368 | } else {
|
---|
3369 | $subject = str_replace( '_', ' ', $matches[2] );
|
---|
3370 | return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject );
|
---|
3371 | }
|
---|
3372 | }
|
---|
3373 |
|
---|
3374 | /**
|
---|
3375 | * Helper function to convert hex encoded chars to ASCII
|
---|
3376 | *
|
---|
3377 | * @since 3.1.0
|
---|
3378 | * @access private
|
---|
3379 | *
|
---|
3380 | * @param array $match The preg_replace_callback matches array
|
---|
3381 | * @return string Converted chars
|
---|
3382 | */
|
---|
3383 | function _wp_iso_convert( $match ) {
|
---|
3384 | return chr( hexdec( strtolower( $match[1] ) ) );
|
---|
3385 | }
|
---|
3386 |
|
---|
3387 | /**
|
---|
3388 | * Returns a date in the GMT equivalent.
|
---|
3389 | *
|
---|
3390 | * Requires and returns a date in the Y-m-d H:i:s format. If there is a
|
---|
3391 | * timezone_string available, the date is assumed to be in that timezone,
|
---|
3392 | * otherwise it simply subtracts the value of the 'gmt_offset' option. Return
|
---|
3393 | * format can be overridden using the $format parameter.
|
---|
3394 | *
|
---|
3395 | * @since 1.2.0
|
---|
3396 | *
|
---|
3397 | * @param string $string The date to be converted.
|
---|
3398 | * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
|
---|
3399 | * @return string GMT version of the date provided.
|
---|
3400 | */
|
---|
3401 | function get_gmt_from_date( $string, $format = 'Y-m-d H:i:s' ) {
|
---|
3402 | $tz = get_option( 'timezone_string' );
|
---|
3403 | if ( $tz ) {
|
---|
3404 | $datetime = date_create( $string, new DateTimeZone( $tz ) );
|
---|
3405 | if ( ! $datetime ) {
|
---|
3406 | return gmdate( $format, 0 );
|
---|
3407 | }
|
---|
3408 | $datetime->setTimezone( new DateTimeZone( 'UTC' ) );
|
---|
3409 | $string_gmt = $datetime->format( $format );
|
---|
3410 | } else {
|
---|
3411 | 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 ) ) {
|
---|
3412 | $datetime = strtotime( $string );
|
---|
3413 | if ( false === $datetime ) {
|
---|
3414 | return gmdate( $format, 0 );
|
---|
3415 | }
|
---|
3416 | return gmdate( $format, $datetime );
|
---|
3417 | }
|
---|
3418 | $string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] );
|
---|
3419 | $string_gmt = gmdate( $format, $string_time - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
|
---|
3420 | }
|
---|
3421 | return $string_gmt;
|
---|
3422 | }
|
---|
3423 |
|
---|
3424 | /**
|
---|
3425 | * Converts a GMT date into the correct format for the blog.
|
---|
3426 | *
|
---|
3427 | * Requires and returns a date in the Y-m-d H:i:s format. If there is a
|
---|
3428 | * timezone_string available, the returned date is in that timezone, otherwise
|
---|
3429 | * it simply adds the value of gmt_offset. Return format can be overridden
|
---|
3430 | * using the $format parameter
|
---|
3431 | *
|
---|
3432 | * @since 1.2.0
|
---|
3433 | *
|
---|
3434 | * @param string $string The date to be converted.
|
---|
3435 | * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
|
---|
3436 | * @return string Formatted date relative to the timezone / GMT offset.
|
---|
3437 | */
|
---|
3438 | function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) {
|
---|
3439 | $tz = get_option( 'timezone_string' );
|
---|
3440 | if ( $tz ) {
|
---|
3441 | $datetime = date_create( $string, new DateTimeZone( 'UTC' ) );
|
---|
3442 | if ( ! $datetime ) {
|
---|
3443 | return date( $format, 0 );
|
---|
3444 | }
|
---|
3445 | $datetime->setTimezone( new DateTimeZone( $tz ) );
|
---|
3446 | $string_localtime = $datetime->format( $format );
|
---|
3447 | } else {
|
---|
3448 | 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 ) ) {
|
---|
3449 | return date( $format, 0 );
|
---|
3450 | }
|
---|
3451 | $string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] );
|
---|
3452 | $string_localtime = gmdate( $format, $string_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
|
---|
3453 | }
|
---|
3454 | return $string_localtime;
|
---|
3455 | }
|
---|
3456 |
|
---|
3457 | /**
|
---|
3458 | * Computes an offset in seconds from an iso8601 timezone.
|
---|
3459 | *
|
---|
3460 | * @since 1.5.0
|
---|
3461 | *
|
---|
3462 | * @param string $timezone Either 'Z' for 0 offset or '±hhmm'.
|
---|
3463 | * @return int|float The offset in seconds.
|
---|
3464 | */
|
---|
3465 | function iso8601_timezone_to_offset( $timezone ) {
|
---|
3466 | // $timezone is either 'Z' or '[+|-]hhmm'
|
---|
3467 | if ( $timezone == 'Z' ) {
|
---|
3468 | $offset = 0;
|
---|
3469 | } else {
|
---|
3470 | $sign = ( substr( $timezone, 0, 1 ) == '+' ) ? 1 : -1;
|
---|
3471 | $hours = intval( substr( $timezone, 1, 2 ) );
|
---|
3472 | $minutes = intval( substr( $timezone, 3, 4 ) ) / 60;
|
---|
3473 | $offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes );
|
---|
3474 | }
|
---|
3475 | return $offset;
|
---|
3476 | }
|
---|
3477 |
|
---|
3478 | /**
|
---|
3479 | * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt].
|
---|
3480 | *
|
---|
3481 | * @since 1.5.0
|
---|
3482 | *
|
---|
3483 | * @param string $date_string Date and time in ISO 8601 format {@link https://en.wikipedia.org/wiki/ISO_8601}.
|
---|
3484 | * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.
|
---|
3485 | * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s.
|
---|
3486 | */
|
---|
3487 | function iso8601_to_datetime( $date_string, $timezone = 'user' ) {
|
---|
3488 | $timezone = strtolower( $timezone );
|
---|
3489 |
|
---|
3490 | if ( $timezone == 'gmt' ) {
|
---|
3491 |
|
---|
3492 | 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 );
|
---|
3493 |
|
---|
3494 | if ( ! empty( $date_bits[7] ) ) { // we have a timezone, so let's compute an offset
|
---|
3495 | $offset = iso8601_timezone_to_offset( $date_bits[7] );
|
---|
3496 | } else { // we don't have a timezone, so we assume user local timezone (not server's!)
|
---|
3497 | $offset = HOUR_IN_SECONDS * get_option( 'gmt_offset' );
|
---|
3498 | }
|
---|
3499 |
|
---|
3500 | $timestamp = gmmktime( $date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1] );
|
---|
3501 | $timestamp -= $offset;
|
---|
3502 |
|
---|
3503 | return gmdate( 'Y-m-d H:i:s', $timestamp );
|
---|
3504 |
|
---|
3505 | } elseif ( $timezone == 'user' ) {
|
---|
3506 | 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 );
|
---|
3507 | }
|
---|
3508 | }
|
---|
3509 |
|
---|
3510 | /**
|
---|
3511 | * Strips out all characters that are not allowable in an email.
|
---|
3512 | *
|
---|
3513 | * @since 1.5.0
|
---|
3514 | *
|
---|
3515 | * @param string $email Email address to filter.
|
---|
3516 | * @return string Filtered email address.
|
---|
3517 | */
|
---|
3518 | function sanitize_email( $email ) {
|
---|
3519 | // Test for the minimum length the email can be
|
---|
3520 | if ( strlen( $email ) < 6 ) {
|
---|
3521 | /**
|
---|
3522 | * Filters a sanitized email address.
|
---|
3523 | *
|
---|
3524 | * This filter is evaluated under several contexts, including 'email_too_short',
|
---|
3525 | * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits',
|
---|
3526 | * 'domain_no_periods', 'domain_no_valid_subs', or no context.
|
---|
3527 | *
|
---|
3528 | * @since 2.8.0
|
---|
3529 | *
|
---|
3530 | * @param string $sanitized_email The sanitized email address.
|
---|
3531 | * @param string $email The email address, as provided to sanitize_email().
|
---|
3532 | * @param string|null $message A message to pass to the user. null if email is sanitized.
|
---|
3533 | */
|
---|
3534 | return apply_filters( 'sanitize_email', '', $email, 'email_too_short' );
|
---|
3535 | }
|
---|
3536 |
|
---|
3537 | // Test for an @ character after the first position
|
---|
3538 | if ( strpos( $email, '@', 1 ) === false ) {
|
---|
3539 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3540 | return apply_filters( 'sanitize_email', '', $email, 'email_no_at' );
|
---|
3541 | }
|
---|
3542 |
|
---|
3543 | // Split out the local and domain parts
|
---|
3544 | list( $local, $domain ) = explode( '@', $email, 2 );
|
---|
3545 |
|
---|
3546 | // LOCAL PART
|
---|
3547 | // Test for invalid characters
|
---|
3548 | $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local );
|
---|
3549 | if ( '' === $local ) {
|
---|
3550 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3551 | return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' );
|
---|
3552 | }
|
---|
3553 |
|
---|
3554 | // DOMAIN PART
|
---|
3555 | // Test for sequences of periods
|
---|
3556 | $domain = preg_replace( '/\.{2,}/', '', $domain );
|
---|
3557 | if ( '' === $domain ) {
|
---|
3558 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3559 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' );
|
---|
3560 | }
|
---|
3561 |
|
---|
3562 | // Test for leading and trailing periods and whitespace
|
---|
3563 | $domain = trim( $domain, " \t\n\r\0\x0B." );
|
---|
3564 | if ( '' === $domain ) {
|
---|
3565 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3566 | return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' );
|
---|
3567 | }
|
---|
3568 |
|
---|
3569 | // Split the domain into subs
|
---|
3570 | $subs = explode( '.', $domain );
|
---|
3571 |
|
---|
3572 | // Assume the domain will have at least two subs
|
---|
3573 | if ( 2 > count( $subs ) ) {
|
---|
3574 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3575 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' );
|
---|
3576 | }
|
---|
3577 |
|
---|
3578 | // Create an array that will contain valid subs
|
---|
3579 | $new_subs = array();
|
---|
3580 |
|
---|
3581 | // Loop through each sub
|
---|
3582 | foreach ( $subs as $sub ) {
|
---|
3583 | // Test for leading and trailing hyphens
|
---|
3584 | $sub = trim( $sub, " \t\n\r\0\x0B-" );
|
---|
3585 |
|
---|
3586 | // Test for invalid characters
|
---|
3587 | $sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub );
|
---|
3588 |
|
---|
3589 | // If there's anything left, add it to the valid subs
|
---|
3590 | if ( '' !== $sub ) {
|
---|
3591 | $new_subs[] = $sub;
|
---|
3592 | }
|
---|
3593 | }
|
---|
3594 |
|
---|
3595 | // If there aren't 2 or more valid subs
|
---|
3596 | if ( 2 > count( $new_subs ) ) {
|
---|
3597 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3598 | return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' );
|
---|
3599 | }
|
---|
3600 |
|
---|
3601 | // Join valid subs into the new domain
|
---|
3602 | $domain = join( '.', $new_subs );
|
---|
3603 |
|
---|
3604 | // Put the email back together
|
---|
3605 | $sanitized_email = $local . '@' . $domain;
|
---|
3606 |
|
---|
3607 | // Congratulations your email made it!
|
---|
3608 | /** This filter is documented in wp-includes/formatting.php */
|
---|
3609 | return apply_filters( 'sanitize_email', $sanitized_email, $email, null );
|
---|
3610 | }
|
---|
3611 |
|
---|
3612 | /**
|
---|
3613 | * Determines the difference between two timestamps.
|
---|
3614 | *
|
---|
3615 | * The difference is returned in a human readable format such as "1 hour",
|
---|
3616 | * "5 mins", "2 days".
|
---|
3617 | *
|
---|
3618 | * @since 1.5.0
|
---|
3619 | *
|
---|
3620 | * @param int $from Unix timestamp from which the difference begins.
|
---|
3621 | * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set.
|
---|
3622 | * @return string Human readable time difference.
|
---|
3623 | */
|
---|
3624 | function human_time_diff( $from, $to = '' ) {
|
---|
3625 | if ( empty( $to ) ) {
|
---|
3626 | $to = time();
|
---|
3627 | }
|
---|
3628 |
|
---|
3629 | $diff = (int) abs( $to - $from );
|
---|
3630 |
|
---|
3631 | if ( $diff < HOUR_IN_SECONDS ) {
|
---|
3632 | $mins = round( $diff / MINUTE_IN_SECONDS );
|
---|
3633 | if ( $mins <= 1 ) {
|
---|
3634 | $mins = 1;
|
---|
3635 | }
|
---|
3636 | /* translators: Time difference between two dates, in minutes (min=minute). %s: Number of minutes */
|
---|
3637 | $since = sprintf( _n( '%s min', '%s mins', $mins ), $mins );
|
---|
3638 | } elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
|
---|
3639 | $hours = round( $diff / HOUR_IN_SECONDS );
|
---|
3640 | if ( $hours <= 1 ) {
|
---|
3641 | $hours = 1;
|
---|
3642 | }
|
---|
3643 | /* translators: Time difference between two dates, in hours. %s: Number of hours */
|
---|
3644 | $since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours );
|
---|
3645 | } elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
|
---|
3646 | $days = round( $diff / DAY_IN_SECONDS );
|
---|
3647 | if ( $days <= 1 ) {
|
---|
3648 | $days = 1;
|
---|
3649 | }
|
---|
3650 | /* translators: Time difference between two dates, in days. %s: Number of days */
|
---|
3651 | $since = sprintf( _n( '%s day', '%s days', $days ), $days );
|
---|
3652 | } elseif ( $diff < MONTH_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
|
---|
3653 | $weeks = round( $diff / WEEK_IN_SECONDS );
|
---|
3654 | if ( $weeks <= 1 ) {
|
---|
3655 | $weeks = 1;
|
---|
3656 | }
|
---|
3657 | /* translators: Time difference between two dates, in weeks. %s: Number of weeks */
|
---|
3658 | $since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks );
|
---|
3659 | } elseif ( $diff < YEAR_IN_SECONDS && $diff >= MONTH_IN_SECONDS ) {
|
---|
3660 | $months = round( $diff / MONTH_IN_SECONDS );
|
---|
3661 | if ( $months <= 1 ) {
|
---|
3662 | $months = 1;
|
---|
3663 | }
|
---|
3664 | /* translators: Time difference between two dates, in months. %s: Number of months */
|
---|
3665 | $since = sprintf( _n( '%s month', '%s months', $months ), $months );
|
---|
3666 | } elseif ( $diff >= YEAR_IN_SECONDS ) {
|
---|
3667 | $years = round( $diff / YEAR_IN_SECONDS );
|
---|
3668 | if ( $years <= 1 ) {
|
---|
3669 | $years = 1;
|
---|
3670 | }
|
---|
3671 | /* translators: Time difference between two dates, in years. %s: Number of years */
|
---|
3672 | $since = sprintf( _n( '%s year', '%s years', $years ), $years );
|
---|
3673 | }
|
---|
3674 |
|
---|
3675 | /**
|
---|
3676 | * Filters the human readable difference between two timestamps.
|
---|
3677 | *
|
---|
3678 | * @since 4.0.0
|
---|
3679 | *
|
---|
3680 | * @param string $since The difference in human readable text.
|
---|
3681 | * @param int $diff The difference in seconds.
|
---|
3682 | * @param int $from Unix timestamp from which the difference begins.
|
---|
3683 | * @param int $to Unix timestamp to end the time difference.
|
---|
3684 | */
|
---|
3685 | return apply_filters( 'human_time_diff', $since, $diff, $from, $to );
|
---|
3686 | }
|
---|
3687 |
|
---|
3688 | /**
|
---|
3689 | * Generates an excerpt from the content, if needed.
|
---|
3690 | *
|
---|
3691 | * The excerpt word amount will be 55 words and if the amount is greater than
|
---|
3692 | * that, then the string ' […]' will be appended to the excerpt. If the string
|
---|
3693 | * is less than 55 words, then the content will be returned as is.
|
---|
3694 | *
|
---|
3695 | * The 55 word limit can be modified by plugins/themes using the {@see 'excerpt_length'} filter
|
---|
3696 | * The ' […]' string can be modified by plugins/themes using the {@see 'excerpt_more'} filter
|
---|
3697 | *
|
---|
3698 | * @since 1.5.0
|
---|
3699 | * @since 5.2.0 Added the `$post` parameter.
|
---|
3700 | *
|
---|
3701 | * @param string $text Optional. The excerpt. If set to empty, an excerpt is generated.
|
---|
3702 | * @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default is null.
|
---|
3703 | * @return string The excerpt.
|
---|
3704 | */
|
---|
3705 | function wp_trim_excerpt( $text = '', $post = null ) {
|
---|
3706 | $raw_excerpt = $text;
|
---|
3707 | if ( '' == $text ) {
|
---|
3708 | $post = get_post( $post );
|
---|
3709 | $text = get_the_content( '', false, $post );
|
---|
3710 |
|
---|
3711 | $text = strip_shortcodes( $text );
|
---|
3712 | $text = excerpt_remove_blocks( $text );
|
---|
3713 |
|
---|
3714 | /** This filter is documented in wp-includes/post-template.php */
|
---|
3715 | $text = apply_filters( 'the_content', $text );
|
---|
3716 | $text = str_replace( ']]>', ']]>', $text );
|
---|
3717 |
|
---|
3718 | /**
|
---|
3719 | * Filters the number of words in an excerpt.
|
---|
3720 | *
|
---|
3721 | * @since 2.7.0
|
---|
3722 | *
|
---|
3723 | * @param int $number The number of words. Default 55.
|
---|
3724 | */
|
---|
3725 | $excerpt_length = apply_filters( 'excerpt_length', 55 );
|
---|
3726 | /**
|
---|
3727 | * Filters the string in the "more" link displayed after a trimmed excerpt.
|
---|
3728 | *
|
---|
3729 | * @since 2.9.0
|
---|
3730 | *
|
---|
3731 | * @param string $more_string The string shown within the more link.
|
---|
3732 | */
|
---|
3733 | $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' );
|
---|
3734 | $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
|
---|
3735 | }
|
---|
3736 | /**
|
---|
3737 | * Filters the trimmed excerpt string.
|
---|
3738 | *
|
---|
3739 | * @since 2.8.0
|
---|
3740 | *
|
---|
3741 | * @param string $text The trimmed text.
|
---|
3742 | * @param string $raw_excerpt The text prior to trimming.
|
---|
3743 | */
|
---|
3744 | return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt );
|
---|
3745 | }
|
---|
3746 |
|
---|
3747 | /**
|
---|
3748 | * Trims text to a certain number of words.
|
---|
3749 | *
|
---|
3750 | * This function is localized. For languages that count 'words' by the individual
|
---|
3751 | * character (such as East Asian languages), the $num_words argument will apply
|
---|
3752 | * to the number of individual characters.
|
---|
3753 | *
|
---|
3754 | * @since 3.3.0
|
---|
3755 | *
|
---|
3756 | * @param string $text Text to trim.
|
---|
3757 | * @param int $num_words Number of words. Default 55.
|
---|
3758 | * @param string $more Optional. What to append if $text needs to be trimmed. Default '…'.
|
---|
3759 | * @return string Trimmed text.
|
---|
3760 | */
|
---|
3761 | function wp_trim_words( $text, $num_words = 55, $more = null ) {
|
---|
3762 | if ( null === $more ) {
|
---|
3763 | $more = __( '…' );
|
---|
3764 | }
|
---|
3765 |
|
---|
3766 | $original_text = $text;
|
---|
3767 | $text = wp_strip_all_tags( $text );
|
---|
3768 |
|
---|
3769 | /*
|
---|
3770 | * translators: If your word count is based on single characters (e.g. East Asian characters),
|
---|
3771 | * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
|
---|
3772 | * Do not translate into your own language.
|
---|
3773 | */
|
---|
3774 | if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
|
---|
3775 | $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
|
---|
3776 | preg_match_all( '/./u', $text, $words_array );
|
---|
3777 | $words_array = array_slice( $words_array[0], 0, $num_words + 1 );
|
---|
3778 | $sep = '';
|
---|
3779 | } else {
|
---|
3780 | $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
|
---|
3781 | $sep = ' ';
|
---|
3782 | }
|
---|
3783 |
|
---|
3784 | if ( count( $words_array ) > $num_words ) {
|
---|
3785 | array_pop( $words_array );
|
---|
3786 | $text = implode( $sep, $words_array );
|
---|
3787 | $text = $text . $more;
|
---|
3788 | } else {
|
---|
3789 | $text = implode( $sep, $words_array );
|
---|
3790 | }
|
---|
3791 |
|
---|
3792 | /**
|
---|
3793 | * Filters the text content after words have been trimmed.
|
---|
3794 | *
|
---|
3795 | * @since 3.3.0
|
---|
3796 | *
|
---|
3797 | * @param string $text The trimmed text.
|
---|
3798 | * @param int $num_words The number of words to trim the text to. Default 55.
|
---|
3799 | * @param string $more An optional string to append to the end of the trimmed text, e.g. ….
|
---|
3800 | * @param string $original_text The text before it was trimmed.
|
---|
3801 | */
|
---|
3802 | return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text );
|
---|
3803 | }
|
---|
3804 |
|
---|
3805 | /**
|
---|
3806 | * Converts named entities into numbered entities.
|
---|
3807 | *
|
---|
3808 | * @since 1.5.1
|
---|
3809 | *
|
---|
3810 | * @param string $text The text within which entities will be converted.
|
---|
3811 | * @return string Text with converted entities.
|
---|
3812 | */
|
---|
3813 | function ent2ncr( $text ) {
|
---|
3814 |
|
---|
3815 | /**
|
---|
3816 | * Filters text before named entities are converted into numbered entities.
|
---|
3817 | *
|
---|
3818 | * A non-null string must be returned for the filter to be evaluated.
|
---|
3819 | *
|
---|
3820 | * @since 3.3.0
|
---|
3821 | *
|
---|
3822 | * @param null $converted_text The text to be converted. Default null.
|
---|
3823 | * @param string $text The text prior to entity conversion.
|
---|
3824 | */
|
---|
3825 | $filtered = apply_filters( 'pre_ent2ncr', null, $text );
|
---|
3826 | if ( null !== $filtered ) {
|
---|
3827 | return $filtered;
|
---|
3828 | }
|
---|
3829 |
|
---|
3830 | $to_ncr = array(
|
---|
3831 | '"' => '"',
|
---|
3832 | '&' => '&',
|
---|
3833 | '<' => '<',
|
---|
3834 | '>' => '>',
|
---|
3835 | '|' => '|',
|
---|
3836 | ' ' => ' ',
|
---|
3837 | '¡' => '¡',
|
---|
3838 | '¢' => '¢',
|
---|
3839 | '£' => '£',
|
---|
3840 | '¤' => '¤',
|
---|
3841 | '¥' => '¥',
|
---|
3842 | '¦' => '¦',
|
---|
3843 | '&brkbar;' => '¦',
|
---|
3844 | '§' => '§',
|
---|
3845 | '¨' => '¨',
|
---|
3846 | '¨' => '¨',
|
---|
3847 | '©' => '©',
|
---|
3848 | 'ª' => 'ª',
|
---|
3849 | '«' => '«',
|
---|
3850 | '¬' => '¬',
|
---|
3851 | '­' => '­',
|
---|
3852 | '®' => '®',
|
---|
3853 | '¯' => '¯',
|
---|
3854 | '&hibar;' => '¯',
|
---|
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 | 'σ' => 'σ',
|
---|
3986 | 'τ' => 'τ',
|
---|
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 | '↓' => '↓',
|
---|
4081 | '↔' => '↔',
|
---|
4082 | '◊' => '◊',
|
---|
4083 | '♠' => '♠',
|
---|
4084 | '♣' => '♣',
|
---|
4085 | '♥' => '♥',
|
---|
4086 | '♦' => '♦',
|
---|
4087 | );
|
---|
4088 |
|
---|
4089 | return str_replace( array_keys( $to_ncr ), array_values( $to_ncr ), $text );
|
---|
4090 | }
|
---|
4091 |
|
---|
4092 | /**
|
---|
4093 | * Formats text for the editor.
|
---|
4094 | *
|
---|
4095 | * Generally the browsers treat everything inside a textarea as text, but
|
---|
4096 | * it is still a good idea to HTML entity encode `<`, `>` and `&` in the content.
|
---|
4097 | *
|
---|
4098 | * The filter {@see 'format_for_editor'} is applied here. If `$text` is empty the
|
---|
4099 | * filter will be applied to an empty string.
|
---|
4100 | *
|
---|
4101 | * @since 4.3.0
|
---|
4102 | *
|
---|
4103 | * @see _WP_Editors::editor()
|
---|
4104 | *
|
---|
4105 | * @param string $text The text to be formatted.
|
---|
4106 | * @param string $default_editor The default editor for the current user.
|
---|
4107 | * It is usually either 'html' or 'tinymce'.
|
---|
4108 | * @return string The formatted text after filter is applied.
|
---|
4109 | */
|
---|
4110 | function format_for_editor( $text, $default_editor = null ) {
|
---|
4111 | if ( $text ) {
|
---|
4112 | $text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) );
|
---|
4113 | }
|
---|
4114 |
|
---|
4115 | /**
|
---|
4116 | * Filters the text after it is formatted for the editor.
|
---|
4117 | *
|
---|
4118 | * @since 4.3.0
|
---|
4119 | *
|
---|
4120 | * @param string $text The formatted text.
|
---|
4121 | * @param string $default_editor The default editor for the current user.
|
---|
4122 | * It is usually either 'html' or 'tinymce'.
|
---|
4123 | */
|
---|
4124 | return apply_filters( 'format_for_editor', $text, $default_editor );
|
---|
4125 | }
|
---|
4126 |
|
---|
4127 | /**
|
---|
4128 | * Perform a deep string replace operation to ensure the values in $search are no longer present
|
---|
4129 | *
|
---|
4130 | * Repeats the replacement operation until it no longer replaces anything so as to remove "nested" values
|
---|
4131 | * e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that
|
---|
4132 | * str_replace would return
|
---|
4133 | *
|
---|
4134 | * @since 2.8.1
|
---|
4135 | * @access private
|
---|
4136 | *
|
---|
4137 | * @param string|array $search The value being searched for, otherwise known as the needle.
|
---|
4138 | * An array may be used to designate multiple needles.
|
---|
4139 | * @param string $subject The string being searched and replaced on, otherwise known as the haystack.
|
---|
4140 | * @return string The string with the replaced values.
|
---|
4141 | */
|
---|
4142 | function _deep_replace( $search, $subject ) {
|
---|
4143 | $subject = (string) $subject;
|
---|
4144 |
|
---|
4145 | $count = 1;
|
---|
4146 | while ( $count ) {
|
---|
4147 | $subject = str_replace( $search, '', $subject, $count );
|
---|
4148 | }
|
---|
4149 |
|
---|
4150 | return $subject;
|
---|
4151 | }
|
---|
4152 |
|
---|
4153 | /**
|
---|
4154 | * Escapes data for use in a MySQL query.
|
---|
4155 | *
|
---|
4156 | * Usually you should prepare queries using wpdb::prepare().
|
---|
4157 | * Sometimes, spot-escaping is required or useful. One example
|
---|
4158 | * is preparing an array for use in an IN clause.
|
---|
4159 | *
|
---|
4160 | * NOTE: Since 4.8.3, '%' characters will be replaced with a placeholder string,
|
---|
4161 | * this prevents certain SQLi attacks from taking place. This change in behaviour
|
---|
4162 | * may cause issues for code that expects the return value of esc_sql() to be useable
|
---|
4163 | * for other purposes.
|
---|
4164 | *
|
---|
4165 | * @since 2.8.0
|
---|
4166 | *
|
---|
4167 | * @global wpdb $wpdb WordPress database abstraction object.
|
---|
4168 | *
|
---|
4169 | * @param string|array $data Unescaped data
|
---|
4170 | * @return string|array Escaped data
|
---|
4171 | */
|
---|
4172 | function esc_sql( $data ) {
|
---|
4173 | global $wpdb;
|
---|
4174 | return $wpdb->_escape( $data );
|
---|
4175 | }
|
---|
4176 |
|
---|
4177 | /**
|
---|
4178 | * Checks and cleans a URL.
|
---|
4179 | *
|
---|
4180 | * A number of characters are removed from the URL. If the URL is for displaying
|
---|
4181 | * (the default behaviour) ampersands are also replaced. The {@see 'clean_url'} filter
|
---|
4182 | * is applied to the returned cleaned URL.
|
---|
4183 | *
|
---|
4184 | * @since 2.8.0
|
---|
4185 | *
|
---|
4186 | * @param string $url The URL to be cleaned.
|
---|
4187 | * @param array $protocols Optional. An array of acceptable protocols.
|
---|
4188 | * Defaults to return value of wp_allowed_protocols()
|
---|
4189 | * @param string $_context Private. Use esc_url_raw() for database usage.
|
---|
4190 | * @return string The cleaned $url after the {@see 'clean_url'} filter is applied.
|
---|
4191 | */
|
---|
4192 | function esc_url( $url, $protocols = null, $_context = 'display' ) {
|
---|
4193 | $original_url = $url;
|
---|
4194 |
|
---|
4195 | if ( '' == $url ) {
|
---|
4196 | return $url;
|
---|
4197 | }
|
---|
4198 |
|
---|
4199 | $url = str_replace( ' ', '%20', $url );
|
---|
4200 | $url = preg_replace( '|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url );
|
---|
4201 |
|
---|
4202 | if ( '' === $url ) {
|
---|
4203 | return $url;
|
---|
4204 | }
|
---|
4205 |
|
---|
4206 | if ( 0 !== stripos( $url, 'mailto:' ) ) {
|
---|
4207 | $strip = array( '%0d', '%0a', '%0D', '%0A' );
|
---|
4208 | $url = _deep_replace( $strip, $url );
|
---|
4209 | }
|
---|
4210 |
|
---|
4211 | $url = str_replace( ';//', '://', $url );
|
---|
4212 | /* If the URL doesn't appear to contain a scheme, we
|
---|
4213 | * presume it needs http:// prepended (unless a relative
|
---|
4214 | * link starting with /, # or ? or a php file).
|
---|
4215 | */
|
---|
4216 | if ( strpos( $url, ':' ) === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
|
---|
4217 | ! preg_match( '/^[a-z0-9-]+?\.php/i', $url ) ) {
|
---|
4218 | $url = 'http://' . $url;
|
---|
4219 | }
|
---|
4220 |
|
---|
4221 | // Replace ampersands and single quotes only when displaying.
|
---|
4222 | if ( 'display' == $_context ) {
|
---|
4223 | $url = wp_kses_normalize_entities( $url );
|
---|
4224 | $url = str_replace( '&', '&', $url );
|
---|
4225 | $url = str_replace( "'", ''', $url );
|
---|
4226 | }
|
---|
4227 |
|
---|
4228 | if ( ( false !== strpos( $url, '[' ) ) || ( false !== strpos( $url, ']' ) ) ) {
|
---|
4229 |
|
---|
4230 | $parsed = wp_parse_url( $url );
|
---|
4231 | $front = '';
|
---|
4232 |
|
---|
4233 | if ( isset( $parsed['scheme'] ) ) {
|
---|
4234 | $front .= $parsed['scheme'] . '://';
|
---|
4235 | } elseif ( '/' === $url[0] ) {
|
---|
4236 | $front .= '//';
|
---|
4237 | }
|
---|
4238 |
|
---|
4239 | if ( isset( $parsed['user'] ) ) {
|
---|
4240 | $front .= $parsed['user'];
|
---|
4241 | }
|
---|
4242 |
|
---|
4243 | if ( isset( $parsed['pass'] ) ) {
|
---|
4244 | $front .= ':' . $parsed['pass'];
|
---|
4245 | }
|
---|
4246 |
|
---|
4247 | if ( isset( $parsed['user'] ) || isset( $parsed['pass'] ) ) {
|
---|
4248 | $front .= '@';
|
---|
4249 | }
|
---|
4250 |
|
---|
4251 | if ( isset( $parsed['host'] ) ) {
|
---|
4252 | $front .= $parsed['host'];
|
---|
4253 | }
|
---|
4254 |
|
---|
4255 | if ( isset( $parsed['port'] ) ) {
|
---|
4256 | $front .= ':' . $parsed['port'];
|
---|
4257 | }
|
---|
4258 |
|
---|
4259 | $end_dirty = str_replace( $front, '', $url );
|
---|
4260 | $end_clean = str_replace( array( '[', ']' ), array( '%5B', '%5D' ), $end_dirty );
|
---|
4261 | $url = str_replace( $end_dirty, $end_clean, $url );
|
---|
4262 |
|
---|
4263 | }
|
---|
4264 |
|
---|
4265 | if ( '/' === $url[0] ) {
|
---|
4266 | $good_protocol_url = $url;
|
---|
4267 | } else {
|
---|
4268 | if ( ! is_array( $protocols ) ) {
|
---|
4269 | $protocols = wp_allowed_protocols();
|
---|
4270 | }
|
---|
4271 | $good_protocol_url = wp_kses_bad_protocol( $url, $protocols );
|
---|
4272 | if ( strtolower( $good_protocol_url ) != strtolower( $url ) ) {
|
---|
4273 | return '';
|
---|
4274 | }
|
---|
4275 | }
|
---|
4276 |
|
---|
4277 | /**
|
---|
4278 | * Filters a string cleaned and escaped for output as a URL.
|
---|
4279 | *
|
---|
4280 | * @since 2.3.0
|
---|
4281 | *
|
---|
4282 | * @param string $good_protocol_url The cleaned URL to be returned.
|
---|
4283 | * @param string $original_url The URL prior to cleaning.
|
---|
4284 | * @param string $_context If 'display', replace ampersands and single quotes only.
|
---|
4285 | */
|
---|
4286 | return apply_filters( 'clean_url', $good_protocol_url, $original_url, $_context );
|
---|
4287 | }
|
---|
4288 |
|
---|
4289 | /**
|
---|
4290 | * Performs esc_url() for database usage.
|
---|
4291 | *
|
---|
4292 | * @since 2.8.0
|
---|
4293 | *
|
---|
4294 | * @param string $url The URL to be cleaned.
|
---|
4295 | * @param array $protocols An array of acceptable protocols.
|
---|
4296 | * @return string The cleaned URL.
|
---|
4297 | */
|
---|
4298 | function esc_url_raw( $url, $protocols = null ) {
|
---|
4299 | return esc_url( $url, $protocols, 'db' );
|
---|
4300 | }
|
---|
4301 |
|
---|
4302 | /**
|
---|
4303 | * Convert entities, while preserving already-encoded entities.
|
---|
4304 | *
|
---|
4305 | * @link https://secure.php.net/htmlentities Borrowed from the PHP Manual user notes.
|
---|
4306 | *
|
---|
4307 | * @since 1.2.2
|
---|
4308 | *
|
---|
4309 | * @param string $myHTML The text to be converted.
|
---|
4310 | * @return string Converted text.
|
---|
4311 | */
|
---|
4312 | function htmlentities2( $myHTML ) {
|
---|
4313 | $translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
|
---|
4314 | $translation_table[ chr( 38 ) ] = '&';
|
---|
4315 | return preg_replace( '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', strtr( $myHTML, $translation_table ) );
|
---|
4316 | }
|
---|
4317 |
|
---|
4318 | /**
|
---|
4319 | * Escape single quotes, htmlspecialchar " < > &, and fix line endings.
|
---|
4320 | *
|
---|
4321 | * Escapes text strings for echoing in JS. It is intended to be used for inline JS
|
---|
4322 | * (in a tag attribute, for example onclick="..."). Note that the strings have to
|
---|
4323 | * be in single quotes. The {@see 'js_escape'} filter is also applied here.
|
---|
4324 | *
|
---|
4325 | * @since 2.8.0
|
---|
4326 | *
|
---|
4327 | * @param string $text The text to be escaped.
|
---|
4328 | * @return string Escaped text.
|
---|
4329 | */
|
---|
4330 | function esc_js( $text ) {
|
---|
4331 | $safe_text = wp_check_invalid_utf8( $text );
|
---|
4332 | $safe_text = _wp_specialchars( $safe_text, ENT_COMPAT );
|
---|
4333 | $safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
|
---|
4334 | $safe_text = str_replace( "\r", '', $safe_text );
|
---|
4335 | $safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) );
|
---|
4336 | /**
|
---|
4337 | * Filters a string cleaned and escaped for output in JavaScript.
|
---|
4338 | *
|
---|
4339 | * Text passed to esc_js() is stripped of invalid or special characters,
|
---|
4340 | * and properly slashed for output.
|
---|
4341 | *
|
---|
4342 | * @since 2.0.6
|
---|
4343 | *
|
---|
4344 | * @param string $safe_text The text after it has been escaped.
|
---|
4345 | * @param string $text The text prior to being escaped.
|
---|
4346 | */
|
---|
4347 | return apply_filters( 'js_escape', $safe_text, $text );
|
---|
4348 | }
|
---|
4349 |
|
---|
4350 | /**
|
---|
4351 | * Escaping for HTML blocks.
|
---|
4352 | *
|
---|
4353 | * @since 2.8.0
|
---|
4354 | *
|
---|
4355 | * @param string $text
|
---|
4356 | * @return string
|
---|
4357 | */
|
---|
4358 | function esc_html( $text ) {
|
---|
4359 | $safe_text = wp_check_invalid_utf8( $text );
|
---|
4360 | $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
|
---|
4361 | /**
|
---|
4362 | * Filters a string cleaned and escaped for output in HTML.
|
---|
4363 | *
|
---|
4364 | * Text passed to esc_html() is stripped of invalid or special characters
|
---|
4365 | * before output.
|
---|
4366 | *
|
---|
4367 | * @since 2.8.0
|
---|
4368 | *
|
---|
4369 | * @param string $safe_text The text after it has been escaped.
|
---|
4370 | * @param string $text The text prior to being escaped.
|
---|
4371 | */
|
---|
4372 | return apply_filters( 'esc_html', $safe_text, $text );
|
---|
4373 | }
|
---|
4374 |
|
---|
4375 | /**
|
---|
4376 | * Escaping for HTML attributes.
|
---|
4377 | *
|
---|
4378 | * @since 2.8.0
|
---|
4379 | *
|
---|
4380 | * @param string $text
|
---|
4381 | * @return string
|
---|
4382 | */
|
---|
4383 | function esc_attr( $text ) {
|
---|
4384 | $safe_text = wp_check_invalid_utf8( $text );
|
---|
4385 | $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
|
---|
4386 | /**
|
---|
4387 | * Filters a string cleaned and escaped for output in an HTML attribute.
|
---|
4388 | *
|
---|
4389 | * Text passed to esc_attr() is stripped of invalid or special characters
|
---|
4390 | * before output.
|
---|
4391 | *
|
---|
4392 | * @since 2.0.6
|
---|
4393 | *
|
---|
4394 | * @param string $safe_text The text after it has been escaped.
|
---|
4395 | * @param string $text The text prior to being escaped.
|
---|
4396 | */
|
---|
4397 | return apply_filters( 'attribute_escape', $safe_text, $text );
|
---|
4398 | }
|
---|
4399 |
|
---|
4400 | /**
|
---|
4401 | * Escaping for textarea values.
|
---|
4402 | *
|
---|
4403 | * @since 3.1.0
|
---|
4404 | *
|
---|
4405 | * @param string $text
|
---|
4406 | * @return string
|
---|
4407 | */
|
---|
4408 | function esc_textarea( $text ) {
|
---|
4409 | $safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( 'blog_charset' ) );
|
---|
4410 | /**
|
---|
4411 | * Filters a string cleaned and escaped for output in a textarea element.
|
---|
4412 | *
|
---|
4413 | * @since 3.1.0
|
---|
4414 | *
|
---|
4415 | * @param string $safe_text The text after it has been escaped.
|
---|
4416 | * @param string $text The text prior to being escaped.
|
---|
4417 | */
|
---|
4418 | return apply_filters( 'esc_textarea', $safe_text, $text );
|
---|
4419 | }
|
---|
4420 |
|
---|
4421 | /**
|
---|
4422 | * Escape an HTML tag name.
|
---|
4423 | *
|
---|
4424 | * @since 2.5.0
|
---|
4425 | *
|
---|
4426 | * @param string $tag_name
|
---|
4427 | * @return string
|
---|
4428 | */
|
---|
4429 | function tag_escape( $tag_name ) {
|
---|
4430 | $safe_tag = strtolower( preg_replace( '/[^a-zA-Z0-9_:]/', '', $tag_name ) );
|
---|
4431 | /**
|
---|
4432 | * Filters a string cleaned and escaped for output as an HTML tag.
|
---|
4433 | *
|
---|
4434 | * @since 2.8.0
|
---|
4435 | *
|
---|
4436 | * @param string $safe_tag The tag name after it has been escaped.
|
---|
4437 | * @param string $tag_name The text before it was escaped.
|
---|
4438 | */
|
---|
4439 | return apply_filters( 'tag_escape', $safe_tag, $tag_name );
|
---|
4440 | }
|
---|
4441 |
|
---|
4442 | /**
|
---|
4443 | * Convert full URL paths to absolute paths.
|
---|
4444 | *
|
---|
4445 | * Removes the http or https protocols and the domain. Keeps the path '/' at the
|
---|
4446 | * beginning, so it isn't a true relative link, but from the web root base.
|
---|
4447 | *
|
---|
4448 | * @since 2.1.0
|
---|
4449 | * @since 4.1.0 Support was added for relative URLs.
|
---|
4450 | *
|
---|
4451 | * @param string $link Full URL path.
|
---|
4452 | * @return string Absolute path.
|
---|
4453 | */
|
---|
4454 | function wp_make_link_relative( $link ) {
|
---|
4455 | return preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', $link );
|
---|
4456 | }
|
---|
4457 |
|
---|
4458 | /**
|
---|
4459 | * Sanitises various option values based on the nature of the option.
|
---|
4460 | *
|
---|
4461 | * This is basically a switch statement which will pass $value through a number
|
---|
4462 | * of functions depending on the $option.
|
---|
4463 | *
|
---|
4464 | * @since 2.0.5
|
---|
4465 | *
|
---|
4466 | * @global wpdb $wpdb WordPress database abstraction object.
|
---|
4467 | *
|
---|
4468 | * @param string $option The name of the option.
|
---|
4469 | * @param string $value The unsanitised value.
|
---|
4470 | * @return string Sanitized value.
|
---|
4471 | */
|
---|
4472 | function sanitize_option( $option, $value ) {
|
---|
4473 | global $wpdb;
|
---|
4474 |
|
---|
4475 | $original_value = $value;
|
---|
4476 | $error = '';
|
---|
4477 |
|
---|
4478 | switch ( $option ) {
|
---|
4479 | case 'admin_email':
|
---|
4480 | case 'new_admin_email':
|
---|
4481 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
---|
4482 | if ( is_wp_error( $value ) ) {
|
---|
4483 | $error = $value->get_error_message();
|
---|
4484 | } else {
|
---|
4485 | $value = sanitize_email( $value );
|
---|
4486 | if ( ! is_email( $value ) ) {
|
---|
4487 | $error = __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' );
|
---|
4488 | }
|
---|
4489 | }
|
---|
4490 | break;
|
---|
4491 |
|
---|
4492 | case 'thumbnail_size_w':
|
---|
4493 | case 'thumbnail_size_h':
|
---|
4494 | case 'medium_size_w':
|
---|
4495 | case 'medium_size_h':
|
---|
4496 | case 'medium_large_size_w':
|
---|
4497 | case 'medium_large_size_h':
|
---|
4498 | case 'large_size_w':
|
---|
4499 | case 'large_size_h':
|
---|
4500 | case 'mailserver_port':
|
---|
4501 | case 'comment_max_links':
|
---|
4502 | case 'page_on_front':
|
---|
4503 | case 'page_for_posts':
|
---|
4504 | case 'rss_excerpt_length':
|
---|
4505 | case 'default_category':
|
---|
4506 | case 'default_email_category':
|
---|
4507 | case 'default_link_category':
|
---|
4508 | case 'close_comments_days_old':
|
---|
4509 | case 'comments_per_page':
|
---|
4510 | case 'thread_comments_depth':
|
---|
4511 | case 'users_can_register':
|
---|
4512 | case 'start_of_week':
|
---|
4513 | case 'site_icon':
|
---|
4514 | $value = absint( $value );
|
---|
4515 | break;
|
---|
4516 |
|
---|
4517 | case 'posts_per_page':
|
---|
4518 | case 'posts_per_rss':
|
---|
4519 | $value = (int) $value;
|
---|
4520 | if ( empty( $value ) ) {
|
---|
4521 | $value = 1;
|
---|
4522 | }
|
---|
4523 | if ( $value < -1 ) {
|
---|
4524 | $value = abs( $value );
|
---|
4525 | }
|
---|
4526 | break;
|
---|
4527 |
|
---|
4528 | case 'default_ping_status':
|
---|
4529 | case 'default_comment_status':
|
---|
4530 | // Options that if not there have 0 value but need to be something like "closed"
|
---|
4531 | if ( $value == '0' || $value == '' ) {
|
---|
4532 | $value = 'closed';
|
---|
4533 | }
|
---|
4534 | break;
|
---|
4535 |
|
---|
4536 | case 'blogdescription':
|
---|
4537 | case 'blogname':
|
---|
4538 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
---|
4539 | if ( $value !== $original_value ) {
|
---|
4540 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', wp_encode_emoji( $original_value ) );
|
---|
4541 | }
|
---|
4542 |
|
---|
4543 | if ( is_wp_error( $value ) ) {
|
---|
4544 | $error = $value->get_error_message();
|
---|
4545 | } else {
|
---|
4546 | $value = esc_html( $value );
|
---|
4547 | }
|
---|
4548 | break;
|
---|
4549 |
|
---|
4550 | case 'blog_charset':
|
---|
4551 | $value = preg_replace( '/[^a-zA-Z0-9_-]/', '', $value ); // strips slashes
|
---|
4552 | break;
|
---|
4553 |
|
---|
4554 | case 'blog_public':
|
---|
4555 | // This is the value if the settings checkbox is not checked on POST. Don't rely on this.
|
---|
4556 | if ( null === $value ) {
|
---|
4557 | $value = 1;
|
---|
4558 | } else {
|
---|
4559 | $value = intval( $value );
|
---|
4560 | }
|
---|
4561 | break;
|
---|
4562 |
|
---|
4563 | case 'date_format':
|
---|
4564 | case 'time_format':
|
---|
4565 | case 'mailserver_url':
|
---|
4566 | case 'mailserver_login':
|
---|
4567 | case 'mailserver_pass':
|
---|
4568 | case 'upload_path':
|
---|
4569 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
---|
4570 | if ( is_wp_error( $value ) ) {
|
---|
4571 | $error = $value->get_error_message();
|
---|
4572 | } else {
|
---|
4573 | $value = strip_tags( $value );
|
---|
4574 | $value = wp_kses_data( $value );
|
---|
4575 | }
|
---|
4576 | break;
|
---|
4577 |
|
---|
4578 | case 'ping_sites':
|
---|
4579 | $value = explode( "\n", $value );
|
---|
4580 | $value = array_filter( array_map( 'trim', $value ) );
|
---|
4581 | $value = array_filter( array_map( 'esc_url_raw', $value ) );
|
---|
4582 | $value = implode( "\n", $value );
|
---|
4583 | break;
|
---|
4584 |
|
---|
4585 | case 'gmt_offset':
|
---|
4586 | $value = preg_replace( '/[^0-9:.-]/', '', $value ); // strips slashes
|
---|
4587 | break;
|
---|
4588 |
|
---|
4589 | case 'siteurl':
|
---|
4590 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
---|
4591 | if ( is_wp_error( $value ) ) {
|
---|
4592 | $error = $value->get_error_message();
|
---|
4593 | } else {
|
---|
4594 | if ( preg_match( '#http(s?)://(.+)#i', $value ) ) {
|
---|
4595 | $value = esc_url_raw( $value );
|
---|
4596 | } else {
|
---|
4597 | $error = __( 'The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.' );
|
---|
4598 | }
|
---|
4599 | }
|
---|
4600 | break;
|
---|
4601 |
|
---|
4602 | case 'home':
|
---|
4603 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
---|
4604 | if ( is_wp_error( $value ) ) {
|
---|
4605 | $error = $value->get_error_message();
|
---|
4606 | } else {
|
---|
4607 | if ( preg_match( '#http(s?)://(.+)#i', $value ) ) {
|
---|
4608 | $value = esc_url_raw( $value );
|
---|
4609 | } else {
|
---|
4610 | $error = __( 'The Site address you entered did not appear to be a valid URL. Please enter a valid URL.' );
|
---|
4611 | }
|
---|
4612 | }
|
---|
4613 | break;
|
---|
4614 |
|
---|
4615 | case 'WPLANG':
|
---|
4616 | $allowed = get_available_languages();
|
---|
4617 | if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG ) {
|
---|
4618 | $allowed[] = WPLANG;
|
---|
4619 | }
|
---|
4620 | if ( ! in_array( $value, $allowed ) && ! empty( $value ) ) {
|
---|
4621 | $value = get_option( $option );
|
---|
4622 | }
|
---|
4623 | break;
|
---|
4624 |
|
---|
4625 | case 'illegal_names':
|
---|
4626 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
---|
4627 | if ( is_wp_error( $value ) ) {
|
---|
4628 | $error = $value->get_error_message();
|
---|
4629 | } else {
|
---|
4630 | if ( ! is_array( $value ) ) {
|
---|
4631 | $value = explode( ' ', $value );
|
---|
4632 | }
|
---|
4633 |
|
---|
4634 | $value = array_values( array_filter( array_map( 'trim', $value ) ) );
|
---|
4635 |
|
---|
4636 | if ( ! $value ) {
|
---|
4637 | $value = '';
|
---|
4638 | }
|
---|
4639 | }
|
---|
4640 | break;
|
---|
4641 |
|
---|
4642 | case 'limited_email_domains':
|
---|
4643 | case 'banned_email_domains':
|
---|
4644 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
---|
4645 | if ( is_wp_error( $value ) ) {
|
---|
4646 | $error = $value->get_error_message();
|
---|
4647 | } else {
|
---|
4648 | if ( ! is_array( $value ) ) {
|
---|
4649 | $value = explode( "\n", $value );
|
---|
4650 | }
|
---|
4651 |
|
---|
4652 | $domains = array_values( array_filter( array_map( 'trim', $value ) ) );
|
---|
4653 | $value = array();
|
---|
4654 |
|
---|
4655 | foreach ( $domains as $domain ) {
|
---|
4656 | if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) {
|
---|
4657 | $value[] = $domain;
|
---|
4658 | }
|
---|
4659 | }
|
---|
4660 | if ( ! $value ) {
|
---|
4661 | $value = '';
|
---|
4662 | }
|
---|
4663 | }
|
---|
4664 | break;
|
---|
4665 |
|
---|
4666 | case 'timezone_string':
|
---|
4667 | $allowed_zones = timezone_identifiers_list();
|
---|
4668 | if ( ! in_array( $value, $allowed_zones ) && ! empty( $value ) ) {
|
---|
4669 | $error = __( 'The timezone you have entered is not valid. Please select a valid timezone.' );
|
---|
4670 | }
|
---|
4671 | break;
|
---|
4672 |
|
---|
4673 | case 'permalink_structure':
|
---|
4674 | case 'category_base':
|
---|
4675 | case 'tag_base':
|
---|
4676 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
---|
4677 | if ( is_wp_error( $value ) ) {
|
---|
4678 | $error = $value->get_error_message();
|
---|
4679 | } else {
|
---|
4680 | $value = esc_url_raw( $value );
|
---|
4681 | $value = str_replace( 'http://', '', $value );
|
---|
4682 | }
|
---|
4683 |
|
---|
4684 | if ( 'permalink_structure' === $option && '' !== $value && ! preg_match( '/%[^\/%]+%/', $value ) ) {
|
---|
4685 | $error = sprintf(
|
---|
4686 | /* translators: %s: Codex URL */
|
---|
4687 | __( 'A structure tag is required when using custom permalinks. <a href="%s">Learn more</a>' ),
|
---|
4688 | __( 'https://codex.wordpress.org/Using_Permalinks#Choosing_your_permalink_structure' )
|
---|
4689 | );
|
---|
4690 | }
|
---|
4691 | break;
|
---|
4692 |
|
---|
4693 | case 'default_role':
|
---|
4694 | if ( ! get_role( $value ) && get_role( 'subscriber' ) ) {
|
---|
4695 | $value = 'subscriber';
|
---|
4696 | }
|
---|
4697 | break;
|
---|
4698 |
|
---|
4699 | case 'moderation_keys':
|
---|
4700 | case 'blacklist_keys':
|
---|
4701 | $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
---|
4702 | if ( is_wp_error( $value ) ) {
|
---|
4703 | $error = $value->get_error_message();
|
---|
4704 | } else {
|
---|
4705 | $value = explode( "\n", $value );
|
---|
4706 | $value = array_filter( array_map( 'trim', $value ) );
|
---|
4707 | $value = array_unique( $value );
|
---|
4708 | $value = implode( "\n", $value );
|
---|
4709 | }
|
---|
4710 | break;
|
---|
4711 | }
|
---|
4712 |
|
---|
4713 | if ( ! empty( $error ) ) {
|
---|
4714 | $value = get_option( $option );
|
---|
4715 | if ( function_exists( 'add_settings_error' ) ) {
|
---|
4716 | add_settings_error( $option, "invalid_{$option}", $error );
|
---|
4717 | }
|
---|
4718 | }
|
---|
4719 |
|
---|
4720 | /**
|
---|
4721 | * Filters an option value following sanitization.
|
---|
4722 | *
|
---|
4723 | * @since 2.3.0
|
---|
4724 | * @since 4.3.0 Added the `$original_value` parameter.
|
---|
4725 | *
|
---|
4726 | * @param string $value The sanitized option value.
|
---|
4727 | * @param string $option The option name.
|
---|
4728 | * @param string $original_value The original value passed to the function.
|
---|
4729 | */
|
---|
4730 | return apply_filters( "sanitize_option_{$option}", $value, $option, $original_value );
|
---|
4731 | }
|
---|
4732 |
|
---|
4733 | /**
|
---|
4734 | * Maps a function to all non-iterable elements of an array or an object.
|
---|
4735 | *
|
---|
4736 | * This is similar to `array_walk_recursive()` but acts upon objects too.
|
---|
4737 | *
|
---|
4738 | * @since 4.4.0
|
---|
4739 | *
|
---|
4740 | * @param mixed $value The array, object, or scalar.
|
---|
4741 | * @param callable $callback The function to map onto $value.
|
---|
4742 | * @return mixed The value with the callback applied to all non-arrays and non-objects inside it.
|
---|
4743 | */
|
---|
4744 | function map_deep( $value, $callback ) {
|
---|
4745 | if ( is_array( $value ) ) {
|
---|
4746 | foreach ( $value as $index => $item ) {
|
---|
4747 | $value[ $index ] = map_deep( $item, $callback );
|
---|
4748 | }
|
---|
4749 | } elseif ( is_object( $value ) ) {
|
---|
4750 | $object_vars = get_object_vars( $value );
|
---|
4751 | foreach ( $object_vars as $property_name => $property_value ) {
|
---|
4752 | $value->$property_name = map_deep( $property_value, $callback );
|
---|
4753 | }
|
---|
4754 | } else {
|
---|
4755 | $value = call_user_func( $callback, $value );
|
---|
4756 | }
|
---|
4757 |
|
---|
4758 | return $value;
|
---|
4759 | }
|
---|
4760 |
|
---|
4761 | /**
|
---|
4762 | * Parses a string into variables to be stored in an array.
|
---|
4763 | *
|
---|
4764 | * Uses {@link https://secure.php.net/parse_str parse_str()} and stripslashes if
|
---|
4765 | * {@link https://secure.php.net/magic_quotes magic_quotes_gpc} is on.
|
---|
4766 | *
|
---|
4767 | * @since 2.2.1
|
---|
4768 | *
|
---|
4769 | * @param string $string The string to be parsed.
|
---|
4770 | * @param array $array Variables will be stored in this array.
|
---|
4771 | */
|
---|
4772 | function wp_parse_str( $string, &$array ) {
|
---|
4773 | parse_str( $string, $array );
|
---|
4774 | if ( get_magic_quotes_gpc() ) {
|
---|
4775 | $array = stripslashes_deep( $array );
|
---|
4776 | }
|
---|
4777 | /**
|
---|
4778 | * Filters the array of variables derived from a parsed string.
|
---|
4779 | *
|
---|
4780 | * @since 2.3.0
|
---|
4781 | *
|
---|
4782 | * @param array $array The array populated with variables.
|
---|
4783 | */
|
---|
4784 | $array = apply_filters( 'wp_parse_str', $array );
|
---|
4785 | }
|
---|
4786 |
|
---|
4787 | /**
|
---|
4788 | * Convert lone less than signs.
|
---|
4789 | *
|
---|
4790 | * KSES already converts lone greater than signs.
|
---|
4791 | *
|
---|
4792 | * @since 2.3.0
|
---|
4793 | *
|
---|
4794 | * @param string $text Text to be converted.
|
---|
4795 | * @return string Converted text.
|
---|
4796 | */
|
---|
4797 | function wp_pre_kses_less_than( $text ) {
|
---|
4798 | return preg_replace_callback( '%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text );
|
---|
4799 | }
|
---|
4800 |
|
---|
4801 | /**
|
---|
4802 | * Callback function used by preg_replace.
|
---|
4803 | *
|
---|
4804 | * @since 2.3.0
|
---|
4805 | *
|
---|
4806 | * @param array $matches Populated by matches to preg_replace.
|
---|
4807 | * @return string The text returned after esc_html if needed.
|
---|
4808 | */
|
---|
4809 | function wp_pre_kses_less_than_callback( $matches ) {
|
---|
4810 | if ( false === strpos( $matches[0], '>' ) ) {
|
---|
4811 | return esc_html( $matches[0] );
|
---|
4812 | }
|
---|
4813 | return $matches[0];
|
---|
4814 | }
|
---|
4815 |
|
---|
4816 | /**
|
---|
4817 | * WordPress implementation of PHP sprintf() with filters.
|
---|
4818 | *
|
---|
4819 | * @since 2.5.0
|
---|
4820 | * @link https://secure.php.net/sprintf
|
---|
4821 | *
|
---|
4822 | * @param string $pattern The string which formatted args are inserted.
|
---|
4823 | * @param mixed $args ,... Arguments to be formatted into the $pattern string.
|
---|
4824 | * @return string The formatted string.
|
---|
4825 | */
|
---|
4826 | function wp_sprintf( $pattern ) {
|
---|
4827 | $args = func_get_args();
|
---|
4828 | $len = strlen( $pattern );
|
---|
4829 | $start = 0;
|
---|
4830 | $result = '';
|
---|
4831 | $arg_index = 0;
|
---|
4832 | while ( $len > $start ) {
|
---|
4833 | // Last character: append and break
|
---|
4834 | if ( strlen( $pattern ) - 1 == $start ) {
|
---|
4835 | $result .= substr( $pattern, -1 );
|
---|
4836 | break;
|
---|
4837 | }
|
---|
4838 |
|
---|
4839 | // Literal %: append and continue
|
---|
4840 | if ( substr( $pattern, $start, 2 ) == '%%' ) {
|
---|
4841 | $start += 2;
|
---|
4842 | $result .= '%';
|
---|
4843 | continue;
|
---|
4844 | }
|
---|
4845 |
|
---|
4846 | // Get fragment before next %
|
---|
4847 | $end = strpos( $pattern, '%', $start + 1 );
|
---|
4848 | if ( false === $end ) {
|
---|
4849 | $end = $len;
|
---|
4850 | }
|
---|
4851 | $fragment = substr( $pattern, $start, $end - $start );
|
---|
4852 |
|
---|
4853 | // Fragment has a specifier
|
---|
4854 | if ( $pattern[ $start ] == '%' ) {
|
---|
4855 | // Find numbered arguments or take the next one in order
|
---|
4856 | if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) {
|
---|
4857 | $arg = isset( $args[ $matches[1] ] ) ? $args[ $matches[1] ] : '';
|
---|
4858 | $fragment = str_replace( "%{$matches[1]}$", '%', $fragment );
|
---|
4859 | } else {
|
---|
4860 | ++$arg_index;
|
---|
4861 | $arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : '';
|
---|
4862 | }
|
---|
4863 |
|
---|
4864 | /**
|
---|
4865 | * Filters a fragment from the pattern passed to wp_sprintf().
|
---|
4866 | *
|
---|
4867 | * If the fragment is unchanged, then sprintf() will be run on the fragment.
|
---|
4868 | *
|
---|
4869 | * @since 2.5.0
|
---|
4870 | *
|
---|
4871 | * @param string $fragment A fragment from the pattern.
|
---|
4872 | * @param string $arg The argument.
|
---|
4873 | */
|
---|
4874 | $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );
|
---|
4875 | if ( $_fragment != $fragment ) {
|
---|
4876 | $fragment = $_fragment;
|
---|
4877 | } else {
|
---|
4878 | $fragment = sprintf( $fragment, strval( $arg ) );
|
---|
4879 | }
|
---|
4880 | }
|
---|
4881 |
|
---|
4882 | // Append to result and move to next fragment
|
---|
4883 | $result .= $fragment;
|
---|
4884 | $start = $end;
|
---|
4885 | }
|
---|
4886 | return $result;
|
---|
4887 | }
|
---|
4888 |
|
---|
4889 | /**
|
---|
4890 | * Localize list items before the rest of the content.
|
---|
4891 | *
|
---|
4892 | * The '%l' must be at the first characters can then contain the rest of the
|
---|
4893 | * content. The list items will have ', ', ', and', and ' and ' added depending
|
---|
4894 | * on the amount of list items in the $args parameter.
|
---|
4895 | *
|
---|
4896 | * @since 2.5.0
|
---|
4897 | *
|
---|
4898 | * @param string $pattern Content containing '%l' at the beginning.
|
---|
4899 | * @param array $args List items to prepend to the content and replace '%l'.
|
---|
4900 | * @return string Localized list items and rest of the content.
|
---|
4901 | */
|
---|
4902 | function wp_sprintf_l( $pattern, $args ) {
|
---|
4903 | // Not a match
|
---|
4904 | if ( substr( $pattern, 0, 2 ) != '%l' ) {
|
---|
4905 | return $pattern;
|
---|
4906 | }
|
---|
4907 |
|
---|
4908 | // Nothing to work with
|
---|
4909 | if ( empty( $args ) ) {
|
---|
4910 | return '';
|
---|
4911 | }
|
---|
4912 |
|
---|
4913 | /**
|
---|
4914 | * Filters the translated delimiters used by wp_sprintf_l().
|
---|
4915 | * Placeholders (%s) are included to assist translators and then
|
---|
4916 | * removed before the array of strings reaches the filter.
|
---|
4917 | *
|
---|
4918 | * Please note: Ampersands and entities should be avoided here.
|
---|
4919 | *
|
---|
4920 | * @since 2.5.0
|
---|
4921 | *
|
---|
4922 | * @param array $delimiters An array of translated delimiters.
|
---|
4923 | */
|
---|
4924 | $l = apply_filters(
|
---|
4925 | 'wp_sprintf_l',
|
---|
4926 | array(
|
---|
4927 | /* translators: used to join items in a list with more than 2 items */
|
---|
4928 | 'between' => sprintf( __( '%1$s, %2$s' ), '', '' ),
|
---|
4929 | /* translators: used to join last two items in a list with more than 2 times */
|
---|
4930 | 'between_last_two' => sprintf( __( '%1$s, and %2$s' ), '', '' ),
|
---|
4931 | /* translators: used to join items in a list with only 2 items */
|
---|
4932 | 'between_only_two' => sprintf( __( '%1$s and %2$s' ), '', '' ),
|
---|
4933 | )
|
---|
4934 | );
|
---|
4935 |
|
---|
4936 | $args = (array) $args;
|
---|
4937 | $result = array_shift( $args );
|
---|
4938 | if ( count( $args ) == 1 ) {
|
---|
4939 | $result .= $l['between_only_two'] . array_shift( $args );
|
---|
4940 | }
|
---|
4941 | // Loop when more than two args
|
---|
4942 | $i = count( $args );
|
---|
4943 | while ( $i ) {
|
---|
4944 | $arg = array_shift( $args );
|
---|
4945 | $i--;
|
---|
4946 | if ( 0 == $i ) {
|
---|
4947 | $result .= $l['between_last_two'] . $arg;
|
---|
4948 | } else {
|
---|
4949 | $result .= $l['between'] . $arg;
|
---|
4950 | }
|
---|
4951 | }
|
---|
4952 | return $result . substr( $pattern, 2 );
|
---|
4953 | }
|
---|
4954 |
|
---|
4955 | /**
|
---|
4956 | * Safely extracts not more than the first $count characters from html string.
|
---|
4957 | *
|
---|
4958 | * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT*
|
---|
4959 | * be counted as one character. For example & will be counted as 4, < as
|
---|
4960 | * 3, etc.
|
---|
4961 | *
|
---|
4962 | * @since 2.5.0
|
---|
4963 | *
|
---|
4964 | * @param string $str String to get the excerpt from.
|
---|
4965 | * @param int $count Maximum number of characters to take.
|
---|
4966 | * @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string.
|
---|
4967 | * @return string The excerpt.
|
---|
4968 | */
|
---|
4969 | function wp_html_excerpt( $str, $count, $more = null ) {
|
---|
4970 | if ( null === $more ) {
|
---|
4971 | $more = '';
|
---|
4972 | }
|
---|
4973 | $str = wp_strip_all_tags( $str, true );
|
---|
4974 | $excerpt = mb_substr( $str, 0, $count );
|
---|
4975 | // remove part of an entity at the end
|
---|
4976 | $excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt );
|
---|
4977 | if ( $str != $excerpt ) {
|
---|
4978 | $excerpt = trim( $excerpt ) . $more;
|
---|
4979 | }
|
---|
4980 | return $excerpt;
|
---|
4981 | }
|
---|
4982 |
|
---|
4983 | /**
|
---|
4984 | * Add a Base url to relative links in passed content.
|
---|
4985 | *
|
---|
4986 | * By default it supports the 'src' and 'href' attributes. However this can be
|
---|
4987 | * changed via the 3rd param.
|
---|
4988 | *
|
---|
4989 | * @since 2.7.0
|
---|
4990 | *
|
---|
4991 | * @global string $_links_add_base
|
---|
4992 | *
|
---|
4993 | * @param string $content String to search for links in.
|
---|
4994 | * @param string $base The base URL to prefix to links.
|
---|
4995 | * @param array $attrs The attributes which should be processed.
|
---|
4996 | * @return string The processed content.
|
---|
4997 | */
|
---|
4998 | function links_add_base_url( $content, $base, $attrs = array( 'src', 'href' ) ) {
|
---|
4999 | global $_links_add_base;
|
---|
5000 | $_links_add_base = $base;
|
---|
5001 | $attrs = implode( '|', (array) $attrs );
|
---|
5002 | return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content );
|
---|
5003 | }
|
---|
5004 |
|
---|
5005 | /**
|
---|
5006 | * Callback to add a base url to relative links in passed content.
|
---|
5007 | *
|
---|
5008 | * @since 2.7.0
|
---|
5009 | * @access private
|
---|
5010 | *
|
---|
5011 | * @global string $_links_add_base
|
---|
5012 | *
|
---|
5013 | * @param string $m The matched link.
|
---|
5014 | * @return string The processed link.
|
---|
5015 | */
|
---|
5016 | function _links_add_base( $m ) {
|
---|
5017 | global $_links_add_base;
|
---|
5018 | //1 = attribute name 2 = quotation mark 3 = URL
|
---|
5019 | return $m[1] . '=' . $m[2] .
|
---|
5020 | ( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols() ) ?
|
---|
5021 | $m[3] :
|
---|
5022 | WP_Http::make_absolute_url( $m[3], $_links_add_base )
|
---|
5023 | )
|
---|
5024 | . $m[2];
|
---|
5025 | }
|
---|
5026 |
|
---|
5027 | /**
|
---|
5028 | * Adds a Target attribute to all links in passed content.
|
---|
5029 | *
|
---|
5030 | * This function by default only applies to `<a>` tags, however this can be
|
---|
5031 | * modified by the 3rd param.
|
---|
5032 | *
|
---|
5033 | * *NOTE:* Any current target attributed will be stripped and replaced.
|
---|
5034 | *
|
---|
5035 | * @since 2.7.0
|
---|
5036 | *
|
---|
5037 | * @global string $_links_add_target
|
---|
5038 | *
|
---|
5039 | * @param string $content String to search for links in.
|
---|
5040 | * @param string $target The Target to add to the links.
|
---|
5041 | * @param array $tags An array of tags to apply to.
|
---|
5042 | * @return string The processed content.
|
---|
5043 | */
|
---|
5044 | function links_add_target( $content, $target = '_blank', $tags = array( 'a' ) ) {
|
---|
5045 | global $_links_add_target;
|
---|
5046 | $_links_add_target = $target;
|
---|
5047 | $tags = implode( '|', (array) $tags );
|
---|
5048 | return preg_replace_callback( "!<($tags)([^>]*)>!i", '_links_add_target', $content );
|
---|
5049 | }
|
---|
5050 |
|
---|
5051 | /**
|
---|
5052 | * Callback to add a target attribute to all links in passed content.
|
---|
5053 | *
|
---|
5054 | * @since 2.7.0
|
---|
5055 | * @access private
|
---|
5056 | *
|
---|
5057 | * @global string $_links_add_target
|
---|
5058 | *
|
---|
5059 | * @param string $m The matched link.
|
---|
5060 | * @return string The processed link.
|
---|
5061 | */
|
---|
5062 | function _links_add_target( $m ) {
|
---|
5063 | global $_links_add_target;
|
---|
5064 | $tag = $m[1];
|
---|
5065 | $link = preg_replace( '|( target=([\'"])(.*?)\2)|i', '', $m[2] );
|
---|
5066 | return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">';
|
---|
5067 | }
|
---|
5068 |
|
---|
5069 | /**
|
---|
5070 | * Normalize EOL characters and strip duplicate whitespace.
|
---|
5071 | *
|
---|
5072 | * @since 2.7.0
|
---|
5073 | *
|
---|
5074 | * @param string $str The string to normalize.
|
---|
5075 | * @return string The normalized string.
|
---|
5076 | */
|
---|
5077 | function normalize_whitespace( $str ) {
|
---|
5078 | $str = trim( $str );
|
---|
5079 | $str = str_replace( "\r", "\n", $str );
|
---|
5080 | $str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
|
---|
5081 | return $str;
|
---|
5082 | }
|
---|
5083 |
|
---|
5084 | /**
|
---|
5085 | * Properly strip all HTML tags including script and style
|
---|
5086 | *
|
---|
5087 | * This differs from strip_tags() because it removes the contents of
|
---|
5088 | * the `<script>` and `<style>` tags. E.g. `strip_tags( '<script>something</script>' )`
|
---|
5089 | * will return 'something'. wp_strip_all_tags will return ''
|
---|
5090 | *
|
---|
5091 | * @since 2.9.0
|
---|
5092 | *
|
---|
5093 | * @param string $string String containing HTML tags
|
---|
5094 | * @param bool $remove_breaks Optional. Whether to remove left over line breaks and white space chars
|
---|
5095 | * @return string The processed string.
|
---|
5096 | */
|
---|
5097 | function wp_strip_all_tags( $string, $remove_breaks = false ) {
|
---|
5098 | $string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
|
---|
5099 | $string = strip_tags( $string );
|
---|
5100 |
|
---|
5101 | if ( $remove_breaks ) {
|
---|
5102 | $string = preg_replace( '/[\r\n\t ]+/', ' ', $string );
|
---|
5103 | }
|
---|
5104 |
|
---|
5105 | return trim( $string );
|
---|
5106 | }
|
---|
5107 |
|
---|
5108 | /**
|
---|
5109 | * Sanitizes a string from user input or from the database.
|
---|
5110 | *
|
---|
5111 | * - Checks for invalid UTF-8,
|
---|
5112 | * - Converts single `<` characters to entities
|
---|
5113 | * - Strips all tags
|
---|
5114 | * - Removes line breaks, tabs, and extra whitespace
|
---|
5115 | * - Strips octets
|
---|
5116 | *
|
---|
5117 | * @since 2.9.0
|
---|
5118 | *
|
---|
5119 | * @see sanitize_textarea_field()
|
---|
5120 | * @see wp_check_invalid_utf8()
|
---|
5121 | * @see wp_strip_all_tags()
|
---|
5122 | *
|
---|
5123 | * @param string $str String to sanitize.
|
---|
5124 | * @return string Sanitized string.
|
---|
5125 | */
|
---|
5126 | function sanitize_text_field( $str ) {
|
---|
5127 | $filtered = _sanitize_text_fields( $str, false );
|
---|
5128 |
|
---|
5129 | /**
|
---|
5130 | * Filters a sanitized text field string.
|
---|
5131 | *
|
---|
5132 | * @since 2.9.0
|
---|
5133 | *
|
---|
5134 | * @param string $filtered The sanitized string.
|
---|
5135 | * @param string $str The string prior to being sanitized.
|
---|
5136 | */
|
---|
5137 | return apply_filters( 'sanitize_text_field', $filtered, $str );
|
---|
5138 | }
|
---|
5139 |
|
---|
5140 | /**
|
---|
5141 | * Sanitizes a multiline string from user input or from the database.
|
---|
5142 | *
|
---|
5143 | * The function is like sanitize_text_field(), but preserves
|
---|
5144 | * new lines (\n) and other whitespace, which are legitimate
|
---|
5145 | * input in textarea elements.
|
---|
5146 | *
|
---|
5147 | * @see sanitize_text_field()
|
---|
5148 | *
|
---|
5149 | * @since 4.7.0
|
---|
5150 | *
|
---|
5151 | * @param string $str String to sanitize.
|
---|
5152 | * @return string Sanitized string.
|
---|
5153 | */
|
---|
5154 | function sanitize_textarea_field( $str ) {
|
---|
5155 | $filtered = _sanitize_text_fields( $str, true );
|
---|
5156 |
|
---|
5157 | /**
|
---|
5158 | * Filters a sanitized textarea field string.
|
---|
5159 | *
|
---|
5160 | * @since 4.7.0
|
---|
5161 | *
|
---|
5162 | * @param string $filtered The sanitized string.
|
---|
5163 | * @param string $str The string prior to being sanitized.
|
---|
5164 | */
|
---|
5165 | return apply_filters( 'sanitize_textarea_field', $filtered, $str );
|
---|
5166 | }
|
---|
5167 |
|
---|
5168 | /**
|
---|
5169 | * Internal helper function to sanitize a string from user input or from the db
|
---|
5170 | *
|
---|
5171 | * @since 4.7.0
|
---|
5172 | * @access private
|
---|
5173 | *
|
---|
5174 | * @param string $str String to sanitize.
|
---|
5175 | * @param bool $keep_newlines optional Whether to keep newlines. Default: false.
|
---|
5176 | * @return string Sanitized string.
|
---|
5177 | */
|
---|
5178 | function _sanitize_text_fields( $str, $keep_newlines = false ) {
|
---|
5179 | if ( is_object( $str ) || is_array( $str ) ) {
|
---|
5180 | return '';
|
---|
5181 | }
|
---|
5182 |
|
---|
5183 | $str = (string) $str;
|
---|
5184 |
|
---|
5185 | $filtered = wp_check_invalid_utf8( $str );
|
---|
5186 |
|
---|
5187 | if ( strpos( $filtered, '<' ) !== false ) {
|
---|
5188 | $filtered = wp_pre_kses_less_than( $filtered );
|
---|
5189 | // This will strip extra whitespace for us.
|
---|
5190 | $filtered = wp_strip_all_tags( $filtered, false );
|
---|
5191 |
|
---|
5192 | // Use html entities in a special case to make sure no later
|
---|
5193 | // newline stripping stage could lead to a functional tag
|
---|
5194 | $filtered = str_replace( "<\n", "<\n", $filtered );
|
---|
5195 | }
|
---|
5196 |
|
---|
5197 | if ( ! $keep_newlines ) {
|
---|
5198 | $filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
|
---|
5199 | }
|
---|
5200 | $filtered = trim( $filtered );
|
---|
5201 |
|
---|
5202 | $found = false;
|
---|
5203 | while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $match ) ) {
|
---|
5204 | $filtered = str_replace( $match[0], '', $filtered );
|
---|
5205 | $found = true;
|
---|
5206 | }
|
---|
5207 |
|
---|
5208 | if ( $found ) {
|
---|
5209 | // Strip out the whitespace that may now exist after removing the octets.
|
---|
5210 | $filtered = trim( preg_replace( '/ +/', ' ', $filtered ) );
|
---|
5211 | }
|
---|
5212 |
|
---|
5213 | return $filtered;
|
---|
5214 | }
|
---|
5215 |
|
---|
5216 | /**
|
---|
5217 | * i18n friendly version of basename()
|
---|
5218 | *
|
---|
5219 | * @since 3.1.0
|
---|
5220 | *
|
---|
5221 | * @param string $path A path.
|
---|
5222 | * @param string $suffix If the filename ends in suffix this will also be cut off.
|
---|
5223 | * @return string
|
---|
5224 | */
|
---|
5225 | function wp_basename( $path, $suffix = '' ) {
|
---|
5226 | return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );
|
---|
5227 | }
|
---|
5228 |
|
---|
5229 | // phpcs:disable WordPress.WP.CapitalPDangit.Misspelled, WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid -- 8-)
|
---|
5230 | /**
|
---|
5231 | * Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence).
|
---|
5232 | *
|
---|
5233 | * Violating our coding standards for a good function name.
|
---|
5234 | *
|
---|
5235 | * @since 3.0.0
|
---|
5236 | *
|
---|
5237 | * @staticvar string|false $dblq
|
---|
5238 | *
|
---|
5239 | * @param string $text The text to be modified.
|
---|
5240 | * @return string The modified text.
|
---|
5241 | */
|
---|
5242 | function capital_P_dangit( $text ) {
|
---|
5243 | // Simple replacement for titles
|
---|
5244 | $current_filter = current_filter();
|
---|
5245 | if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) {
|
---|
5246 | return str_replace( 'Wordpress', 'WordPress', $text );
|
---|
5247 | }
|
---|
5248 | // Still here? Use the more judicious replacement
|
---|
5249 | static $dblq = false;
|
---|
5250 | if ( false === $dblq ) {
|
---|
5251 | $dblq = _x( '“', 'opening curly double quote' );
|
---|
5252 | }
|
---|
5253 | return str_replace(
|
---|
5254 | array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ),
|
---|
5255 | array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ),
|
---|
5256 | $text
|
---|
5257 | );
|
---|
5258 | }
|
---|
5259 | // phpcs:enable
|
---|
5260 |
|
---|
5261 | /**
|
---|
5262 | * Sanitize a mime type
|
---|
5263 | *
|
---|
5264 | * @since 3.1.3
|
---|
5265 | *
|
---|
5266 | * @param string $mime_type Mime type
|
---|
5267 | * @return string Sanitized mime type
|
---|
5268 | */
|
---|
5269 | function sanitize_mime_type( $mime_type ) {
|
---|
5270 | $sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type );
|
---|
5271 | /**
|
---|
5272 | * Filters a mime type following sanitization.
|
---|
5273 | *
|
---|
5274 | * @since 3.1.3
|
---|
5275 | *
|
---|
5276 | * @param string $sani_mime_type The sanitized mime type.
|
---|
5277 | * @param string $mime_type The mime type prior to sanitization.
|
---|
5278 | */
|
---|
5279 | return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type );
|
---|
5280 | }
|
---|
5281 |
|
---|
5282 | /**
|
---|
5283 | * Sanitize space or carriage return separated URLs that are used to send trackbacks.
|
---|
5284 | *
|
---|
5285 | * @since 3.4.0
|
---|
5286 | *
|
---|
5287 | * @param string $to_ping Space or carriage return separated URLs
|
---|
5288 | * @return string URLs starting with the http or https protocol, separated by a carriage return.
|
---|
5289 | */
|
---|
5290 | function sanitize_trackback_urls( $to_ping ) {
|
---|
5291 | $urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY );
|
---|
5292 | foreach ( $urls_to_ping as $k => $url ) {
|
---|
5293 | if ( ! preg_match( '#^https?://.#i', $url ) ) {
|
---|
5294 | unset( $urls_to_ping[ $k ] );
|
---|
5295 | }
|
---|
5296 | }
|
---|
5297 | $urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping );
|
---|
5298 | $urls_to_ping = implode( "\n", $urls_to_ping );
|
---|
5299 | /**
|
---|
5300 | * Filters a list of trackback URLs following sanitization.
|
---|
5301 | *
|
---|
5302 | * The string returned here consists of a space or carriage return-delimited list
|
---|
5303 | * of trackback URLs.
|
---|
5304 | *
|
---|
5305 | * @since 3.4.0
|
---|
5306 | *
|
---|
5307 | * @param string $urls_to_ping Sanitized space or carriage return separated URLs.
|
---|
5308 | * @param string $to_ping Space or carriage return separated URLs before sanitization.
|
---|
5309 | */
|
---|
5310 | return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping );
|
---|
5311 | }
|
---|
5312 |
|
---|
5313 | /**
|
---|
5314 | * Add slashes to a string or array of strings.
|
---|
5315 | *
|
---|
5316 | * This should be used when preparing data for core API that expects slashed data.
|
---|
5317 | * This should not be used to escape data going directly into an SQL query.
|
---|
5318 | *
|
---|
5319 | * @since 3.6.0
|
---|
5320 | *
|
---|
5321 | * @param string|array $value String or array of strings to slash.
|
---|
5322 | * @return string|array Slashed $value
|
---|
5323 | */
|
---|
5324 | function wp_slash( $value ) {
|
---|
5325 | if ( is_array( $value ) ) {
|
---|
5326 | foreach ( $value as $k => $v ) {
|
---|
5327 | if ( is_array( $v ) ) {
|
---|
5328 | $value[ $k ] = wp_slash( $v );
|
---|
5329 | } else {
|
---|
5330 | $value[ $k ] = addslashes( $v );
|
---|
5331 | }
|
---|
5332 | }
|
---|
5333 | } else {
|
---|
5334 | $value = addslashes( $value );
|
---|
5335 | }
|
---|
5336 |
|
---|
5337 | return $value;
|
---|
5338 | }
|
---|
5339 |
|
---|
5340 | /**
|
---|
5341 | * Remove slashes from a string or array of strings.
|
---|
5342 | *
|
---|
5343 | * This should be used to remove slashes from data passed to core API that
|
---|
5344 | * expects data to be unslashed.
|
---|
5345 | *
|
---|
5346 | * @since 3.6.0
|
---|
5347 | *
|
---|
5348 | * @param string|array $value String or array of strings to unslash.
|
---|
5349 | * @return string|array Unslashed $value
|
---|
5350 | */
|
---|
5351 | function wp_unslash( $value ) {
|
---|
5352 | return stripslashes_deep( $value );
|
---|
5353 | }
|
---|
5354 |
|
---|
5355 | /**
|
---|
5356 | * Extract and return the first URL from passed content.
|
---|
5357 | *
|
---|
5358 | * @since 3.6.0
|
---|
5359 | *
|
---|
5360 | * @param string $content A string which might contain a URL.
|
---|
5361 | * @return string|false The found URL.
|
---|
5362 | */
|
---|
5363 | function get_url_in_content( $content ) {
|
---|
5364 | if ( empty( $content ) ) {
|
---|
5365 | return false;
|
---|
5366 | }
|
---|
5367 |
|
---|
5368 | if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) {
|
---|
5369 | return esc_url_raw( $matches[2] );
|
---|
5370 | }
|
---|
5371 |
|
---|
5372 | return false;
|
---|
5373 | }
|
---|
5374 |
|
---|
5375 | /**
|
---|
5376 | * Returns the regexp for common whitespace characters.
|
---|
5377 | *
|
---|
5378 | * By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp.
|
---|
5379 | * This is designed to replace the PCRE \s sequence. In ticket #22692, that
|
---|
5380 | * sequence was found to be unreliable due to random inclusion of the A0 byte.
|
---|
5381 | *
|
---|
5382 | * @since 4.0.0
|
---|
5383 | *
|
---|
5384 | * @staticvar string $spaces
|
---|
5385 | *
|
---|
5386 | * @return string The spaces regexp.
|
---|
5387 | */
|
---|
5388 | function wp_spaces_regexp() {
|
---|
5389 | static $spaces = '';
|
---|
5390 |
|
---|
5391 | if ( empty( $spaces ) ) {
|
---|
5392 | /**
|
---|
5393 | * Filters the regexp for common whitespace characters.
|
---|
5394 | *
|
---|
5395 | * This string is substituted for the \s sequence as needed in regular
|
---|
5396 | * expressions. For websites not written in English, different characters
|
---|
5397 | * may represent whitespace. For websites not encoded in UTF-8, the 0xC2 0xA0
|
---|
5398 | * sequence may not be in use.
|
---|
5399 | *
|
---|
5400 | * @since 4.0.0
|
---|
5401 | *
|
---|
5402 | * @param string $spaces Regexp pattern for matching common whitespace characters.
|
---|
5403 | */
|
---|
5404 | $spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0| ' );
|
---|
5405 | }
|
---|
5406 |
|
---|
5407 | return $spaces;
|
---|
5408 | }
|
---|
5409 |
|
---|
5410 | /**
|
---|
5411 | * Print the important emoji-related styles.
|
---|
5412 | *
|
---|
5413 | * @since 4.2.0
|
---|
5414 | *
|
---|
5415 | * @staticvar bool $printed
|
---|
5416 | */
|
---|
5417 | function print_emoji_styles() {
|
---|
5418 | static $printed = false;
|
---|
5419 |
|
---|
5420 | if ( $printed ) {
|
---|
5421 | return;
|
---|
5422 | }
|
---|
5423 |
|
---|
5424 | $printed = true;
|
---|
5425 | ?>
|
---|
5426 | <style type="text/css">
|
---|
5427 | img.wp-smiley,
|
---|
5428 | img.emoji {
|
---|
5429 | display: inline !important;
|
---|
5430 | border: none !important;
|
---|
5431 | box-shadow: none !important;
|
---|
5432 | height: 1em !important;
|
---|
5433 | width: 1em !important;
|
---|
5434 | margin: 0 .07em !important;
|
---|
5435 | vertical-align: -0.1em !important;
|
---|
5436 | background: none !important;
|
---|
5437 | padding: 0 !important;
|
---|
5438 | }
|
---|
5439 | </style>
|
---|
5440 | <?php
|
---|
5441 | }
|
---|
5442 |
|
---|
5443 | /**
|
---|
5444 | * Print the inline Emoji detection script if it is not already printed.
|
---|
5445 | *
|
---|
5446 | * @since 4.2.0
|
---|
5447 | * @staticvar bool $printed
|
---|
5448 | */
|
---|
5449 | function print_emoji_detection_script() {
|
---|
5450 | static $printed = false;
|
---|
5451 |
|
---|
5452 | if ( $printed ) {
|
---|
5453 | return;
|
---|
5454 | }
|
---|
5455 |
|
---|
5456 | $printed = true;
|
---|
5457 |
|
---|
5458 | _print_emoji_detection_script();
|
---|
5459 | }
|
---|
5460 |
|
---|
5461 | /**
|
---|
5462 | * Prints inline Emoji dection script
|
---|
5463 | *
|
---|
5464 | * @ignore
|
---|
5465 | * @since 4.6.0
|
---|
5466 | * @access private
|
---|
5467 | */
|
---|
5468 | function _print_emoji_detection_script() {
|
---|
5469 | $settings = array(
|
---|
5470 | /**
|
---|
5471 | * Filters the URL where emoji png images are hosted.
|
---|
5472 | *
|
---|
5473 | * @since 4.2.0
|
---|
5474 | *
|
---|
5475 | * @param string The emoji base URL for png images.
|
---|
5476 | */
|
---|
5477 | 'baseUrl' => apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/12.0.0-1/72x72/' ),
|
---|
5478 |
|
---|
5479 | /**
|
---|
5480 | * Filters the extension of the emoji png files.
|
---|
5481 | *
|
---|
5482 | * @since 4.2.0
|
---|
5483 | *
|
---|
5484 | * @param string The emoji extension for png files. Default .png.
|
---|
5485 | */
|
---|
5486 | 'ext' => apply_filters( 'emoji_ext', '.png' ),
|
---|
5487 |
|
---|
5488 | /**
|
---|
5489 | * Filters the URL where emoji SVG images are hosted.
|
---|
5490 | *
|
---|
5491 | * @since 4.6.0
|
---|
5492 | *
|
---|
5493 | * @param string The emoji base URL for svg images.
|
---|
5494 | */
|
---|
5495 | 'svgUrl' => apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/12.0.0-1/svg/' ),
|
---|
5496 |
|
---|
5497 | /**
|
---|
5498 | * Filters the extension of the emoji SVG files.
|
---|
5499 | *
|
---|
5500 | * @since 4.6.0
|
---|
5501 | *
|
---|
5502 | * @param string The emoji extension for svg files. Default .svg.
|
---|
5503 | */
|
---|
5504 | 'svgExt' => apply_filters( 'emoji_svg_ext', '.svg' ),
|
---|
5505 | );
|
---|
5506 |
|
---|
5507 | $version = 'ver=' . get_bloginfo( 'version' );
|
---|
5508 |
|
---|
5509 | if ( SCRIPT_DEBUG ) {
|
---|
5510 | $settings['source'] = array(
|
---|
5511 | /** This filter is documented in wp-includes/class.wp-scripts.php */
|
---|
5512 | 'wpemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji.js?$version" ), 'wpemoji' ),
|
---|
5513 | /** This filter is documented in wp-includes/class.wp-scripts.php */
|
---|
5514 | 'twemoji' => apply_filters( 'script_loader_src', includes_url( "js/twemoji.js?$version" ), 'twemoji' ),
|
---|
5515 | );
|
---|
5516 |
|
---|
5517 | ?>
|
---|
5518 | <script type="text/javascript">
|
---|
5519 | window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>;
|
---|
5520 | <?php readfile( ABSPATH . WPINC . '/js/wp-emoji-loader.js' ); ?>
|
---|
5521 | </script>
|
---|
5522 | <?php
|
---|
5523 | } else {
|
---|
5524 | $settings['source'] = array(
|
---|
5525 | /** This filter is documented in wp-includes/class.wp-scripts.php */
|
---|
5526 | 'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ),
|
---|
5527 | );
|
---|
5528 |
|
---|
5529 | /*
|
---|
5530 | * If you're looking at a src version of this file, you'll see an "include"
|
---|
5531 | * statement below. This is used by the `grunt build` process to directly
|
---|
5532 | * include a minified version of wp-emoji-loader.js, instead of using the
|
---|
5533 | * readfile() method from above.
|
---|
5534 | *
|
---|
5535 | * If you're looking at a build version of this file, you'll see a string of
|
---|
5536 | * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
|
---|
5537 | * and edit wp-emoji-loader.js directly.
|
---|
5538 | */
|
---|
5539 | ?>
|
---|
5540 | <script type="text/javascript">
|
---|
5541 | window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>;
|
---|
5542 | !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);
|
---|
5543 | </script>
|
---|
5544 | <?php
|
---|
5545 | }
|
---|
5546 | }
|
---|
5547 |
|
---|
5548 | /**
|
---|
5549 | * Convert emoji characters to their equivalent HTML entity.
|
---|
5550 | *
|
---|
5551 | * This allows us to store emoji in a DB using the utf8 character set.
|
---|
5552 | *
|
---|
5553 | * @since 4.2.0
|
---|
5554 | *
|
---|
5555 | * @param string $content The content to encode.
|
---|
5556 | * @return string The encoded content.
|
---|
5557 | */
|
---|
5558 | function wp_encode_emoji( $content ) {
|
---|
5559 | $emoji = _wp_emoji_list( 'partials' );
|
---|
5560 | $compat = version_compare( phpversion(), '5.4', '<' );
|
---|
5561 |
|
---|
5562 | foreach ( $emoji as $emojum ) {
|
---|
5563 | if ( $compat ) {
|
---|
5564 | $emoji_char = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' );
|
---|
5565 | } else {
|
---|
5566 | $emoji_char = html_entity_decode( $emojum );
|
---|
5567 | }
|
---|
5568 | if ( false !== strpos( $content, $emoji_char ) ) {
|
---|
5569 | $content = preg_replace( "/$emoji_char/", $emojum, $content );
|
---|
5570 | }
|
---|
5571 | }
|
---|
5572 |
|
---|
5573 | return $content;
|
---|
5574 | }
|
---|
5575 |
|
---|
5576 | /**
|
---|
5577 | * Convert emoji to a static img element.
|
---|
5578 | *
|
---|
5579 | * @since 4.2.0
|
---|
5580 | *
|
---|
5581 | * @param string $text The content to encode.
|
---|
5582 | * @return string The encoded content.
|
---|
5583 | */
|
---|
5584 | function wp_staticize_emoji( $text ) {
|
---|
5585 | if ( false === strpos( $text, '&#x' ) ) {
|
---|
5586 | if ( ( function_exists( 'mb_check_encoding' ) && mb_check_encoding( $text, 'ASCII' ) ) || ! preg_match( '/[^\x00-\x7F]/', $text ) ) {
|
---|
5587 | // The text doesn't contain anything that might be emoji, so we can return early.
|
---|
5588 | return $text;
|
---|
5589 | } else {
|
---|
5590 | $encoded_text = wp_encode_emoji( $text );
|
---|
5591 | if ( $encoded_text === $text ) {
|
---|
5592 | return $encoded_text;
|
---|
5593 | }
|
---|
5594 |
|
---|
5595 | $text = $encoded_text;
|
---|
5596 | }
|
---|
5597 | }
|
---|
5598 |
|
---|
5599 | $emoji = _wp_emoji_list( 'entities' );
|
---|
5600 |
|
---|
5601 | // Quickly narrow down the list of emoji that might be in the text and need replacing.
|
---|
5602 | $possible_emoji = array();
|
---|
5603 | $compat = version_compare( phpversion(), '5.4', '<' );
|
---|
5604 | foreach ( $emoji as $emojum ) {
|
---|
5605 | if ( false !== strpos( $text, $emojum ) ) {
|
---|
5606 | if ( $compat ) {
|
---|
5607 | $possible_emoji[ $emojum ] = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' );
|
---|
5608 | } else {
|
---|
5609 | $possible_emoji[ $emojum ] = html_entity_decode( $emojum );
|
---|
5610 | }
|
---|
5611 | }
|
---|
5612 | }
|
---|
5613 |
|
---|
5614 | if ( ! $possible_emoji ) {
|
---|
5615 | return $text;
|
---|
5616 | }
|
---|
5617 |
|
---|
5618 | /** This filter is documented in wp-includes/formatting.php */
|
---|
5619 | $cdn_url = apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/12.0.0-1/72x72/' );
|
---|
5620 |
|
---|
5621 | /** This filter is documented in wp-includes/formatting.php */
|
---|
5622 | $ext = apply_filters( 'emoji_ext', '.png' );
|
---|
5623 |
|
---|
5624 | $output = '';
|
---|
5625 | /*
|
---|
5626 | * HTML loop taken from smiley function, which was taken from texturize function.
|
---|
5627 | * It'll never be consolidated.
|
---|
5628 | *
|
---|
5629 | * First, capture the tags as well as in between.
|
---|
5630 | */
|
---|
5631 | $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE );
|
---|
5632 | $stop = count( $textarr );
|
---|
5633 |
|
---|
5634 | // Ignore processing of specific tags.
|
---|
5635 | $tags_to_ignore = 'code|pre|style|script|textarea';
|
---|
5636 | $ignore_block_element = '';
|
---|
5637 |
|
---|
5638 | for ( $i = 0; $i < $stop; $i++ ) {
|
---|
5639 | $content = $textarr[ $i ];
|
---|
5640 |
|
---|
5641 | // If we're in an ignore block, wait until we find its closing tag.
|
---|
5642 | if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) {
|
---|
5643 | $ignore_block_element = $matches[1];
|
---|
5644 | }
|
---|
5645 |
|
---|
5646 | // If it's not a tag and not in ignore block.
|
---|
5647 | if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] && false !== strpos( $content, '&#x' ) ) {
|
---|
5648 | foreach ( $possible_emoji as $emojum => $emoji_char ) {
|
---|
5649 | if ( false === strpos( $content, $emojum ) ) {
|
---|
5650 | continue;
|
---|
5651 | }
|
---|
5652 |
|
---|
5653 | $file = str_replace( ';&#x', '-', $emojum );
|
---|
5654 | $file = str_replace( array( '&#x', ';' ), '', $file );
|
---|
5655 |
|
---|
5656 | $entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $file . $ext, $emoji_char );
|
---|
5657 |
|
---|
5658 | $content = str_replace( $emojum, $entity, $content );
|
---|
5659 | }
|
---|
5660 | }
|
---|
5661 |
|
---|
5662 | // Did we exit ignore block.
|
---|
5663 | if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) {
|
---|
5664 | $ignore_block_element = '';
|
---|
5665 | }
|
---|
5666 |
|
---|
5667 | $output .= $content;
|
---|
5668 | }
|
---|
5669 |
|
---|
5670 | // Finally, remove any stray U+FE0F characters
|
---|
5671 | $output = str_replace( '️', '', $output );
|
---|
5672 |
|
---|
5673 | return $output;
|
---|
5674 | }
|
---|
5675 |
|
---|
5676 | /**
|
---|
5677 | * Convert emoji in emails into static images.
|
---|
5678 | *
|
---|
5679 | * @since 4.2.0
|
---|
5680 | *
|
---|
5681 | * @param array $mail The email data array.
|
---|
5682 | * @return array The email data array, with emoji in the message staticized.
|
---|
5683 | */
|
---|
5684 | function wp_staticize_emoji_for_email( $mail ) {
|
---|
5685 | if ( ! isset( $mail['message'] ) ) {
|
---|
5686 | return $mail;
|
---|
5687 | }
|
---|
5688 |
|
---|
5689 | /*
|
---|
5690 | * We can only transform the emoji into images if it's a text/html email.
|
---|
5691 | * To do that, here's a cut down version of the same process that happens
|
---|
5692 | * in wp_mail() - get the Content-Type from the headers, if there is one,
|
---|
5693 | * then pass it through the wp_mail_content_type filter, in case a plugin
|
---|
5694 | * is handling changing the Content-Type.
|
---|
5695 | */
|
---|
5696 | $headers = array();
|
---|
5697 | if ( isset( $mail['headers'] ) ) {
|
---|
5698 | if ( is_array( $mail['headers'] ) ) {
|
---|
5699 | $headers = $mail['headers'];
|
---|
5700 | } else {
|
---|
5701 | $headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) );
|
---|
5702 | }
|
---|
5703 | }
|
---|
5704 |
|
---|
5705 | foreach ( $headers as $header ) {
|
---|
5706 | if ( strpos( $header, ':' ) === false ) {
|
---|
5707 | continue;
|
---|
5708 | }
|
---|
5709 |
|
---|
5710 | // Explode them out.
|
---|
5711 | list( $name, $content ) = explode( ':', trim( $header ), 2 );
|
---|
5712 |
|
---|
5713 | // Cleanup crew.
|
---|
5714 | $name = trim( $name );
|
---|
5715 | $content = trim( $content );
|
---|
5716 |
|
---|
5717 | if ( 'content-type' === strtolower( $name ) ) {
|
---|
5718 | if ( strpos( $content, ';' ) !== false ) {
|
---|
5719 | list( $type, $charset ) = explode( ';', $content );
|
---|
5720 | $content_type = trim( $type );
|
---|
5721 | } else {
|
---|
5722 | $content_type = trim( $content );
|
---|
5723 | }
|
---|
5724 | break;
|
---|
5725 | }
|
---|
5726 | }
|
---|
5727 |
|
---|
5728 | // Set Content-Type if we don't have a content-type from the input headers.
|
---|
5729 | if ( ! isset( $content_type ) ) {
|
---|
5730 | $content_type = 'text/plain';
|
---|
5731 | }
|
---|
5732 |
|
---|
5733 | /** This filter is documented in wp-includes/pluggable.php */
|
---|
5734 | $content_type = apply_filters( 'wp_mail_content_type', $content_type );
|
---|
5735 |
|
---|
5736 | if ( 'text/html' === $content_type ) {
|
---|
5737 | $mail['message'] = wp_staticize_emoji( $mail['message'] );
|
---|
5738 | }
|
---|
5739 |
|
---|
5740 | return $mail;
|
---|
5741 | }
|
---|
5742 |
|
---|
5743 | /**
|
---|
5744 | * Returns arrays of emoji data.
|
---|
5745 | *
|
---|
5746 | * These arrays are automatically built from the regex in twemoji.js - if they need to be updated,
|
---|
5747 | * you should update the regex there, then run the `grunt precommit:emoji` job.
|
---|
5748 | *
|
---|
5749 | * @since 4.9.0
|
---|
5750 | * @access private
|
---|
5751 | *
|
---|
5752 | * @param string $type Optional. Which array type to return. Accepts 'partials' or 'entities', default 'entities'.
|
---|
5753 | * @return array An array to match all emoji that WordPress recognises.
|
---|
5754 | */
|
---|
5755 | function _wp_emoji_list( $type = 'entities' ) {
|
---|
5756 | // Do not remove the START/END comments - they're used to find where to insert the arrays.
|
---|
5757 |
|
---|
5758 | // START: emoji arrays
|
---|
5759 | $entities = array( '👨‍❤️‍💋‍👨', '👩‍❤️‍💋‍👩', '👩‍❤️‍💋‍👨', '🏴󠁧󠁢󠁥󠁮󠁧󠁿', '🏴󠁧󠁢󠁳󠁣󠁴󠁿', '🏴󠁧󠁢󠁷󠁬󠁳󠁿', '🧑🏿‍🤝‍🧑🏻', '🧑🏾‍🤝‍🧑🏾', '🧑🏾‍🤝‍🧑🏽', '🧑🏾‍🤝‍🧑🏼', '🧑🏾‍🤝‍🧑🏻', '🧑🏽‍🤝‍🧑🏽', '🧑🏽‍🤝‍🧑🏼', '🧑🏽‍🤝‍🧑🏻', '🧑🏼‍🤝‍🧑🏼', '🧑🏼‍🤝‍🧑🏻', '🧑🏻‍🤝‍🧑🏻', '👩🏾‍🤝‍👩🏽', '🧑🏿‍🤝‍🧑🏿', '🧑🏿‍🤝‍🧑🏾', '👨🏼‍🤝‍👨🏻', '🧑🏿‍🤝‍🧑🏽', '🧑🏿‍🤝‍🧑🏼', '👩🏻‍🤝‍👨🏼', '👩🏻‍🤝‍👨🏽', '👩🏻‍🤝‍👨🏾', '👩🏻‍🤝‍👨🏿', '👨🏿‍🤝‍👨🏾', '👨🏿‍🤝‍👨🏽', '👨🏿‍🤝‍👨🏼', '👨🏿‍🤝‍👨🏻', '👩🏼‍🤝‍👨🏻', '👩🏼‍🤝‍👨🏽', '👨🏽‍🤝‍👨🏻', '👨🏽‍🤝‍👨🏼', '👩🏿‍🤝‍👩🏾', '👩🏿‍🤝‍👩🏽', '👩🏿‍🤝‍👩🏼', '👩🏿‍🤝‍👩🏻', '👩🏿‍🤝‍👨🏾', '👩🏿‍🤝‍👨🏽', '👩🏿‍🤝‍👨🏼', '👩🏿‍🤝‍👨🏻', '👩🏼‍🤝‍👨🏾', '👩🏾‍🤝‍👩🏼', '👩🏾‍🤝‍👩🏻', '👩🏾‍🤝‍👨🏿', '👩🏾‍🤝‍👨🏽', '👩🏾‍🤝‍👨🏼', '👨🏾‍🤝‍👨🏻', '👨🏾‍🤝‍👨🏼', '👨🏾‍🤝‍👨🏽', '👩🏾‍🤝‍👨🏻', '👩🏽‍🤝‍👩🏼', '👩🏽‍🤝‍👩🏻', '👩🏽‍🤝‍👨🏿', '👩🏽‍🤝‍👨🏾', '👩🏽‍🤝‍👨🏼', '👩🏽‍🤝‍👨🏻', '👩🏼‍🤝‍👩🏻', '👩🏼‍🤝‍👨🏿', '👨‍👨‍👧‍👦', '👩‍👩‍👧‍👦', '👩‍👩‍👧‍👧', '👨‍👨‍👦‍👦', '👩‍👩‍👦‍👦', '👨‍👨‍👧‍👧', '👨‍👩‍👦‍👦', '👨‍👩‍👧‍👦', '👨‍👩‍👧‍👧', '👨‍❤️‍👨', '👩‍❤️‍👨', '👩‍❤️‍👩', '👩‍👦‍👦', '👩‍👩‍👦', '👨‍👨‍👦', '👩‍👧‍👦', '👩‍👧‍👧', '👨‍👨‍👧', '👩‍👩‍👧', '👨‍👩‍👦', '🧑‍🤝‍🧑', '👨‍👦‍👦', '👨‍👩‍👧', '👨‍👧‍👦', '👨‍👧‍👧', '🧗🏽‍♀️', '🧗🏼‍♂️', '🧗🏼‍♀️', '🧗🏻‍♂️', '🧗🏻‍♀️', '👷🏿‍♀️', '💆🏻‍♀️', '🧖🏿‍♂️', '🧖🏿‍♀️', '🧖🏾‍♂️', '🧖🏾‍♀️', '🧖🏽‍♂️', '🧖🏽‍♀️', '🧖🏼‍♂️', '🧖🏼‍♀️', '🧖🏻‍♂️', '🧖🏻‍♀️', '💁🏿‍♀️', '💁🏾‍♂️', '💁🏾‍♀️', '💁🏽‍♂️', '💁🏽‍♀️', '💁🏼‍♂️', '💁🏼‍♀️', '💂🏻‍♀️', '🧝🏿‍♂️', '🧝🏿‍♀️', '🧝🏾‍♂️', '🧝🏾‍♀️', '🧝🏽‍♂️', '🧝🏽‍♀️', '🧝🏼‍♂️', '🧝🏼‍♀️', '👷🏾‍♂️', '👷🏾‍♀️', '🧏🏿‍♂️', '🧏🏿‍♀️', '🧏🏾‍♂️', '🧏🏾‍♀️', '🧏🏽‍♂️', '🧏🏽‍♀️', '🧏🏼‍♂️', '🧏🏼‍♀️', '🧏🏻‍♂️', '🧏🏻‍♀️', '💆🏻‍♂️', '👷🏽‍♂️', '🧎🏿‍♂️', '🧎🏿‍♀️', '🧎🏾‍♂️', '🧎🏾‍♀️', '🧎🏽‍♂️', '🧎🏽‍♀️', '🧎🏼‍♂️', '🧎🏼‍♀️', '🧎🏻‍♂️', '🧎🏻‍♀️', '👷🏽‍♀️', '💆🏼‍♀️', '🧍🏿‍♂️', '🧍🏿‍♀️', '🧍🏾‍♂️', '🧍🏾‍♀️', '🧍🏽‍♂️', '🧍🏽‍♀️', '🧍🏼‍♂️', '🧍🏼‍♀️', '🧍🏻‍♂️', '🧍🏻‍♀️', '👷🏼‍♂️', '👷🏼‍♀️', '🦹🏿‍♂️', '🦹🏿‍♀️', '🦹🏾‍♂️', '🦹🏾‍♀️', '🦹🏽‍♂️', '🦹🏽‍♀️', '🦹🏼‍♂️', '🦹🏼‍♀️', '🦹🏻‍♂️', '🦹🏻‍♀️', '💆🏼‍♂️', '👷🏻‍♂️', '🦸🏿‍♂️', '🦸🏿‍♀️', '🦸🏾‍♂️', '🦸🏾‍♀️', '🦸🏽‍♂️', '🦸🏽‍♀️', '🦸🏼‍♂️', '🦸🏼‍♀️', '🦸🏻‍♂️', '🦸🏻‍♀️', '👷🏻‍♀️', '💆🏽‍♀️', '🤾🏿‍♂️', '🤾🏿‍♀️', '🤾🏾‍♂️', '🤾🏾‍♀️', '🤾🏽‍♂️', '🤾🏽‍♀️', '🤾🏼‍♂️', '🤾🏼‍♀️', '🤾🏻‍♂️', '🤾🏻‍♀️', '💆🏽‍♂️', '💆🏾‍♀️', '🤽🏿‍♂️', '🤽🏿‍♀️', '🤽🏾‍♂️', '🤽🏾‍♀️', '🤽🏽‍♂️', '🤽🏽‍♀️', '🤽🏼‍♂️', '🤽🏼‍♀️', '🤽🏻‍♂️', '🤽🏻‍♀️', '💆🏾‍♂️', '💆🏿‍♀️', '💆🏿‍♂️', '💇🏻‍♀️', '🤹🏿‍♂️', '🤹🏿‍♀️', '🤹🏾‍♂️', '🤹🏾‍♀️', '🤹🏽‍♂️', '🤹🏽‍♀️', '🤹🏼‍♂️', '🤹🏼‍♀️', '🤹🏻‍♂️', '🤹🏻‍♀️', '💇🏻‍♂️', '💇🏼‍♀️', '🤸🏿‍♂️', '🤸🏿‍♀️', '🤸🏾‍♂️', '🤸🏾‍♀️', '🤸🏽‍♂️', '🤸🏽‍♀️', '🤸🏼‍♂️', '🤸🏼‍♀️', '🤸🏻‍♂️', '🤸🏻‍♀️', '💇🏼‍♂️', '💇🏽‍♀️', '🤷🏿‍♂️', '🤷🏿‍♀️', '🤷🏾‍♂️', '🤷🏾‍♀️', '🤷🏽‍♂️', '🤷🏽‍♀️', '🤷🏼‍♂️', '🤷🏼‍♀️', '🤷🏻‍♂️', '🤷🏻‍♀️', '💇🏽‍♂️', '💇🏾‍♀️', '🤵🏿‍♂️', '🤵🏿‍♀️', '🤵🏾‍♂️', '🤵🏾‍♀️', '🤵🏽‍♂️', '🤵🏽‍♀️', '🤵🏼‍♂️', '🤵🏼‍♀️', '🤵🏻‍♂️', '🤵🏻‍♀️', '💇🏾‍♂️', '👳🏿‍♂️', '🤦🏿‍♂️', '🤦🏿‍♀️', '🤦🏾‍♂️', '🏃🏻‍♀️', '🏃🏻‍♂️', '🤦🏾‍♀️', '🏃🏼‍♀️', '🏃🏼‍♂️', '🤦🏽‍♂️', '🏃🏽‍♀️', '🏃🏽‍♂️', '🤦🏽‍♀️', '🏃🏾‍♀️', '🏃🏾‍♂️', '🤦🏼‍♂️', '🏃🏿‍♀️', '🏃🏿‍♂️', '🤦🏼‍♀️', '👳🏿‍♀️', '💇🏿‍♀️', '🏄🏻‍♀️', '🏄🏻‍♂️', '🤦🏻‍♂️', '🏄🏼‍♀️', '🏄🏼‍♂️', '🤦🏻‍♀️', '🏄🏽‍♀️', '🏄🏽‍♂️', '💁🏿‍♂️', '🏄🏾‍♀️', '🏄🏾‍♂️', '👳🏾‍♀️', '🏄🏿‍♀️', '🏄🏿‍♂️', '🚶🏿‍♂️', '💇🏿‍♂️', '👳🏽‍♂️', '🚶🏿‍♀️', '🚶🏾‍♂️', '🚶🏾‍♀️', '🚶🏽‍♂️', '🚶🏽‍♀️', '🏊🏻‍♀️', '🏊🏻‍♂️', '🚶🏼‍♂️', '🏊🏼‍♀️', '🏊🏼‍♂️', '🚶🏼‍♀️', '🏊🏽‍♀️', '🏊🏽‍♂️', '🚶🏻‍♂️', '🏊🏾‍♀️', '🏊🏾‍♂️', '🚶🏻‍♀️', '🏊🏿‍♀️', '🏊🏿‍♂️', '👳🏽‍&#ð |
---|
5760 | ñð |
---|
5761 | ñ@²Ç°«ÇXññ@ñf;', '🏋🏻‍♀️', '🏋🏻‍♂️', '👳🏻‍♂️', '🏋🏼‍♀️', '🏋🏼‍♂️', '🚵🏿‍♂️', '🏋🏽‍♀️', '🏋🏽‍♂️', '🚵🏿‍♀️', '🏋🏾‍♀️', '🏋🏾‍♂️', '🚵🏾‍♂️', '🏋🏿‍♀️', '🏋🏿‍♂️', '🚵🏾‍♀️', '🏌🏻‍♀️', '🏌🏻‍♂️', '🚵🏽‍♂️', '🏌🏼‍♀️', '🏌🏼‍♂️', '🚵🏽‍♀️', '🏌🏽‍♀️', '🏌🏽‍♂️', '🚵🏼‍♂️', '🏌🏾‍♀️', '🏌🏾‍♂️', '🚵🏼‍♀️', '🏌🏿‍♀️', '🏌🏿‍♂️', '🚵🏻‍♂️', '👳🏻‍♀️', '🕴🏻‍♀️', '🧝🏻‍♂️', '🧝🏻‍♀️', '💁🏻‍♂️', '🚵🏻‍♀️', '🕴🏻‍♂️', '🕴🏼‍♀️', '🚴🏿‍♂️', '🚴🏿‍♀️', '🚴🏾‍♂️', '🚴🏾‍♀️', '🚴🏽‍♂️', '🚴🏽‍♀️', '🚴🏼‍♂️', '🚴🏼‍♀️', '🚴🏻‍♂️', '🚴🏻‍♀️', '🕴🏼‍♂️', '🕴🏽‍♀️', '🚣🏿‍♂️', '🚣🏿‍♀️', '🚣🏾‍♂️', '🚣🏾‍♀️', '🚣🏽‍♂️', '🚣🏽‍♀️', '🚣🏼‍♂️', '🚣🏼‍♀️', '🚣🏻‍♂️', '🚣🏻‍♀️', '🕴🏽‍♂️', '👱🏿‍♂️', '🙎🏿‍♂️', '🙎🏿‍♀️', '🙎🏾‍♂️', '🙎🏾‍♀️', '🙎🏽‍♂️', '🙎🏽‍♀️', '🙎🏼‍♂️', '🙎🏼‍♀️', '🙎🏻‍♂️', '🙎🏻‍♀️', '👱🏿‍♀️', '🕴🏾‍♀️', '🙍🏿‍♂️', '🙍🏿‍♀️', '🙍🏾‍♂️', '🙍🏾‍♀️', '🙍🏽‍♂️', '🙍🏽‍♀️', '🙍🏼‍♂️', '🙍🏼‍♀️', '🙍🏻‍♂️', '🙍🏻‍♀️', '👱🏾‍♂️', '👱🏾‍♀️', '🙋🏿‍♂️', '🙋🏿‍♀️', '🙋🏾‍♂️', '🙋🏾‍♀️', '🙋🏽‍♂️', '🙋🏽‍♀️', '🙋🏼‍♂️', '🙋🏼‍♀️', '🙋🏻‍♂️', '🙋🏻‍♀️', '🕴🏾‍♂️', '👱🏽‍♂️', '🙇🏿‍♂️', '🙇🏿‍♀️', '🙇🏾‍♂️', '🙇🏾‍♀️', '🙇🏽‍♂️', '🙇🏽‍♀️', '🙇🏼‍♂️', '🙇🏼‍♀️', '🙇🏻‍♂️', '🙇🏻‍♀️', '👱🏽‍♀️', '🕴🏿‍♀️', '👱🏼‍♂️', '👱🏼‍♀️', '🕴🏿‍♂️', '👱🏻‍♂️', '👱🏻‍♀️', '🕵🏻‍♀️', '🕵🏻‍♂️', '🕵🏼‍♀️', '🕵🏼‍♂️', '👮🏿‍♂️', '👮🏿‍♀️', '🕵🏽‍♀️', '👮🏾‍♂️', '👮🏾‍♀️', '🕵🏽‍♂️', '👮🏽‍♂️', '👮🏽‍♀️', '👨🏻‍⚕️', '👨🏻‍⚖️', '👨🏻‍✈️', '🙆🏿‍♂️', '🕵🏾‍♀️', '👮🏼‍♂️', '👮🏼‍♀️', '🕵🏾‍♂️', '👮🏻‍♂️', '👮🏻‍♀️', '🕵🏿‍♀️', '🕵🏿‍♂️', '🙅🏻‍♀️', '🙅🏻‍♂️', '🙅🏼‍♀️', '💁🏻‍♀️', '🙅🏼‍♂️', '🙅🏽‍♀️', '🙅🏽‍♂️', '🙅🏾‍♀️', '🙅🏾‍♂️', '🙅🏿‍♀️', '🙅🏿‍♂️', '👨🏼‍⚕️', '👨🏼‍⚖️', '👨🏼‍✈️', '🙆🏿‍♀️', '🧜🏿‍♂️', '🧜🏿‍♀️', '🧜🏾‍♂️', '🧜🏾‍♀️', '🧜🏽‍♂️', '🧜🏽‍♀️', '🧜🏼‍♂️', '🧜🏼‍♀️', '🧜🏻‍♂️', '🧜🏻‍♀️', '💂🏻‍♂️', '💂🏼‍♀️', '👩🏿‍✈️', '🧛🏿‍♂️', '🧛🏿‍♀️', '👩🏿‍⚖️', '👩🏿‍⚕️', '🧛🏾‍♂️', '🧛🏾‍♀️', '🧛🏽‍♂️', '🧛🏽‍♀️', '🧛🏼‍♂️', '👨🏽‍⚕️', '👨🏽‍⚖️', '👨🏽‍✈️', '🙆🏾‍♂️', '🧛🏼‍♀️', '🧛🏻‍♂️', '🧛🏻‍♀️', '🙆🏻‍♀️', '👩🏾‍✈️', '👩🏾‍⚖️', '👩🏾‍⚕️', '💂🏼‍♂️', '💂🏽‍♀️', '🧚🏿‍♂️', '🧚🏿‍♀️', '🧚🏾‍♂️', '🧚🏾‍♀️', '🧚🏽‍♂️', '🧚🏽‍♀️', '🧚🏼‍♂️', '🧚🏼‍♀️', '🙆🏻‍♂️', '👩🏽‍✈️', '👩🏽‍⚖️', '👩🏽‍⚕️', '🧚🏻‍♂️', '🧚🏻‍♀️', '👨🏾‍⚕️', '👨🏾‍⚖️', '👨🏾‍✈️', '🙆🏾‍♀️', '💂🏽‍♂️', '💂🏾‍♀️', '🧙🏿‍♂️', '🧙🏿‍♀️', '🙆🏼‍♀️', '👩🏼‍✈️', '👩🏼‍⚖️', '👩🏼‍⚕️', '🧙🏾‍♂️', '🧙🏾‍♀️', '🧙🏽‍♂️', '🧙🏽‍♀️', '🧙🏼‍♂️', '🧙🏼‍♀️', '🧙🏻‍♂️', '🧙🏻‍♀️', '💂🏾‍♂️', '🙆🏼‍♂️', '👩🏻‍✈️', '👩🏻‍⚖️', '👩🏻‍⚕️', '💂🏿‍♀️', '🧘🏿‍♂️', '🧘🏿‍♀️', '👨🏿‍⚕️', '👨🏿‍⚖️', '👨🏿‍✈️', '🙆🏽‍♂️', '🧘🏾‍♂️', '🧘🏾‍♀️', '🧘🏽‍♂️', '🧘🏽‍♀️', '🧘🏼‍♂️', '🧘🏼‍♀️', '🧘🏻‍♂️', '🧘🏻‍♀️', '💂🏿‍♂️', '👷🏿‍♂️', '🧗🏿‍♂️', '🧗🏿‍♀️', '🧗🏾‍♂️', '🙆🏽‍♀️', '🧗🏾‍♀️', '🧗🏽‍♂️', '👳🏾‍♂️', '⛹🏼‍♂️', '🕴️‍♀️', '🕴️‍♂️', '⛹🏾‍♂️', '⛹🏿‍♀️', '⛹🏿‍♂️', '⛹🏼‍♀️', '🏌️‍♀️', '🏌️‍♂️', '⛹🏽‍♀️', '⛹🏻‍♂️', '🕵️‍♀️', '🕵️‍♂️', '⛹🏻‍♀️', '⛹🏽‍♂️', '⛹🏾‍♀️', '🏋️‍♀️', '🏋️‍♂️', '⛹️‍♀️', '⛹️‍♂️', '👨🏽‍🚒', '👩🏻‍🍳', '👩🏻‍🎓', '👩🏻‍🎤', '👩🏻‍🎨', '👩🏻‍🏫', '👩🏻‍🏭', '👩🏻‍💻', '👩🏻‍💼', '👩🏻‍🔧', '👩🏻‍🔬', '👩🏻‍🚀', '👩🏻‍🚒', '👨🏻‍🏫', '👨🏿‍🦽', '👨🏿‍🦼', '👨🏿‍🦳', '👩🏻‍🦯', '👩🏻‍🦰', '👩🏻‍🦱', '👩🏻‍🦲', '👩🏻‍🦳', '👩🏻‍🦼', '👩🏻‍🦽', '👨🏿‍🦲', '👨🏿‍🦱', '👨🏿‍🦰', '👨🏿‍🦯', '👩🏼‍🌾', '👩🏼‍🍳', '👩🏼‍🎓', '👩🏼‍🎤', '👩🏼‍🎨', '👩🏼‍🏫', '👩🏼‍🏭', '👩🏼‍💻', '👩🏼‍💼', '👩🏼‍🔧', '👩🏼‍🔬', '👩🏼‍🚀', '👩🏼‍🚒', '👨🏿‍🚒', '👨🏿‍🚀', '👨🏿‍🔬', '👨🏿‍🔧', '👨🏿‍💼', '👩🏼‍🦯', '👩🏼‍🦰', '👩🏼‍🦱', '👩🏼‍🦲', '👩🏼‍🦳', '👩🏼‍🦼', '👩🏼‍🦽', '👨🏿‍💻', '👨🏿‍🏭', '👨🏿‍🏫', '👨🏿‍🎨', '👩🏽‍🌾', '👩🏽‍🍳', '👩🏽‍🎓', '👩🏽‍🎤', '👩🏽‍🎨', '👩🏽‍🏫', '👩🏽‍🏭', '👩🏽‍💻', '👩🏽‍💼', '👩🏽‍🔧', '👩🏽‍🔬', '👩🏽‍🚀', '👩🏽‍🚒', '👨🏿‍🎤', '👨🏿‍🎓', '👨🏿‍🍳', '👨🏿‍🌾', '👨🏾‍🦽', '👨🏾‍🦼', '👩🏽‍🦯', '👩🏽‍🦰', '👩🏽‍🦱', '👩🏽‍🦲', '👩🏽‍🦳', '👩🏽‍🦼', '👩🏽‍🦽', '👨🏾‍🦳', '👨🏾‍🦲', '👨🏾‍🦱', '👨🏾‍🦰', '👩🏾‍🌾', '👩🏾‍🍳', '👩🏾‍🎓', '👩🏾‍🎤', '👩🏾‍🎨', '👩🏾‍🏫', '👩🏾‍🏭', '👩🏾‍💻', '👩🏾‍💼', '👩🏾‍🔧', '&ð |
---|
5762 | ñð |
---|
5763 | ñ@²Ç°«ÇXññ@ñ#x1f692;', '👨🏾‍🦯', '👨🏾‍🚒', '👨🏾‍🚀', '👨🏾‍🔬', '👨🏾‍🔧', '👨🏾‍💼', '👨🏾‍💻', '👩🏾‍🦯', '👩🏾‍🦰', '👩🏾‍🦱', '👩🏾‍🦲', '👩🏾‍🦳', '👩🏾‍🦼', '👩🏾‍🦽', '👨🏾‍🏭', '👨🏾‍🏫', '👨🏾‍🎨', '👨🏾‍🎤', '👩🏿‍🌾', '👩🏿‍🍳', '👩🏿‍🎓', '👩🏿‍🎤', '👩🏿‍🎨', '👩🏿‍🏫', '👩🏿‍🏭', '👩🏿‍💻', '👩🏿‍💼', '👩🏿‍🔧', '👩🏿‍🔬', '👩🏿‍🚀', '👩🏿‍🚒', '👨🏾‍🎓', '👨🏾‍🍳', '👨🏾‍🌾', '👨🏽‍🦽', '👨🏽‍🦼', '👨🏽‍🦳', '👨🏽‍🦲', '👨🏽‍🦱', '👩🏿‍🦯', '👩🏿‍🦰', '👩🏿‍🦱', '👩🏿‍🦲', '👩🏿‍🦳', '👩🏿‍🦼', '👩🏿‍🦽', '👨🏽‍🦰', '👨🏽‍🦯', '👩🏻‍🌾', '👨🏻‍🌾', '👨🏽‍🚀', '👨🏽‍🔬', '👨🏽‍🔧', '👨🏽‍💼', '👨🏽‍💻', '👨🏽‍🏭', '👨🏽‍🏫', '👨🏽‍🎨', '👨🏻‍🍳', '👨🏻‍🎓', '👨🏻‍🎤', '👨🏽‍🎤', '👨🏽‍🎓', '👨🏽‍🍳', '👨🏽‍🌾', '👨🏻‍🎨', '👨🏼‍🦽', '👨🏼‍🦼', '👨🏼‍🦳', '👨🏼‍🦲', '👨🏼‍🦱', '👨🏼‍🦰', '👨🏼‍🦯', '👨🏼‍🚒', '👨🏼‍🚀', '👨🏼‍🔬', '👨🏼‍🔧', '👨🏼‍💼', '👨🏼‍💻', '👨🏼‍🏭', '👨🏼‍🏫', '👨🏼‍🎨', '👨🏼‍🎤', '👨🏼‍🎓', '👨🏼‍🍳', '👨🏼‍🌾', '👨🏻‍🦽', '👨🏻‍🦼', '👨🏻‍🦳', '👨🏻‍🦲', '👨🏻‍🦱', '👨🏻‍🦰', '👨🏻‍🦯', '👨🏻‍🚒', '👨🏻‍🚀', '👨🏻‍🏭', '👨🏻‍💻', '👨🏻‍💼', '👨🏻‍🔧', '👨🏻‍🔬', '🏳️‍🌈', '🤹‍♀️', '👮‍♂️', '👮‍♀️', '🙅‍♀️', '👩‍✈️', '👩‍⚖️', '👩‍⚕️', '🙅‍♂️', '🙆‍♀️', '🙆‍♂️', '🙇‍♀️', '🙇‍♂️', '🙋‍♀️', '🙋‍♂️', '🙍‍♀️', '🙍‍♂️', '🙎‍♀️', '🙎‍♂️', '👱‍♀️', '👱‍♂️', '🚣‍♀️', '🚣‍♂️', '🚴‍♀️', '🚴‍♂️', '🏴‍☠️', '👯‍♂️', '🚵‍♀️', '💇‍♂️', '🏊‍♂️', '🏊‍♀️', '💇‍♀️', '🚵‍♂️', '🏄‍♂️', '🏄‍♀️', '🚶‍♀️', '🚶‍♂️', '🏃‍♂️', '🏃‍♀️', '🤦‍♀️', '🤦‍♂️', '👳‍♀️', '👳‍♂️', '🤵‍♀️', '🤵‍♂️', '🤷‍♀️', '🤷‍♂️', '🤸‍♀️', '🤸‍♂️', '👯‍♀️', '💆‍♂️', '💆‍♀️', '🤹‍♂️', '🤼‍♀️', '🤼‍♂️', '🤽‍♀️', '🤽‍♂️', '🤾‍♀️', '🤾‍♂️', '🦸‍♀️', '🦸‍♂️', '🦹‍♀️', '🦹‍♂️', '🧍‍♀️', '🧍‍♂️', '🧎‍♀️', '🧎‍♂️', '🧏‍♀️', '🧏‍♂️', '🧖‍♀️', '🧖‍♂️', '🧗‍♀️', '💂‍♂️', '👷‍♀️', '👷‍♂️', '💂‍♀️', '🧗‍♂️', '🧘‍♀️', '🧘‍♂️', '🧙‍♀️', '🧙‍♂️', '🧚‍♀️', '🧚‍♂️', '🧛‍♀️', '🧛‍♂️', '🧜‍♀️', '🧜‍♂️', '🧝‍♀️', '🧝‍♂️', '🧞‍♀️', '💁‍♂️', '🧞‍♂️', '🧟‍♀️', '💁‍♀️', '🧟‍♂️', '👨‍⚖️', '👨‍⚕️', '👨‍✈️', '👨‍🦳', '👨‍🦼', '👨‍🦽', '👨‍👧', '👨‍🌾', '👨‍🍳', '👨‍🎓', '👨‍🎤', '👨‍🎨', '👨‍🏫', '👨‍🏭', '🐕‍🦺', '👨‍👦', '👁‍🗨', '👩‍🌾', '👩‍🍳', '👩‍🎓', '👩‍🎤', '👩‍🎨', '👩‍🏫', '👩‍🏭', '👨‍💻', '👩‍👦', '👨‍💼', '👨‍🔧', '👩‍👧', '👨‍🔬', '👨‍🚀', '👨‍🚒', '👨‍🦯', '👨‍🦰', '👩‍💻', '👩‍💼', '👩‍🔧', '👩‍🔬', '👩‍🚀', '👩‍🚒', '👩‍🦯', '👩‍🦰', '👩‍🦱', '👩‍🦲', '👩‍🦳', '👩‍🦼', '👩‍🦽', '👨‍🦱', '👨‍🦲', '🎅🏽', '💁🏾', '💁🏽', '💁🏼', '💁🏻', '👼🏿', '💂🏻', '👼🏾', '👼🏽', '💂🏼', '👼🏼', '👼🏻', '💂🏽', '👸🏿', '👸🏾', '💂🏾', '👸🏽', '👸🏼', '💂🏿', '👸🏻', '👷🏿', '💃🏻', '💃🏼', '💃🏽', '💃🏾', '💃🏿', '💅🏻', '💅🏼', '💅🏽', '💅🏾', '💅🏿', '👷🏾', '👷🏽', '💆🏻', '👷🏼', '👷🏻', '💆🏼', '👶🏿', '👶🏾', '💆🏽', '👶🏽', '👶🏼', '💆🏾', '👶🏻', '👵🏿', '💆🏿', '👵🏾', '👵🏽', '👵🏼', '👵🏻', '💇🏻', '👴🏿', '👴🏾', '💇🏼', '👴🏽', '👴🏼', '💇🏽', '👴🏻', '👳🏿', '💇🏾', '👳🏾', '👳🏽', '💇🏿', '👳🏼', '👳🏻', '💪🏻', '💪🏼', '💪🏽', '💪🏾', '💪🏿', '👲🏿', '👲🏾', '🕴🏻', '👲🏽', '👲🏼', '🕴🏼', '👲🏻', '👱🏿', '🕴🏽', '👱🏾', '👱🏽', '🕴🏾', '👱🏼', '👱🏻', '🕴🏿', '👰🏿', '👰🏾', '👰🏽', '👰🏼', '🕵🏻', '👰🏻', '👮🏿', '🕵🏼', '👮🏾', '👮🏽', '🕵🏽', '👮🏼', '👮🏻', '🕵🏾', '👭🏿', '👭🏾', '🕵🏿', '👭🏽', '👭🏼', '🕺🏻', '🕺🏼', '🕺🏽', '🕺🏾', '🕺🏿', '🖐🏻', '🖐🏼', '🖐🏽', '🖐🏾', '🖐🏿', '🖕🏻', '🖕🏼', '🖕🏽', '🖕🏾', '🖕🏿', '🖖🏻', '🖖🏼', '🖖🏽', '🖖🏾', '🖖🏿', '👭🏻', '👬🏿', '🙅🏻', '👬🏾', '👬🏽', '🙅🏼', '👬🏼', '👬🏻', '🙅🏽', '👫🏿', '👫🏾', '🙅🏾', '👫🏽', '👫🏼', '🙅🏿', '👫🏻', '👩🏿', '👩🏾', '👩🏽', '🙆🏻', '👩🏼', '👩🏻', '🙆🏼', '🇦🇨', '👨🏿', '🙆🏽', '👨🏾', '👨🏽', '🙆🏾', '👨🏼', '👨🏻', '🙆🏿', '👧🏿', '👧🏾', '👧🏽', '👧🏼', '🙇🏻', '👧🏻', '👦🏿', '🙇🏼', '👦🏾', '👦🏽', '🙇🏽', '👦🏼', '👦🏻', '🙇🏾', '👐🏿', '👐🏾', '🙇🏿', '👐🏽', '👐🏼', '👐🏻', '👏🏿', '🙋🏻', '👏🏾', '👏🏽', '🙋🏼', '👏🏼', '👏🏻', '🙋🏽', '👎🏿', '👎🏾', '🙋🏾', '👎🏽', '👎🏼', '🙋🏿', '👎🏻', '👍🏿', '🙌🏻', '🙌🏼', '🙌🏽', '🙌🏾', '🙌🏿', '👍🏾', '👍🏽', '🙍🏻', '👍🏼', '👍🏻', '🙍🏼', '👌🏿', '👌🏾', '🙍🏽', '👌🏽', '👌🏼', '🙍🏾', '👌🏻', '👋🏿', '🙍🏿', '👋🏾', '👋🏽', '👋🏼', '👋🏻', '🙎🏻', '👊🏿', '👊🏾', '🙎🏼', '👊🏽', '👊🏼', '🙎🏽', '👊🏻', '👉🏿', '🙎🏾', '👉🏾', '👉🏽', '🙎🏿', '👉🏼', '👉🏻', '🙏🏻', '🙏🏼', '🙏🏽', '🙏🏾', '🙏🏿', '👈🏿', '👈🏾', '🚣🏻', '👈🏽', '👈🏼', '🚣🏼', '👈🏻', '👇🏿', '🚣🏽', '👇🏾', '👇🏽', '🚣🏾', '👇🏼', '👇🏻', '🚣🏿', '👆🏿', '👆🏾', '👆🏽', '👆🏼', '🚴🏻', '👆🏻', '👃🏿', '🚴🏼', '👃🏾', '👃🏽', '🚴🏽', '👃🏼', '👃🏻', '🚴🏾', '👂🏿', '👂🏾', '🚴🏿', '👂🏽', '👂🏼', '👂🏻', '🏌🏿', '🚵🏻', '🏌🏾', '🏌🏽', '🚵🏼', '🏌🏼', '🏌🏻', '🚵🏽', '🏋🏿', '🏋🏾', '🚵🏾', '🏋🏽', '🏋🏼', '🚵🏿', '🏋🏻', '🏊🏿', '🏊🏾', '🏊🏽', '🚶🏻', '🏊🏼', '🏊🏻', '🚶🏼', '🏇🏿', '🏇🏾', '🚶🏽', '🏇🏽', '🏇🏼', '🚶🏾', '🏇🏻', '🏄🏿', '🚶🏿', '🏄🏾', '🏄🏽', '🛀🏻', '🛀🏼', '🛀🏽', '🛀🏾', '🛀🏿', '🛌🏻', '🛌🏼', '🛌🏽', '🛌🏾', '🛌🏿', '🤏🏻', '🤏🏼', '🤏🏽', '🤏🏾', '🤏🏿', '🤘🏻', '🤘🏼', '🤘🏽', '🤘🏾', '🤘🏿', '🤙🏻', '🤙🏼', '🤙🏽', '🤙🏾', '🤙🏿', '🤚🏻', '🤚🏼', '🤚🏽', '🤚🏾', '🤚🏿', '🤛ð |
---|
5764 | ñð |
---|
5765 | ñ@²Ç°«ÇXññ@ñc;🏻', '🤜🏼', '🤜🏽', '🤜🏾', '🤜🏿', '🤞🏻', '🤞🏼', '🤞🏽', '🤞🏾', '🤞🏿', '🤟🏻', '🤟🏼', '🤟🏽', '🤟🏾', '🤟🏿', '🏄🏼', '🏄🏻', '🤦🏻', '🏃🏿', '🏃🏾', '🤦🏼', '🏃🏽', '🏃🏼', '🤦🏽', '🏃🏻', '🏂🏿', '🤦🏾', '🏂🏾', '🏂🏽', '🤦🏿', '🏂🏼', '🏂🏻', '🤰🏻', '🤰🏼', '🤰🏽', '🤰🏾', '🤰🏿', '🤱🏻', '🤱🏼', '🤱🏽', '🤱🏾', '🤱🏿', '🤲🏻', '🤲🏼', '🤲🏽', '🤲🏾', '🤲🏿', '🤳🏻', '🤳🏼', '🤳🏽', '🤳🏾', '🤳🏿', '🤴🏻', '🤴🏼', '🤴🏽', '🤴🏾', '🤴🏿', '🎅🏿', '🎅🏾', '🤵🏻', '💁🏿', '🎅🏼', '🤵🏼', '🎅🏻', '🇿🇼', '🤵🏽', '🇿🇲', '🇿🇦', '🤵🏾', '🇾🇹', '🇾🇪', '🤵🏿', '🇽🇰', '🇼🇸', '🤶🏻', '🤶🏼', '🤶🏽', '🤶🏾', '🤶🏿', '🇼🇫', '🇻🇺', '🤷🏻', '🇻🇳', '🇻🇮', '🤷🏼', '🇻🇬', '🇻🇪', '🤷🏽', '🇻🇨', '🇻🇦', '🤷🏾', '🇺🇿', '🇺🇾', '🤷🏿', '🇺🇸', '🇺🇳', '🇺🇲', '🇺🇬', '🤸🏻', '🇺🇦', '🇹🇿', '🤸🏼', '🇹🇼', '🇹🇻', '🤸🏽', '🇹🇹', '🇹🇷', '🤸🏾', '🇹🇴', '🇹🇳', '🤸🏿', '🇹🇲', '🇹🇱', '🇹🇰', '🇹🇯', '🤹🏻', '🇹🇭', '🇹🇬', '🤹🏼', '🇹🇫', '🇹🇩', '🤹🏽', '🇹🇨', '🇹🇦', '🤹🏾', '🇸🇿', '🇸🇾', '🤹🏿', '🇸🇽', '🇸🇻', '🇸🇹', '🇸🇸', '🇸🇷', '🇸🇴', '🤽🏻', '🇸🇳', '🇸🇲', '🤽🏼', '🇸🇱', '🇸🇰', '🤽🏽', '🇸🇯', '🇸🇮', '🤽🏾', '🇸🇭', '🇸🇬', '🤽🏿', '🇸🇪', '🇸🇩', '🇸🇨', '🇸🇧', '🤾🏻', '🇸🇦', '🇷🇼', '🤾🏼', '🇷🇺', '🇷🇸', '🤾🏽', '🇷🇴', '🇷🇪', '🤾🏾', '🇶🇦', '🇵🇾', '🤾🏿', '🇵🇼', '🇵🇹', '🦵🏻', '🦵🏼', '🦵🏽', '🦵🏾', '🦵🏿', '🦶🏻', '🦶🏼', '🦶🏽', '🦶🏾', '🦶🏿', '🇵🇸', '🇵🇷', '🦸🏻', '🇵🇳', '🇵🇲', '🦸🏼', '🇵🇱', '🇵🇰', '🦸🏽', '🇵🇭', '🇵🇬', '🦸🏾', '🇵🇫', '🇵🇪', '🦸🏿', '🇵🇦', '🇴🇲', '🇳🇿', '🇳🇺', '🦹🏻', '🇳🇷', '🇳🇵', '🦹🏼', '🇳🇴', '🇳🇱', '🦹🏽', '🇳🇮', '🇳🇬', '🦹🏾', '🇳🇫', '🇳🇪', '🦹🏿', '🇳🇨', '🇳🇦', '🦻🏻', '🦻🏼', '🦻🏽', '🦻🏾', '🦻🏿', '🇲🇿', '🇲🇾', '🧍🏻', '🇲🇽', '🇲🇼', '🧍🏼', '🇲🇻', '🇲🇺', '🧍🏽', '🇲🇹', '🇲🇸', '🧍🏾', '🇲🇷', '🇲🇶', '🧍🏿', '🇲🇵', '🇲🇴', '🇲🇳', '🇲🇲', '🧎🏻', '🇲🇱', '🇲🇰', '🧎🏼', '🇲🇭', '🇲🇬', '🧎🏽', '🇲🇫', '🇲🇪', '🧎🏾', '🇲🇩', '🇲🇨', '🧎🏿', '🇲🇦', '🇱🇾', '🇱🇻', '🇱🇺', '🧏🏻', '🇱🇹', '🇱🇸', '🧏🏼', '🇱🇷', '🇱🇰', '🧏🏽', '🇱🇮', '🇱🇨', '🧏🏾', '🇱🇧', '🇱🇦', '🧏🏿', '🇰🇿', '🇰🇾', '🇰🇼', '🧑🏻', '🇰🇷', '🇰🇵', '🧑🏼', '🇰🇳', '🇰🇲', '🇰🇮', '🧑🏽', '🇰🇭', '🇰🇬', '🇰🇪', '🇯🇵', '🧑🏾', '🇯🇴', '🇯🇲', '🇯🇪', '🇮🇹', '🇮🇸', '🧑🏿', '🇮🇷', '🧒🏻', '🧒🏼', '🧒🏽', '🧒🏾', '🧒🏿', '🧓🏻', '🧓🏼', '🧓🏽', '🧓🏾', '🧓🏿', '🧔🏻', '🧔🏼', '🧔🏽', '🧔🏾', '🧔🏿', '🧕🏻', '🧕🏼', '🧕🏽', '🧕🏾', '🧕🏿', '🇮🇶', '🇮🇴', '🧖🏻', '🇮🇳', '🇮🇲', '🧖🏼', '🇮🇱', '🇮🇪', '🧖🏽', '🇮🇩', '🇮🇨', '🧖🏾', '🇭🇺', '🇭🇹', '🧖🏿', '🇭🇷', '🇭🇳', '🇭🇲', '🇭🇰', '🧗🏻', '🇬🇾', '🇬🇼', '🧗🏼', '🇬🇺', '🇬🇹', '🧗🏽', '🇬🇸', '🇬🇷', '🧗🏾', '🇬🇶', '🇬🇵', '🧗🏿', '🇬🇳', '🇬🇲', '🇬🇱', '🇬🇮', '🧘🏻', '🇬🇭', '🇬🇬', '🧘🏼', '🇬🇫', '🇬🇪', '🧘🏽', '🇬🇩', '🇬🇧', '🧘🏾', '🇬🇦', '🇫🇷', '🧘🏿', '🇫🇴', '🇫🇲', '🇫🇰', '🇫🇯', '🧙🏻', '🇫🇮', '🇪🇺', '🧙🏼', '🇪🇹', '🇪🇸', '🧙🏽', '🇪🇷', '🇪🇭', '🧙🏾', '🇪🇬', '🇪🇪', '🧙🏿', '🇪🇨', '🇪🇦', '🇩🇿', '🇩🇴', '🧚🏻', '🇩🇲', '🇩🇰', '🧚🏼', '🇩🇯', '🇩🇬', '🧚🏽', '🇩🇪', '🇨🇿', '🧚🏾', '🇨🇾', '🇨🇽', '🧚🏿', '🇨🇼', '🇨🇻', '🇨🇺', '🇨🇷', '🧛🏻', '🇨🇵', '🇨🇴', '🧛🏼', '🇨🇳', '🇨🇲', '🧛🏽', '🇨🇱', '🇨🇰', '🧛🏾', '🇨🇮', '🇨🇭', '🧛🏿', '🇨🇬', '🇨🇫', '🇨🇩', '🇨🇨', '🧜🏻', '🇨🇦', '🇧🇿', '🧜🏼', '🇧🇾', '🇧🇼', '🧜🏽', '🇧🇻', '🇧🇹', '🧜🏾', '🇧🇸', '🇧🇷', '🧜🏿', '🇧🇶', '🇧🇴', '🇧🇳', '🇧🇲', '🧝🏻', '🇧🇱', '🇧🇯', '🧝🏼', '🇧🇮', '🇧🇭', '🧝🏽', '🇧🇬', '🇧🇫', '🧝🏾', '🇧🇪', '🇧🇩', '🧝🏿', '🇧🇧', '🇧🇦', '🇦🇿', '🇦🇽', '🇦🇼', '🇦🇺', '🇦🇹', '🇦🇸', '🇦🇷', '🇦🇶', '🇦🇴', '🇦🇲', '🇦🇱', '🇦🇮', '🇦🇬', '🇦🇫', '🇦🇪', '🇦🇩', '✍🏿', '⛹🏻', '✍🏾', '✍🏽', '✍🏼', '✍🏻', '✌🏿', '✌🏾', '✌🏽', '✌🏼', '✌🏻', '✋🏿', '✋🏾', '✋🏽', '✋🏼', '✋🏻', '✊🏿', '✊🏾', '✊🏽', '✊🏼', '✊🏻', '⛷🏽', '⛷🏾', '⛹🏿', '☝🏿', '☝🏾', '⛹🏾', '☝🏽', '☝🏼', '⛹🏽', '☝🏻', '⛷🏿', '⛹🏼', '⛷🏻', '⛷🏼', '4⃣', '#⃣', '0⃣', '1⃣', '2⃣', '3⃣', '*⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🏌', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '🙃', '🙄', '🏮', '🏯', '🏰', '🌭', '🏳', '🌮', '🌯', '🌰', '🌱', '🏴', '🏵', '🏷', '🏸', '🏹', '🏺', '🏻', '🏼', '🙅', '🏽', '🏾', '🏿', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '🐉', '🐊', '🐋', '🐌', '🐍', '🙆', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🌲', '🐕', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🙇', '🙈', '🙉', '🙊', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🙋', '🐯', '🐰', '🐱', '🐲', '🐳', '🙌', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '🐼', '🐽', '🐾', '🐿', '👀', '🌳', '👁', '🌴', '🌵', '🙍', '🌶', '🌷', '🌸', '👂', '🌹', '🌺', '🌻', '🌼', '🌽', '👃', '👄', '👅', '🌾', '🌿', '🍀', '🍁', '🍂', '🙎', '👆', '🍃', '🍄', '🍅', '🍆', '🙏', '🚀', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚒', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🍇', '👇', '🍈', '🍉', '🍊', '🍋', '🍌', '👈', '🍍', '🍎', '🍏', '🍐', '🍑', '👉', '🍒', '🍓', '🍔', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🍕', '🍖', '👊', '🍗', '🍘', '🍙', '🍚', '🍛', '👋', '🍜', '🍝', '🍞', '🍟', '🍠', '👌', '🍡', '🍢', '🚴', '🍣', '🍤', '🍥', '👍', '🍦', '👩', '👪', '🍧', '🍨', '🍩', '🍪', '👎', '👫', '🍫', '🍬', '🍭', '🍮', '🚵', '🍯', '👬', '👏', '🍰', '🍱', '🍲', '🍳', '👭', '🍴', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '👘', '👙', '👚', '👛', '👜', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '👝', '👞', '👟', '👮', '👠', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟩', '🟪', '🟫', '🤍', '🤎', '👡', '👯', '👢', '👣', '👤', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '👥', '🍵', '👰', '🍶', '🍷', '🤘', '🍸', '🍹', '👦', '🍺', '🍻', '🤙', '🍼', '🍽', '🍾', '👧', '🍿', '🤚', '🎀', '🎁', '🎂', '🎃', '🎄', '🤛', '👱', '🇵', '🅾', '🇶', '🇲', '🤜', '🤝', '🅿', '👲', '🎅', '🎆', '🎇', '🤞', '🎈', '🎉', '🎊', '🎋', '🎌', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '👳', '🎙', '🎚', '🎛', '🎞', '🎟', '👴', '🎠', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🎡', '🎢', '🎣', '🎤', '👵', '🤰', '🎥', '🎦', '🎧', '🎨', '🎩', '🤱', '👶', '🎪', '🎫', '🎬', '🎭', '🤲', '🎮', '🎯', '🎰', '🎱', '🎲', '🤳', '🎳', '🎴', '🎵', '🎶', '🎷', '🤴', '🎸', '🎹', '🎺', '👷', '🎻', '🎼', '🎽', '🎾', '🎿', '👸', '👹', '👺', '👻', '🏀', '🏁', '🇧', '🇮', '🤵', '🇪', '👼', '👽', '👾', '👿', '🤶', '💀', '🇷', '🇱', '🏂', '🆎', '🆑', '🇨', '🇹', '🇯', '🆒', '🇬', '🆓', '🇳', '🆔', '🇴', '🇺', '🇫', '🤷', '🆕', '💁', '🆖', '🆗', '🇭', '🏃', '🆘', '🇩', '🇻', '🇰', '🆙', '🇼', '🆚', '🇽', '🇸', '🀄', '🇾', '🤸', '🇦', '🅰', '💂', '🅱', '🇿', '🈁', '🈂', '🏄', '💃', '💄', '🏅', '🏆', '🈚', '🈯', '🈲', '💅', '🈳', '🤹', '🤺', '🈴', '🏇', '🤼', '🏈', '🏉', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '💆', '🌄', '🌅', '🤽', '🌆', '🌇', '🌈', '🏊', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '💇', '💈', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥳', '🥴', '🥵', '🥶', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦮', '🦯', '🦰', '🦱', '🦲', '🦳', '🦴', '💉', '💊', '💋', '💌', '💍', '🦵', '💎', '💏', '💐', '💑', '💒', '🦶', '🦷', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '🦸', '💤', '💥', '💦', '💧', '💨', '💩', '🌔', '🌕', '🌖', '🌗', '🌘', '💪', '💫', '💬', '💭', '💮', '💯', '🦹', '🦺', '💰', '💱', '💲', '💳', '💴', '🦻', '🦼', '🦽', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '💵', '💶', '💷', '💸', '💹', '💺', '💻', '💼', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '🧍', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '🧎', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '🧏', '🧐', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '🧑', '📽', '📿', '🔀', '🔁', '🔂', '🧒', '🔃', '🔄', '🔅', '🔆', '🔇', '🧓', '🔈', '🔉', '🔊', '🔋', '🔌', '🧔', '🔍', '🔎', '🔏', '🔐', '🔑', '🧕', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🧖', '🔣', '🔤', '🔥', '🔦', '🔧', '🔨', '🔩', '🔪', '🔫', '🔬', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🧗', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🧘', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🧙', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🌙', '🏋', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🧚', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🕴', '👨', '🌫', '🌬', '🃏', '🏍', '🏎', '🏏', '🧛', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🕵', '🕶', '🕷', '🕸', '🕹', '🏚', '🏛', '🧜', '🏜', '🏝', '🏞', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🏟', '🏠', '🏡', '🏢', '🏣', '🖐', '🏤', '🏥', '🧝', '🏦', '🏧', '🧞', '🏨', '🖕', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩰', '🩱', '🩲', '🩳', '🩸', '🩹', '🩺', '🪀', '🪁', '🪂', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '🏩', '🏪', '🏫', '🏬', '🏭', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗨', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '▫', '☦', '☮', '☯', '☸', '☹', '☺', '♀', '♂', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚕', '⚖', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '☣', '☢', '☠', '☝', '☘', '⛷', '⛸', '☕', '☔', '☑', '☎', '☄', '☃', '☂', '☁', '☀', '◾', '◽', '◼', '◻', '◀', '▶', '☪', '▪', '⛹', '⛺', '⛽', '✂', '✅', '✈', '✉', 'Ⓜ', '⏺', '⏹', '⏸', '⏳', '✊', '⏲', '⏱', '⏰', '⏯', '⏮', '✋', '⏭', '⏬', '⏫', '⏪', '⏩', '✌', '⏏', '⌨', '⌛', '⌚', '↪', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❄', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '❤', '➕', '➖', '➗', '➡', '➰', '➿', '⤴', '⤵', '↩', '⬅', '⬆', '⬇', '⬛', '⬜', '⭐', '⭕', '↙', '〰', '〽', '↘', '↗', '㊗', '㊙', '↖', '↕', '↔', 'ℹ', '™', '⁉', '‼', '' );
|
---|
5766 | $partials = array( '🀄', '🃏', '🅰', '🅱', '🅾', '🅿', '🆎', '🆑', '🆒', '🆓', '🆔', '🆕', '🆖', '🆗', '🆘', '🆙', '🆚', '🇦', '🇨', '🇩', '🇪', '🇫', '🇬', '🇮', '🇱', '🇲', '🇴', '🇶', '🇷', '🇸', '🇹', '🇺', '🇼', '🇽', '🇿', '🇧', '🇭', '🇯', '🇳', '🇻', '🇾', '🇰', '🇵', '🈁', '🈂', '🈚', '🈯', '🈲', '🈳', '🈴', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '🌄', '🌅', '🌆', '🌇', '🌈', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘', '🌙', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🌫', '🌬', '🌭', '🌮', '🌯', '🌰', '🌱', '🌲', '🌳', '🌴', '🌵', '🌶', '🌷', '🌸', '🌹', '🌺', '🌻', '🌼', '🌽', '🌾', '🌿', '🍀', '🍁', '🍂', '🍃', '🍄', '🍅', '🍆', '🍇', '🍈', '🍉', '🍊', '🍋', '🍌', '🍍', '🍎', '🍏', '🍐', '🍑', '🍒', '🍓', '🍔', '🍕', '🍖', '🍗', '🍘', '🍙', '🍚', '🍛', '🍜', '🍝', '🍞', '🍟', '🍠', '🍡', '🍢', '🍣', '🍤', '🍥', '🍦', '🍧', '🍨', '🍩', '🍪', '🍫', '🍬', '🍭', '🍮', '🍯', '🍰', '🍱', '🍲', '🍳', '🍴', '🍵', '🍶', '🍷', '🍸', '🍹', '🍺', '🍻', '🍼', '🍽', '🍾', '🍿', '🎀', '🎁', '🎂', '🎃', '🎄', '🎅', '🏻', '🏼', '🏽', '🏾', '🏿', '🎆', '🎇', '🎈', '🎉', '🎊', '🎋', '🎌', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '🎙', '🎚', '🎛', '🎞', '🎟', '🎠', '🎡', '🎢', '🎣', '🎤', '🎥', '🎦', '🎧', '🎨', '🎩', '🎪', '🎫', '🎬', '🎭', '🎮', '🎯', '🎰', '🎱', '🎲', '🎳', '🎴', '🎵', '🎶', '🎷', '🎸', '🎹', '🎺', '🎻', '🎼', '🎽', '🎾', '🎿', '🏀', '🏁', '🏂', '🏃', '‍', '♀', '️', '♂', '🏄', '🏅', '🏆', '🏇', '🏈', '🏉', '🏊', '🏋', '🏌', '🏍', '🏎', '🏏', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🏚', '🏛', '🏜', '🏝', '🏞', '🏟', '🏠', '🏡', '🏢', '🏣', '🏤', '🏥', '🏦', '🏧', '🏨', '🏩', '🏪', '🏫', '🏬', '🏭', '🏮', '🏯', '🏰', '🏳', '🏴', '☠', '󠁧', '󠁢', '󠁥', '󠁮', '󠁿', '󠁳', '󠁣', '󠁴', '󠁷', '󠁬', '🏵', '🏷', '🏸', '🏹', '🏺', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '🐉', '🐊', '🐋', '🐌', '🐍', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🐕', '🦺', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🐯', '🐰', '🐱', '🐲', '🐳', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '🐼', '🐽', '🐾', '🐿', '👀', '👁', '🗨', '👂', '👃', '👄', '👅', '👆', '👇', '👈', '👉', '👊', '👋', '👌', '👍', '👎', '👏', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '👘', '👙', '👚', '👛', '👜', '👝', '👞', '👟', '👠', '👡', '👢', '👣', '👤', '👥', '👦', '👧', '👨', '💻', '💼', '🔧', '🔬', '🚀', '🚒', '🦯', '🦰', '🦱', '🦲', '🦳', '🦼', '🦽', '⚕', '⚖', '✈', '🤝', '👩', '❤', '💋', '👪', '👫', '👬', '👭', '👮', '👯', '👰', '👱', '👲', '👳', '👴', '👵', '👶', '👷', '👸', '👹', '👺', '👻', '👼', '👽', '👾', '👿', '💀', '💁', '💂', '💃', '💄', '💅', '💆', '💇', '💈', '💉', '💊', '💌', '💍', '💎', '💏', '💐', '💑', '💒', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '💤', '💥', '💦', '💧', '💨', '💩', '💪', '💫', '💬', '💭', '💮', '💯', '💰', '💱', '💲', '💳', '💴', '💵', '💶', '💷', '💸', '💹', '💺', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '📽', '📿', '🔀', '🔁', '🔂', '🔃', '🔄', '🔅', '🔆', '🔇', '🔈', '🔉', '🔊', '🔋', '🔌', '🔍', '🔎', '🔏', '🔐', '🔑', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🔣', '🔤', '🔥', '🔦', '🔨', '🔩', '🔪', '🔫', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🕴', '🕵', '🕶', '🕷', '🕸', '🕹', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🖐', '🖕', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '🙃', '🙄', '🙅', '🙆', '🙇', '🙈', '🙉', '🙊', '🙋', '🙌', '🙍', '🙎', '🙏', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🚴', '🚵', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟩', '🟪', '🟫', '🤍', '🤎', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '🤘', '🤙', '🤚', '🤛', '🤜', '🤞', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🤰', '🤱', '🤲', '🤳', '🤴', '🤵', '🤶', '🤷', '🤸', '🤹', '🤺', '🤼', '🤽', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥳', '🥴', '🥵', '🥶', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦮', '🦴', '🦵', '🦶', '🦷', '🦸', '🦹', '🦻', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '🧍', '🧎', '🧏', '🧐', '🧑', '🧒', '🧓', '🧔', '🧕', '🧖', '🧗', '🧘', '🧙', '🧚', '🧛', '🧜', '🧝', '🧞', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩰', '🩱', '🩲', '🩳', '🩸', '🩹', '🩺', '🪀', '🪁', '🪂', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '‼', '⁉', '™', 'ℹ', '↔', '↕', '↖', '↗', '↘', '↙', '↩', '↪', '⃣', '⌚', '⌛', '⌨', '⏏', '⏩', '⏪', '⏫', '⏬', '⏭', '⏮', '⏯', '⏰', '⏱', '⏲', '⏳', '⏸', '⏹', '⏺', 'Ⓜ', '▪', '▫', '▶', '◀', '◻', '◼', '◽', '◾', '☀', '☁', '☂', '☃', '☄', '☎', '☑', '☔', '☕', '☘', '☝', '☢', '☣', '☦', '☪', '☮', '☯', '☸', '☹', '☺', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '⛷', '⛸', '⛹', '⛺', '⛽', '✂', '✅', '✉', '✊', '✋', '✌', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❄', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '➕', '➖', '➗', '➡', '➰', '➿', '⤴', '⤵', '⬅', '⬆', '⬇', '⬛', '⬜', '⭐', '⭕', '〰', '〽', '㊗', '㊙', '' );
|
---|
5767 | // END: emoji arrays
|
---|
5768 |
|
---|
5769 | if ( 'entities' === $type ) {
|
---|
5770 | return $entities;
|
---|
5771 | }
|
---|
5772 |
|
---|
5773 | return $partials;
|
---|
5774 | }
|
---|
5775 |
|
---|
5776 | /**
|
---|
5777 | * Shorten a URL, to be used as link text.
|
---|
5778 | *
|
---|
5779 | * @since 1.2.0
|
---|
5780 | * @since 4.4.0 Moved to wp-includes/formatting.php from wp-admin/includes/misc.php and added $length param.
|
---|
5781 | *
|
---|
5782 | * @param string $url URL to shorten.
|
---|
5783 | * @param int $length Optional. Maximum length of the shortened URL. Default 35 characters.
|
---|
5784 | * @return string Shortened URL.
|
---|
5785 | */
|
---|
5786 | function url_shorten( $url, $length = 35 ) {
|
---|
5787 | $stripped = str_replace( array( 'https://', 'http://', 'www.' ), '', $url );
|
---|
5788 | $short_url = untrailingslashit( $stripped );
|
---|
5789 |
|
---|
5790 | if ( strlen( $short_url ) > $length ) {
|
---|
5791 | $short_url = substr( $short_url, 0, $length - 3 ) . '…';
|
---|
5792 | }
|
---|
5793 | return $short_url;
|
---|
5794 | }
|
---|
5795 |
|
---|
5796 | /**
|
---|
5797 | * Sanitizes a hex color.
|
---|
5798 | *
|
---|
5799 | * Returns either '', a 3 or 6 digit hex color (with #), or nothing.
|
---|
5800 | * For sanitizing values without a #, see sanitize_hex_color_no_hash().
|
---|
5801 | *
|
---|
5802 | * @since 3.4.0
|
---|
5803 | *
|
---|
5804 | * @param string $color
|
---|
5805 | * @return string|void
|
---|
5806 | */
|
---|
5807 | function sanitize_hex_color( $color ) {
|
---|
5808 | if ( '' === $color ) {
|
---|
5809 | return '';
|
---|
5810 | }
|
---|
5811 |
|
---|
5812 | // 3 or 6 hex digits, or the empty string.
|
---|
5813 | if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
|
---|
5814 | return $color;
|
---|
5815 | }
|
---|
5816 | }
|
---|
5817 |
|
---|
5818 | /**
|
---|
5819 | * Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible.
|
---|
5820 | *
|
---|
5821 | * Saving hex colors without a hash puts the burden of adding the hash on the
|
---|
5822 | * UI, which makes it difficult to use or upgrade to other color types such as
|
---|
5823 | * rgba, hsl, rgb, and html color names.
|
---|
5824 | *
|
---|
5825 | * Returns either '', a 3 or 6 digit hex color (without a #), or null.
|
---|
5826 | *
|
---|
5827 | * @since 3.4.0
|
---|
5828 | *
|
---|
5829 | * @param string $color
|
---|
5830 | * @return string|null
|
---|
5831 | */
|
---|
5832 | function sanitize_hex_color_no_hash( $color ) {
|
---|
5833 | $color = ltrim( $color, '#' );
|
---|
5834 |
|
---|
5835 | if ( '' === $color ) {
|
---|
5836 | return '';
|
---|
5837 | }
|
---|
5838 |
|
---|
5839 | return sanitize_hex_color( '#' . $color ) ? $color : null;
|
---|
5840 | }
|
---|
5841 |
|
---|
5842 | /**
|
---|
5843 | * Ensures that any hex color is properly hashed.
|
---|
5844 | * Otherwise, returns value untouched.
|
---|
5845 | *
|
---|
5846 | * This method should only be necessary if using sanitize_hex_color_no_hash().
|
---|
5847 | *
|
---|
5848 | * @since 3.4.0
|
---|
5849 | *
|
---|
5850 | * @param string $color
|
---|
5851 | * @return string
|
---|
5852 | */
|
---|
5853 | function maybe_hash_hex_color( $color ) {
|
---|
5854 | if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) {
|
---|
5855 | return '#' . $unhashed;
|
---|
5856 | }
|
---|
5857 |
|
---|
5858 | return $color;
|
---|
5859 | }
|
---|