author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Main WordPress Formatting API. |
|
4 |
* |
|
5 |
* Handles many functions for formatting output. |
|
6 |
* |
|
7 |
* @package WordPress |
|
8 |
*/ |
|
9 |
||
10 |
/** |
|
16 | 11 |
* Replaces common plain text characters with formatted entities. |
12 |
* |
|
13 |
* Returns given text with transformations of quotes into smart quotes, apostrophes, |
|
14 |
* dashes, ellipses, the trademark symbol, and the multiplication symbol. |
|
0 | 15 |
* |
16 |
* As an example, |
|
5 | 17 |
* |
18 |
* 'cause today's effort makes it worth tomorrow's "holiday" ... |
|
19 |
* |
|
0 | 20 |
* Becomes: |
5 | 21 |
* |
22 |
* ’cause today’s effort makes it worth tomorrow’s “holiday” … |
|
23 |
* |
|
16 | 24 |
* Code within certain HTML blocks are skipped. |
0 | 25 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
* Do not use this function before the {@see 'init'} action hook; everything will break. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
* |
0 | 28 |
* @since 0.71 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
* |
16 | 30 |
* @global array $wp_cockneyreplace Array of formatted entities for certain common phrases. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
* @global array $shortcode_tags |
16 | 32 |
* |
33 |
* @param string $text The text to be formatted. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
* @param bool $reset Set to true for unit testing. Translated patterns will reset. |
16 | 35 |
* @return string The string replaced with HTML entities. |
0 | 36 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
function wptexturize( $text, $reset = false ) { |
5 | 38 |
global $wp_cockneyreplace, $shortcode_tags; |
9 | 39 |
static $static_characters = null, |
40 |
$static_replacements = null, |
|
41 |
$dynamic_characters = null, |
|
42 |
$dynamic_replacements = null, |
|
43 |
$default_no_texturize_tags = null, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
$default_no_texturize_shortcodes = null, |
9 | 45 |
$run_texturize = true, |
46 |
$apos = null, |
|
47 |
$prime = null, |
|
48 |
$double_prime = null, |
|
49 |
$opening_quote = null, |
|
50 |
$closing_quote = null, |
|
51 |
$opening_single_quote = null, |
|
52 |
$closing_single_quote = null, |
|
53 |
$open_q_flag = '<!--oq-->', |
|
54 |
$open_sq_flag = '<!--osq-->', |
|
55 |
$apos_flag = '<!--apos-->'; |
|
5 | 56 |
|
57 |
// If there's nothing to do, just stop. |
|
58 |
if ( empty( $text ) || false === $run_texturize ) { |
|
59 |
return $text; |
|
60 |
} |
|
61 |
||
62 |
// Set up static variables. Run once only. |
|
63 |
if ( $reset || ! isset( $static_characters ) ) { |
|
64 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
* Filters whether to skip running wptexturize(). |
5 | 66 |
* |
16 | 67 |
* Returning false from the filter will effectively short-circuit wptexturize() |
68 |
* and return the original text passed to the function instead. |
|
5 | 69 |
* |
70 |
* The filter runs only once, the first time wptexturize() is called. |
|
71 |
* |
|
72 |
* @since 4.0.0 |
|
73 |
* |
|
74 |
* @see wptexturize() |
|
75 |
* |
|
76 |
* @param bool $run_texturize Whether to short-circuit wptexturize(). |
|
77 |
*/ |
|
78 |
$run_texturize = apply_filters( 'run_wptexturize', $run_texturize ); |
|
79 |
if ( false === $run_texturize ) { |
|
80 |
return $text; |
|
81 |
} |
|
82 |
||
16 | 83 |
/* translators: Opening curly double quote. */ |
0 | 84 |
$opening_quote = _x( '“', 'opening curly double quote' ); |
16 | 85 |
/* translators: Closing curly double quote. */ |
0 | 86 |
$closing_quote = _x( '”', 'closing curly double quote' ); |
87 |
||
16 | 88 |
/* translators: Apostrophe, for example in 'cause or can't. */ |
0 | 89 |
$apos = _x( '’', 'apostrophe' ); |
90 |
||
16 | 91 |
/* translators: Prime, for example in 9' (nine feet). */ |
0 | 92 |
$prime = _x( '′', 'prime' ); |
16 | 93 |
/* translators: Double prime, for example in 9" (nine inches). */ |
0 | 94 |
$double_prime = _x( '″', 'double prime' ); |
95 |
||
16 | 96 |
/* translators: Opening curly single quote. */ |
0 | 97 |
$opening_single_quote = _x( '‘', 'opening curly single quote' ); |
16 | 98 |
/* translators: Closing curly single quote. */ |
0 | 99 |
$closing_single_quote = _x( '’', 'closing curly single quote' ); |
100 |
||
16 | 101 |
/* translators: En dash. */ |
0 | 102 |
$en_dash = _x( '–', 'en dash' ); |
16 | 103 |
/* translators: Em dash. */ |
0 | 104 |
$em_dash = _x( '—', 'em dash' ); |
105 |
||
9 | 106 |
$default_no_texturize_tags = array( 'pre', 'code', 'kbd', 'style', 'script', 'tt' ); |
107 |
$default_no_texturize_shortcodes = array( 'code' ); |
|
0 | 108 |
|
16 | 109 |
// If a plugin has provided an autocorrect array, use it. |
9 | 110 |
if ( isset( $wp_cockneyreplace ) ) { |
111 |
$cockney = array_keys( $wp_cockneyreplace ); |
|
5 | 112 |
$cockneyreplace = array_values( $wp_cockneyreplace ); |
0 | 113 |
} else { |
16 | 114 |
/* |
115 |
* translators: This is a comma-separated list of words that defy the syntax of quotations in normal use, |
|
116 |
* for example... 'We do not have enough words yet'... is a typical quoted phrase. But when we write |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
* lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
118 |
*/ |
9 | 119 |
$cockney = explode( |
120 |
',', |
|
121 |
_x( |
|
122 |
"'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em", |
|
123 |
'Comma-separated list of words to texturize in your language' |
|
124 |
) |
|
125 |
); |
|
126 |
||
127 |
$cockneyreplace = explode( |
|
128 |
',', |
|
129 |
_x( |
|
130 |
'’tain’t,’twere,’twas,’tis,’twill,’til,’bout,’nuff,’round,’cause,’em', |
|
131 |
'Comma-separated list of replacement words in your language' |
|
132 |
) |
|
133 |
); |
|
0 | 134 |
} |
135 |
||
9 | 136 |
$static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); |
5 | 137 |
$static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); |
138 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
139 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
140 |
* Pattern-based replacements of characters. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
141 |
* Sort the remaining patterns into several arrays for performance tuning. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
142 |
*/ |
9 | 143 |
$dynamic_characters = array( |
144 |
'apos' => array(), |
|
145 |
'quote' => array(), |
|
146 |
'dash' => array(), |
|
147 |
); |
|
148 |
$dynamic_replacements = array( |
|
149 |
'apos' => array(), |
|
150 |
'quote' => array(), |
|
151 |
'dash' => array(), |
|
152 |
); |
|
153 |
$dynamic = array(); |
|
154 |
$spaces = wp_spaces_regexp(); |
|
5 | 155 |
|
156 |
// '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. |
|
157 |
if ( "'" !== $apos || "'" !== $closing_single_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
$dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_single_quote; |
5 | 159 |
} |
160 |
if ( "'" !== $apos || '"' !== $closing_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
$dynamic[ '/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_quote; |
5 | 162 |
} |
163 |
||
164 |
// '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0. |
|
165 |
if ( "'" !== $apos ) { |
|
9 | 166 |
$dynamic['/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/'] = $apos_flag; |
5 | 167 |
} |
168 |
||
16 | 169 |
// Quoted numbers like '0.42'. |
5 | 170 |
if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
$dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $open_sq_flag . '$1' . $closing_single_quote; |
5 | 172 |
} |
173 |
||
174 |
// Single quote at start, or preceded by (, {, <, [, ", -, or spaces. |
|
175 |
if ( "'" !== $opening_single_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
$dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $open_sq_flag; |
5 | 177 |
} |
178 |
||
16 | 179 |
// Apostrophe in a word. No spaces, double apostrophes, or other punctuation. |
5 | 180 |
if ( "'" !== $apos ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
$dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos_flag; |
0 | 182 |
} |
5 | 183 |
|
9 | 184 |
$dynamic_characters['apos'] = array_keys( $dynamic ); |
5 | 185 |
$dynamic_replacements['apos'] = array_values( $dynamic ); |
9 | 186 |
$dynamic = array(); |
5 | 187 |
|
16 | 188 |
// Quoted numbers like "42". |
5 | 189 |
if ( '"' !== $opening_quote && '"' !== $closing_quote ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
$dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $open_q_flag . '$1' . $closing_quote; |
5 | 191 |
} |
192 |
||
193 |
// Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces. |
|
194 |
if ( '"' !== $opening_quote ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
$dynamic[ '/(?<=\A|[([{\-]|<|' . $spaces . ')"(?!' . $spaces . ')/' ] = $open_q_flag; |
5 | 196 |
} |
197 |
||
9 | 198 |
$dynamic_characters['quote'] = array_keys( $dynamic ); |
5 | 199 |
$dynamic_replacements['quote'] = array_values( $dynamic ); |
9 | 200 |
$dynamic = array(); |
5 | 201 |
|
16 | 202 |
// Dashes and spaces. |
9 | 203 |
$dynamic['/---/'] = $em_dash; |
5 | 204 |
$dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash; |
9 | 205 |
$dynamic['/(?<!xn)--/'] = $en_dash; |
206 |
$dynamic[ '/(?<=^|' . $spaces . ')-(?=$|' . $spaces . ')/' ] = $en_dash; |
|
207 |
||
208 |
$dynamic_characters['dash'] = array_keys( $dynamic ); |
|
5 | 209 |
$dynamic_replacements['dash'] = array_values( $dynamic ); |
0 | 210 |
} |
211 |
||
16 | 212 |
// Must do this every time in case plugins use these filters in a context sensitive manner. |
5 | 213 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
* Filters the list of HTML elements not to texturize. |
5 | 215 |
* |
216 |
* @since 2.8.0 |
|
217 |
* |
|
16 | 218 |
* @param string[] $default_no_texturize_tags An array of HTML element names. |
5 | 219 |
*/ |
220 |
$no_texturize_tags = apply_filters( 'no_texturize_tags', $default_no_texturize_tags ); |
|
221 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
222 |
* Filters the list of shortcodes not to texturize. |
5 | 223 |
* |
224 |
* @since 2.8.0 |
|
225 |
* |
|
16 | 226 |
* @param string[] $default_no_texturize_shortcodes An array of shortcode names. |
5 | 227 |
*/ |
228 |
$no_texturize_shortcodes = apply_filters( 'no_texturize_shortcodes', $default_no_texturize_shortcodes ); |
|
0 | 229 |
|
9 | 230 |
$no_texturize_tags_stack = array(); |
0 | 231 |
$no_texturize_shortcodes_stack = array(); |
232 |
||
5 | 233 |
// Look for shortcodes and HTML elements. |
234 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
preg_match_all( '@\[/?([^<>&/\[\]\x00-\x20=]++)@', $text, $matches ); |
9 | 236 |
$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
$found_shortcodes = ! empty( $tagnames ); |
9 | 238 |
$shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : ''; |
239 |
$regex = _get_wptexturize_split_regex( $shortcode_regex ); |
|
5 | 240 |
|
241 |
$textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); |
|
0 | 242 |
|
243 |
foreach ( $textarr as &$curl ) { |
|
5 | 244 |
// Only call _wptexturize_pushpop_element if $curl is a delimiter. |
0 | 245 |
$first = $curl[0]; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
if ( '<' === $first ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
247 |
if ( str_starts_with( $curl, '<!--' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
// This is an HTML comment delimiter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
// This is an HTML element delimiter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
// Replace each & with & unless it already looks like an entity. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
$curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
_wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
} |
5 | 258 |
} elseif ( '' === trim( $curl ) ) { |
16 | 259 |
// This is a newline between delimiters. Performance improves when we check this. |
5 | 260 |
continue; |
261 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
262 |
} elseif ( '[' === $first && $found_shortcodes && 1 === preg_match( '/^' . $shortcode_regex . '$/', $curl ) ) { |
5 | 263 |
// This is a shortcode delimiter. |
264 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
265 |
if ( ! str_starts_with( $curl, '[[' ) && ! str_ends_with( $curl, ']]' ) ) { |
5 | 266 |
// Looks like a normal shortcode. |
267 |
_wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes ); |
|
268 |
} else { |
|
269 |
// Looks like an escaped shortcode. |
|
270 |
continue; |
|
271 |
} |
|
272 |
} elseif ( empty( $no_texturize_shortcodes_stack ) && empty( $no_texturize_tags_stack ) ) { |
|
16 | 273 |
// This is neither a delimiter, nor is this content inside of no_texturize pairs. Do texturize. |
5 | 274 |
|
275 |
$curl = str_replace( $static_characters, $static_replacements, $curl ); |
|
276 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
277 |
if ( str_contains( $curl, "'" ) ) { |
5 | 278 |
$curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
$curl = wptexturize_primes( $curl, "'", $prime, $open_sq_flag, $closing_single_quote ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
$curl = str_replace( $apos_flag, $apos, $curl ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
281 |
$curl = str_replace( $open_sq_flag, $opening_single_quote, $curl ); |
5 | 282 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
283 |
if ( str_contains( $curl, '"' ) ) { |
5 | 284 |
$curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
$curl = wptexturize_primes( $curl, '"', $double_prime, $open_q_flag, $closing_quote ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
$curl = str_replace( $open_q_flag, $opening_quote, $curl ); |
5 | 287 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
288 |
if ( str_contains( $curl, '-' ) ) { |
5 | 289 |
$curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl ); |
290 |
} |
|
291 |
||
16 | 292 |
// 9x9 (times), but never 0x9999. |
5 | 293 |
if ( 1 === preg_match( '/(?<=\d)x\d/', $curl ) ) { |
294 |
// Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one! |
|
295 |
$curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl ); |
|
296 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
// Replace each & with & unless it already looks like an entity. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
$curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl ); |
0 | 300 |
} |
301 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
return implode( '', $textarr ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
* Implements a logic tree to determine whether or not "7'." represents seven feet, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
* then converts the special char into either a prime char or a closing quote char. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
* @param string $haystack The plain text to be searched. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
* @param string $needle The character to search for such as ' or ". |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
* @param string $prime The prime char to use for replacement. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
* @param string $open_quote The opening quote char. Opening quote replacement must be |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
* accomplished already. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
* @param string $close_quote The closing quote char to use for replacement. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
* @return string The $haystack value after primes and quotes replacements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quote ) { |
9 | 321 |
$spaces = wp_spaces_regexp(); |
322 |
$flag = '<!--wp-prime-or-quote-->'; |
|
323 |
$quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|>|" . $spaces . ')/'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
$prime_pattern = "/(?<=\\d)$needle/"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
$flag_after_digit = "/(?<=\\d)$flag/"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
$flag_no_digit = "/(?<!\\d)$flag/"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
$sentences = explode( $open_quote, $haystack ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
foreach ( $sentences as $key => &$sentence ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
331 |
if ( ! str_contains( $sentence, $needle ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
} elseif ( 0 !== $key && 0 === substr_count( $sentence, $close_quote ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
$sentence = preg_replace( $quote_pattern, $flag, $sentence, -1, $count ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
if ( $count > 1 ) { |
16 | 336 |
// This sentence appears to have multiple closing quotes. Attempt Vulcan logic. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
$sentence = preg_replace( $flag_no_digit, $close_quote, $sentence, -1, $count2 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
if ( 0 === $count2 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
// Try looking for a quote followed by a period. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
$count2 = substr_count( $sentence, "$flag." ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
if ( $count2 > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
// Assume the rightmost quote-period match is the end of quotation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
$pos = strrpos( $sentence, "$flag." ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
345 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
346 |
* When all else fails, make the rightmost candidate a closing quote. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
347 |
* This is most likely to be problematic in the context of bug #18549. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
348 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
$pos = strrpos( $sentence, $flag ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
$sentence = substr_replace( $sentence, $close_quote, $pos, strlen( $flag ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
// Use conventional replacement on any remaining primes and quotes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
$sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
$sentence = preg_replace( $flag_after_digit, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
$sentence = str_replace( $flag, $close_quote, $sentence ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
357 |
} elseif ( 1 === $count ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
// Found only one closing quote candidate, so give it priority over primes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
$sentence = str_replace( $flag, $close_quote, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
360 |
$sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
} else { |
16 | 362 |
// No closing quotes found. Just run primes pattern. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
363 |
$sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
$sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
$sentence = preg_replace( $quote_pattern, $close_quote, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
369 |
if ( '"' === $needle && str_contains( $sentence, '"' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
$sentence = str_replace( '"', $close_quote, $sentence ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
return implode( $open_quote, $sentences ); |
0 | 375 |
} |
376 |
||
377 |
/** |
|
19 | 378 |
* Searches for disabled element tags. Pushes element to stack on tag open |
379 |
* and pops on tag close. |
|
380 |
* |
|
381 |
* Assumes first char of `$text` is tag opening and last char is tag closing. |
|
382 |
* Assumes second char of `$text` is optionally `/` to indicate closing as in `</html>`. |
|
0 | 383 |
* |
384 |
* @since 2.9.0 |
|
385 |
* @access private |
|
386 |
* |
|
16 | 387 |
* @param string $text Text to check. Must be a tag like `<html>` or `[shortcode]`. |
388 |
* @param string[] $stack Array of open tag elements. |
|
389 |
* @param string[] $disabled_elements Array of tag names to match against. Spaces are not allowed in tag names. |
|
0 | 390 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) { |
5 | 392 |
// Is it an opening tag or closing tag? |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
if ( isset( $text[1] ) && '/' !== $text[1] ) { |
5 | 394 |
$opening_tag = true; |
395 |
$name_offset = 1; |
|
16 | 396 |
} elseif ( 0 === count( $stack ) ) { |
5 | 397 |
// Stack is empty. Just stop. |
398 |
return; |
|
399 |
} else { |
|
400 |
$opening_tag = false; |
|
401 |
$name_offset = 2; |
|
402 |
} |
|
403 |
||
404 |
// Parse out the tag name. |
|
405 |
$space = strpos( $text, ' ' ); |
|
406 |
if ( false === $space ) { |
|
407 |
$space = -1; |
|
408 |
} else { |
|
409 |
$space -= $name_offset; |
|
410 |
} |
|
411 |
$tag = substr( $text, $name_offset, $space ); |
|
412 |
||
413 |
// Handle disabled tags. |
|
16 | 414 |
if ( in_array( $tag, $disabled_elements, true ) ) { |
5 | 415 |
if ( $opening_tag ) { |
0 | 416 |
/* |
417 |
* This disables texturize until we find a closing tag of our type |
|
16 | 418 |
* (e.g. <pre>) even if there was invalid nesting before that. |
0 | 419 |
* |
420 |
* Example: in the case <pre>sadsadasd</code>"baba"</pre> |
|
16 | 421 |
* "baba" won't be texturized. |
0 | 422 |
*/ |
423 |
||
5 | 424 |
array_push( $stack, $tag ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
425 |
} elseif ( end( $stack ) === $tag ) { |
5 | 426 |
array_pop( $stack ); |
0 | 427 |
} |
428 |
} |
|
429 |
} |
|
430 |
||
431 |
/** |
|
16 | 432 |
* Replaces double line breaks with paragraph elements. |
0 | 433 |
* |
434 |
* A group of regex replaces used to identify text formatted with newlines and |
|
16 | 435 |
* replace double line breaks with HTML paragraph tags. The remaining line breaks |
19 | 436 |
* after conversion become `<br />` tags, unless `$br` is set to '0' or 'false'. |
0 | 437 |
* |
438 |
* @since 0.71 |
|
439 |
* |
|
19 | 440 |
* @param string $text The text which has to be formatted. |
441 |
* @param bool $br Optional. If set, this will convert all remaining line breaks |
|
442 |
* after paragraphing. Line breaks within `<script>`, `<style>`, |
|
443 |
* and `<svg>` tags are not affected. Default true. |
|
0 | 444 |
* @return string Text which has been converted into correct paragraph tags. |
445 |
*/ |
|
19 | 446 |
function wpautop( $text, $br = true ) { |
0 | 447 |
$pre_tags = array(); |
448 |
||
19 | 449 |
if ( trim( $text ) === '' ) { |
0 | 450 |
return ''; |
9 | 451 |
} |
0 | 452 |
|
5 | 453 |
// Just to make things a little easier, pad the end. |
19 | 454 |
$text = $text . "\n"; |
5 | 455 |
|
456 |
/* |
|
457 |
* Pre tags shouldn't be touched by autop. |
|
458 |
* Replace pre tags with placeholders and bring them back after autop. |
|
459 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
460 |
if ( str_contains( $text, '<pre' ) ) { |
19 | 461 |
$text_parts = explode( '</pre>', $text ); |
462 |
$last_part = array_pop( $text_parts ); |
|
463 |
$text = ''; |
|
464 |
$i = 0; |
|
465 |
||
466 |
foreach ( $text_parts as $text_part ) { |
|
467 |
$start = strpos( $text_part, '<pre' ); |
|
0 | 468 |
|
16 | 469 |
// Malformed HTML? |
470 |
if ( false === $start ) { |
|
19 | 471 |
$text .= $text_part; |
0 | 472 |
continue; |
473 |
} |
|
474 |
||
9 | 475 |
$name = "<pre wp-pre-tag-$i></pre>"; |
19 | 476 |
$pre_tags[ $name ] = substr( $text_part, $start ) . '</pre>'; |
477 |
||
478 |
$text .= substr( $text_part, 0, $start ) . $name; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
479 |
++$i; |
0 | 480 |
} |
481 |
||
19 | 482 |
$text .= $last_part; |
0 | 483 |
} |
16 | 484 |
// Change multiple <br>'s into two line breaks, which will turn into paragraphs. |
19 | 485 |
$text = preg_replace( '|<br\s*/?>\s*<br\s*/?>|', "\n\n", $text ); |
5 | 486 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
487 |
$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; |
5 | 488 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
// Add a double line break above block-level opening tags. |
19 | 490 |
$text = preg_replace( '!(<' . $allblocks . '[\s/>])!', "\n\n$1", $text ); |
5 | 491 |
|
492 |
// Add a double line break below block-level closing tags. |
|
19 | 493 |
$text = preg_replace( '!(</' . $allblocks . '>)!', "$1\n\n", $text ); |
5 | 494 |
|
16 | 495 |
// Add a double line break after hr tags, which are self closing. |
19 | 496 |
$text = preg_replace( '!(<hr\s*?/?>)!', "$1\n\n", $text ); |
16 | 497 |
|
5 | 498 |
// Standardize newline characters to "\n". |
19 | 499 |
$text = str_replace( array( "\r\n", "\r" ), "\n", $text ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
500 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
501 |
// Find newlines in all elements and add placeholders. |
19 | 502 |
$text = wp_replace_in_html_tags( $text, array( "\n" => ' <!-- wpnl --> ' ) ); |
5 | 503 |
|
504 |
// Collapse line breaks before and after <option> elements so they don't get autop'd. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
505 |
if ( str_contains( $text, '<option' ) ) { |
19 | 506 |
$text = preg_replace( '|\s*<option|', '<option', $text ); |
507 |
$text = preg_replace( '|</option>\s*|', '</option>', $text ); |
|
5 | 508 |
} |
509 |
||
510 |
/* |
|
511 |
* Collapse line breaks inside <object> elements, before <param> and <embed> elements |
|
512 |
* so they don't get autop'd. |
|
513 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
514 |
if ( str_contains( $text, '</object>' ) ) { |
19 | 515 |
$text = preg_replace( '|(<object[^>]*>)\s*|', '$1', $text ); |
516 |
$text = preg_replace( '|\s*</object>|', '</object>', $text ); |
|
517 |
$text = preg_replace( '%\s*(</?(?:param|embed)[^>]*>)\s*%', '$1', $text ); |
|
0 | 518 |
} |
5 | 519 |
|
520 |
/* |
|
521 |
* Collapse line breaks inside <audio> and <video> elements, |
|
522 |
* before and after <source> and <track> elements. |
|
523 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
524 |
if ( str_contains( $text, '<source' ) || str_contains( $text, '<track' ) ) { |
19 | 525 |
$text = preg_replace( '%([<\[](?:audio|video)[^>\]]*[>\]])\s*%', '$1', $text ); |
526 |
$text = preg_replace( '%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $text ); |
|
527 |
$text = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $text ); |
|
5 | 528 |
} |
529 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
530 |
// Collapse line breaks before and after <figcaption> elements. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
531 |
if ( str_contains( $text, '<figcaption' ) ) { |
19 | 532 |
$text = preg_replace( '|\s*(<figcaption[^>]*>)|', '$1', $text ); |
533 |
$text = preg_replace( '|</figcaption>\s*|', '</figcaption>', $text ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
534 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
|
5 | 536 |
// Remove more than two contiguous line breaks. |
19 | 537 |
$text = preg_replace( "/\n\n+/", "\n\n", $text ); |
5 | 538 |
|
539 |
// Split up the contents into an array of strings, separated by double line breaks. |
|
19 | 540 |
$paragraphs = preg_split( '/\n\s*\n/', $text, -1, PREG_SPLIT_NO_EMPTY ); |
541 |
||
542 |
// Reset $text prior to rebuilding. |
|
543 |
$text = ''; |
|
5 | 544 |
|
545 |
// Rebuild the content as a string, wrapping every bit with a <p>. |
|
19 | 546 |
foreach ( $paragraphs as $paragraph ) { |
547 |
$text .= '<p>' . trim( $paragraph, "\n" ) . "</p>\n"; |
|
5 | 548 |
} |
549 |
||
550 |
// Under certain strange conditions it could create a P of entirely whitespace. |
|
19 | 551 |
$text = preg_replace( '|<p>\s*</p>|', '', $text ); |
5 | 552 |
|
553 |
// Add a closing <p> inside <div>, <address>, or <form> tag if missing. |
|
19 | 554 |
$text = preg_replace( '!<p>([^<]+)</(div|address|form)>!', '<p>$1</p></$2>', $text ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
555 |
|
5 | 556 |
// If an opening or closing block element tag is wrapped in a <p>, unwrap it. |
19 | 557 |
$text = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', '$1', $text ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
|
5 | 559 |
// In some cases <li> may get wrapped in <p>, fix them. |
19 | 560 |
$text = preg_replace( '|<p>(<li.+?)</p>|', '$1', $text ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
561 |
|
5 | 562 |
// If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>. |
19 | 563 |
$text = preg_replace( '|<p><blockquote([^>]*)>|i', '<blockquote$1><p>', $text ); |
564 |
$text = str_replace( '</blockquote></p>', '</p></blockquote>', $text ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
565 |
|
5 | 566 |
// If an opening or closing block element tag is preceded by an opening <p> tag, remove it. |
19 | 567 |
$text = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)!', '$1', $text ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
568 |
|
5 | 569 |
// If an opening or closing block element tag is followed by a closing <p> tag, remove it. |
19 | 570 |
$text = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*</p>!', '$1', $text ); |
5 | 571 |
|
572 |
// Optionally insert line breaks. |
|
0 | 573 |
if ( $br ) { |
5 | 574 |
// Replace newlines that shouldn't be touched with a placeholder. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
575 |
$text = preg_replace_callback( '/<(script|style|svg|math).*?<\/\\1>/s', '_autop_newline_preservation_helper', $text ); |
5 | 576 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
577 |
// Normalize <br>. |
19 | 578 |
$text = str_replace( array( '<br>', '<br/>' ), '<br />', $text ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
579 |
|
5 | 580 |
// Replace any new line characters that aren't preceded by a <br /> with a <br />. |
19 | 581 |
$text = preg_replace( '|(?<!<br />)\s*\n|', "<br />\n", $text ); |
5 | 582 |
|
583 |
// Replace newline placeholders with newlines. |
|
19 | 584 |
$text = str_replace( '<WPPreserveNewline />', "\n", $text ); |
0 | 585 |
} |
5 | 586 |
|
587 |
// If a <br /> tag is after an opening or closing block tag, remove it. |
|
19 | 588 |
$text = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*<br />!', '$1', $text ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
589 |
|
5 | 590 |
// If a <br /> tag is before a subset of opening or closing block tags, remove it. |
19 | 591 |
$text = preg_replace( '!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $text ); |
592 |
$text = preg_replace( "|\n</p>$|", '</p>', $text ); |
|
0 | 593 |
|
5 | 594 |
// Replace placeholder <pre> tags with their original content. |
9 | 595 |
if ( ! empty( $pre_tags ) ) { |
19 | 596 |
$text = str_replace( array_keys( $pre_tags ), array_values( $pre_tags ), $text ); |
9 | 597 |
} |
0 | 598 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
599 |
// Restore newlines in all elements. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
600 |
if ( str_contains( $text, '<!-- wpnl -->' ) ) { |
19 | 601 |
$text = str_replace( array( ' <!-- wpnl --> ', '<!-- wpnl -->' ), "\n", $text ); |
602 |
} |
|
603 |
||
604 |
return $text; |
|
0 | 605 |
} |
606 |
||
607 |
/** |
|
19 | 608 |
* Separates HTML elements and comments from the text. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
* @since 4.2.4 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
611 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
* @param string $input The text which has to be formatted. |
16 | 613 |
* @return string[] Array of the formatted text. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
function wp_html_split( $input ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
616 |
return preg_split( get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
/** |
19 | 620 |
* Retrieves the regular expression for an HTML element. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
624 |
* @return string The regular expression. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
626 |
function get_html_split_regex() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
static $regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
629 |
if ( ! isset( $regex ) ) { |
9 | 630 |
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
631 |
$comments = |
9 | 632 |
'!' // Start of comment, after the <. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
633 |
. '(?:' // Unroll the loop: Consume everything until --> is found. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
634 |
. '-(?!->)' // Dash not followed by end of comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
635 |
. '[^\-]*+' // Consume non-dashes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
. ')*+' // Loop possessively. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
637 |
. '(?:-->)?'; // End of comment. If not found, match all input. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
638 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
$cdata = |
9 | 640 |
'!\[CDATA\[' // Start of comment, after the <. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
641 |
. '[^\]]*+' // Consume non-]. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
. '(?:' // Unroll the loop: Consume everything until ]]> is found. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
. '](?!]>)' // One ] not followed by end of comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
644 |
. '[^\]]*+' // Consume non-]. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
645 |
. ')*+' // Loop possessively. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
. '(?:]]>)?'; // End of comment. If not found, match all input. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
647 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
648 |
$escaped = |
9 | 649 |
'(?=' // Is the element escaped? |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
. '!--' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
. '|' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
. '!\[CDATA\[' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
. ')' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
654 |
. '(?(?=!-)' // If yes, which type? |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
655 |
. $comments |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
656 |
. '|' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
657 |
. $cdata |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
. ')'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
660 |
$regex = |
9 | 661 |
'/(' // Capture the entire match. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
. '<' // Find start of element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
663 |
. '(?' // Conditional expression follows. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
. $escaped // Find end of escaped element. |
16 | 665 |
. '|' // ...else... |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
666 |
. '[^>]*>?' // Find end of normal element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
. ')' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
668 |
. ')/'; |
9 | 669 |
// phpcs:enable |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
return $regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
674 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
675 |
/** |
19 | 676 |
* Retrieves the combined regular expression for HTML and shortcodes. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
678 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
* @ignore |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
680 |
* @internal This function will be removed in 4.5.0 per Shortcode API Roadmap. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
* |
19 | 683 |
* @param string $shortcode_regex Optional. The result from _get_wptexturize_shortcode_regex(). |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
684 |
* @return string The regular expression. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
685 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
686 |
function _get_wptexturize_split_regex( $shortcode_regex = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
static $html_regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
688 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
689 |
if ( ! isset( $html_regex ) ) { |
9 | 690 |
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
691 |
$comment_regex = |
9 | 692 |
'!' // Start of comment, after the <. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
. '(?:' // Unroll the loop: Consume everything until --> is found. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
. '-(?!->)' // Dash not followed by end of comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
. '[^\-]*+' // Consume non-dashes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
. ')*+' // Loop possessively. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
. '(?:-->)?'; // End of comment. If not found, match all input. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
|
9 | 699 |
$html_regex = // Needs replaced with wp_html_split() per Shortcode API Roadmap. |
700 |
'<' // Find start of element. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
. '(?(?=!--)' // Is this a comment? |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
. $comment_regex // Find end of comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
. '|' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
. '[^>]*>?' // Find end of element. If not found, match all input. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
. ')'; |
9 | 706 |
// phpcs:enable |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
709 |
if ( empty( $shortcode_regex ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
710 |
$regex = '/(' . $html_regex . ')/'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
$regex = '/(' . $html_regex . '|' . $shortcode_regex . ')/'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
return $regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
716 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
718 |
/** |
19 | 719 |
* Retrieves the regular expression for shortcodes. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
721 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
* @ignore |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
723 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
724 |
* |
16 | 725 |
* @param string[] $tagnames Array of shortcodes to find. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
726 |
* @return string The regular expression. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
727 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
728 |
function _get_wptexturize_shortcode_regex( $tagnames ) { |
18 | 729 |
$tagregexp = implode( '|', array_map( 'preg_quote', $tagnames ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
$tagregexp = "(?:$tagregexp)(?=[\\s\\]\\/])"; // Excerpt of get_shortcode_regex(). |
9 | 731 |
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
$regex = |
16 | 733 |
'\[' // Find start of shortcode. |
734 |
. '[\/\[]?' // Shortcodes may begin with [/ or [[. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
735 |
. $tagregexp // Only match registered shortcodes, because performance. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
736 |
. '(?:' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
. '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
738 |
. '|' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
. '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
740 |
. ')*+' // Possessive critical. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
. '\]' // Find end of shortcode. |
16 | 742 |
. '\]?'; // Shortcodes may end with ]]. |
9 | 743 |
// phpcs:enable |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
744 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
745 |
return $regex; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
746 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
748 |
/** |
19 | 749 |
* Replaces characters or phrases within HTML elements only. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
750 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
751 |
* @since 4.2.3 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
752 |
* |
16 | 753 |
* @param string $haystack The text which has to be formatted. |
754 |
* @param array $replace_pairs In the form array('from' => 'to', ...). |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
755 |
* @return string The formatted text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
756 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
757 |
function wp_replace_in_html_tags( $haystack, $replace_pairs ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
758 |
// Find all elements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
$textarr = wp_html_split( $haystack ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
$changed = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
// Optimize when searching for one item. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
if ( 1 === count( $replace_pairs ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
// Extract $needle and $replace. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
765 |
$needle = array_key_first( $replace_pairs ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
766 |
$replace = $replace_pairs[ $needle ]; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
767 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
768 |
// Loop through delimiters (elements) only. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
769 |
for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
770 |
if ( str_contains( $textarr[ $i ], $needle ) ) { |
9 | 771 |
$textarr[ $i ] = str_replace( $needle, $replace, $textarr[ $i ] ); |
772 |
$changed = true; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
773 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
774 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
775 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
// Extract all $needles. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
777 |
$needles = array_keys( $replace_pairs ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
778 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
// Loop through delimiters (elements) only. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
780 |
for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
781 |
foreach ( $needles as $needle ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
782 |
if ( str_contains( $textarr[ $i ], $needle ) ) { |
9 | 783 |
$textarr[ $i ] = strtr( $textarr[ $i ], $replace_pairs ); |
784 |
$changed = true; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
// After one strtr() break out of the foreach loop and look at next element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
786 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
787 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
789 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
790 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
791 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
792 |
if ( $changed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
$haystack = implode( $textarr ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
794 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
return $haystack; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
798 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
799 |
/** |
19 | 800 |
* Newline preservation help function for wpautop(). |
0 | 801 |
* |
802 |
* @since 3.1.0 |
|
803 |
* @access private |
|
804 |
* |
|
805 |
* @param array $matches preg_replace_callback matches array |
|
806 |
* @return string |
|
807 |
*/ |
|
808 |
function _autop_newline_preservation_helper( $matches ) { |
|
9 | 809 |
return str_replace( "\n", '<WPPreserveNewline />', $matches[0] ); |
0 | 810 |
} |
811 |
||
812 |
/** |
|
19 | 813 |
* Don't auto-p wrap shortcodes that stand alone. |
0 | 814 |
* |
5 | 815 |
* Ensures that shortcodes are not wrapped in `<p>...</p>`. |
0 | 816 |
* |
817 |
* @since 2.9.0 |
|
818 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
819 |
* @global array $shortcode_tags |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
820 |
* |
19 | 821 |
* @param string $text The content. |
0 | 822 |
* @return string The filtered content. |
823 |
*/ |
|
19 | 824 |
function shortcode_unautop( $text ) { |
0 | 825 |
global $shortcode_tags; |
826 |
||
9 | 827 |
if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { |
19 | 828 |
return $text; |
0 | 829 |
} |
830 |
||
18 | 831 |
$tagregexp = implode( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) ); |
9 | 832 |
$spaces = wp_spaces_regexp(); |
833 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
834 |
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound,Universal.WhiteSpace.PrecisionAlignment.Found -- don't remove regex indentation |
0 | 835 |
$pattern = |
9 | 836 |
'/' |
16 | 837 |
. '<p>' // Opening paragraph. |
838 |
. '(?:' . $spaces . ')*+' // Optional leading whitespace. |
|
839 |
. '(' // 1: The shortcode. |
|
840 |
. '\\[' // Opening bracket. |
|
841 |
. "($tagregexp)" // 2: Shortcode name. |
|
842 |
. '(?![\\w-])' // Not followed by word character or hyphen. |
|
843 |
// Unroll the loop: Inside the opening shortcode tag. |
|
844 |
. '[^\\]\\/]*' // Not a closing bracket or forward slash. |
|
0 | 845 |
. '(?:' |
16 | 846 |
. '\\/(?!\\])' // A forward slash not followed by a closing bracket. |
847 |
. '[^\\]\\/]*' // Not a closing bracket or forward slash. |
|
0 | 848 |
. ')*?' |
849 |
. '(?:' |
|
16 | 850 |
. '\\/\\]' // Self closing tag and closing bracket. |
0 | 851 |
. '|' |
16 | 852 |
. '\\]' // Closing bracket. |
853 |
. '(?:' // Unroll the loop: Optionally, anything between the opening and closing shortcode tags. |
|
854 |
. '[^\\[]*+' // Not an opening bracket. |
|
0 | 855 |
. '(?:' |
16 | 856 |
. '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag. |
857 |
. '[^\\[]*+' // Not an opening bracket. |
|
0 | 858 |
. ')*+' |
16 | 859 |
. '\\[\\/\\2\\]' // Closing shortcode tag. |
0 | 860 |
. ')?' |
861 |
. ')' |
|
862 |
. ')' |
|
16 | 863 |
. '(?:' . $spaces . ')*+' // Optional trailing whitespace. |
864 |
. '<\\/p>' // Closing paragraph. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
865 |
. '/'; |
9 | 866 |
// phpcs:enable |
0 | 867 |
|
19 | 868 |
return preg_replace( $pattern, '$1', $text ); |
0 | 869 |
} |
870 |
||
871 |
/** |
|
872 |
* Checks to see if a string is utf8 encoded. |
|
873 |
* |
|
874 |
* NOTE: This function checks for 5-Byte sequences, UTF8 |
|
875 |
* has Bytes Sequences with a maximum length of 4. |
|
876 |
* |
|
877 |
* @author bmorel at ssi dot fr (modified) |
|
878 |
* @since 1.2.1 |
|
879 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
880 |
* @param string $str The string to be checked. |
0 | 881 |
* @return bool True if $str fits a UTF-8 model, false otherwise. |
882 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
883 |
function seems_utf8( $str ) { |
5 | 884 |
mbstring_binary_safe_encoding(); |
9 | 885 |
$length = strlen( $str ); |
5 | 886 |
reset_mbstring_encoding(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
887 |
|
9 | 888 |
for ( $i = 0; $i < $length; $i++ ) { |
889 |
$c = ord( $str[ $i ] ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
890 |
|
9 | 891 |
if ( $c < 0x80 ) { |
892 |
$n = 0; // 0bbbbbbb |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
893 |
} elseif ( ( $c & 0xE0 ) === 0xC0 ) { |
9 | 894 |
$n = 1; // 110bbbbb |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
895 |
} elseif ( ( $c & 0xF0 ) === 0xE0 ) { |
9 | 896 |
$n = 2; // 1110bbbb |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
897 |
} elseif ( ( $c & 0xF8 ) === 0xF0 ) { |
9 | 898 |
$n = 3; // 11110bbb |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
899 |
} elseif ( ( $c & 0xFC ) === 0xF8 ) { |
9 | 900 |
$n = 4; // 111110bb |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
901 |
} elseif ( ( $c & 0xFE ) === 0xFC ) { |
9 | 902 |
$n = 5; // 1111110b |
903 |
} else { |
|
16 | 904 |
return false; // Does not match any model. |
9 | 905 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
906 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
907 |
for ( $j = 0; $j < $n; $j++ ) { // n bytes matching 10bbbbbb follow? |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
908 |
if ( ( ++$i === $length ) || ( ( ord( $str[ $i ] ) & 0xC0 ) !== 0x80 ) ) { |
0 | 909 |
return false; |
9 | 910 |
} |
0 | 911 |
} |
912 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
913 |
|
0 | 914 |
return true; |
915 |
} |
|
916 |
||
917 |
/** |
|
918 |
* Converts a number of special characters into their HTML entities. |
|
919 |
* |
|
19 | 920 |
* Specifically deals with: `&`, `<`, `>`, `"`, and `'`. |
921 |
* |
|
922 |
* `$quote_style` can be set to ENT_COMPAT to encode `"` to |
|
923 |
* `"`, or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded. |
|
0 | 924 |
* |
925 |
* @since 1.2.2 |
|
16 | 926 |
* @since 5.5.0 `$quote_style` also accepts `ENT_XML1`. |
0 | 927 |
* @access private |
928 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
929 |
* @param string $text The text which is to be encoded. |
16 | 930 |
* @param int|string $quote_style Optional. Converts double quotes if set to ENT_COMPAT, |
931 |
* both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. |
|
932 |
* Converts single and double quotes, as well as converting HTML |
|
933 |
* named entities (that are not also XML named entities) to their |
|
934 |
* code points if set to ENT_XML1. Also compatible with old values; |
|
935 |
* converting single quotes if set to 'single', |
|
936 |
* double if set to 'double' or both if otherwise set. |
|
937 |
* Default is ENT_NOQUOTES. |
|
938 |
* @param false|string $charset Optional. The character encoding of the string. Default false. |
|
939 |
* @param bool $double_encode Optional. Whether to encode existing HTML entities. Default false. |
|
0 | 940 |
* @return string The encoded text with HTML entities. |
941 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
942 |
function _wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
943 |
$text = (string) $text; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
944 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
945 |
if ( 0 === strlen( $text ) ) { |
0 | 946 |
return ''; |
9 | 947 |
} |
0 | 948 |
|
16 | 949 |
// Don't bother if there are no specialchars - saves some processing. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
950 |
if ( ! preg_match( '/[&<>"\']/', $text ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
951 |
return $text; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
952 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
953 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
954 |
// Account for the previous behavior of the function when the $quote_style is not an accepted value. |
9 | 955 |
if ( empty( $quote_style ) ) { |
0 | 956 |
$quote_style = ENT_NOQUOTES; |
16 | 957 |
} elseif ( ENT_XML1 === $quote_style ) { |
958 |
$quote_style = ENT_QUOTES | ENT_XML1; |
|
959 |
} elseif ( ! in_array( $quote_style, array( ENT_NOQUOTES, ENT_COMPAT, ENT_QUOTES, 'single', 'double' ), true ) ) { |
|
0 | 960 |
$quote_style = ENT_QUOTES; |
9 | 961 |
} |
0 | 962 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
963 |
$charset = _canonical_charset( $charset ? $charset : get_option( 'blog_charset' ) ); |
0 | 964 |
|
965 |
$_quote_style = $quote_style; |
|
966 |
||
16 | 967 |
if ( 'double' === $quote_style ) { |
9 | 968 |
$quote_style = ENT_COMPAT; |
0 | 969 |
$_quote_style = ENT_COMPAT; |
16 | 970 |
} elseif ( 'single' === $quote_style ) { |
0 | 971 |
$quote_style = ENT_NOQUOTES; |
972 |
} |
|
973 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
974 |
if ( ! $double_encode ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
975 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
976 |
* Guarantee every &entity; is valid, convert &garbage; into &garbage; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
977 |
* This is required for PHP < 5.4.0 because ENT_HTML401 flag is unavailable. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
978 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
979 |
$text = wp_kses_normalize_entities( $text, ( $quote_style & ENT_XML1 ) ? 'xml' : 'html' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
980 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
981 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
982 |
$text = htmlspecialchars( $text, $quote_style, $charset, $double_encode ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
983 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
984 |
// Back-compat. |
9 | 985 |
if ( 'single' === $_quote_style ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
986 |
$text = str_replace( "'", ''', $text ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
987 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
988 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
989 |
return $text; |
0 | 990 |
} |
991 |
||
992 |
/** |
|
993 |
* Converts a number of HTML entities into their special characters. |
|
994 |
* |
|
19 | 995 |
* Specifically deals with: `&`, `<`, `>`, `"`, and `'`. |
996 |
* |
|
997 |
* `$quote_style` can be set to ENT_COMPAT to decode `"` entities, |
|
998 |
* or ENT_QUOTES to do both `"` and `'`. Default is ENT_NOQUOTES where no quotes are decoded. |
|
0 | 999 |
* |
1000 |
* @since 2.8.0 |
|
1001 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1002 |
* @param string $text The text which is to be decoded. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
* @param string|int $quote_style Optional. Converts double quotes if set to ENT_COMPAT, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1004 |
* both single and double if set to ENT_QUOTES or |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1005 |
* none if set to ENT_NOQUOTES. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1006 |
* Also compatible with old _wp_specialchars() values; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1007 |
* converting single quotes if set to 'single', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
* double if set to 'double' or both if otherwise set. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1009 |
* Default is ENT_NOQUOTES. |
0 | 1010 |
* @return string The decoded text without HTML entities. |
1011 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1012 |
function wp_specialchars_decode( $text, $quote_style = ENT_NOQUOTES ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1013 |
$text = (string) $text; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1014 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1015 |
if ( 0 === strlen( $text ) ) { |
0 | 1016 |
return ''; |
1017 |
} |
|
1018 |
||
16 | 1019 |
// Don't bother if there are no entities - saves a lot of processing. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1020 |
if ( ! str_contains( $text, '&' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1021 |
return $text; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1022 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1023 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1024 |
// Match the previous behavior of _wp_specialchars() when the $quote_style is not an accepted value. |
0 | 1025 |
if ( empty( $quote_style ) ) { |
1026 |
$quote_style = ENT_NOQUOTES; |
|
9 | 1027 |
} elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { |
0 | 1028 |
$quote_style = ENT_QUOTES; |
1029 |
} |
|
1030 |
||
16 | 1031 |
// More complete than get_html_translation_table( HTML_SPECIALCHARS ). |
9 | 1032 |
$single = array( |
1033 |
''' => '\'', |
|
1034 |
''' => '\'', |
|
1035 |
); |
|
1036 |
$single_preg = array( |
|
1037 |
'/�*39;/' => ''', |
|
1038 |
'/�*27;/i' => ''', |
|
1039 |
); |
|
1040 |
$double = array( |
|
1041 |
'"' => '"', |
|
1042 |
'"' => '"', |
|
1043 |
'"' => '"', |
|
1044 |
); |
|
1045 |
$double_preg = array( |
|
1046 |
'/�*34;/' => '"', |
|
1047 |
'/�*22;/i' => '"', |
|
1048 |
); |
|
1049 |
$others = array( |
|
1050 |
'<' => '<', |
|
1051 |
'<' => '<', |
|
1052 |
'>' => '>', |
|
1053 |
'>' => '>', |
|
1054 |
'&' => '&', |
|
1055 |
'&' => '&', |
|
1056 |
'&' => '&', |
|
1057 |
); |
|
1058 |
$others_preg = array( |
|
1059 |
'/�*60;/' => '<', |
|
1060 |
'/�*62;/' => '>', |
|
1061 |
'/�*38;/' => '&', |
|
1062 |
'/�*26;/i' => '&', |
|
1063 |
); |
|
0 | 1064 |
|
16 | 1065 |
if ( ENT_QUOTES === $quote_style ) { |
9 | 1066 |
$translation = array_merge( $single, $double, $others ); |
0 | 1067 |
$translation_preg = array_merge( $single_preg, $double_preg, $others_preg ); |
16 | 1068 |
} elseif ( ENT_COMPAT === $quote_style || 'double' === $quote_style ) { |
9 | 1069 |
$translation = array_merge( $double, $others ); |
0 | 1070 |
$translation_preg = array_merge( $double_preg, $others_preg ); |
16 | 1071 |
} elseif ( 'single' === $quote_style ) { |
9 | 1072 |
$translation = array_merge( $single, $others ); |
0 | 1073 |
$translation_preg = array_merge( $single_preg, $others_preg ); |
16 | 1074 |
} elseif ( ENT_NOQUOTES === $quote_style ) { |
9 | 1075 |
$translation = $others; |
0 | 1076 |
$translation_preg = $others_preg; |
1077 |
} |
|
1078 |
||
16 | 1079 |
// Remove zero padding on numeric entities. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1080 |
$text = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $text ); |
0 | 1081 |
|
16 | 1082 |
// Replace characters according to translation table. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1083 |
return strtr( $text, $translation ); |
0 | 1084 |
} |
1085 |
||
1086 |
/** |
|
1087 |
* Checks for invalid UTF8 in a string. |
|
1088 |
* |
|
1089 |
* @since 2.8.0 |
|
1090 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1091 |
* @param string $text The text which is to be checked. |
16 | 1092 |
* @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default false. |
0 | 1093 |
* @return string The checked text. |
1094 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1095 |
function wp_check_invalid_utf8( $text, $strip = false ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1096 |
$text = (string) $text; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1097 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1098 |
if ( 0 === strlen( $text ) ) { |
0 | 1099 |
return ''; |
1100 |
} |
|
1101 |
||
16 | 1102 |
// Store the site charset as a static to avoid multiple calls to get_option(). |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1103 |
static $is_utf8 = null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1104 |
if ( ! isset( $is_utf8 ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1105 |
$is_utf8 = is_utf8_charset(); |
0 | 1106 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
if ( ! $is_utf8 ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1108 |
return $text; |
0 | 1109 |
} |
1110 |
||
16 | 1111 |
// Check for support for utf8 in the installed PCRE library once and store the result in a static. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1112 |
static $utf8_pcre = null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1113 |
if ( ! isset( $utf8_pcre ) ) { |
16 | 1114 |
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
0 | 1115 |
$utf8_pcre = @preg_match( '/^./u', 'a' ); |
1116 |
} |
|
16 | 1117 |
// We can't demand utf8 in the PCRE installation, so just return the string in those cases. |
9 | 1118 |
if ( ! $utf8_pcre ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1119 |
return $text; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1120 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1121 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1122 |
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- preg_match fails when it encounters invalid UTF8 in $text. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1123 |
if ( 1 === @preg_match( '/^./us', $text ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1124 |
return $text; |
0 | 1125 |
} |
1126 |
||
16 | 1127 |
// Attempt to strip the bad chars if requested (not recommended). |
0 | 1128 |
if ( $strip && function_exists( 'iconv' ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1129 |
return iconv( 'utf-8', 'utf-8', $text ); |
0 | 1130 |
} |
1131 |
||
1132 |
return ''; |
|
1133 |
} |
|
1134 |
||
1135 |
/** |
|
19 | 1136 |
* Encodes the Unicode values to be used in the URI. |
0 | 1137 |
* |
1138 |
* @since 1.5.0 |
|
19 | 1139 |
* @since 5.8.3 Added the `encode_ascii_characters` parameter. |
1140 |
* |
|
1141 |
* @param string $utf8_string String to encode. |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1142 |
* @param int $length Max length of the string. |
19 | 1143 |
* @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' |
0 | 1144 |
* @return string String with Unicode encoded for URI. |
1145 |
*/ |
|
19 | 1146 |
function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { |
9 | 1147 |
$unicode = ''; |
1148 |
$values = array(); |
|
1149 |
$num_octets = 1; |
|
0 | 1150 |
$unicode_length = 0; |
1151 |
||
5 | 1152 |
mbstring_binary_safe_encoding(); |
0 | 1153 |
$string_length = strlen( $utf8_string ); |
5 | 1154 |
reset_mbstring_encoding(); |
1155 |
||
9 | 1156 |
for ( $i = 0; $i < $string_length; $i++ ) { |
0 | 1157 |
|
1158 |
$value = ord( $utf8_string[ $i ] ); |
|
1159 |
||
1160 |
if ( $value < 128 ) { |
|
19 | 1161 |
$char = chr( $value ); |
1162 |
$encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; |
|
1163 |
$encoded_char_length = strlen( $encoded_char ); |
|
1164 |
if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { |
|
0 | 1165 |
break; |
9 | 1166 |
} |
19 | 1167 |
$unicode .= $encoded_char; |
1168 |
$unicode_length += $encoded_char_length; |
|
0 | 1169 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1170 |
if ( count( $values ) === 0 ) { |
5 | 1171 |
if ( $value < 224 ) { |
1172 |
$num_octets = 2; |
|
1173 |
} elseif ( $value < 240 ) { |
|
1174 |
$num_octets = 3; |
|
1175 |
} else { |
|
1176 |
$num_octets = 4; |
|
1177 |
} |
|
1178 |
} |
|
0 | 1179 |
|
1180 |
$values[] = $value; |
|
1181 |
||
9 | 1182 |
if ( $length && ( $unicode_length + ( $num_octets * 3 ) ) > $length ) { |
0 | 1183 |
break; |
9 | 1184 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1185 |
if ( count( $values ) === $num_octets ) { |
5 | 1186 |
for ( $j = 0; $j < $num_octets; $j++ ) { |
1187 |
$unicode .= '%' . dechex( $values[ $j ] ); |
|
0 | 1188 |
} |
1189 |
||
5 | 1190 |
$unicode_length += $num_octets * 3; |
1191 |
||
9 | 1192 |
$values = array(); |
0 | 1193 |
$num_octets = 1; |
1194 |
} |
|
1195 |
} |
|
1196 |
} |
|
1197 |
||
1198 |
return $unicode; |
|
1199 |
} |
|
1200 |
||
1201 |
/** |
|
1202 |
* Converts all accent characters to ASCII characters. |
|
1203 |
* |
|
1204 |
* If there are no accent characters, then the string given is just returned. |
|
1205 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1206 |
* **Accent characters converted:** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1207 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1208 |
* Currency signs: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1209 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1210 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1211 |
* | -------- | ----- | ----------- | ------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1212 |
* | U+00A3 | £ | (empty) | British Pound sign | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1213 |
* | U+20AC | € | E | Euro sign | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1214 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1215 |
* Decompositions for Latin-1 Supplement: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1216 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1217 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1218 |
* | ------- | ----- | ----------- | -------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
* | U+00AA | ª | a | Feminine ordinal indicator | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1220 |
* | U+00BA | º | o | Masculine ordinal indicator | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1221 |
* | U+00C0 | À | A | Latin capital letter A with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1222 |
* | U+00C1 | Á | A | Latin capital letter A with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1223 |
* | U+00C2 | Â | A | Latin capital letter A with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
* | U+00C3 | Ã | A | Latin capital letter A with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
* | U+00C4 | Ä | A | Latin capital letter A with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1226 |
* | U+00C5 | Å | A | Latin capital letter A with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1227 |
* | U+00C6 | Æ | AE | Latin capital letter AE | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
* | U+00C7 | Ç | C | Latin capital letter C with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1229 |
* | U+00C8 | È | E | Latin capital letter E with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1230 |
* | U+00C9 | É | E | Latin capital letter E with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1231 |
* | U+00CA | Ê | E | Latin capital letter E with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1232 |
* | U+00CB | Ë | E | Latin capital letter E with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1233 |
* | U+00CC | Ì | I | Latin capital letter I with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1234 |
* | U+00CD | Í | I | Latin capital letter I with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1235 |
* | U+00CE | Î | I | Latin capital letter I with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1236 |
* | U+00CF | Ï | I | Latin capital letter I with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
* | U+00D0 | Ð | D | Latin capital letter Eth | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1238 |
* | U+00D1 | Ñ | N | Latin capital letter N with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1239 |
* | U+00D2 | Ò | O | Latin capital letter O with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1240 |
* | U+00D3 | Ó | O | Latin capital letter O with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1241 |
* | U+00D4 | Ô | O | Latin capital letter O with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
* | U+00D5 | Õ | O | Latin capital letter O with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1243 |
* | U+00D6 | Ö | O | Latin capital letter O with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
* | U+00D8 | Ø | O | Latin capital letter O with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
* | U+00D9 | Ù | U | Latin capital letter U with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1246 |
* | U+00DA | Ú | U | Latin capital letter U with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1247 |
* | U+00DB | Û | U | Latin capital letter U with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1248 |
* | U+00DC | Ü | U | Latin capital letter U with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1249 |
* | U+00DD | Ý | Y | Latin capital letter Y with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
* | U+00DE | Þ | TH | Latin capital letter Thorn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1251 |
* | U+00DF | ß | s | Latin small letter sharp s | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1252 |
* | U+00E0 | à | a | Latin small letter a with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
* | U+00E1 | á | a | Latin small letter a with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
* | U+00E2 | â | a | Latin small letter a with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
* | U+00E3 | ã | a | Latin small letter a with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
* | U+00E4 | ä | a | Latin small letter a with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
* | U+00E5 | å | a | Latin small letter a with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
* | U+00E6 | æ | ae | Latin small letter ae | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1259 |
* | U+00E7 | ç | c | Latin small letter c with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1260 |
* | U+00E8 | è | e | Latin small letter e with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1261 |
* | U+00E9 | é | e | Latin small letter e with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
* | U+00EA | ê | e | Latin small letter e with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1263 |
* | U+00EB | ë | e | Latin small letter e with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
* | U+00EC | ì | i | Latin small letter i with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1265 |
* | U+00ED | í | i | Latin small letter i with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1266 |
* | U+00EE | î | i | Latin small letter i with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1267 |
* | U+00EF | ï | i | Latin small letter i with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
* | U+00F0 | ð | d | Latin small letter Eth | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1269 |
* | U+00F1 | ñ | n | Latin small letter n with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
* | U+00F2 | ò | o | Latin small letter o with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1271 |
* | U+00F3 | ó | o | Latin small letter o with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1272 |
* | U+00F4 | ô | o | Latin small letter o with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1273 |
* | U+00F5 | õ | o | Latin small letter o with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1274 |
* | U+00F6 | ö | o | Latin small letter o with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1275 |
* | U+00F8 | ø | o | Latin small letter o with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
* | U+00F9 | ù | u | Latin small letter u with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
* | U+00FA | ú | u | Latin small letter u with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1278 |
* | U+00FB | û | u | Latin small letter u with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1279 |
* | U+00FC | ü | u | Latin small letter u with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
* | U+00FD | ý | y | Latin small letter y with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1281 |
* | U+00FE | þ | th | Latin small letter Thorn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1282 |
* | U+00FF | ÿ | y | Latin small letter y with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1283 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1284 |
* Decompositions for Latin Extended-A: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1285 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1286 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1287 |
* | ------- | ----- | ----------- | ------------------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1288 |
* | U+0100 | Ā | A | Latin capital letter A with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1289 |
* | U+0101 | ā | a | Latin small letter a with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1290 |
* | U+0102 | Ă | A | Latin capital letter A with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1291 |
* | U+0103 | ă | a | Latin small letter a with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1292 |
* | U+0104 | Ą | A | Latin capital letter A with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1293 |
* | U+0105 | ą | a | Latin small letter a with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1294 |
* | U+01006 | Ć | C | Latin capital letter C with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1295 |
* | U+0107 | ć | c | Latin small letter c with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1296 |
* | U+0108 | Ĉ | C | Latin capital letter C with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1297 |
* | U+0109 | ĉ | c | Latin small letter c with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1298 |
* | U+010A | Ċ | C | Latin capital letter C with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1299 |
* | U+010B | ċ | c | Latin small letter c with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
* | U+010C | Č | C | Latin capital letter C with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1301 |
* | U+010D | č | c | Latin small letter c with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
* | U+010E | Ď | D | Latin capital letter D with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
* | U+010F | ď | d | Latin small letter d with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1304 |
* | U+0110 | Đ | D | Latin capital letter D with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1305 |
* | U+0111 | đ | d | Latin small letter d with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1306 |
* | U+0112 | Ē | E | Latin capital letter E with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1307 |
* | U+0113 | ē | e | Latin small letter e with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1308 |
* | U+0114 | Ĕ | E | Latin capital letter E with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1309 |
* | U+0115 | ĕ | e | Latin small letter e with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1310 |
* | U+0116 | Ė | E | Latin capital letter E with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1311 |
* | U+0117 | ė | e | Latin small letter e with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1312 |
* | U+0118 | Ę | E | Latin capital letter E with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1313 |
* | U+0119 | ę | e | Latin small letter e with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1314 |
* | U+011A | Ě | E | Latin capital letter E with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1315 |
* | U+011B | ě | e | Latin small letter e with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1316 |
* | U+011C | Ĝ | G | Latin capital letter G with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1317 |
* | U+011D | ĝ | g | Latin small letter g with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1318 |
* | U+011E | Ğ | G | Latin capital letter G with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1319 |
* | U+011F | ğ | g | Latin small letter g with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1320 |
* | U+0120 | Ġ | G | Latin capital letter G with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1321 |
* | U+0121 | ġ | g | Latin small letter g with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1322 |
* | U+0122 | Ģ | G | Latin capital letter G with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1323 |
* | U+0123 | ģ | g | Latin small letter g with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1324 |
* | U+0124 | Ĥ | H | Latin capital letter H with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1325 |
* | U+0125 | ĥ | h | Latin small letter h with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1326 |
* | U+0126 | Ħ | H | Latin capital letter H with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1327 |
* | U+0127 | ħ | h | Latin small letter h with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1328 |
* | U+0128 | Ĩ | I | Latin capital letter I with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1329 |
* | U+0129 | ĩ | i | Latin small letter i with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1330 |
* | U+012A | Ī | I | Latin capital letter I with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1331 |
* | U+012B | ī | i | Latin small letter i with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1332 |
* | U+012C | Ĭ | I | Latin capital letter I with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1333 |
* | U+012D | ĭ | i | Latin small letter i with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1334 |
* | U+012E | Į | I | Latin capital letter I with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1335 |
* | U+012F | į | i | Latin small letter i with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1336 |
* | U+0130 | İ | I | Latin capital letter I with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1337 |
* | U+0131 | ı | i | Latin small letter dotless i | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1338 |
* | U+0132 | IJ | IJ | Latin capital ligature IJ | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1339 |
* | U+0133 | ij | ij | Latin small ligature ij | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1340 |
* | U+0134 | Ĵ | J | Latin capital letter J with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1341 |
* | U+0135 | ĵ | j | Latin small letter j with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1342 |
* | U+0136 | Ķ | K | Latin capital letter K with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1343 |
* | U+0137 | ķ | k | Latin small letter k with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1344 |
* | U+0138 | ĸ | k | Latin small letter Kra | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1345 |
* | U+0139 | Ĺ | L | Latin capital letter L with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1346 |
* | U+013A | ĺ | l | Latin small letter l with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1347 |
* | U+013B | Ļ | L | Latin capital letter L with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1348 |
* | U+013C | ļ | l | Latin small letter l with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1349 |
* | U+013D | Ľ | L | Latin capital letter L with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1350 |
* | U+013E | ľ | l | Latin small letter l with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1351 |
* | U+013F | Ŀ | L | Latin capital letter L with middle dot | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
* | U+0140 | ŀ | l | Latin small letter l with middle dot | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1353 |
* | U+0141 | Ł | L | Latin capital letter L with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
* | U+0142 | ł | l | Latin small letter l with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1355 |
* | U+0143 | Ń | N | Latin capital letter N with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1356 |
* | U+0144 | ń | n | Latin small letter N with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1357 |
* | U+0145 | Ņ | N | Latin capital letter N with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1358 |
* | U+0146 | ņ | n | Latin small letter n with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1359 |
* | U+0147 | Ň | N | Latin capital letter N with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1360 |
* | U+0148 | ň | n | Latin small letter n with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1361 |
* | U+0149 | ʼn | n | Latin small letter n preceded by apostrophe | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1362 |
* | U+014A | Ŋ | N | Latin capital letter Eng | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1363 |
* | U+014B | ŋ | n | Latin small letter Eng | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1364 |
* | U+014C | Ō | O | Latin capital letter O with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1365 |
* | U+014D | ō | o | Latin small letter o with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1366 |
* | U+014E | Ŏ | O | Latin capital letter O with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1367 |
* | U+014F | ŏ | o | Latin small letter o with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1368 |
* | U+0150 | Ő | O | Latin capital letter O with double acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1369 |
* | U+0151 | ő | o | Latin small letter o with double acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1370 |
* | U+0152 | Œ | OE | Latin capital ligature OE | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1371 |
* | U+0153 | œ | oe | Latin small ligature oe | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1372 |
* | U+0154 | Ŕ | R | Latin capital letter R with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1373 |
* | U+0155 | ŕ | r | Latin small letter r with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1374 |
* | U+0156 | Ŗ | R | Latin capital letter R with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1375 |
* | U+0157 | ŗ | r | Latin small letter r with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1376 |
* | U+0158 | Ř | R | Latin capital letter R with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1377 |
* | U+0159 | ř | r | Latin small letter r with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1378 |
* | U+015A | Ś | S | Latin capital letter S with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1379 |
* | U+015B | ś | s | Latin small letter s with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1380 |
* | U+015C | Ŝ | S | Latin capital letter S with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1381 |
* | U+015D | ŝ | s | Latin small letter s with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1382 |
* | U+015E | Ş | S | Latin capital letter S with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1383 |
* | U+015F | ş | s | Latin small letter s with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1384 |
* | U+0160 | Š | S | Latin capital letter S with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1385 |
* | U+0161 | š | s | Latin small letter s with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1386 |
* | U+0162 | Ţ | T | Latin capital letter T with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1387 |
* | U+0163 | ţ | t | Latin small letter t with cedilla | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1388 |
* | U+0164 | Ť | T | Latin capital letter T with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1389 |
* | U+0165 | ť | t | Latin small letter t with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1390 |
* | U+0166 | Ŧ | T | Latin capital letter T with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
* | U+0167 | ŧ | t | Latin small letter t with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1392 |
* | U+0168 | Ũ | U | Latin capital letter U with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1393 |
* | U+0169 | ũ | u | Latin small letter u with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
* | U+016A | Ū | U | Latin capital letter U with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1395 |
* | U+016B | ū | u | Latin small letter u with macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
* | U+016C | Ŭ | U | Latin capital letter U with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1397 |
* | U+016D | ŭ | u | Latin small letter u with breve | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1398 |
* | U+016E | Ů | U | Latin capital letter U with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1399 |
* | U+016F | ů | u | Latin small letter u with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
* | U+0170 | Ű | U | Latin capital letter U with double acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1401 |
* | U+0171 | ű | u | Latin small letter u with double acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1402 |
* | U+0172 | Ų | U | Latin capital letter U with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1403 |
* | U+0173 | ų | u | Latin small letter u with ogonek | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1404 |
* | U+0174 | Ŵ | W | Latin capital letter W with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1405 |
* | U+0175 | ŵ | w | Latin small letter w with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1406 |
* | U+0176 | Ŷ | Y | Latin capital letter Y with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1407 |
* | U+0177 | ŷ | y | Latin small letter y with circumflex | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1408 |
* | U+0178 | Ÿ | Y | Latin capital letter Y with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1409 |
* | U+0179 | Ź | Z | Latin capital letter Z with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1410 |
* | U+017A | ź | z | Latin small letter z with acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1411 |
* | U+017B | Ż | Z | Latin capital letter Z with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1412 |
* | U+017C | ż | z | Latin small letter z with dot above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1413 |
* | U+017D | Ž | Z | Latin capital letter Z with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1414 |
* | U+017E | ž | z | Latin small letter z with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1415 |
* | U+017F | ſ | s | Latin small letter long s | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1416 |
* | U+01A0 | Ơ | O | Latin capital letter O with horn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1417 |
* | U+01A1 | ơ | o | Latin small letter o with horn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1418 |
* | U+01AF | Ư | U | Latin capital letter U with horn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1419 |
* | U+01B0 | ư | u | Latin small letter u with horn | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1420 |
* | U+01CD | Ǎ | A | Latin capital letter A with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1421 |
* | U+01CE | ǎ | a | Latin small letter a with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1422 |
* | U+01CF | Ǐ | I | Latin capital letter I with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1423 |
* | U+01D0 | ǐ | i | Latin small letter i with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1424 |
* | U+01D1 | Ǒ | O | Latin capital letter O with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1425 |
* | U+01D2 | ǒ | o | Latin small letter o with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1426 |
* | U+01D3 | Ǔ | U | Latin capital letter U with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1427 |
* | U+01D4 | ǔ | u | Latin small letter u with caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1428 |
* | U+01D5 | Ǖ | U | Latin capital letter U with diaeresis and macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1429 |
* | U+01D6 | ǖ | u | Latin small letter u with diaeresis and macron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1430 |
* | U+01D7 | Ǘ | U | Latin capital letter U with diaeresis and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1431 |
* | U+01D8 | ǘ | u | Latin small letter u with diaeresis and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1432 |
* | U+01D9 | Ǚ | U | Latin capital letter U with diaeresis and caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1433 |
* | U+01DA | ǚ | u | Latin small letter u with diaeresis and caron | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1434 |
* | U+01DB | Ǜ | U | Latin capital letter U with diaeresis and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1435 |
* | U+01DC | ǜ | u | Latin small letter u with diaeresis and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1436 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1437 |
* Decompositions for Latin Extended-B: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1438 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1440 |
* | -------- | ----- | ----------- | ----------------------------------------- | |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1441 |
* | U+018F | Ə | E | Latin capital letter Ə | |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1442 |
* | U+0259 | ǝ | e | Latin small letter ǝ | |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
* | U+0218 | Ș | S | Latin capital letter S with comma below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
* | U+0219 | ș | s | Latin small letter s with comma below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
* | U+021A | Ț | T | Latin capital letter T with comma below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1446 |
* | U+021B | ț | t | Latin small letter t with comma below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1448 |
* Vowels with diacritic (Chinese, Hanyu Pinyin): |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1451 |
* | -------- | ----- | ----------- | ----------------------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1452 |
* | U+0251 | ɑ | a | Latin small letter alpha | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1453 |
* | U+1EA0 | Ạ | A | Latin capital letter A with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1454 |
* | U+1EA1 | ạ | a | Latin small letter a with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1455 |
* | U+1EA2 | Ả | A | Latin capital letter A with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1456 |
* | U+1EA3 | ả | a | Latin small letter a with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1457 |
* | U+1EA4 | Ấ | A | Latin capital letter A with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1458 |
* | U+1EA5 | ấ | a | Latin small letter a with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1459 |
* | U+1EA6 | Ầ | A | Latin capital letter A with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1460 |
* | U+1EA7 | ầ | a | Latin small letter a with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1461 |
* | U+1EA8 | Ẩ | A | Latin capital letter A with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
* | U+1EA9 | ẩ | a | Latin small letter a with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
* | U+1EAA | Ẫ | A | Latin capital letter A with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
* | U+1EAB | ẫ | a | Latin small letter a with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
* | U+1EA6 | Ậ | A | Latin capital letter A with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1466 |
* | U+1EAD | ậ | a | Latin small letter a with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1467 |
* | U+1EAE | Ắ | A | Latin capital letter A with breve and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1468 |
* | U+1EAF | ắ | a | Latin small letter a with breve and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1469 |
* | U+1EB0 | Ằ | A | Latin capital letter A with breve and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1470 |
* | U+1EB1 | ằ | a | Latin small letter a with breve and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1471 |
* | U+1EB2 | Ẳ | A | Latin capital letter A with breve and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1472 |
* | U+1EB3 | ẳ | a | Latin small letter a with breve and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1473 |
* | U+1EB4 | Ẵ | A | Latin capital letter A with breve and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1474 |
* | U+1EB5 | ẵ | a | Latin small letter a with breve and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1475 |
* | U+1EB6 | Ặ | A | Latin capital letter A with breve and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1476 |
* | U+1EB7 | ặ | a | Latin small letter a with breve and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1477 |
* | U+1EB8 | Ẹ | E | Latin capital letter E with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1478 |
* | U+1EB9 | ẹ | e | Latin small letter e with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1479 |
* | U+1EBA | Ẻ | E | Latin capital letter E with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1480 |
* | U+1EBB | ẻ | e | Latin small letter e with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1481 |
* | U+1EBC | Ẽ | E | Latin capital letter E with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1482 |
* | U+1EBD | ẽ | e | Latin small letter e with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1483 |
* | U+1EBE | Ế | E | Latin capital letter E with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1484 |
* | U+1EBF | ế | e | Latin small letter e with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1485 |
* | U+1EC0 | Ề | E | Latin capital letter E with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1486 |
* | U+1EC1 | ề | e | Latin small letter e with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1487 |
* | U+1EC2 | Ể | E | Latin capital letter E with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1488 |
* | U+1EC3 | ể | e | Latin small letter e with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1489 |
* | U+1EC4 | Ễ | E | Latin capital letter E with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1490 |
* | U+1EC5 | ễ | e | Latin small letter e with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1491 |
* | U+1EC6 | Ệ | E | Latin capital letter E with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1492 |
* | U+1EC7 | ệ | e | Latin small letter e with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1493 |
* | U+1EC8 | Ỉ | I | Latin capital letter I with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1494 |
* | U+1EC9 | ỉ | i | Latin small letter i with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1495 |
* | U+1ECA | Ị | I | Latin capital letter I with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1496 |
* | U+1ECB | ị | i | Latin small letter i with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1497 |
* | U+1ECC | Ọ | O | Latin capital letter O with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1498 |
* | U+1ECD | ọ | o | Latin small letter o with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1499 |
* | U+1ECE | Ỏ | O | Latin capital letter O with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1500 |
* | U+1ECF | ỏ | o | Latin small letter o with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1501 |
* | U+1ED0 | Ố | O | Latin capital letter O with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1502 |
* | U+1ED1 | ố | o | Latin small letter o with circumflex and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1503 |
* | U+1ED2 | Ồ | O | Latin capital letter O with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1504 |
* | U+1ED3 | ồ | o | Latin small letter o with circumflex and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1505 |
* | U+1ED4 | Ổ | O | Latin capital letter O with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1506 |
* | U+1ED5 | ổ | o | Latin small letter o with circumflex and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1507 |
* | U+1ED6 | Ỗ | O | Latin capital letter O with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1508 |
* | U+1ED7 | ỗ | o | Latin small letter o with circumflex and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1509 |
* | U+1ED8 | Ộ | O | Latin capital letter O with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1510 |
* | U+1ED9 | ộ | o | Latin small letter o with circumflex and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1511 |
* | U+1EDA | Ớ | O | Latin capital letter O with horn and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1512 |
* | U+1EDB | ớ | o | Latin small letter o with horn and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1513 |
* | U+1EDC | Ờ | O | Latin capital letter O with horn and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1514 |
* | U+1EDD | ờ | o | Latin small letter o with horn and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1515 |
* | U+1EDE | Ở | O | Latin capital letter O with horn and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1516 |
* | U+1EDF | ở | o | Latin small letter o with horn and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1517 |
* | U+1EE0 | Ỡ | O | Latin capital letter O with horn and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1518 |
* | U+1EE1 | ỡ | o | Latin small letter o with horn and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1519 |
* | U+1EE2 | Ợ | O | Latin capital letter O with horn and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1520 |
* | U+1EE3 | ợ | o | Latin small letter o with horn and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1521 |
* | U+1EE4 | Ụ | U | Latin capital letter U with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1522 |
* | U+1EE5 | ụ | u | Latin small letter u with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1523 |
* | U+1EE6 | Ủ | U | Latin capital letter U with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1524 |
* | U+1EE7 | ủ | u | Latin small letter u with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1525 |
* | U+1EE8 | Ứ | U | Latin capital letter U with horn and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1526 |
* | U+1EE9 | ứ | u | Latin small letter u with horn and acute | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1527 |
* | U+1EEA | Ừ | U | Latin capital letter U with horn and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1528 |
* | U+1EEB | ừ | u | Latin small letter u with horn and grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1529 |
* | U+1EEC | Ử | U | Latin capital letter U with horn and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1530 |
* | U+1EED | ử | u | Latin small letter u with horn and hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1531 |
* | U+1EEE | Ữ | U | Latin capital letter U with horn and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1532 |
* | U+1EEF | ữ | u | Latin small letter u with horn and tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1533 |
* | U+1EF0 | Ự | U | Latin capital letter U with horn and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1534 |
* | U+1EF1 | ự | u | Latin small letter u with horn and dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1535 |
* | U+1EF2 | Ỳ | Y | Latin capital letter Y with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1536 |
* | U+1EF3 | ỳ | y | Latin small letter y with grave | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1537 |
* | U+1EF4 | Ỵ | Y | Latin capital letter Y with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1538 |
* | U+1EF5 | ỵ | y | Latin small letter y with dot below | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1539 |
* | U+1EF6 | Ỷ | Y | Latin capital letter Y with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1540 |
* | U+1EF7 | ỷ | y | Latin small letter y with hook above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1541 |
* | U+1EF8 | Ỹ | Y | Latin capital letter Y with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1542 |
* | U+1EF9 | ỹ | y | Latin small letter y with tilde | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1543 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1544 |
* German (`de_DE`), German formal (`de_DE_formal`), German (Switzerland) formal (`de_CH`), |
18 | 1545 |
* German (Switzerland) informal (`de_CH_informal`), and German (Austria) (`de_AT`) locales: |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1546 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1547 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1548 |
* | -------- | ----- | ----------- | --------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1549 |
* | U+00C4 | Ä | Ae | Latin capital letter A with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1550 |
* | U+00E4 | ä | ae | Latin small letter a with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1551 |
* | U+00D6 | Ö | Oe | Latin capital letter O with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1552 |
* | U+00F6 | ö | oe | Latin small letter o with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1553 |
* | U+00DC | Ü | Ue | Latin capital letter U with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1554 |
* | U+00FC | ü | ue | Latin small letter u with diaeresis | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1555 |
* | U+00DF | ß | ss | Latin small letter sharp s | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1556 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1557 |
* Danish (`da_DK`) locale: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1558 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1559 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1560 |
* | -------- | ----- | ----------- | --------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1561 |
* | U+00C6 | Æ | Ae | Latin capital letter AE | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1562 |
* | U+00E6 | æ | ae | Latin small letter ae | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1563 |
* | U+00D8 | Ø | Oe | Latin capital letter O with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1564 |
* | U+00F8 | ø | oe | Latin small letter o with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1565 |
* | U+00C5 | Å | Aa | Latin capital letter A with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1566 |
* | U+00E5 | å | aa | Latin small letter a with ring above | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1567 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1568 |
* Catalan (`ca`) locale: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1569 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1570 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1571 |
* | -------- | ----- | ----------- | --------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1572 |
* | U+00B7 | l·l | ll | Flown dot (between two Ls) | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1573 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1574 |
* Serbian (`sr_RS`) and Bosnian (`bs_BA`) locales: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1575 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1576 |
* | Code | Glyph | Replacement | Description | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1577 |
* | -------- | ----- | ----------- | --------------------------------------- | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1578 |
* | U+0110 | Đ | DJ | Latin capital letter D with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1579 |
* | U+0111 | đ | dj | Latin small letter d with stroke | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1580 |
* |
0 | 1581 |
* @since 1.2.1 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1582 |
* @since 4.6.0 Added locale support for `de_CH`, `de_CH_informal`, and `ca`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1583 |
* @since 4.7.0 Added locale support for `sr_RS`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1584 |
* @since 4.8.0 Added locale support for `bs_BA`. |
18 | 1585 |
* @since 5.7.0 Added locale support for `de_AT`. |
19 | 1586 |
* @since 6.0.0 Added the `$locale` parameter. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1587 |
* @since 6.1.0 Added Unicode NFC encoding normalization support. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1588 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1589 |
* @param string $text Text that might have accent characters. |
19 | 1590 |
* @param string $locale Optional. The locale to use for accent removal. Some character |
1591 |
* replacements depend on the locale being used (e.g. 'de_DE'). |
|
1592 |
* Defaults to the current locale. |
|
0 | 1593 |
* @return string Filtered string with replaced "nice" characters. |
1594 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1595 |
function remove_accents( $text, $locale = '' ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1596 |
if ( ! preg_match( '/[\x80-\xff]/', $text ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1597 |
return $text; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1598 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1599 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1600 |
if ( seems_utf8( $text ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1601 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1602 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1603 |
* Unicode sequence normalization from NFD (Normalization Form Decomposed) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1604 |
* to NFC (Normalization Form [Pre]Composed), the encoding used in this function. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1605 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1606 |
if ( function_exists( 'normalizer_is_normalized' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1607 |
&& function_exists( 'normalizer_normalize' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1608 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1609 |
if ( ! normalizer_is_normalized( $text ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1610 |
$text = normalizer_normalize( $text ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1611 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1612 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1613 |
|
0 | 1614 |
$chars = array( |
16 | 1615 |
// Decompositions for Latin-1 Supplement. |
9 | 1616 |
'ª' => 'a', |
1617 |
'º' => 'o', |
|
1618 |
'À' => 'A', |
|
1619 |
'Á' => 'A', |
|
1620 |
'Â' => 'A', |
|
1621 |
'Ã' => 'A', |
|
1622 |
'Ä' => 'A', |
|
1623 |
'Å' => 'A', |
|
1624 |
'Æ' => 'AE', |
|
1625 |
'Ç' => 'C', |
|
1626 |
'È' => 'E', |
|
1627 |
'É' => 'E', |
|
1628 |
'Ê' => 'E', |
|
1629 |
'Ë' => 'E', |
|
1630 |
'Ì' => 'I', |
|
1631 |
'Í' => 'I', |
|
1632 |
'Î' => 'I', |
|
1633 |
'Ï' => 'I', |
|
1634 |
'Ð' => 'D', |
|
1635 |
'Ñ' => 'N', |
|
1636 |
'Ò' => 'O', |
|
1637 |
'Ó' => 'O', |
|
1638 |
'Ô' => 'O', |
|
1639 |
'Õ' => 'O', |
|
1640 |
'Ö' => 'O', |
|
1641 |
'Ù' => 'U', |
|
1642 |
'Ú' => 'U', |
|
1643 |
'Û' => 'U', |
|
1644 |
'Ü' => 'U', |
|
1645 |
'Ý' => 'Y', |
|
1646 |
'Þ' => 'TH', |
|
1647 |
'ß' => 's', |
|
1648 |
'à' => 'a', |
|
1649 |
'á' => 'a', |
|
1650 |
'â' => 'a', |
|
1651 |
'ã' => 'a', |
|
1652 |
'ä' => 'a', |
|
1653 |
'å' => 'a', |
|
1654 |
'æ' => 'ae', |
|
1655 |
'ç' => 'c', |
|
1656 |
'è' => 'e', |
|
1657 |
'é' => 'e', |
|
1658 |
'ê' => 'e', |
|
1659 |
'ë' => 'e', |
|
1660 |
'ì' => 'i', |
|
1661 |
'í' => 'i', |
|
1662 |
'î' => 'i', |
|
1663 |
'ï' => 'i', |
|
1664 |
'ð' => 'd', |
|
1665 |
'ñ' => 'n', |
|
1666 |
'ò' => 'o', |
|
1667 |
'ó' => 'o', |
|
1668 |
'ô' => 'o', |
|
1669 |
'õ' => 'o', |
|
1670 |
'ö' => 'o', |
|
1671 |
'ø' => 'o', |
|
1672 |
'ù' => 'u', |
|
1673 |
'ú' => 'u', |
|
1674 |
'û' => 'u', |
|
1675 |
'ü' => 'u', |
|
1676 |
'ý' => 'y', |
|
1677 |
'þ' => 'th', |
|
1678 |
'ÿ' => 'y', |
|
1679 |
'Ø' => 'O', |
|
16 | 1680 |
// Decompositions for Latin Extended-A. |
9 | 1681 |
'Ā' => 'A', |
1682 |
'ā' => 'a', |
|
1683 |
'Ă' => 'A', |
|
1684 |
'ă' => 'a', |
|
1685 |
'Ą' => 'A', |
|
1686 |
'ą' => 'a', |
|
1687 |
'Ć' => 'C', |
|
1688 |
'ć' => 'c', |
|
1689 |
'Ĉ' => 'C', |
|
1690 |
'ĉ' => 'c', |
|
1691 |
'Ċ' => 'C', |
|
1692 |
'ċ' => 'c', |
|
1693 |
'Č' => 'C', |
|
1694 |
'č' => 'c', |
|
1695 |
'Ď' => 'D', |
|
1696 |
'ď' => 'd', |
|
1697 |
'Đ' => 'D', |
|
1698 |
'đ' => 'd', |
|
1699 |
'Ē' => 'E', |
|
1700 |
'ē' => 'e', |
|
1701 |
'Ĕ' => 'E', |
|
1702 |
'ĕ' => 'e', |
|
1703 |
'Ė' => 'E', |
|
1704 |
'ė' => 'e', |
|
1705 |
'Ę' => 'E', |
|
1706 |
'ę' => 'e', |
|
1707 |
'Ě' => 'E', |
|
1708 |
'ě' => 'e', |
|
1709 |
'Ĝ' => 'G', |
|
1710 |
'ĝ' => 'g', |
|
1711 |
'Ğ' => 'G', |
|
1712 |
'ğ' => 'g', |
|
1713 |
'Ġ' => 'G', |
|
1714 |
'ġ' => 'g', |
|
1715 |
'Ģ' => 'G', |
|
1716 |
'ģ' => 'g', |
|
1717 |
'Ĥ' => 'H', |
|
1718 |
'ĥ' => 'h', |
|
1719 |
'Ħ' => 'H', |
|
1720 |
'ħ' => 'h', |
|
1721 |
'Ĩ' => 'I', |
|
1722 |
'ĩ' => 'i', |
|
1723 |
'Ī' => 'I', |
|
1724 |
'ī' => 'i', |
|
1725 |
'Ĭ' => 'I', |
|
1726 |
'ĭ' => 'i', |
|
1727 |
'Į' => 'I', |
|
1728 |
'į' => 'i', |
|
1729 |
'İ' => 'I', |
|
1730 |
'ı' => 'i', |
|
1731 |
'IJ' => 'IJ', |
|
1732 |
'ij' => 'ij', |
|
1733 |
'Ĵ' => 'J', |
|
1734 |
'ĵ' => 'j', |
|
1735 |
'Ķ' => 'K', |
|
1736 |
'ķ' => 'k', |
|
1737 |
'ĸ' => 'k', |
|
1738 |
'Ĺ' => 'L', |
|
1739 |
'ĺ' => 'l', |
|
1740 |
'Ļ' => 'L', |
|
1741 |
'ļ' => 'l', |
|
1742 |
'Ľ' => 'L', |
|
1743 |
'ľ' => 'l', |
|
1744 |
'Ŀ' => 'L', |
|
1745 |
'ŀ' => 'l', |
|
1746 |
'Ł' => 'L', |
|
1747 |
'ł' => 'l', |
|
1748 |
'Ń' => 'N', |
|
1749 |
'ń' => 'n', |
|
1750 |
'Ņ' => 'N', |
|
1751 |
'ņ' => 'n', |
|
1752 |
'Ň' => 'N', |
|
1753 |
'ň' => 'n', |
|
1754 |
'ʼn' => 'n', |
|
1755 |
'Ŋ' => 'N', |
|
1756 |
'ŋ' => 'n', |
|
1757 |
'Ō' => 'O', |
|
1758 |
'ō' => 'o', |
|
1759 |
'Ŏ' => 'O', |
|
1760 |
'ŏ' => 'o', |
|
1761 |
'Ő' => 'O', |
|
1762 |
'ő' => 'o', |
|
1763 |
'Œ' => 'OE', |
|
1764 |
'œ' => 'oe', |
|
1765 |
'Ŕ' => 'R', |
|
1766 |
'ŕ' => 'r', |
|
1767 |
'Ŗ' => 'R', |
|
1768 |
'ŗ' => 'r', |
|
1769 |
'Ř' => 'R', |
|
1770 |
'ř' => 'r', |
|
1771 |
'Ś' => 'S', |
|
1772 |
'ś' => 's', |
|
1773 |
'Ŝ' => 'S', |
|
1774 |
'ŝ' => 's', |
|
1775 |
'Ş' => 'S', |
|
1776 |
'ş' => 's', |
|
1777 |
'Š' => 'S', |
|
1778 |
'š' => 's', |
|
1779 |
'Ţ' => 'T', |
|
1780 |
'ţ' => 't', |
|
1781 |
'Ť' => 'T', |
|
1782 |
'ť' => 't', |
|
1783 |
'Ŧ' => 'T', |
|
1784 |
'ŧ' => 't', |
|
1785 |
'Ũ' => 'U', |
|
1786 |
'ũ' => 'u', |
|
1787 |
'Ū' => 'U', |
|
1788 |
'ū' => 'u', |
|
1789 |
'Ŭ' => 'U', |
|
1790 |
'ŭ' => 'u', |
|
1791 |
'Ů' => 'U', |
|
1792 |
'ů' => 'u', |
|
1793 |
'Ű' => 'U', |
|
1794 |
'ű' => 'u', |
|
1795 |
'Ų' => 'U', |
|
1796 |
'ų' => 'u', |
|
1797 |
'Ŵ' => 'W', |
|
1798 |
'ŵ' => 'w', |
|
1799 |
'Ŷ' => 'Y', |
|
1800 |
'ŷ' => 'y', |
|
1801 |
'Ÿ' => 'Y', |
|
1802 |
'Ź' => 'Z', |
|
1803 |
'ź' => 'z', |
|
1804 |
'Ż' => 'Z', |
|
1805 |
'ż' => 'z', |
|
1806 |
'Ž' => 'Z', |
|
1807 |
'ž' => 'z', |
|
1808 |
'ſ' => 's', |
|
16 | 1809 |
// Decompositions for Latin Extended-B. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1810 |
'Ə' => 'E', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1811 |
'ǝ' => 'e', |
9 | 1812 |
'Ș' => 'S', |
1813 |
'ș' => 's', |
|
1814 |
'Ț' => 'T', |
|
1815 |
'ț' => 't', |
|
16 | 1816 |
// Euro sign. |
9 | 1817 |
'€' => 'E', |
16 | 1818 |
// GBP (Pound) sign. |
9 | 1819 |
'£' => '', |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1820 |
// Vowels with diacritic (Vietnamese). Unmarked. |
9 | 1821 |
'Ơ' => 'O', |
1822 |
'ơ' => 'o', |
|
1823 |
'Ư' => 'U', |
|
1824 |
'ư' => 'u', |
|
16 | 1825 |
// Grave accent. |
9 | 1826 |
'Ầ' => 'A', |
1827 |
'ầ' => 'a', |
|
1828 |
'Ằ' => 'A', |
|
1829 |
'ằ' => 'a', |
|
1830 |
'Ề' => 'E', |
|
1831 |
'ề' => 'e', |
|
1832 |
'Ồ' => 'O', |
|
1833 |
'ồ' => 'o', |
|
1834 |
'Ờ' => 'O', |
|
1835 |
'ờ' => 'o', |
|
1836 |
'Ừ' => 'U', |
|
1837 |
'ừ' => 'u', |
|
1838 |
'Ỳ' => 'Y', |
|
1839 |
'ỳ' => 'y', |
|
16 | 1840 |
// Hook. |
9 | 1841 |
'Ả' => 'A', |
1842 |
'ả' => 'a', |
|
1843 |
'Ẩ' => 'A', |
|
1844 |
'ẩ' => 'a', |
|
1845 |
'Ẳ' => 'A', |
|
1846 |
'ẳ' => 'a', |
|
1847 |
'Ẻ' => 'E', |
|
1848 |
'ẻ' => 'e', |
|
1849 |
'Ể' => 'E', |
|
1850 |
'ể' => 'e', |
|
1851 |
'Ỉ' => 'I', |
|
1852 |
'ỉ' => 'i', |
|
1853 |
'Ỏ' => 'O', |
|
1854 |
'ỏ' => 'o', |
|
1855 |
'Ổ' => 'O', |
|
1856 |
'ổ' => 'o', |
|
1857 |
'Ở' => 'O', |
|
1858 |
'ở' => 'o', |
|
1859 |
'Ủ' => 'U', |
|
1860 |
'ủ' => 'u', |
|
1861 |
'Ử' => 'U', |
|
1862 |
'ử' => 'u', |
|
1863 |
'Ỷ' => 'Y', |
|
1864 |
'ỷ' => 'y', |
|
16 | 1865 |
// Tilde. |
9 | 1866 |
'Ẫ' => 'A', |
1867 |
'ẫ' => 'a', |
|
1868 |
'Ẵ' => 'A', |
|
1869 |
'ẵ' => 'a', |
|
1870 |
'Ẽ' => 'E', |
|
1871 |
'ẽ' => 'e', |
|
1872 |
'Ễ' => 'E', |
|
1873 |
'ễ' => 'e', |
|
1874 |
'Ỗ' => 'O', |
|
1875 |
'ỗ' => 'o', |
|
1876 |
'Ỡ' => 'O', |
|
1877 |
'ỡ' => 'o', |
|
1878 |
'Ữ' => 'U', |
|
1879 |
'ữ' => 'u', |
|
1880 |
'Ỹ' => 'Y', |
|
1881 |
'ỹ' => 'y', |
|
16 | 1882 |
// Acute accent. |
9 | 1883 |
'Ấ' => 'A', |
1884 |
'ấ' => 'a', |
|
1885 |
'Ắ' => 'A', |
|
1886 |
'ắ' => 'a', |
|
1887 |
'Ế' => 'E', |
|
1888 |
'ế' => 'e', |
|
1889 |
'Ố' => 'O', |
|
1890 |
'ố' => 'o', |
|
1891 |
'Ớ' => 'O', |
|
1892 |
'ớ' => 'o', |
|
1893 |
'Ứ' => 'U', |
|
1894 |
'ứ' => 'u', |
|
16 | 1895 |
// Dot below. |
9 | 1896 |
'Ạ' => 'A', |
1897 |
'ạ' => 'a', |
|
1898 |
'Ậ' => 'A', |
|
1899 |
'ậ' => 'a', |
|
1900 |
'Ặ' => 'A', |
|
1901 |
'ặ' => 'a', |
|
1902 |
'Ẹ' => 'E', |
|
1903 |
'ẹ' => 'e', |
|
1904 |
'Ệ' => 'E', |
|
1905 |
'ệ' => 'e', |
|
1906 |
'Ị' => 'I', |
|
1907 |
'ị' => 'i', |
|
1908 |
'Ọ' => 'O', |
|
1909 |
'ọ' => 'o', |
|
1910 |
'Ộ' => 'O', |
|
1911 |
'ộ' => 'o', |
|
1912 |
'Ợ' => 'O', |
|
1913 |
'ợ' => 'o', |
|
1914 |
'Ụ' => 'U', |
|
1915 |
'ụ' => 'u', |
|
1916 |
'Ự' => 'U', |
|
1917 |
'ự' => 'u', |
|
1918 |
'Ỵ' => 'Y', |
|
1919 |
'ỵ' => 'y', |
|
16 | 1920 |
// Vowels with diacritic (Chinese, Hanyu Pinyin). |
9 | 1921 |
'ɑ' => 'a', |
16 | 1922 |
// Macron. |
9 | 1923 |
'Ǖ' => 'U', |
1924 |
'ǖ' => 'u', |
|
16 | 1925 |
// Acute accent. |
9 | 1926 |
'Ǘ' => 'U', |
1927 |
'ǘ' => 'u', |
|
16 | 1928 |
// Caron. |
9 | 1929 |
'Ǎ' => 'A', |
1930 |
'ǎ' => 'a', |
|
1931 |
'Ǐ' => 'I', |
|
1932 |
'ǐ' => 'i', |
|
1933 |
'Ǒ' => 'O', |
|
1934 |
'ǒ' => 'o', |
|
1935 |
'Ǔ' => 'U', |
|
1936 |
'ǔ' => 'u', |
|
1937 |
'Ǚ' => 'U', |
|
1938 |
'ǚ' => 'u', |
|
16 | 1939 |
// Grave accent. |
9 | 1940 |
'Ǜ' => 'U', |
1941 |
'ǜ' => 'u', |
|
0 | 1942 |
); |
1943 |
||
16 | 1944 |
// Used for locale-specific rules. |
19 | 1945 |
if ( empty( $locale ) ) { |
1946 |
$locale = get_locale(); |
|
1947 |
} |
|
1948 |
||
1949 |
/* |
|
1950 |
* German has various locales (de_DE, de_CH, de_AT, ...) with formal and informal variants. |
|
1951 |
* There is no 3-letter locale like 'def', so checking for 'de' instead of 'de_' is safe, |
|
1952 |
* since 'de' itself would be a valid locale too. |
|
1953 |
*/ |
|
1954 |
if ( str_starts_with( $locale, 'de' ) ) { |
|
9 | 1955 |
$chars['Ä'] = 'Ae'; |
1956 |
$chars['ä'] = 'ae'; |
|
1957 |
$chars['Ö'] = 'Oe'; |
|
1958 |
$chars['ö'] = 'oe'; |
|
1959 |
$chars['Ü'] = 'Ue'; |
|
1960 |
$chars['ü'] = 'ue'; |
|
1961 |
$chars['ß'] = 'ss'; |
|
5 | 1962 |
} elseif ( 'da_DK' === $locale ) { |
9 | 1963 |
$chars['Æ'] = 'Ae'; |
1964 |
$chars['æ'] = 'ae'; |
|
1965 |
$chars['Ø'] = 'Oe'; |
|
1966 |
$chars['ø'] = 'oe'; |
|
1967 |
$chars['Å'] = 'Aa'; |
|
1968 |
$chars['å'] = 'aa'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1969 |
} elseif ( 'ca' === $locale ) { |
9 | 1970 |
$chars['l·l'] = 'll'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1971 |
} elseif ( 'sr_RS' === $locale || 'bs_BA' === $locale ) { |
9 | 1972 |
$chars['Đ'] = 'DJ'; |
1973 |
$chars['đ'] = 'dj'; |
|
0 | 1974 |
} |
1975 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1976 |
$text = strtr( $text, $chars ); |
0 | 1977 |
} else { |
5 | 1978 |
$chars = array(); |
16 | 1979 |
// Assume ISO-8859-1 if not UTF-8. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1980 |
$chars['in'] = "\x80\x83\x8a\x8e\x9a\x9e" |
9 | 1981 |
. "\x9f\xa2\xa5\xb5\xc0\xc1\xc2" |
1982 |
. "\xc3\xc4\xc5\xc7\xc8\xc9\xca" |
|
1983 |
. "\xcb\xcc\xcd\xce\xcf\xd1\xd2" |
|
1984 |
. "\xd3\xd4\xd5\xd6\xd8\xd9\xda" |
|
1985 |
. "\xdb\xdc\xdd\xe0\xe1\xe2\xe3" |
|
1986 |
. "\xe4\xe5\xe7\xe8\xe9\xea\xeb" |
|
1987 |
. "\xec\xed\xee\xef\xf1\xf2\xf3" |
|
1988 |
. "\xf4\xf5\xf6\xf8\xf9\xfa\xfb" |
|
1989 |
. "\xfc\xfd\xff"; |
|
1990 |
||
1991 |
$chars['out'] = 'EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'; |
|
1992 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1993 |
$text = strtr( $text, $chars['in'], $chars['out'] ); |
9 | 1994 |
$double_chars = array(); |
1995 |
$double_chars['in'] = array( "\x8c", "\x9c", "\xc6", "\xd0", "\xde", "\xdf", "\xe6", "\xf0", "\xfe" ); |
|
1996 |
$double_chars['out'] = array( 'OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th' ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1997 |
$text = str_replace( $double_chars['in'], $double_chars['out'], $text ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1998 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1999 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2000 |
return $text; |
0 | 2001 |
} |
2002 |
||
2003 |
/** |
|
2004 |
* Sanitizes a filename, replacing whitespace with dashes. |
|
2005 |
* |
|
2006 |
* Removes special characters that are illegal in filenames on certain |
|
2007 |
* operating systems and special characters requiring special escaping |
|
2008 |
* to manipulate at the command line. Replaces spaces and consecutive |
|
2009 |
* dashes with a single dash. Trims period, dash and underscore from beginning |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2010 |
* and end of filename. It is not guaranteed that this function will return a |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2011 |
* filename that is allowed to be uploaded. |
0 | 2012 |
* |
2013 |
* @since 2.1.0 |
|
2014 |
* |
|
16 | 2015 |
* @param string $filename The filename to be sanitized. |
2016 |
* @return string The sanitized filename. |
|
0 | 2017 |
*/ |
2018 |
function sanitize_file_name( $filename ) { |
|
16 | 2019 |
$filename_raw = $filename; |
2020 |
$filename = remove_accents( $filename ); |
|
2021 |
||
2022 |
$special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '«', '»', '”', '“', chr( 0 ) ); |
|
2023 |
||
2024 |
// Check for support for utf8 in the installed PCRE library once and store the result in a static. |
|
2025 |
static $utf8_pcre = null; |
|
2026 |
if ( ! isset( $utf8_pcre ) ) { |
|
2027 |
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
|
2028 |
$utf8_pcre = @preg_match( '/^./u', 'a' ); |
|
2029 |
} |
|
2030 |
||
2031 |
if ( ! seems_utf8( $filename ) ) { |
|
2032 |
$_ext = pathinfo( $filename, PATHINFO_EXTENSION ); |
|
2033 |
$_name = pathinfo( $filename, PATHINFO_FILENAME ); |
|
2034 |
$filename = sanitize_title_with_dashes( $_name ) . '.' . $_ext; |
|
2035 |
} |
|
2036 |
||
2037 |
if ( $utf8_pcre ) { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2038 |
/** |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2039 |
* Replace all whitespace characters with a basic space (U+0020). |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2040 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2041 |
* The “Zs” in the pattern selects characters in the `Space_Separator` |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2042 |
* category, which is what Unicode considers space characters. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2043 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2044 |
* @see https://www.unicode.org/reports/tr44/#General_Category_Values |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2045 |
* @see https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-6/#G17548 |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2046 |
* @see https://www.php.net/manual/en/regexp.reference.unicode.php |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2047 |
*/ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2048 |
$filename = preg_replace( '#\p{Zs}#siu', ' ', $filename ); |
16 | 2049 |
} |
2050 |
||
5 | 2051 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2052 |
* Filters the list of characters to remove from a filename. |
5 | 2053 |
* |
2054 |
* @since 2.8.0 |
|
2055 |
* |
|
16 | 2056 |
* @param string[] $special_chars Array of characters to remove. |
2057 |
* @param string $filename_raw The original filename to be sanitized. |
|
5 | 2058 |
*/ |
2059 |
$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); |
|
16 | 2060 |
|
2061 |
$filename = str_replace( $special_chars, '', $filename ); |
|
2062 |
$filename = str_replace( array( '%20', '+' ), '-', $filename ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2063 |
$filename = preg_replace( '/\.{2,}/', '.', $filename ); |
16 | 2064 |
$filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); |
2065 |
$filename = trim( $filename, '.-_' ); |
|
0 | 2066 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2067 |
if ( ! str_contains( $filename, '.' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2068 |
$mime_types = wp_get_mime_types(); |
9 | 2069 |
$filetype = wp_check_filetype( 'test.' . $filename, $mime_types ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2070 |
if ( $filetype['ext'] === $filename ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2071 |
$filename = 'unnamed-file.' . $filetype['ext']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2072 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2073 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2074 |
|
16 | 2075 |
// Split the filename into a base and extension[s]. |
9 | 2076 |
$parts = explode( '.', $filename ); |
0 | 2077 |
|
16 | 2078 |
// Return if only one extension. |
5 | 2079 |
if ( count( $parts ) <= 2 ) { |
18 | 2080 |
/** This filter is documented in wp-includes/formatting.php */ |
5 | 2081 |
return apply_filters( 'sanitize_file_name', $filename, $filename_raw ); |
2082 |
} |
|
0 | 2083 |
|
16 | 2084 |
// Process multiple extensions. |
9 | 2085 |
$filename = array_shift( $parts ); |
2086 |
$extension = array_pop( $parts ); |
|
2087 |
$mimes = get_allowed_mime_types(); |
|
0 | 2088 |
|
5 | 2089 |
/* |
2090 |
* Loop over any intermediate extensions. Postfix them with a trailing underscore |
|
16 | 2091 |
* if they are a 2 - 5 character long alpha string not in the allowed extension list. |
5 | 2092 |
*/ |
9 | 2093 |
foreach ( (array) $parts as $part ) { |
0 | 2094 |
$filename .= '.' . $part; |
2095 |
||
9 | 2096 |
if ( preg_match( '/^[a-zA-Z]{2,5}\d?$/', $part ) ) { |
0 | 2097 |
$allowed = false; |
2098 |
foreach ( $mimes as $ext_preg => $mime_match ) { |
|
2099 |
$ext_preg = '!^(' . $ext_preg . ')$!i'; |
|
2100 |
if ( preg_match( $ext_preg, $part ) ) { |
|
2101 |
$allowed = true; |
|
2102 |
break; |
|
2103 |
} |
|
2104 |
} |
|
9 | 2105 |
if ( ! $allowed ) { |
0 | 2106 |
$filename .= '_'; |
9 | 2107 |
} |
0 | 2108 |
} |
2109 |
} |
|
16 | 2110 |
|
0 | 2111 |
$filename .= '.' . $extension; |
16 | 2112 |
|
18 | 2113 |
/** |
2114 |
* Filters a sanitized filename string. |
|
2115 |
* |
|
2116 |
* @since 2.8.0 |
|
2117 |
* |
|
2118 |
* @param string $filename Sanitized filename. |
|
2119 |
* @param string $filename_raw The filename prior to sanitization. |
|
2120 |
*/ |
|
9 | 2121 |
return apply_filters( 'sanitize_file_name', $filename, $filename_raw ); |
0 | 2122 |
} |
2123 |
||
2124 |
/** |
|
2125 |
* Sanitizes a username, stripping out unsafe characters. |
|
2126 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2127 |
* Removes tags, percent-encoded characters, HTML entities, and if strict is enabled, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2128 |
* will only keep alphanumeric, _, space, ., -, @. After sanitizing, it passes the username, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2129 |
* raw username (the username in the parameter), and the value of $strict as parameters |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2130 |
* for the {@see 'sanitize_user'} filter. |
0 | 2131 |
* |
2132 |
* @since 2.0.0 |
|
2133 |
* |
|
2134 |
* @param string $username The username to be sanitized. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2135 |
* @param bool $strict Optional. If set to true, limits $username to specific characters. |
16 | 2136 |
* Default false. |
0 | 2137 |
* @return string The sanitized username, after passing through filters. |
2138 |
*/ |
|
2139 |
function sanitize_user( $username, $strict = false ) { |
|
2140 |
$raw_username = $username; |
|
9 | 2141 |
$username = wp_strip_all_tags( $username ); |
2142 |
$username = remove_accents( $username ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2143 |
// Remove percent-encoded characters. |
0 | 2144 |
$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2145 |
// Remove HTML entities. |
16 | 2146 |
$username = preg_replace( '/&.+?;/', '', $username ); |
0 | 2147 |
|
2148 |
// If strict, reduce to ASCII for max portability. |
|
9 | 2149 |
if ( $strict ) { |
0 | 2150 |
$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); |
9 | 2151 |
} |
0 | 2152 |
|
2153 |
$username = trim( $username ); |
|
16 | 2154 |
// Consolidate contiguous whitespace. |
0 | 2155 |
$username = preg_replace( '|\s+|', ' ', $username ); |
2156 |
||
5 | 2157 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2158 |
* Filters a sanitized username string. |
5 | 2159 |
* |
2160 |
* @since 2.0.1 |
|
2161 |
* |
|
2162 |
* @param string $username Sanitized username. |
|
2163 |
* @param string $raw_username The username prior to sanitization. |
|
16 | 2164 |
* @param bool $strict Whether to limit the sanitization to specific characters. |
5 | 2165 |
*/ |
0 | 2166 |
return apply_filters( 'sanitize_user', $username, $raw_username, $strict ); |
2167 |
} |
|
2168 |
||
2169 |
/** |
|
2170 |
* Sanitizes a string key. |
|
2171 |
* |
|
16 | 2172 |
* Keys are used as internal identifiers. Lowercase alphanumeric characters, |
2173 |
* dashes, and underscores are allowed. |
|
0 | 2174 |
* |
2175 |
* @since 3.0.0 |
|
2176 |
* |
|
19 | 2177 |
* @param string $key String key. |
2178 |
* @return string Sanitized key. |
|
0 | 2179 |
*/ |
2180 |
function sanitize_key( $key ) { |
|
19 | 2181 |
$sanitized_key = ''; |
2182 |
||
2183 |
if ( is_scalar( $key ) ) { |
|
2184 |
$sanitized_key = strtolower( $key ); |
|
2185 |
$sanitized_key = preg_replace( '/[^a-z0-9_\-]/', '', $sanitized_key ); |
|
2186 |
} |
|
5 | 2187 |
|
2188 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2189 |
* Filters a sanitized key string. |
5 | 2190 |
* |
2191 |
* @since 3.0.0 |
|
2192 |
* |
|
19 | 2193 |
* @param string $sanitized_key Sanitized key. |
2194 |
* @param string $key The key prior to sanitization. |
|
5 | 2195 |
*/ |
19 | 2196 |
return apply_filters( 'sanitize_key', $sanitized_key, $key ); |
0 | 2197 |
} |
2198 |
||
2199 |
/** |
|
16 | 2200 |
* Sanitizes a string into a slug, which can be used in URLs or HTML attributes. |
2201 |
* |
|
2202 |
* By default, converts accent characters to ASCII characters and further |
|
2203 |
* limits the output to alphanumeric characters, underscore (_) and dash (-) |
|
2204 |
* through the {@see 'sanitize_title'} filter. |
|
2205 |
* |
|
2206 |
* If `$title` is empty and `$fallback_title` is set, the latter will be used. |
|
0 | 2207 |
* |
2208 |
* @since 1.0.0 |
|
2209 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2210 |
* @param string $title The string to be sanitized. |
16 | 2211 |
* @param string $fallback_title Optional. A title to use if $title is empty. Default empty. |
2212 |
* @param string $context Optional. The operation for which the string is sanitized. |
|
18 | 2213 |
* When set to 'save', the string runs through remove_accents(). |
16 | 2214 |
* Default 'save'. |
0 | 2215 |
* @return string The sanitized string. |
2216 |
*/ |
|
2217 |
function sanitize_title( $title, $fallback_title = '', $context = 'save' ) { |
|
2218 |
$raw_title = $title; |
|
2219 |
||
16 | 2220 |
if ( 'save' === $context ) { |
9 | 2221 |
$title = remove_accents( $title ); |
2222 |
} |
|
0 | 2223 |
|
5 | 2224 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2225 |
* Filters a sanitized title string. |
5 | 2226 |
* |
2227 |
* @since 1.2.0 |
|
2228 |
* |
|
2229 |
* @param string $title Sanitized title. |
|
2230 |
* @param string $raw_title The title prior to sanitization. |
|
2231 |
* @param string $context The context for which the title is being sanitized. |
|
2232 |
*/ |
|
2233 |
$title = apply_filters( 'sanitize_title', $title, $raw_title, $context ); |
|
0 | 2234 |
|
9 | 2235 |
if ( '' === $title || false === $title ) { |
0 | 2236 |
$title = $fallback_title; |
9 | 2237 |
} |
0 | 2238 |
|
2239 |
return $title; |
|
2240 |
} |
|
2241 |
||
2242 |
/** |
|
2243 |
* Sanitizes a title with the 'query' context. |
|
2244 |
* |
|
2245 |
* Used for querying the database for a value from URL. |
|
2246 |
* |
|
2247 |
* @since 3.1.0 |
|
2248 |
* |
|
2249 |
* @param string $title The string to be sanitized. |
|
2250 |
* @return string The sanitized string. |
|
2251 |
*/ |
|
2252 |
function sanitize_title_for_query( $title ) { |
|
2253 |
return sanitize_title( $title, '', 'query' ); |
|
2254 |
} |
|
2255 |
||
2256 |
/** |
|
2257 |
* Sanitizes a title, replacing whitespace and a few other characters with dashes. |
|
2258 |
* |
|
2259 |
* Limits the output to alphanumeric characters, underscore (_) and dash (-). |
|
2260 |
* Whitespace becomes a dash. |
|
2261 |
* |
|
2262 |
* @since 1.2.0 |
|
2263 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2264 |
* @param string $title The title to be sanitized. |
16 | 2265 |
* @param string $raw_title Optional. Not used. Default empty. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2266 |
* @param string $context Optional. The operation for which the string is sanitized. |
18 | 2267 |
* When set to 'save', additional entities are converted to hyphens |
2268 |
* or stripped entirely. Default 'display'. |
|
0 | 2269 |
* @return string The sanitized title. |
2270 |
*/ |
|
2271 |
function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) { |
|
9 | 2272 |
$title = strip_tags( $title ); |
0 | 2273 |
// Preserve escaped octets. |
9 | 2274 |
$title = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title ); |
0 | 2275 |
// Remove percent signs that are not part of an octet. |
9 | 2276 |
$title = str_replace( '%', '', $title ); |
0 | 2277 |
// Restore octets. |
9 | 2278 |
$title = preg_replace( '|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title ); |
2279 |
||
2280 |
if ( seems_utf8( $title ) ) { |
|
2281 |
if ( function_exists( 'mb_strtolower' ) ) { |
|
2282 |
$title = mb_strtolower( $title, 'UTF-8' ); |
|
0 | 2283 |
} |
9 | 2284 |
$title = utf8_uri_encode( $title, 200 ); |
0 | 2285 |
} |
2286 |
||
9 | 2287 |
$title = strtolower( $title ); |
0 | 2288 |
|
16 | 2289 |
if ( 'save' === $context ) { |
2290 |
// Convert  , &ndash, and &mdash to hyphens. |
|
0 | 2291 |
$title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title ); |
16 | 2292 |
// Convert  , &ndash, and &mdash HTML entities to hyphens. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2293 |
$title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title ); |
16 | 2294 |
// Convert forward slash to hyphen. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2295 |
$title = str_replace( '/', '-', $title ); |
0 | 2296 |
|
16 | 2297 |
// Strip these characters entirely. |
9 | 2298 |
$title = str_replace( |
2299 |
array( |
|
16 | 2300 |
// Soft hyphens. |
9 | 2301 |
'%c2%ad', |
16 | 2302 |
// ¡ and ¿. |
9 | 2303 |
'%c2%a1', |
2304 |
'%c2%bf', |
|
16 | 2305 |
// Angle quotes. |
9 | 2306 |
'%c2%ab', |
2307 |
'%c2%bb', |
|
2308 |
'%e2%80%b9', |
|
2309 |
'%e2%80%ba', |
|
16 | 2310 |
// Curly quotes. |
9 | 2311 |
'%e2%80%98', |
2312 |
'%e2%80%99', |
|
2313 |
'%e2%80%9c', |
|
2314 |
'%e2%80%9d', |
|
2315 |
'%e2%80%9a', |
|
2316 |
'%e2%80%9b', |
|
2317 |
'%e2%80%9e', |
|
2318 |
'%e2%80%9f', |
|
16 | 2319 |
// Bullet. |
2320 |
'%e2%80%a2', |
|
2321 |
// ©, ®, °, &hellip, and &trade. |
|
9 | 2322 |
'%c2%a9', |
2323 |
'%c2%ae', |
|
2324 |
'%c2%b0', |
|
2325 |
'%e2%80%a6', |
|
2326 |
'%e2%84%a2', |
|
16 | 2327 |
// Acute accents. |
9 | 2328 |
'%c2%b4', |
2329 |
'%cb%8a', |
|
2330 |
'%cc%81', |
|
2331 |
'%cd%81', |
|
16 | 2332 |
// Grave accent, macron, caron. |
9 | 2333 |
'%cc%80', |
2334 |
'%cc%84', |
|
2335 |
'%cc%8c', |
|
19 | 2336 |
// Non-visible characters that display without a width. |
2337 |
'%e2%80%8b', // Zero width space. |
|
2338 |
'%e2%80%8c', // Zero width non-joiner. |
|
2339 |
'%e2%80%8d', // Zero width joiner. |
|
2340 |
'%e2%80%8e', // Left-to-right mark. |
|
2341 |
'%e2%80%8f', // Right-to-left mark. |
|
2342 |
'%e2%80%aa', // Left-to-right embedding. |
|
2343 |
'%e2%80%ab', // Right-to-left embedding. |
|
2344 |
'%e2%80%ac', // Pop directional formatting. |
|
2345 |
'%e2%80%ad', // Left-to-right override. |
|
2346 |
'%e2%80%ae', // Right-to-left override. |
|
2347 |
'%ef%bb%bf', // Byte order mark. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2348 |
'%ef%bf%bc', // Object replacement character. |
9 | 2349 |
), |
2350 |
'', |
|
2351 |
$title |
|
2352 |
); |
|
0 | 2353 |
|
19 | 2354 |
// Convert non-visible characters that display with a width to hyphen. |
2355 |
$title = str_replace( |
|
2356 |
array( |
|
2357 |
'%e2%80%80', // En quad. |
|
2358 |
'%e2%80%81', // Em quad. |
|
2359 |
'%e2%80%82', // En space. |
|
2360 |
'%e2%80%83', // Em space. |
|
2361 |
'%e2%80%84', // Three-per-em space. |
|
2362 |
'%e2%80%85', // Four-per-em space. |
|
2363 |
'%e2%80%86', // Six-per-em space. |
|
2364 |
'%e2%80%87', // Figure space. |
|
2365 |
'%e2%80%88', // Punctuation space. |
|
2366 |
'%e2%80%89', // Thin space. |
|
2367 |
'%e2%80%8a', // Hair space. |
|
2368 |
'%e2%80%a8', // Line separator. |
|
2369 |
'%e2%80%a9', // Paragraph separator. |
|
2370 |
'%e2%80%af', // Narrow no-break space. |
|
2371 |
), |
|
2372 |
'-', |
|
2373 |
$title |
|
2374 |
); |
|
2375 |
||
16 | 2376 |
// Convert × to 'x'. |
0 | 2377 |
$title = str_replace( '%c3%97', 'x', $title ); |
2378 |
} |
|
2379 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2380 |
// Remove HTML entities. |
16 | 2381 |
$title = preg_replace( '/&.+?;/', '', $title ); |
9 | 2382 |
$title = str_replace( '.', '-', $title ); |
2383 |
||
2384 |
$title = preg_replace( '/[^%a-z0-9 _-]/', '', $title ); |
|
2385 |
$title = preg_replace( '/\s+/', '-', $title ); |
|
2386 |
$title = preg_replace( '|-+|', '-', $title ); |
|
2387 |
$title = trim( $title, '-' ); |
|
0 | 2388 |
|
2389 |
return $title; |
|
2390 |
} |
|
2391 |
||
2392 |
/** |
|
5 | 2393 |
* Ensures a string is a valid SQL 'order by' clause. |
2394 |
* |
|
2395 |
* Accepts one or more columns, with or without a sort order (ASC / DESC). |
|
2396 |
* e.g. 'column_1', 'column_1, column_2', 'column_1 ASC, column_2 DESC' etc. |
|
2397 |
* |
|
2398 |
* Also accepts 'RAND()'. |
|
0 | 2399 |
* |
2400 |
* @since 2.5.1 |
|
2401 |
* |
|
5 | 2402 |
* @param string $orderby Order by clause to be validated. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2403 |
* @return string|false Returns $orderby if valid, false otherwise. |
0 | 2404 |
*/ |
5 | 2405 |
function sanitize_sql_orderby( $orderby ) { |
2406 |
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 ) ) { |
|
2407 |
return $orderby; |
|
2408 |
} |
|
2409 |
return false; |
|
0 | 2410 |
} |
2411 |
||
2412 |
/** |
|
2413 |
* Sanitizes an HTML classname to ensure it only contains valid characters. |
|
2414 |
* |
|
2415 |
* Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty |
|
2416 |
* string then it will return the alternative value supplied. |
|
2417 |
* |
|
2418 |
* @todo Expand to support the full range of CDATA that a class attribute can contain. |
|
2419 |
* |
|
2420 |
* @since 2.8.0 |
|
2421 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2422 |
* @param string $classname The classname to be sanitized. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2423 |
* @param string $fallback Optional. The value to return if the sanitization ends up as an empty string. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2424 |
* Default empty string. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2425 |
* @return string The sanitized value. |
0 | 2426 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2427 |
function sanitize_html_class( $classname, $fallback = '' ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2428 |
// Strip out any percent-encoded characters. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2429 |
$sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $classname ); |
0 | 2430 |
|
16 | 2431 |
// Limit to A-Z, a-z, 0-9, '_', '-'. |
0 | 2432 |
$sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); |
2433 |
||
16 | 2434 |
if ( '' === $sanitized && $fallback ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2435 |
return sanitize_html_class( $fallback ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2436 |
} |
5 | 2437 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2438 |
* Filters a sanitized HTML class string. |
5 | 2439 |
* |
2440 |
* @since 2.8.0 |
|
2441 |
* |
|
2442 |
* @param string $sanitized The sanitized HTML class. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2443 |
* @param string $classname HTML class before sanitization. |
5 | 2444 |
* @param string $fallback The fallback string. |
2445 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2446 |
return apply_filters( 'sanitize_html_class', $sanitized, $classname, $fallback ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2447 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2448 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2449 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2450 |
* Strips out all characters not allowed in a locale name. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2451 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2452 |
* @since 6.2.1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2453 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2454 |
* @param string $locale_name The locale name to be sanitized. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2455 |
* @return string The sanitized value. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2456 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2457 |
function sanitize_locale_name( $locale_name ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2458 |
// Limit to A-Z, a-z, 0-9, '_', '-'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2459 |
$sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $locale_name ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2460 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2461 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2462 |
* Filters a sanitized locale name string. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2463 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2464 |
* @since 6.2.1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2465 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2466 |
* @param string $sanitized The sanitized locale name. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2467 |
* @param string $locale_name The locale name before sanitization. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2468 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2469 |
return apply_filters( 'sanitize_locale_name', $sanitized, $locale_name ); |
0 | 2470 |
} |
2471 |
||
2472 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2473 |
* Converts lone & characters into `&` (a.k.a. `&`) |
0 | 2474 |
* |
2475 |
* @since 0.71 |
|
2476 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2477 |
* @param string $content String of characters to be converted. |
0 | 2478 |
* @param string $deprecated Not used. |
2479 |
* @return string Converted string. |
|
2480 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2481 |
function convert_chars( $content, $deprecated = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2482 |
if ( ! empty( $deprecated ) ) { |
0 | 2483 |
_deprecated_argument( __FUNCTION__, '0.71' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2484 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2485 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2486 |
if ( str_contains( $content, '&' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2487 |
$content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2488 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2489 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2490 |
return $content; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2491 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2492 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2493 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2494 |
* Converts invalid Unicode references range to valid range. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2495 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2496 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2497 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2498 |
* @param string $content String with entities that need converting. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2499 |
* @return string Converted string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2500 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2501 |
function convert_invalid_entities( $content ) { |
0 | 2502 |
$wp_htmltranswinuni = array( |
16 | 2503 |
'€' => '€', // The Euro sign. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2504 |
'' => '', |
16 | 2505 |
'‚' => '‚', // These are Windows CP1252 specific characters. |
2506 |
'ƒ' => 'ƒ', // They would look weird on non-Windows browsers. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2507 |
'„' => '„', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2508 |
'…' => '…', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2509 |
'†' => '†', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2510 |
'‡' => '‡', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2511 |
'ˆ' => 'ˆ', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2512 |
'‰' => '‰', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2513 |
'Š' => 'Š', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2514 |
'‹' => '‹', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2515 |
'Œ' => 'Œ', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2516 |
'' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2517 |
'Ž' => 'Ž', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2518 |
'' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2519 |
'' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2520 |
'‘' => '‘', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2521 |
'’' => '’', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2522 |
'“' => '“', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2523 |
'”' => '”', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2524 |
'•' => '•', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2525 |
'–' => '–', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2526 |
'—' => '—', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2527 |
'˜' => '˜', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2528 |
'™' => '™', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2529 |
'š' => 'š', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2530 |
'›' => '›', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2531 |
'œ' => 'œ', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2532 |
'' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2533 |
'ž' => 'ž', |
9 | 2534 |
'Ÿ' => 'Ÿ', |
0 | 2535 |
); |
2536 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2537 |
if ( str_contains( $content, '' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2538 |
$content = strtr( $content, $wp_htmltranswinuni ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2539 |
} |
0 | 2540 |
|
2541 |
return $content; |
|
2542 |
} |
|
2543 |
||
2544 |
/** |
|
2545 |
* Balances tags if forced to, or if the 'use_balanceTags' option is set to true. |
|
2546 |
* |
|
2547 |
* @since 0.71 |
|
2548 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2549 |
* @param string $text Text to be balanced. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2550 |
* @param bool $force If true, forces balancing, ignoring the value of the option. Default false. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2551 |
* @return string Balanced text. |
0 | 2552 |
*/ |
16 | 2553 |
function balanceTags( $text, $force = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid |
2554 |
if ( $force || (int) get_option( 'use_balanceTags' ) === 1 ) { |
|
0 | 2555 |
return force_balance_tags( $text ); |
5 | 2556 |
} else { |
0 | 2557 |
return $text; |
5 | 2558 |
} |
0 | 2559 |
} |
2560 |
||
2561 |
/** |
|
2562 |
* Balances tags of string using a modified stack. |
|
2563 |
* |
|
2564 |
* @since 2.0.4 |
|
16 | 2565 |
* @since 5.3.0 Improve accuracy and add support for custom element tags. |
0 | 2566 |
* |
2567 |
* @author Leonard Lin <leonard@acm.org> |
|
2568 |
* @license GPL |
|
2569 |
* @copyright November 4, 2001 |
|
2570 |
* @version 1.1 |
|
2571 |
* @todo Make better - change loop condition to $text in 1.2 |
|
2572 |
* @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004 |
|
9 | 2573 |
* 1.1 Fixed handling of append/stack pop order of end text |
2574 |
* Added Cleaning Hooks |
|
2575 |
* 1.0 First Version |
|
0 | 2576 |
* |
2577 |
* @param string $text Text to be balanced. |
|
2578 |
* @return string Balanced text. |
|
2579 |
*/ |
|
2580 |
function force_balance_tags( $text ) { |
|
9 | 2581 |
$tagstack = array(); |
0 | 2582 |
$stacksize = 0; |
9 | 2583 |
$tagqueue = ''; |
2584 |
$newtext = ''; |
|
16 | 2585 |
// Known single-entity/self-closing tags. |
19 | 2586 |
$single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source', 'track', 'wbr' ); |
16 | 2587 |
// Tags that can be immediately nested within themselves. |
19 | 2588 |
$nestable_tags = array( 'article', 'aside', 'blockquote', 'details', 'div', 'figure', 'object', 'q', 'section', 'span' ); |
0 | 2589 |
|
16 | 2590 |
// WP bug fix for comments - in case you REALLY meant to type '< !--'. |
9 | 2591 |
$text = str_replace( '< !--', '< !--', $text ); |
16 | 2592 |
// WP bug fix for LOVE <3 (and other situations with '<' before a number). |
9 | 2593 |
$text = preg_replace( '#<([0-9]{1})#', '<$1', $text ); |
2594 |
||
16 | 2595 |
/** |
2596 |
* Matches supported tags. |
|
2597 |
* |
|
2598 |
* To get the pattern as a string without the comments paste into a PHP |
|
2599 |
* REPL like `php -a`. |
|
2600 |
* |
|
2601 |
* @see https://html.spec.whatwg.org/#elements-2 |
|
19 | 2602 |
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name |
16 | 2603 |
* |
2604 |
* @example |
|
2605 |
* ~# php -a |
|
2606 |
* php > $s = [paste copied contents of expression below including parentheses]; |
|
2607 |
* php > echo $s; |
|
2608 |
*/ |
|
2609 |
$tag_pattern = ( |
|
2610 |
'#<' . // Start with an opening bracket. |
|
2611 |
'(/?)' . // Group 1 - If it's a closing tag it'll have a leading slash. |
|
2612 |
'(' . // Group 2 - Tag name. |
|
2613 |
// Custom element tags have more lenient rules than HTML tag names. |
|
2614 |
'(?:[a-z](?:[a-z0-9._]*)-(?:[a-z0-9._-]+)+)' . |
|
2615 |
'|' . |
|
2616 |
// Traditional tag rules approximate HTML tag names. |
|
2617 |
'(?:[\w:]+)' . |
|
2618 |
')' . |
|
2619 |
'(?:' . |
|
2620 |
// We either immediately close the tag with its '>' and have nothing here. |
|
2621 |
'\s*' . |
|
2622 |
'(/?)' . // Group 3 - "attributes" for empty tag. |
|
2623 |
'|' . |
|
2624 |
// Or we must start with space characters to separate the tag name from the attributes (or whitespace). |
|
2625 |
'(\s+)' . // Group 4 - Pre-attribute whitespace. |
|
2626 |
'([^>]*)' . // Group 5 - Attributes. |
|
2627 |
')' . |
|
2628 |
'>#' // End with a closing bracket. |
|
2629 |
); |
|
2630 |
||
2631 |
while ( preg_match( $tag_pattern, $text, $regex ) ) { |
|
2632 |
$full_match = $regex[0]; |
|
2633 |
$has_leading_slash = ! empty( $regex[1] ); |
|
2634 |
$tag_name = $regex[2]; |
|
2635 |
$tag = strtolower( $tag_name ); |
|
2636 |
$is_single_tag = in_array( $tag, $single_tags, true ); |
|
2637 |
$pre_attribute_ws = isset( $regex[4] ) ? $regex[4] : ''; |
|
2638 |
$attributes = trim( isset( $regex[5] ) ? $regex[5] : $regex[3] ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2639 |
$has_self_closer = str_ends_with( $attributes, '/' ); |
16 | 2640 |
|
0 | 2641 |
$newtext .= $tagqueue; |
2642 |
||
16 | 2643 |
$i = strpos( $text, $full_match ); |
2644 |
$l = strlen( $full_match ); |
|
2645 |
||
2646 |
// Clear the shifter. |
|
0 | 2647 |
$tagqueue = ''; |
16 | 2648 |
if ( $has_leading_slash ) { // End tag. |
2649 |
// If too many closing tags. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2650 |
if ( $stacksize <= 0 ) { |
0 | 2651 |
$tag = ''; |
16 | 2652 |
// Or close to be safe $tag = '/' . $tag. |
2653 |
||
2654 |
// If stacktop value = tag close value, then pop. |
|
2655 |
} elseif ( $tagstack[ $stacksize - 1 ] === $tag ) { // Found closing tag. |
|
2656 |
$tag = '</' . $tag . '>'; // Close tag. |
|
0 | 2657 |
array_pop( $tagstack ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2658 |
--$stacksize; |
16 | 2659 |
} else { // Closing tag not at top, search for it. |
9 | 2660 |
for ( $j = $stacksize - 1; $j >= 0; $j-- ) { |
16 | 2661 |
if ( $tagstack[ $j ] === $tag ) { |
2662 |
// Add tag to tagqueue. |
|
9 | 2663 |
for ( $k = $stacksize - 1; $k >= $j; $k-- ) { |
0 | 2664 |
$tagqueue .= '</' . array_pop( $tagstack ) . '>'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2665 |
--$stacksize; |
0 | 2666 |
} |
2667 |
break; |
|
2668 |
} |
|
2669 |
} |
|
2670 |
$tag = ''; |
|
2671 |
} |
|
16 | 2672 |
} else { // Begin tag. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2673 |
if ( $has_self_closer ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2674 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2675 |
* If it presents itself as a self-closing tag, but it isn't a known single-entity self-closing tag, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2676 |
* then don't let it be treated as such and immediately close it with a closing tag. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2677 |
* The tag will encapsulate no text as a result. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2678 |
*/ |
16 | 2679 |
if ( ! $is_single_tag ) { |
2680 |
$attributes = trim( substr( $attributes, 0, -1 ) ) . "></$tag"; |
|
9 | 2681 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2682 |
} elseif ( $is_single_tag ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2683 |
// Else if it's a known single-entity tag but it doesn't close itself, do so. |
16 | 2684 |
$pre_attribute_ws = ' '; |
2685 |
$attributes .= '/'; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2686 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2687 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2688 |
* It's not a single-entity tag. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2689 |
* If the top of the stack is the same as the tag we want to push, close previous tag. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2690 |
*/ |
16 | 2691 |
if ( $stacksize > 0 && ! in_array( $tag, $nestable_tags, true ) && $tagstack[ $stacksize - 1 ] === $tag ) { |
0 | 2692 |
$tagqueue = '</' . array_pop( $tagstack ) . '>'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2693 |
--$stacksize; |
0 | 2694 |
} |
2695 |
$stacksize = array_push( $tagstack, $tag ); |
|
2696 |
} |
|
2697 |
||
16 | 2698 |
// Attributes. |
2699 |
if ( $has_self_closer && $is_single_tag ) { |
|
2700 |
// We need some space - avoid <br/> and prefer <br />. |
|
2701 |
$pre_attribute_ws = ' '; |
|
9 | 2702 |
} |
0 | 2703 |
|
16 | 2704 |
$tag = '<' . $tag . $pre_attribute_ws . $attributes . '>'; |
2705 |
// If already queuing a close tag, then put this tag on too. |
|
9 | 2706 |
if ( ! empty( $tagqueue ) ) { |
0 | 2707 |
$tagqueue .= $tag; |
9 | 2708 |
$tag = ''; |
0 | 2709 |
} |
2710 |
} |
|
9 | 2711 |
$newtext .= substr( $text, 0, $i ) . $tag; |
2712 |
$text = substr( $text, $i + $l ); |
|
0 | 2713 |
} |
2714 |
||
16 | 2715 |
// Clear tag queue. |
0 | 2716 |
$newtext .= $tagqueue; |
2717 |
||
16 | 2718 |
// Add remaining text. |
0 | 2719 |
$newtext .= $text; |
2720 |
||
9 | 2721 |
while ( $x = array_pop( $tagstack ) ) { |
16 | 2722 |
$newtext .= '</' . $x . '>'; // Add remaining tags to close. |
2723 |
} |
|
2724 |
||
2725 |
// WP fix for the bug with HTML comments. |
|
9 | 2726 |
$newtext = str_replace( '< !--', '<!--', $newtext ); |
2727 |
$newtext = str_replace( '< !--', '< !--', $newtext ); |
|
0 | 2728 |
|
2729 |
return $newtext; |
|
2730 |
} |
|
2731 |
||
2732 |
/** |
|
2733 |
* Acts on text which is about to be edited. |
|
2734 |
* |
|
2735 |
* The $content is run through esc_textarea(), which uses htmlspecialchars() |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2736 |
* to convert special characters to HTML entities. If `$richedit` is set to true, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2737 |
* it is simply a holder for the {@see 'format_to_edit'} filter. |
0 | 2738 |
* |
2739 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2740 |
* @since 4.4.0 The `$richedit` parameter was renamed to `$rich_text` for clarity. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2741 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2742 |
* @param string $content The text about to be edited. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2743 |
* @param bool $rich_text Optional. Whether `$content` should be considered rich text, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2744 |
* in which case it would not be passed through esc_textarea(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2745 |
* Default false. |
0 | 2746 |
* @return string The text after the filter (and possibly htmlspecialchars()) has been run. |
2747 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2748 |
function format_to_edit( $content, $rich_text = false ) { |
5 | 2749 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2750 |
* Filters the text to be formatted for editing. |
5 | 2751 |
* |
2752 |
* @since 1.2.0 |
|
2753 |
* |
|
2754 |
* @param string $content The text, prior to formatting for editing. |
|
2755 |
*/ |
|
0 | 2756 |
$content = apply_filters( 'format_to_edit', $content ); |
9 | 2757 |
if ( ! $rich_text ) { |
0 | 2758 |
$content = esc_textarea( $content ); |
9 | 2759 |
} |
0 | 2760 |
return $content; |
2761 |
} |
|
2762 |
||
2763 |
/** |
|
2764 |
* Add leading zeros when necessary. |
|
2765 |
* |
|
2766 |
* If you set the threshold to '4' and the number is '10', then you will get |
|
2767 |
* back '0010'. If you set the threshold to '4' and the number is '5000', then you |
|
2768 |
* will get back '5000'. |
|
2769 |
* |
|
2770 |
* Uses sprintf to append the amount of zeros based on the $threshold parameter |
|
2771 |
* and the size of the number. If the number is large enough, then no zeros will |
|
2772 |
* be appended. |
|
2773 |
* |
|
2774 |
* @since 0.71 |
|
2775 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2776 |
* @param int $number Number to append zeros to if not greater than threshold. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2777 |
* @param int $threshold Digit places number needs to be to not have zeros added. |
0 | 2778 |
* @return string Adds leading zeros to number if needed. |
2779 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2780 |
function zeroise( $number, $threshold ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2781 |
return sprintf( '%0' . $threshold . 's', $number ); |
0 | 2782 |
} |
2783 |
||
2784 |
/** |
|
2785 |
* Adds backslashes before letters and before a number at the start of a string. |
|
2786 |
* |
|
2787 |
* @since 0.71 |
|
2788 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2789 |
* @param string $value Value to which backslashes will be added. |
0 | 2790 |
* @return string String with backslashes inserted. |
2791 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2792 |
function backslashit( $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2793 |
if ( isset( $value[0] ) && $value[0] >= '0' && $value[0] <= '9' ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2794 |
$value = '\\\\' . $value; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2795 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2796 |
return addcslashes( $value, 'A..Za..z' ); |
0 | 2797 |
} |
2798 |
||
2799 |
/** |
|
2800 |
* Appends a trailing slash. |
|
2801 |
* |
|
5 | 2802 |
* Will remove trailing forward and backslashes if it exists already before adding |
2803 |
* a trailing forward slash. This prevents double slashing a string or path. |
|
0 | 2804 |
* |
2805 |
* The primary use of this is for paths and thus should be used for paths. It is |
|
2806 |
* not restricted to paths and offers no specific path support. |
|
2807 |
* |
|
2808 |
* @since 1.2.0 |
|
2809 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2810 |
* @param string $value Value to which trailing slash will be added. |
0 | 2811 |
* @return string String with trailing slash added. |
2812 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2813 |
function trailingslashit( $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2814 |
return untrailingslashit( $value ) . '/'; |
0 | 2815 |
} |
2816 |
||
2817 |
/** |
|
5 | 2818 |
* Removes trailing forward slashes and backslashes if they exist. |
0 | 2819 |
* |
2820 |
* The primary use of this is for paths and thus should be used for paths. It is |
|
2821 |
* not restricted to paths and offers no specific path support. |
|
2822 |
* |
|
2823 |
* @since 2.2.0 |
|
2824 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2825 |
* @param string $value Value from which trailing slashes will be removed. |
5 | 2826 |
* @return string String without the trailing slashes. |
0 | 2827 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2828 |
function untrailingslashit( $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2829 |
return rtrim( $value, '/\\' ); |
0 | 2830 |
} |
2831 |
||
2832 |
/** |
|
19 | 2833 |
* Adds slashes to a string or recursively adds slashes to strings within an array. |
0 | 2834 |
* |
2835 |
* @since 0.71 |
|
2836 |
* |
|
19 | 2837 |
* @param string|array $gpc String or array of data to slash. |
2838 |
* @return string|array Slashed `$gpc`. |
|
0 | 2839 |
*/ |
9 | 2840 |
function addslashes_gpc( $gpc ) { |
2841 |
return wp_slash( $gpc ); |
|
0 | 2842 |
} |
2843 |
||
2844 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2845 |
* Navigates through an array, object, or scalar, and removes slashes from the values. |
0 | 2846 |
* |
2847 |
* @since 2.0.0 |
|
2848 |
* |
|
2849 |
* @param mixed $value The value to be stripped. |
|
2850 |
* @return mixed Stripped value. |
|
2851 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2852 |
function stripslashes_deep( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2853 |
return map_deep( $value, 'stripslashes_from_strings_only' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2854 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2855 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2856 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2857 |
* Callback function for `stripslashes_deep()` which strips slashes from strings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2858 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2859 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2860 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2861 |
* @param mixed $value The array or string to be stripped. |
16 | 2862 |
* @return mixed The stripped value. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2863 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2864 |
function stripslashes_from_strings_only( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2865 |
return is_string( $value ) ? stripslashes( $value ) : $value; |
0 | 2866 |
} |
2867 |
||
2868 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2869 |
* Navigates through an array, object, or scalar, and encodes the values to be used in a URL. |
0 | 2870 |
* |
2871 |
* @since 2.2.0 |
|
2872 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2873 |
* @param mixed $value The array or string to be encoded. |
16 | 2874 |
* @return mixed The encoded value. |
0 | 2875 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2876 |
function urlencode_deep( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2877 |
return map_deep( $value, 'urlencode' ); |
0 | 2878 |
} |
2879 |
||
2880 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2881 |
* Navigates through an array, object, or scalar, and raw-encodes the values to be used in a URL. |
0 | 2882 |
* |
2883 |
* @since 3.4.0 |
|
2884 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2885 |
* @param mixed $value The array or string to be encoded. |
16 | 2886 |
* @return mixed The encoded value. |
0 | 2887 |
*/ |
2888 |
function rawurlencode_deep( $value ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2889 |
return map_deep( $value, 'rawurlencode' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2890 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2891 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2892 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2893 |
* Navigates through an array, object, or scalar, and decodes URL-encoded values |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2894 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2895 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2896 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2897 |
* @param mixed $value The array or string to be decoded. |
16 | 2898 |
* @return mixed The decoded value. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2899 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2900 |
function urldecode_deep( $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2901 |
return map_deep( $value, 'urldecode' ); |
0 | 2902 |
} |
2903 |
||
2904 |
/** |
|
2905 |
* Converts email addresses characters to HTML entities to block spam bots. |
|
2906 |
* |
|
2907 |
* @since 0.71 |
|
2908 |
* |
|
2909 |
* @param string $email_address Email address. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2910 |
* @param int $hex_encoding Optional. Set to 1 to enable hex encoding. |
0 | 2911 |
* @return string Converted email address. |
2912 |
*/ |
|
2913 |
function antispambot( $email_address, $hex_encoding = 0 ) { |
|
2914 |
$email_no_spam_address = ''; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2915 |
|
5 | 2916 |
for ( $i = 0, $len = strlen( $email_address ); $i < $len; $i++ ) { |
0 | 2917 |
$j = rand( 0, 1 + $hex_encoding ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2918 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2919 |
if ( 0 === $j ) { |
9 | 2920 |
$email_no_spam_address .= '&#' . ord( $email_address[ $i ] ) . ';'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2921 |
} elseif ( 1 === $j ) { |
9 | 2922 |
$email_no_spam_address .= $email_address[ $i ]; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2923 |
} elseif ( 2 === $j ) { |
9 | 2924 |
$email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[ $i ] ) ), 2 ); |
0 | 2925 |
} |
2926 |
} |
|
2927 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2928 |
return str_replace( '@', '@', $email_no_spam_address ); |
0 | 2929 |
} |
2930 |
||
2931 |
/** |
|
2932 |
* Callback to convert URI match to HTML A element. |
|
2933 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2934 |
* This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable(). |
0 | 2935 |
* |
2936 |
* @since 2.3.2 |
|
2937 |
* @access private |
|
2938 |
* |
|
2939 |
* @param array $matches Single Regex Match. |
|
2940 |
* @return string HTML A element with URI address. |
|
2941 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2942 |
function _make_url_clickable_cb( $matches ) { |
0 | 2943 |
$url = $matches[2]; |
2944 |
||
16 | 2945 |
if ( ')' === $matches[3] && strpos( $url, '(' ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2946 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2947 |
* If the trailing character is a closing parenthesis, and the URL has an opening parenthesis in it, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2948 |
* add the closing parenthesis to the URL. Then we can let the parenthesis balancer do its thing below. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2949 |
*/ |
9 | 2950 |
$url .= $matches[3]; |
0 | 2951 |
$suffix = ''; |
2952 |
} else { |
|
2953 |
$suffix = $matches[3]; |
|
2954 |
} |
|
2955 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2956 |
if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2957 |
$url .= $matches[4]; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2958 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2959 |
|
16 | 2960 |
// Include parentheses in the URL only if paired. |
0 | 2961 |
while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { |
2962 |
$suffix = strrchr( $url, ')' ) . $suffix; |
|
9 | 2963 |
$url = substr( $url, 0, strrpos( $url, ')' ) ); |
0 | 2964 |
} |
2965 |
||
9 | 2966 |
$url = esc_url( $url ); |
2967 |
if ( empty( $url ) ) { |
|
0 | 2968 |
return $matches[0]; |
9 | 2969 |
} |
0 | 2970 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2971 |
$rel_attr = _make_clickable_rel_attr( $url ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2972 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2973 |
return $matches[1] . "<a href=\"{$url}\"{$rel_attr}>{$url}</a>" . $suffix; |
0 | 2974 |
} |
2975 |
||
2976 |
/** |
|
2977 |
* Callback to convert URL match to HTML A element. |
|
2978 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2979 |
* This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable(). |
0 | 2980 |
* |
2981 |
* @since 2.3.2 |
|
2982 |
* @access private |
|
2983 |
* |
|
2984 |
* @param array $matches Single Regex Match. |
|
2985 |
* @return string HTML A element with URL address. |
|
2986 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2987 |
function _make_web_ftp_clickable_cb( $matches ) { |
9 | 2988 |
$ret = ''; |
0 | 2989 |
$dest = $matches[2]; |
2990 |
$dest = 'http://' . $dest; |
|
2991 |
||
16 | 2992 |
// Removed trailing [.,;:)] from URL. |
2993 |
$last_char = substr( $dest, -1 ); |
|
2994 |
if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) === true ) { |
|
2995 |
$ret = $last_char; |
|
9 | 2996 |
$dest = substr( $dest, 0, strlen( $dest ) - 1 ); |
0 | 2997 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2998 |
|
9 | 2999 |
$dest = esc_url( $dest ); |
3000 |
if ( empty( $dest ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3001 |
return $matches[0]; |
9 | 3002 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3003 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3004 |
$rel_attr = _make_clickable_rel_attr( $dest ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3005 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3006 |
return $matches[1] . "<a href=\"{$dest}\"{$rel_attr}>{$dest}</a>{$ret}"; |
0 | 3007 |
} |
3008 |
||
3009 |
/** |
|
3010 |
* Callback to convert email address match to HTML A element. |
|
3011 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3012 |
* This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable(). |
0 | 3013 |
* |
3014 |
* @since 2.3.2 |
|
3015 |
* @access private |
|
3016 |
* |
|
3017 |
* @param array $matches Single Regex Match. |
|
3018 |
* @return string HTML A element with email address. |
|
3019 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3020 |
function _make_email_clickable_cb( $matches ) { |
0 | 3021 |
$email = $matches[2] . '@' . $matches[3]; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3022 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3023 |
return $matches[1] . "<a href=\"mailto:{$email}\">{$email}</a>"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3024 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3025 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3026 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3027 |
* Helper function used to build the "rel" attribute for a URL when creating an anchor using make_clickable(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3028 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3029 |
* @since 6.2.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3030 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3031 |
* @param string $url The URL. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3032 |
* @return string The rel attribute for the anchor or an empty string if no rel attribute should be added. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3033 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3034 |
function _make_clickable_rel_attr( $url ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3035 |
$rel_parts = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3036 |
$scheme = strtolower( wp_parse_url( $url, PHP_URL_SCHEME ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3037 |
$nofollow_schemes = array_intersect( wp_allowed_protocols(), array( 'https', 'http' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3038 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3039 |
// Apply "nofollow" to external links with qualifying URL schemes (mailto:, tel:, etc... shouldn't be followed). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3040 |
if ( ! wp_is_internal_link( $url ) && in_array( $scheme, $nofollow_schemes, true ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3041 |
$rel_parts[] = 'nofollow'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3042 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3043 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3044 |
// Apply "ugc" when in comment context. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3045 |
if ( 'comment_text' === current_filter() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3046 |
$rel_parts[] = 'ugc'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3047 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3048 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3049 |
$rel = implode( ' ', $rel_parts ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3050 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3051 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3052 |
* Filters the rel value that is added to URL matches converted to links. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3053 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3054 |
* @since 5.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3055 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3056 |
* @param string $rel The rel value. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3057 |
* @param string $url The matched URL being converted to a link tag. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3058 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3059 |
$rel = apply_filters( 'make_clickable_rel', $rel, $url ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3060 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3061 |
$rel_attr = $rel ? ' rel="' . esc_attr( $rel ) . '"' : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3062 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3063 |
return $rel_attr; |
0 | 3064 |
} |
3065 |
||
3066 |
/** |
|
19 | 3067 |
* Converts plaintext URI to HTML links. |
0 | 3068 |
* |
3069 |
* Converts URI, www and ftp, and email addresses. Finishes by fixing links |
|
3070 |
* within links. |
|
3071 |
* |
|
3072 |
* @since 0.71 |
|
3073 |
* |
|
3074 |
* @param string $text Content to convert URIs. |
|
3075 |
* @return string Content with converted URIs. |
|
3076 |
*/ |
|
3077 |
function make_clickable( $text ) { |
|
9 | 3078 |
$r = ''; |
16 | 3079 |
$textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Split out HTML tags. |
3080 |
$nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>. |
|
0 | 3081 |
foreach ( $textarr as $piece ) { |
5 | 3082 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3083 |
if ( preg_match( '|^<code[\s>]|i', $piece ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3084 |
|| preg_match( '|^<pre[\s>]|i', $piece ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3085 |
|| preg_match( '|^<script[\s>]|i', $piece ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3086 |
|| preg_match( '|^<style[\s>]|i', $piece ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3087 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3088 |
++$nested_code_pre; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3089 |
} elseif ( $nested_code_pre |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3090 |
&& ( '</code>' === strtolower( $piece ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3091 |
|| '</pre>' === strtolower( $piece ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3092 |
|| '</script>' === strtolower( $piece ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3093 |
|| '</style>' === strtolower( $piece ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3094 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3095 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3096 |
--$nested_code_pre; |
9 | 3097 |
} |
5 | 3098 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3099 |
if ( $nested_code_pre |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3100 |
|| empty( $piece ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3101 |
|| ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3102 |
) { |
0 | 3103 |
$r .= $piece; |
3104 |
continue; |
|
3105 |
} |
|
3106 |
||
16 | 3107 |
// Long strings might contain expensive edge cases... |
0 | 3108 |
if ( 10000 < strlen( $piece ) ) { |
16 | 3109 |
// ...break it up. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3110 |
foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing parentheses. |
0 | 3111 |
if ( 2101 < strlen( $chunk ) ) { |
3112 |
$r .= $chunk; // Too big, no whitespace: bail. |
|
3113 |
} else { |
|
3114 |
$r .= make_clickable( $chunk ); |
|
3115 |
} |
|
3116 |
} |
|
3117 |
} else { |
|
16 | 3118 |
$ret = " $piece "; // Pad with whitespace to simplify the regexes. |
0 | 3119 |
|
3120 |
$url_clickable = '~ |
|
16 | 3121 |
([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation. |
3122 |
( # 2: URL. |
|
3123 |
[\\w]{1,20}+:// # Scheme and hier-part prefix. |
|
3124 |
(?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long. |
|
3125 |
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3126 |
(?: # Unroll the Loop: Only allow punctuation URL character if followed by a non-punctuation URL character. |
16 | 3127 |
[\'.,;:!?)] # Punctuation URL character. |
3128 |
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character. |
|
0 | 3129 |
)* |
3130 |
) |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3131 |
(\)?) # 3: Trailing closing parenthesis (for parenthesis balancing post processing). |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3132 |
(\\.\\w{2,6})? # 4: Allowing file extensions (e.g., .jpg, .png). |
16 | 3133 |
~xS'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3134 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3135 |
* The regex is a non-anchored pattern and does not have a single fixed starting character. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3136 |
* Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3137 |
*/ |
0 | 3138 |
|
3139 |
$ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); |
|
3140 |
||
3141 |
$ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); |
|
3142 |
$ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); |
|
3143 |
||
3144 |
$ret = substr( $ret, 1, -1 ); // Remove our whitespace padding. |
|
9 | 3145 |
$r .= $ret; |
0 | 3146 |
} |
3147 |
} |
|
3148 |
||
16 | 3149 |
// Cleanup of accidental links within links. |
9 | 3150 |
return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', '$1$3</a>', $r ); |
0 | 3151 |
} |
3152 |
||
3153 |
/** |
|
3154 |
* Breaks a string into chunks by splitting at whitespace characters. |
|
19 | 3155 |
* |
0 | 3156 |
* The length of each returned chunk is as close to the specified length goal as possible, |
3157 |
* with the caveat that each chunk includes its trailing delimiter. |
|
3158 |
* Chunks longer than the goal are guaranteed to not have any inner whitespace. |
|
3159 |
* |
|
3160 |
* Joining the returned chunks with empty delimiters reconstructs the input string losslessly. |
|
3161 |
* |
|
3162 |
* Input string must have no null characters (or eventual transformations on output chunks must not care about null characters) |
|
3163 |
* |
|
5 | 3164 |
* _split_str_by_whitespace( "1234 67890 1234 67890a cd 1234 890 123456789 1234567890a 45678 1 3 5 7 90 ", 10 ) == |
3165 |
* array ( |
|
16 | 3166 |
* 0 => '1234 67890 ', // 11 characters: Perfect split. |
3167 |
* 1 => '1234 ', // 5 characters: '1234 67890a' was too long. |
|
3168 |
* 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long. |
|
3169 |
* 3 => '1234 890 ', // 11 characters: Perfect split. |
|
3170 |
* 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long. |
|
3171 |
* 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split. |
|
3172 |
* 6 => ' 45678 ', // 11 characters: Perfect split. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3173 |
* 7 => '1 3 5 7 90 ', // 11 characters: End of $text. |
5 | 3174 |
* ); |
0 | 3175 |
* |
3176 |
* @since 3.4.0 |
|
3177 |
* @access private |
|
3178 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3179 |
* @param string $text The string to split. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3180 |
* @param int $goal The desired chunk length. |
0 | 3181 |
* @return array Numeric array of chunks. |
3182 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3183 |
function _split_str_by_whitespace( $text, $goal ) { |
0 | 3184 |
$chunks = array(); |
3185 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3186 |
$string_nullspace = strtr( $text, "\r\n\t\v\f ", "\000\000\000\000\000\000" ); |
0 | 3187 |
|
3188 |
while ( $goal < strlen( $string_nullspace ) ) { |
|
3189 |
$pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" ); |
|
3190 |
||
3191 |
if ( false === $pos ) { |
|
3192 |
$pos = strpos( $string_nullspace, "\000", $goal + 1 ); |
|
3193 |
if ( false === $pos ) { |
|
3194 |
break; |
|
3195 |
} |
|
3196 |
} |
|
3197 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3198 |
$chunks[] = substr( $text, 0, $pos + 1 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3199 |
$text = substr( $text, $pos + 1 ); |
0 | 3200 |
$string_nullspace = substr( $string_nullspace, $pos + 1 ); |
3201 |
} |
|
3202 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3203 |
if ( $text ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3204 |
$chunks[] = $text; |
0 | 3205 |
} |
3206 |
||
3207 |
return $chunks; |
|
3208 |
} |
|
3209 |
||
3210 |
/** |
|
16 | 3211 |
* Callback to add a rel attribute to HTML A element. |
3212 |
* |
|
3213 |
* Will remove already existing string before adding to prevent invalidating (X)HTML. |
|
3214 |
* |
|
3215 |
* @since 5.3.0 |
|
3216 |
* |
|
3217 |
* @param array $matches Single match. |
|
3218 |
* @param string $rel The rel attribute to add. |
|
3219 |
* @return string HTML A element with the added rel attribute. |
|
0 | 3220 |
*/ |
16 | 3221 |
function wp_rel_callback( $matches, $rel ) { |
0 | 3222 |
$text = $matches[1]; |
9 | 3223 |
$atts = wp_kses_hair( $matches[1], wp_allowed_protocols() ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3224 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3225 |
if ( ! empty( $atts['href'] ) && wp_is_internal_link( $atts['href']['value'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3226 |
$rel = trim( str_replace( 'nofollow', '', $rel ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3227 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3228 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3229 |
if ( ! empty( $atts['rel'] ) ) { |
16 | 3230 |
$parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) ); |
3231 |
$rel_array = array_map( 'trim', explode( ' ', $rel ) ); |
|
3232 |
$parts = array_unique( array_merge( $parts, $rel_array ) ); |
|
3233 |
$rel = implode( ' ', $parts ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3234 |
unset( $atts['rel'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3235 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3236 |
$html = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3237 |
foreach ( $atts as $name => $value ) { |
9 | 3238 |
if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) { |
3239 |
$html .= $name . ' '; |
|
3240 |
} else { |
|
3241 |
$html .= "{$name}=\"" . esc_attr( $value['value'] ) . '" '; |
|
3242 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3243 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3244 |
$text = trim( $html ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3245 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3246 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3247 |
$rel_attr = $rel ? ' rel="' . esc_attr( $rel ) . '"' : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3248 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3249 |
return "<a {$text}{$rel_attr}>"; |
9 | 3250 |
} |
3251 |
||
3252 |
/** |
|
16 | 3253 |
* Adds `rel="nofollow"` string to all HTML A elements in content. |
3254 |
* |
|
3255 |
* @since 1.5.0 |
|
3256 |
* |
|
3257 |
* @param string $text Content that may contain HTML A elements. |
|
3258 |
* @return string Converted content. |
|
3259 |
*/ |
|
3260 |
function wp_rel_nofollow( $text ) { |
|
3261 |
// This is a pre-save filter, so text is already escaped. |
|
3262 |
$text = stripslashes( $text ); |
|
3263 |
$text = preg_replace_callback( |
|
3264 |
'|<a (.+?)>|i', |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3265 |
static function ( $matches ) { |
16 | 3266 |
return wp_rel_callback( $matches, 'nofollow' ); |
3267 |
}, |
|
3268 |
$text |
|
3269 |
); |
|
3270 |
return wp_slash( $text ); |
|
3271 |
} |
|
3272 |
||
3273 |
/** |
|
3274 |
* Callback to add `rel="nofollow"` string to HTML A element. |
|
3275 |
* |
|
3276 |
* @since 2.3.0 |
|
3277 |
* @deprecated 5.3.0 Use wp_rel_callback() |
|
3278 |
* |
|
3279 |
* @param array $matches Single match. |
|
3280 |
* @return string HTML A Element with `rel="nofollow"`. |
|
3281 |
*/ |
|
3282 |
function wp_rel_nofollow_callback( $matches ) { |
|
3283 |
return wp_rel_callback( $matches, 'nofollow' ); |
|
3284 |
} |
|
3285 |
||
3286 |
/** |
|
3287 |
* Adds `rel="nofollow ugc"` string to all HTML A elements in content. |
|
3288 |
* |
|
3289 |
* @since 5.3.0 |
|
3290 |
* |
|
3291 |
* @param string $text Content that may contain HTML A elements. |
|
3292 |
* @return string Converted content. |
|
3293 |
*/ |
|
3294 |
function wp_rel_ugc( $text ) { |
|
3295 |
// This is a pre-save filter, so text is already escaped. |
|
3296 |
$text = stripslashes( $text ); |
|
3297 |
$text = preg_replace_callback( |
|
3298 |
'|<a (.+?)>|i', |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3299 |
static function ( $matches ) { |
16 | 3300 |
return wp_rel_callback( $matches, 'nofollow ugc' ); |
3301 |
}, |
|
3302 |
$text |
|
3303 |
); |
|
3304 |
return wp_slash( $text ); |
|
3305 |
} |
|
3306 |
||
3307 |
/** |
|
18 | 3308 |
* Adds `rel="noopener"` to all HTML A elements that have a target. |
9 | 3309 |
* |
3310 |
* @since 5.1.0 |
|
18 | 3311 |
* @since 5.6.0 Removed 'noreferrer' relationship. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3312 |
* @deprecated 6.7.0 |
9 | 3313 |
* |
3314 |
* @param string $text Content that may contain HTML A elements. |
|
3315 |
* @return string Converted content. |
|
3316 |
*/ |
|
3317 |
function wp_targeted_link_rel( $text ) { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3318 |
_deprecated_function( __FUNCTION__, '6.7.0' ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3319 |
|
9 | 3320 |
// Don't run (more expensive) regex if no links with targets. |
16 | 3321 |
if ( stripos( $text, 'target' ) === false || stripos( $text, '<a ' ) === false || is_serialized( $text ) ) { |
3322 |
return $text; |
|
3323 |
} |
|
3324 |
||
3325 |
$script_and_style_regex = '/<(script|style).*?<\/\\1>/si'; |
|
3326 |
||
3327 |
preg_match_all( $script_and_style_regex, $text, $matches ); |
|
3328 |
$extra_parts = $matches[0]; |
|
3329 |
$html_parts = preg_split( $script_and_style_regex, $text ); |
|
3330 |
||
3331 |
foreach ( $html_parts as &$part ) { |
|
3332 |
$part = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $part ); |
|
3333 |
} |
|
3334 |
||
3335 |
$text = ''; |
|
3336 |
for ( $i = 0; $i < count( $html_parts ); $i++ ) { |
|
3337 |
$text .= $html_parts[ $i ]; |
|
3338 |
if ( isset( $extra_parts[ $i ] ) ) { |
|
3339 |
$text .= $extra_parts[ $i ]; |
|
3340 |
} |
|
9 | 3341 |
} |
3342 |
||
3343 |
return $text; |
|
3344 |
} |
|
3345 |
||
3346 |
/** |
|
18 | 3347 |
* Callback to add `rel="noopener"` string to HTML A element. |
3348 |
* |
|
3349 |
* Will not duplicate an existing 'noopener' value to avoid invalidating the HTML. |
|
9 | 3350 |
* |
3351 |
* @since 5.1.0 |
|
18 | 3352 |
* @since 5.6.0 Removed 'noreferrer' relationship. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3353 |
* @deprecated 6.7.0 |
18 | 3354 |
* |
3355 |
* @param array $matches Single match. |
|
3356 |
* @return string HTML A Element with `rel="noopener"` in addition to any existing values. |
|
9 | 3357 |
*/ |
3358 |
function wp_targeted_link_rel_callback( $matches ) { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3359 |
_deprecated_function( __FUNCTION__, '6.7.0' ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3360 |
|
16 | 3361 |
$link_html = $matches[1]; |
3362 |
$original_link_html = $link_html; |
|
3363 |
||
3364 |
// Consider the HTML escaped if there are no unescaped quotes. |
|
3365 |
$is_escaped = ! preg_match( '/(^|[^\\\\])[\'"]/', $link_html ); |
|
3366 |
if ( $is_escaped ) { |
|
3367 |
// Replace only the quotes so that they are parsable by wp_kses_hair(), leave the rest as is. |
|
3368 |
$link_html = preg_replace( '/\\\\([\'"])/', '$1', $link_html ); |
|
3369 |
} |
|
3370 |
||
3371 |
$atts = wp_kses_hair( $link_html, wp_allowed_protocols() ); |
|
9 | 3372 |
|
3373 |
/** |
|
3374 |
* Filters the rel values that are added to links with `target` attribute. |
|
3375 |
* |
|
3376 |
* @since 5.1.0 |
|
3377 |
* |
|
16 | 3378 |
* @param string $rel The rel values. |
9 | 3379 |
* @param string $link_html The matched content of the link tag including all HTML attributes. |
3380 |
*/ |
|
18 | 3381 |
$rel = apply_filters( 'wp_targeted_link_rel', 'noopener', $link_html ); |
9 | 3382 |
|
16 | 3383 |
// Return early if no rel values to be added or if no actual target attribute. |
3384 |
if ( ! $rel || ! isset( $atts['target'] ) ) { |
|
3385 |
return "<a $original_link_html>"; |
|
3386 |
} |
|
3387 |
||
3388 |
if ( isset( $atts['rel'] ) ) { |
|
3389 |
$all_parts = preg_split( '/\s/', "{$atts['rel']['value']} $rel", -1, PREG_SPLIT_NO_EMPTY ); |
|
3390 |
$rel = implode( ' ', array_unique( $all_parts ) ); |
|
3391 |
} |
|
3392 |
||
3393 |
$atts['rel']['whole'] = 'rel="' . esc_attr( $rel ) . '"'; |
|
18 | 3394 |
$link_html = implode( ' ', array_column( $atts, 'whole' ) ); |
16 | 3395 |
|
3396 |
if ( $is_escaped ) { |
|
3397 |
$link_html = preg_replace( '/[\'"]/', '\\\\$0', $link_html ); |
|
9 | 3398 |
} |
3399 |
||
3400 |
return "<a $link_html>"; |
|
3401 |
} |
|
3402 |
||
3403 |
/** |
|
3404 |
* Adds all filters modifying the rel attribute of targeted links. |
|
3405 |
* |
|
3406 |
* @since 5.1.0 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3407 |
* @deprecated 6.7.0 |
9 | 3408 |
*/ |
3409 |
function wp_init_targeted_link_rel_filters() { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3410 |
_deprecated_function( __FUNCTION__, '6.7.0' ); |
9 | 3411 |
} |
3412 |
||
3413 |
/** |
|
3414 |
* Removes all filters modifying the rel attribute of targeted links. |
|
3415 |
* |
|
3416 |
* @since 5.1.0 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3417 |
* @deprecated 6.7.0 |
9 | 3418 |
*/ |
3419 |
function wp_remove_targeted_link_rel_filters() { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3420 |
_deprecated_function( __FUNCTION__, '6.7.0' ); |
0 | 3421 |
} |
3422 |
||
3423 |
/** |
|
19 | 3424 |
* Converts one smiley code to the icon graphic file equivalent. |
0 | 3425 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3426 |
* Callback handler for convert_smilies(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3427 |
* |
0 | 3428 |
* Looks up one smiley code in the $wpsmiliestrans global array and returns an |
5 | 3429 |
* `<img>` string for that smiley. |
0 | 3430 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3431 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3432 |
* |
0 | 3433 |
* @global array $wpsmiliestrans |
3434 |
* |
|
3435 |
* @param array $matches Single match. Smiley code to convert to image. |
|
3436 |
* @return string Image string for smiley. |
|
3437 |
*/ |
|
3438 |
function translate_smiley( $matches ) { |
|
3439 |
global $wpsmiliestrans; |
|
3440 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3441 |
if ( count( $matches ) === 0 ) { |
0 | 3442 |
return ''; |
9 | 3443 |
} |
0 | 3444 |
|
3445 |
$smiley = trim( reset( $matches ) ); |
|
9 | 3446 |
$img = $wpsmiliestrans[ $smiley ]; |
3447 |
||
3448 |
$matches = array(); |
|
3449 |
$ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3450 |
$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp', 'avif' ); |
5 | 3451 |
|
3452 |
// Don't convert smilies that aren't images - they're probably emoji. |
|
16 | 3453 |
if ( ! in_array( $ext, $image_exts, true ) ) { |
5 | 3454 |
return $img; |
3455 |
} |
|
3456 |
||
3457 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3458 |
* Filters the Smiley image URL before it's used in the image element. |
5 | 3459 |
* |
3460 |
* @since 2.9.0 |
|
3461 |
* |
|
3462 |
* @param string $smiley_url URL for the smiley image. |
|
3463 |
* @param string $img Filename for the smiley image. |
|
3464 |
* @param string $site_url Site URL, as returned by site_url(). |
|
3465 |
*/ |
|
0 | 3466 |
$src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() ); |
3467 |
||
5 | 3468 |
return sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', esc_url( $src_url ), esc_attr( $smiley ) ); |
0 | 3469 |
} |
3470 |
||
3471 |
/** |
|
19 | 3472 |
* Converts text equivalent of smilies to images. |
0 | 3473 |
* |
3474 |
* Will only convert smilies if the option 'use_smilies' is true and the global |
|
3475 |
* used in the function isn't empty. |
|
3476 |
* |
|
3477 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3478 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3479 |
* @global string|array $wp_smiliessearch |
0 | 3480 |
* |
3481 |
* @param string $text Content to convert smilies from text. |
|
3482 |
* @return string Converted content with text smilies replaced with images. |
|
3483 |
*/ |
|
5 | 3484 |
function convert_smilies( $text ) { |
0 | 3485 |
global $wp_smiliessearch; |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3486 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3487 |
if ( ! get_option( 'use_smilies' ) || empty( $wp_smiliessearch ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3488 |
// Return default text. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3489 |
return $text; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3490 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3491 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3492 |
// HTML loop taken from texturize function, could possible be consolidated. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3493 |
$textarr = preg_split( '/(<[^>]*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Capture the tags as well as in between. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3494 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3495 |
if ( false === $textarr ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3496 |
// Return default text. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3497 |
return $text; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3498 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3499 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3500 |
// Loop stuff. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3501 |
$stop = count( $textarr ); |
0 | 3502 |
$output = ''; |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3503 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3504 |
// Ignore processing of specific tags. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3505 |
$tags_to_ignore = 'code|pre|style|script|textarea'; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3506 |
$ignore_block_element = ''; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3507 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3508 |
for ( $i = 0; $i < $stop; $i++ ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3509 |
$content = $textarr[ $i ]; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3510 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3511 |
// If we're in an ignore block, wait until we find its closing tag. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3512 |
if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3513 |
$ignore_block_element = $matches[1]; |
0 | 3514 |
} |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3515 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3516 |
// If it's not a tag and not in ignore block. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3517 |
if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3518 |
$content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3519 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3520 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3521 |
// Did we exit ignore block? |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3522 |
if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3523 |
$ignore_block_element = ''; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3524 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3525 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3526 |
$output .= $content; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3527 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3528 |
|
0 | 3529 |
return $output; |
3530 |
} |
|
3531 |
||
3532 |
/** |
|
3533 |
* Verifies that an email is valid. |
|
3534 |
* |
|
3535 |
* Does not grok i18n domains. Not RFC compliant. |
|
3536 |
* |
|
3537 |
* @since 0.71 |
|
3538 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3539 |
* @param string $email Email address to verify. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3540 |
* @param bool $deprecated Deprecated. |
16 | 3541 |
* @return string|false Valid email address on success, false on failure. |
0 | 3542 |
*/ |
3543 |
function is_email( $email, $deprecated = false ) { |
|
9 | 3544 |
if ( ! empty( $deprecated ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3545 |
_deprecated_argument( __FUNCTION__, '3.0.0' ); |
9 | 3546 |
} |
0 | 3547 |
|
16 | 3548 |
// Test for the minimum length the email can be. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3549 |
if ( strlen( $email ) < 6 ) { |
5 | 3550 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3551 |
* Filters whether an email address is valid. |
5 | 3552 |
* |
3553 |
* This filter is evaluated under several different contexts, such as 'email_too_short', |
|
3554 |
* 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
|
3555 |
* 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context. |
|
3556 |
* |
|
3557 |
* @since 2.8.0 |
|
3558 |
* |
|
16 | 3559 |
* @param string|false $is_email The email address if successfully passed the is_email() checks, false otherwise. |
3560 |
* @param string $email The email address being checked. |
|
3561 |
* @param string $context Context under which the email was tested. |
|
5 | 3562 |
*/ |
0 | 3563 |
return apply_filters( 'is_email', false, $email, 'email_too_short' ); |
3564 |
} |
|
3565 |
||
16 | 3566 |
// Test for an @ character after the first position. |
0 | 3567 |
if ( strpos( $email, '@', 1 ) === false ) { |
5 | 3568 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3569 |
return apply_filters( 'is_email', false, $email, 'email_no_at' ); |
3570 |
} |
|
3571 |
||
16 | 3572 |
// Split out the local and domain parts. |
0 | 3573 |
list( $local, $domain ) = explode( '@', $email, 2 ); |
3574 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3575 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3576 |
* LOCAL PART |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3577 |
* Test for invalid characters. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3578 |
*/ |
9 | 3579 |
if ( ! preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { |
5 | 3580 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3581 |
return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); |
3582 |
} |
|
3583 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3584 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3585 |
* DOMAIN PART |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3586 |
* Test for sequences of periods. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3587 |
*/ |
0 | 3588 |
if ( preg_match( '/\.{2,}/', $domain ) ) { |
5 | 3589 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3590 |
return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); |
3591 |
} |
|
3592 |
||
16 | 3593 |
// Test for leading and trailing periods and whitespace. |
0 | 3594 |
if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { |
5 | 3595 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3596 |
return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); |
3597 |
} |
|
3598 |
||
16 | 3599 |
// Split the domain into subs. |
0 | 3600 |
$subs = explode( '.', $domain ); |
3601 |
||
16 | 3602 |
// Assume the domain will have at least two subs. |
0 | 3603 |
if ( 2 > count( $subs ) ) { |
5 | 3604 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3605 |
return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); |
3606 |
} |
|
3607 |
||
16 | 3608 |
// Loop through each sub. |
0 | 3609 |
foreach ( $subs as $sub ) { |
16 | 3610 |
// Test for leading and trailing hyphens and whitespace. |
0 | 3611 |
if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { |
5 | 3612 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3613 |
return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); |
3614 |
} |
|
3615 |
||
16 | 3616 |
// Test for invalid characters. |
9 | 3617 |
if ( ! preg_match( '/^[a-z0-9-]+$/i', $sub ) ) { |
5 | 3618 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3619 |
return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); |
3620 |
} |
|
3621 |
} |
|
3622 |
||
16 | 3623 |
// Congratulations, your email made it! |
5 | 3624 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3625 |
return apply_filters( 'is_email', $email, $email, null ); |
3626 |
} |
|
3627 |
||
3628 |
/** |
|
19 | 3629 |
* Converts to ASCII from email subjects. |
0 | 3630 |
* |
3631 |
* @since 1.2.0 |
|
3632 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3633 |
* @param string $subject Subject line. |
19 | 3634 |
* @return string Converted string to ASCII. |
0 | 3635 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3636 |
function wp_iso_descrambler( $subject ) { |
0 | 3637 |
/* this may only work with iso-8859-1, I'm afraid */ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3638 |
if ( ! preg_match( '#\=\?(.+)\?Q\?(.+)\?\=#i', $subject, $matches ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3639 |
return $subject; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3640 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3641 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3642 |
$subject = str_replace( '_', ' ', $matches[2] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3643 |
return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject ); |
0 | 3644 |
} |
3645 |
||
3646 |
/** |
|
19 | 3647 |
* Helper function to convert hex encoded chars to ASCII. |
0 | 3648 |
* |
3649 |
* @since 3.1.0 |
|
3650 |
* @access private |
|
3651 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3652 |
* @param array $matches The preg_replace_callback matches array. |
19 | 3653 |
* @return string Converted chars. |
0 | 3654 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3655 |
function _wp_iso_convert( $matches ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3656 |
return chr( hexdec( strtolower( $matches[1] ) ) ); |
0 | 3657 |
} |
3658 |
||
3659 |
/** |
|
16 | 3660 |
* Given a date in the timezone of the site, returns that date in UTC. |
3661 |
* |
|
3662 |
* Requires and returns a date in the Y-m-d H:i:s format. |
|
3663 |
* Return format can be overridden using the $format parameter. |
|
0 | 3664 |
* |
3665 |
* @since 1.2.0 |
|
3666 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3667 |
* @param string $date_string The date to be converted, in the timezone of the site. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3668 |
* @param string $format The format string for the returned date. Default 'Y-m-d H:i:s'. |
16 | 3669 |
* @return string Formatted version of the date, in UTC. |
0 | 3670 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3671 |
function get_gmt_from_date( $date_string, $format = 'Y-m-d H:i:s' ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3672 |
$datetime = date_create( $date_string, wp_timezone() ); |
16 | 3673 |
|
3674 |
if ( false === $datetime ) { |
|
3675 |
return gmdate( $format, 0 ); |
|
3676 |
} |
|
3677 |
||
3678 |
return $datetime->setTimezone( new DateTimeZone( 'UTC' ) )->format( $format ); |
|
0 | 3679 |
} |
3680 |
||
3681 |
/** |
|
16 | 3682 |
* Given a date in UTC or GMT timezone, returns that date in the timezone of the site. |
3683 |
* |
|
19 | 3684 |
* Requires a date in the Y-m-d H:i:s format. |
3685 |
* Default return format of 'Y-m-d H:i:s' can be overridden using the `$format` parameter. |
|
0 | 3686 |
* |
3687 |
* @since 1.2.0 |
|
3688 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3689 |
* @param string $date_string The date to be converted, in UTC or GMT timezone. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3690 |
* @param string $format The format string for the returned date. Default 'Y-m-d H:i:s'. |
16 | 3691 |
* @return string Formatted version of the date, in the site's timezone. |
0 | 3692 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3693 |
function get_date_from_gmt( $date_string, $format = 'Y-m-d H:i:s' ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3694 |
$datetime = date_create( $date_string, new DateTimeZone( 'UTC' ) ); |
16 | 3695 |
|
3696 |
if ( false === $datetime ) { |
|
3697 |
return gmdate( $format, 0 ); |
|
3698 |
} |
|
3699 |
||
3700 |
return $datetime->setTimezone( wp_timezone() )->format( $format ); |
|
0 | 3701 |
} |
3702 |
||
3703 |
/** |
|
16 | 3704 |
* Given an ISO 8601 timezone, returns its UTC offset in seconds. |
0 | 3705 |
* |
3706 |
* @since 1.5.0 |
|
3707 |
* |
|
3708 |
* @param string $timezone Either 'Z' for 0 offset or '±hhmm'. |
|
3709 |
* @return int|float The offset in seconds. |
|
3710 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3711 |
function iso8601_timezone_to_offset( $timezone ) { |
16 | 3712 |
// $timezone is either 'Z' or '[+|-]hhmm'. |
3713 |
if ( 'Z' === $timezone ) { |
|
0 | 3714 |
$offset = 0; |
3715 |
} else { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3716 |
$sign = ( str_starts_with( $timezone, '+' ) ) ? 1 : -1; |
18 | 3717 |
$hours = (int) substr( $timezone, 1, 2 ); |
3718 |
$minutes = (int) substr( $timezone, 3, 4 ) / 60; |
|
9 | 3719 |
$offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes ); |
0 | 3720 |
} |
3721 |
return $offset; |
|
3722 |
} |
|
3723 |
||
3724 |
/** |
|
16 | 3725 |
* Given an ISO 8601 (Ymd\TH:i:sO) date, returns a MySQL DateTime (Y-m-d H:i:s) format used by post_date[_gmt]. |
0 | 3726 |
* |
3727 |
* @since 1.5.0 |
|
3728 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3729 |
* @param string $date_string Date and time in ISO 8601 format {@link https://en.wikipedia.org/wiki/ISO_8601}. |
16 | 3730 |
* @param string $timezone Optional. If set to 'gmt' returns the result in UTC. Default 'user'. |
18 | 3731 |
* @return string|false The date and time in MySQL DateTime format - Y-m-d H:i:s, or false on failure. |
0 | 3732 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3733 |
function iso8601_to_datetime( $date_string, $timezone = 'user' ) { |
16 | 3734 |
$timezone = strtolower( $timezone ); |
3735 |
$wp_timezone = wp_timezone(); |
|
3736 |
$datetime = date_create( $date_string, $wp_timezone ); // Timezone is ignored if input has one. |
|
3737 |
||
3738 |
if ( false === $datetime ) { |
|
3739 |
return false; |
|
3740 |
} |
|
3741 |
||
3742 |
if ( 'gmt' === $timezone ) { |
|
3743 |
return $datetime->setTimezone( new DateTimeZone( 'UTC' ) )->format( 'Y-m-d H:i:s' ); |
|
3744 |
} |
|
3745 |
||
3746 |
if ( 'user' === $timezone ) { |
|
3747 |
return $datetime->setTimezone( $wp_timezone )->format( 'Y-m-d H:i:s' ); |
|
3748 |
} |
|
3749 |
||
3750 |
return false; |
|
0 | 3751 |
} |
3752 |
||
3753 |
/** |
|
3754 |
* Strips out all characters that are not allowable in an email. |
|
3755 |
* |
|
3756 |
* @since 1.5.0 |
|
3757 |
* |
|
3758 |
* @param string $email Email address to filter. |
|
3759 |
* @return string Filtered email address. |
|
3760 |
*/ |
|
3761 |
function sanitize_email( $email ) { |
|
16 | 3762 |
// Test for the minimum length the email can be. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3763 |
if ( strlen( $email ) < 6 ) { |
5 | 3764 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3765 |
* Filters a sanitized email address. |
5 | 3766 |
* |
3767 |
* This filter is evaluated under several contexts, including 'email_too_short', |
|
3768 |
* 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', |
|
3769 |
* 'domain_no_periods', 'domain_no_valid_subs', or no context. |
|
3770 |
* |
|
3771 |
* @since 2.8.0 |
|
3772 |
* |
|
9 | 3773 |
* @param string $sanitized_email The sanitized email address. |
3774 |
* @param string $email The email address, as provided to sanitize_email(). |
|
3775 |
* @param string|null $message A message to pass to the user. null if email is sanitized. |
|
5 | 3776 |
*/ |
0 | 3777 |
return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); |
3778 |
} |
|
3779 |
||
16 | 3780 |
// Test for an @ character after the first position. |
0 | 3781 |
if ( strpos( $email, '@', 1 ) === false ) { |
5 | 3782 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3783 |
return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); |
3784 |
} |
|
3785 |
||
16 | 3786 |
// Split out the local and domain parts. |
0 | 3787 |
list( $local, $domain ) = explode( '@', $email, 2 ); |
3788 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3789 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3790 |
* LOCAL PART |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3791 |
* Test for invalid characters. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3792 |
*/ |
0 | 3793 |
$local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); |
3794 |
if ( '' === $local ) { |
|
5 | 3795 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3796 |
return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' ); |
3797 |
} |
|
3798 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3799 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3800 |
* DOMAIN PART |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3801 |
* Test for sequences of periods. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3802 |
*/ |
0 | 3803 |
$domain = preg_replace( '/\.{2,}/', '', $domain ); |
3804 |
if ( '' === $domain ) { |
|
5 | 3805 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3806 |
return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); |
3807 |
} |
|
3808 |
||
16 | 3809 |
// Test for leading and trailing periods and whitespace. |
0 | 3810 |
$domain = trim( $domain, " \t\n\r\0\x0B." ); |
3811 |
if ( '' === $domain ) { |
|
5 | 3812 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3813 |
return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); |
3814 |
} |
|
3815 |
||
16 | 3816 |
// Split the domain into subs. |
0 | 3817 |
$subs = explode( '.', $domain ); |
3818 |
||
16 | 3819 |
// Assume the domain will have at least two subs. |
0 | 3820 |
if ( 2 > count( $subs ) ) { |
5 | 3821 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3822 |
return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); |
3823 |
} |
|
3824 |
||
16 | 3825 |
// Create an array that will contain valid subs. |
0 | 3826 |
$new_subs = array(); |
3827 |
||
16 | 3828 |
// Loop through each sub. |
0 | 3829 |
foreach ( $subs as $sub ) { |
16 | 3830 |
// Test for leading and trailing hyphens. |
0 | 3831 |
$sub = trim( $sub, " \t\n\r\0\x0B-" ); |
3832 |
||
16 | 3833 |
// Test for invalid characters. |
0 | 3834 |
$sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub ); |
3835 |
||
16 | 3836 |
// If there's anything left, add it to the valid subs. |
0 | 3837 |
if ( '' !== $sub ) { |
3838 |
$new_subs[] = $sub; |
|
3839 |
} |
|
3840 |
} |
|
3841 |
||
16 | 3842 |
// If there aren't 2 or more valid subs. |
0 | 3843 |
if ( 2 > count( $new_subs ) ) { |
5 | 3844 |
/** This filter is documented in wp-includes/formatting.php */ |
0 | 3845 |
return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); |
3846 |
} |
|
3847 |
||
16 | 3848 |
// Join valid subs into the new domain. |
18 | 3849 |
$domain = implode( '.', $new_subs ); |
0 | 3850 |
|
16 | 3851 |
// Put the email back together. |
9 | 3852 |
$sanitized_email = $local . '@' . $domain; |
0 | 3853 |
|
16 | 3854 |
// Congratulations, your email made it! |
5 | 3855 |
/** This filter is documented in wp-includes/formatting.php */ |
9 | 3856 |
return apply_filters( 'sanitize_email', $sanitized_email, $email, null ); |
0 | 3857 |
} |
3858 |
||
3859 |
/** |
|
3860 |
* Determines the difference between two timestamps. |
|
3861 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3862 |
* The difference is returned in a human-readable format such as "1 hour", |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3863 |
* "5 minutes", "2 days". |
0 | 3864 |
* |
3865 |
* @since 1.5.0 |
|
16 | 3866 |
* @since 5.3.0 Added support for showing a difference in seconds. |
0 | 3867 |
* |
3868 |
* @param int $from Unix timestamp from which the difference begins. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3869 |
* @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3870 |
* @return string Human-readable time difference. |
0 | 3871 |
*/ |
16 | 3872 |
function human_time_diff( $from, $to = 0 ) { |
5 | 3873 |
if ( empty( $to ) ) { |
0 | 3874 |
$to = time(); |
5 | 3875 |
} |
0 | 3876 |
|
3877 |
$diff = (int) abs( $to - $from ); |
|
3878 |
||
16 | 3879 |
if ( $diff < MINUTE_IN_SECONDS ) { |
3880 |
$secs = $diff; |
|
3881 |
if ( $secs <= 1 ) { |
|
3882 |
$secs = 1; |
|
3883 |
} |
|
3884 |
/* translators: Time difference between two dates, in seconds. %s: Number of seconds. */ |
|
3885 |
$since = sprintf( _n( '%s second', '%s seconds', $secs ), $secs ); |
|
3886 |
} elseif ( $diff < HOUR_IN_SECONDS && $diff >= MINUTE_IN_SECONDS ) { |
|
0 | 3887 |
$mins = round( $diff / MINUTE_IN_SECONDS ); |
9 | 3888 |
if ( $mins <= 1 ) { |
0 | 3889 |
$mins = 1; |
9 | 3890 |
} |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3891 |
/* translators: Time difference between two dates, in minutes. %s: Number of minutes. */ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3892 |
$since = sprintf( _n( '%s minute', '%s minutes', $mins ), $mins ); |
0 | 3893 |
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) { |
3894 |
$hours = round( $diff / HOUR_IN_SECONDS ); |
|
9 | 3895 |
if ( $hours <= 1 ) { |
0 | 3896 |
$hours = 1; |
9 | 3897 |
} |
16 | 3898 |
/* translators: Time difference between two dates, in hours. %s: Number of hours. */ |
0 | 3899 |
$since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours ); |
3900 |
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) { |
|
3901 |
$days = round( $diff / DAY_IN_SECONDS ); |
|
9 | 3902 |
if ( $days <= 1 ) { |
0 | 3903 |
$days = 1; |
9 | 3904 |
} |
16 | 3905 |
/* translators: Time difference between two dates, in days. %s: Number of days. */ |
0 | 3906 |
$since = sprintf( _n( '%s day', '%s days', $days ), $days ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3907 |
} elseif ( $diff < MONTH_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) { |
0 | 3908 |
$weeks = round( $diff / WEEK_IN_SECONDS ); |
9 | 3909 |
if ( $weeks <= 1 ) { |
0 | 3910 |
$weeks = 1; |
9 | 3911 |
} |
16 | 3912 |
/* translators: Time difference between two dates, in weeks. %s: Number of weeks. */ |
0 | 3913 |
$since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3914 |
} elseif ( $diff < YEAR_IN_SECONDS && $diff >= MONTH_IN_SECONDS ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3915 |
$months = round( $diff / MONTH_IN_SECONDS ); |
9 | 3916 |
if ( $months <= 1 ) { |
0 | 3917 |
$months = 1; |
9 | 3918 |
} |
16 | 3919 |
/* translators: Time difference between two dates, in months. %s: Number of months. */ |
0 | 3920 |
$since = sprintf( _n( '%s month', '%s months', $months ), $months ); |
3921 |
} elseif ( $diff >= YEAR_IN_SECONDS ) { |
|
3922 |
$years = round( $diff / YEAR_IN_SECONDS ); |
|
9 | 3923 |
if ( $years <= 1 ) { |
0 | 3924 |
$years = 1; |
9 | 3925 |
} |
16 | 3926 |
/* translators: Time difference between two dates, in years. %s: Number of years. */ |
0 | 3927 |
$since = sprintf( _n( '%s year', '%s years', $years ), $years ); |
3928 |
} |
|
3929 |
||
5 | 3930 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3931 |
* Filters the human-readable difference between two timestamps. |
5 | 3932 |
* |
3933 |
* @since 4.0.0 |
|
3934 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3935 |
* @param string $since The difference in human-readable text. |
5 | 3936 |
* @param int $diff The difference in seconds. |
3937 |
* @param int $from Unix timestamp from which the difference begins. |
|
3938 |
* @param int $to Unix timestamp to end the time difference. |
|
3939 |
*/ |
|
3940 |
return apply_filters( 'human_time_diff', $since, $diff, $from, $to ); |
|
0 | 3941 |
} |
3942 |
||
3943 |
/** |
|
3944 |
* Generates an excerpt from the content, if needed. |
|
3945 |
* |
|
16 | 3946 |
* Returns a maximum of 55 words with an ellipsis appended if necessary. |
0 | 3947 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3948 |
* The 55-word limit can be modified by plugins/themes using the {@see 'excerpt_length'} filter |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3949 |
* The ' […]' string can be modified by plugins/themes using the {@see 'excerpt_more'} filter |
0 | 3950 |
* |
3951 |
* @since 1.5.0 |
|
9 | 3952 |
* @since 5.2.0 Added the `$post` parameter. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3953 |
* @since 6.3.0 Removes footnotes markup from the excerpt content. |
9 | 3954 |
* |
3955 |
* @param string $text Optional. The excerpt. If set to empty, an excerpt is generated. |
|
16 | 3956 |
* @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default null. |
0 | 3957 |
* @return string The excerpt. |
3958 |
*/ |
|
9 | 3959 |
function wp_trim_excerpt( $text = '', $post = null ) { |
0 | 3960 |
$raw_excerpt = $text; |
16 | 3961 |
|
3962 |
if ( '' === trim( $text ) ) { |
|
9 | 3963 |
$post = get_post( $post ); |
3964 |
$text = get_the_content( '', false, $post ); |
|
0 | 3965 |
|
3966 |
$text = strip_shortcodes( $text ); |
|
9 | 3967 |
$text = excerpt_remove_blocks( $text ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3968 |
$text = excerpt_remove_footnotes( $text ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3969 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3970 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3971 |
* Temporarily unhook wp_filter_content_tags() since any tags |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3972 |
* within the excerpt are stripped out. Modifying the tags here |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3973 |
* is wasteful and can lead to bugs in the image counting logic. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3974 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3975 |
$filter_image_removed = remove_filter( 'the_content', 'wp_filter_content_tags', 12 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3976 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3977 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3978 |
* Temporarily unhook do_blocks() since excerpt_remove_blocks( $text ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3979 |
* handles block rendering needed for excerpt. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3980 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3981 |
$filter_block_removed = remove_filter( 'the_content', 'do_blocks', 9 ); |
0 | 3982 |
|
5 | 3983 |
/** This filter is documented in wp-includes/post-template.php */ |
3984 |
$text = apply_filters( 'the_content', $text ); |
|
9 | 3985 |
$text = str_replace( ']]>', ']]>', $text ); |
5 | 3986 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3987 |
// Restore the original filter if removed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3988 |
if ( $filter_block_removed ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3989 |
add_filter( 'the_content', 'do_blocks', 9 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3990 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3991 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3992 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3993 |
* Only restore the filter callback if it was removed above. The logic |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3994 |
* to unhook and restore only applies on the default priority of 10, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3995 |
* which is generally used for the filter callback in WordPress core. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3996 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3997 |
if ( $filter_image_removed ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3998 |
add_filter( 'the_content', 'wp_filter_content_tags', 12 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3999 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4000 |
|
16 | 4001 |
/* translators: Maximum number of words used in a post excerpt. */ |
18 | 4002 |
$excerpt_length = (int) _x( '55', 'excerpt_length' ); |
16 | 4003 |
|
5 | 4004 |
/** |
16 | 4005 |
* Filters the maximum number of words in a post excerpt. |
5 | 4006 |
* |
4007 |
* @since 2.7.0 |
|
4008 |
* |
|
16 | 4009 |
* @param int $number The maximum number of words. Default 55. |
5 | 4010 |
*/ |
16 | 4011 |
$excerpt_length = (int) apply_filters( 'excerpt_length', $excerpt_length ); |
4012 |
||
5 | 4013 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4014 |
* Filters the string in the "more" link displayed after a trimmed excerpt. |
5 | 4015 |
* |
4016 |
* @since 2.9.0 |
|
4017 |
* |
|
4018 |
* @param string $more_string The string shown within the more link. |
|
4019 |
*/ |
|
4020 |
$excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' ); |
|
9 | 4021 |
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4022 |
|
0 | 4023 |
} |
16 | 4024 |
|
5 | 4025 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4026 |
* Filters the trimmed excerpt string. |
5 | 4027 |
* |
4028 |
* @since 2.8.0 |
|
4029 |
* |
|
4030 |
* @param string $text The trimmed text. |
|
4031 |
* @param string $raw_excerpt The text prior to trimming. |
|
4032 |
*/ |
|
4033 |
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt ); |
|
0 | 4034 |
} |
4035 |
||
4036 |
/** |
|
4037 |
* Trims text to a certain number of words. |
|
4038 |
* |
|
4039 |
* This function is localized. For languages that count 'words' by the individual |
|
4040 |
* character (such as East Asian languages), the $num_words argument will apply |
|
4041 |
* to the number of individual characters. |
|
4042 |
* |
|
4043 |
* @since 3.3.0 |
|
4044 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4045 |
* @param string $text Text to trim. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4046 |
* @param int $num_words Number of words. Default 55. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4047 |
* @param string $more Optional. What to append if $text needs to be trimmed. Default '…'. |
0 | 4048 |
* @return string Trimmed text. |
4049 |
*/ |
|
4050 |
function wp_trim_words( $text, $num_words = 55, $more = null ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4051 |
if ( null === $more ) { |
0 | 4052 |
$more = __( '…' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4053 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4054 |
|
0 | 4055 |
$original_text = $text; |
9 | 4056 |
$text = wp_strip_all_tags( $text ); |
16 | 4057 |
$num_words = (int) $num_words; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4058 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4059 |
if ( str_starts_with( wp_get_word_count_type(), 'characters' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
0 | 4060 |
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
4061 |
preg_match_all( '/./u', $text, $words_array ); |
|
4062 |
$words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
9 | 4063 |
$sep = ''; |
0 | 4064 |
} else { |
4065 |
$words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
9 | 4066 |
$sep = ' '; |
0 | 4067 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4068 |
|
0 | 4069 |
if ( count( $words_array ) > $num_words ) { |
4070 |
array_pop( $words_array ); |
|
4071 |
$text = implode( $sep, $words_array ); |
|
4072 |
$text = $text . $more; |
|
4073 |
} else { |
|
4074 |
$text = implode( $sep, $words_array ); |
|
4075 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4076 |
|
5 | 4077 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4078 |
* Filters the text content after words have been trimmed. |
5 | 4079 |
* |
4080 |
* @since 3.3.0 |
|
4081 |
* |
|
4082 |
* @param string $text The trimmed text. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4083 |
* @param int $num_words The number of words to trim the text to. Default 55. |
5 | 4084 |
* @param string $more An optional string to append to the end of the trimmed text, e.g. …. |
4085 |
* @param string $original_text The text before it was trimmed. |
|
4086 |
*/ |
|
0 | 4087 |
return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
4088 |
} |
|
4089 |
||
4090 |
/** |
|
4091 |
* Converts named entities into numbered entities. |
|
4092 |
* |
|
4093 |
* @since 1.5.1 |
|
4094 |
* |
|
4095 |
* @param string $text The text within which entities will be converted. |
|
4096 |
* @return string Text with converted entities. |
|
4097 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4098 |
function ent2ncr( $text ) { |
0 | 4099 |
|
5 | 4100 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4101 |
* Filters text before named entities are converted into numbered entities. |
5 | 4102 |
* |
4103 |
* A non-null string must be returned for the filter to be evaluated. |
|
4104 |
* |
|
4105 |
* @since 3.3.0 |
|
4106 |
* |
|
16 | 4107 |
* @param string|null $converted_text The text to be converted. Default null. |
4108 |
* @param string $text The text prior to entity conversion. |
|
5 | 4109 |
*/ |
0 | 4110 |
$filtered = apply_filters( 'pre_ent2ncr', null, $text ); |
9 | 4111 |
if ( null !== $filtered ) { |
0 | 4112 |
return $filtered; |
9 | 4113 |
} |
0 | 4114 |
|
4115 |
$to_ncr = array( |
|
9 | 4116 |
'"' => '"', |
4117 |
'&' => '&', |
|
4118 |
'<' => '<', |
|
4119 |
'>' => '>', |
|
4120 |
'|' => '|', |
|
4121 |
' ' => ' ', |
|
4122 |
'¡' => '¡', |
|
4123 |
'¢' => '¢', |
|
4124 |
'£' => '£', |
|
4125 |
'¤' => '¤', |
|
4126 |
'¥' => '¥', |
|
4127 |
'¦' => '¦', |
|
4128 |
'&brkbar;' => '¦', |
|
4129 |
'§' => '§', |
|
4130 |
'¨' => '¨', |
|
4131 |
'¨' => '¨', |
|
4132 |
'©' => '©', |
|
4133 |
'ª' => 'ª', |
|
4134 |
'«' => '«', |
|
4135 |
'¬' => '¬', |
|
4136 |
'­' => '­', |
|
4137 |
'®' => '®', |
|
4138 |
'¯' => '¯', |
|
4139 |
'&hibar;' => '¯', |
|
4140 |
'°' => '°', |
|
4141 |
'±' => '±', |
|
4142 |
'²' => '²', |
|
4143 |
'³' => '³', |
|
4144 |
'´' => '´', |
|
4145 |
'µ' => 'µ', |
|
4146 |
'¶' => '¶', |
|
4147 |
'·' => '·', |
|
4148 |
'¸' => '¸', |
|
4149 |
'¹' => '¹', |
|
4150 |
'º' => 'º', |
|
4151 |
'»' => '»', |
|
4152 |
'¼' => '¼', |
|
4153 |
'½' => '½', |
|
4154 |
'¾' => '¾', |
|
4155 |
'¿' => '¿', |
|
4156 |
'À' => 'À', |
|
4157 |
'Á' => 'Á', |
|
4158 |
'Â' => 'Â', |
|
4159 |
'Ã' => 'Ã', |
|
4160 |
'Ä' => 'Ä', |
|
4161 |
'Å' => 'Å', |
|
4162 |
'Æ' => 'Æ', |
|
4163 |
'Ç' => 'Ç', |
|
4164 |
'È' => 'È', |
|
4165 |
'É' => 'É', |
|
4166 |
'Ê' => 'Ê', |
|
4167 |
'Ë' => 'Ë', |
|
4168 |
'Ì' => 'Ì', |
|
4169 |
'Í' => 'Í', |
|
4170 |
'Î' => 'Î', |
|
4171 |
'Ï' => 'Ï', |
|
4172 |
'Ð' => 'Ð', |
|
4173 |
'Ñ' => 'Ñ', |
|
4174 |
'Ò' => 'Ò', |
|
4175 |
'Ó' => 'Ó', |
|
4176 |
'Ô' => 'Ô', |
|
4177 |
'Õ' => 'Õ', |
|
4178 |
'Ö' => 'Ö', |
|
4179 |
'×' => '×', |
|
4180 |
'Ø' => 'Ø', |
|
4181 |
'Ù' => 'Ù', |
|
4182 |
'Ú' => 'Ú', |
|
4183 |
'Û' => 'Û', |
|
4184 |
'Ü' => 'Ü', |
|
4185 |
'Ý' => 'Ý', |
|
4186 |
'Þ' => 'Þ', |
|
4187 |
'ß' => 'ß', |
|
4188 |
'à' => 'à', |
|
4189 |
'á' => 'á', |
|
4190 |
'â' => 'â', |
|
4191 |
'ã' => 'ã', |
|
4192 |
'ä' => 'ä', |
|
4193 |
'å' => 'å', |
|
4194 |
'æ' => 'æ', |
|
4195 |
'ç' => 'ç', |
|
4196 |
'è' => 'è', |
|
4197 |
'é' => 'é', |
|
4198 |
'ê' => 'ê', |
|
4199 |
'ë' => 'ë', |
|
4200 |
'ì' => 'ì', |
|
4201 |
'í' => 'í', |
|
4202 |
'î' => 'î', |
|
4203 |
'ï' => 'ï', |
|
4204 |
'ð' => 'ð', |
|
4205 |
'ñ' => 'ñ', |
|
4206 |
'ò' => 'ò', |
|
4207 |
'ó' => 'ó', |
|
4208 |
'ô' => 'ô', |
|
4209 |
'õ' => 'õ', |
|
4210 |
'ö' => 'ö', |
|
4211 |
'÷' => '÷', |
|
4212 |
'ø' => 'ø', |
|
4213 |
'ù' => 'ù', |
|
4214 |
'ú' => 'ú', |
|
4215 |
'û' => 'û', |
|
4216 |
'ü' => 'ü', |
|
4217 |
'ý' => 'ý', |
|
4218 |
'þ' => 'þ', |
|
4219 |
'ÿ' => 'ÿ', |
|
4220 |
'Œ' => 'Œ', |
|
4221 |
'œ' => 'œ', |
|
4222 |
'Š' => 'Š', |
|
4223 |
'š' => 'š', |
|
4224 |
'Ÿ' => 'Ÿ', |
|
4225 |
'ƒ' => 'ƒ', |
|
4226 |
'ˆ' => 'ˆ', |
|
4227 |
'˜' => '˜', |
|
4228 |
'Α' => 'Α', |
|
4229 |
'Β' => 'Β', |
|
4230 |
'Γ' => 'Γ', |
|
4231 |
'Δ' => 'Δ', |
|
4232 |
'Ε' => 'Ε', |
|
4233 |
'Ζ' => 'Ζ', |
|
4234 |
'Η' => 'Η', |
|
4235 |
'Θ' => 'Θ', |
|
4236 |
'Ι' => 'Ι', |
|
4237 |
'Κ' => 'Κ', |
|
4238 |
'Λ' => 'Λ', |
|
4239 |
'Μ' => 'Μ', |
|
4240 |
'Ν' => 'Ν', |
|
4241 |
'Ξ' => 'Ξ', |
|
4242 |
'Ο' => 'Ο', |
|
4243 |
'Π' => 'Π', |
|
4244 |
'Ρ' => 'Ρ', |
|
4245 |
'Σ' => 'Σ', |
|
4246 |
'Τ' => 'Τ', |
|
4247 |
'Υ' => 'Υ', |
|
4248 |
'Φ' => 'Φ', |
|
4249 |
'Χ' => 'Χ', |
|
4250 |
'Ψ' => 'Ψ', |
|
4251 |
'Ω' => 'Ω', |
|
4252 |
'α' => 'α', |
|
4253 |
'β' => 'β', |
|
4254 |
'γ' => 'γ', |
|
4255 |
'δ' => 'δ', |
|
4256 |
'ε' => 'ε', |
|
4257 |
'ζ' => 'ζ', |
|
4258 |
'η' => 'η', |
|
4259 |
'θ' => 'θ', |
|
4260 |
'ι' => 'ι', |
|
4261 |
'κ' => 'κ', |
|
4262 |
'λ' => 'λ', |
|
4263 |
'μ' => 'μ', |
|
4264 |
'ν' => 'ν', |
|
4265 |
'ξ' => 'ξ', |
|
4266 |
'ο' => 'ο', |
|
4267 |
'π' => 'π', |
|
4268 |
'ρ' => 'ρ', |
|
4269 |
'ς' => 'ς', |
|
4270 |
'σ' => 'σ', |
|
4271 |
'τ' => 'τ', |
|
4272 |
'υ' => 'υ', |
|
4273 |
'φ' => 'φ', |
|
4274 |
'χ' => 'χ', |
|
4275 |
'ψ' => 'ψ', |
|
4276 |
'ω' => 'ω', |
|
0 | 4277 |
'ϑ' => 'ϑ', |
9 | 4278 |
'ϒ' => 'ϒ', |
4279 |
'ϖ' => 'ϖ', |
|
4280 |
' ' => ' ', |
|
4281 |
' ' => ' ', |
|
4282 |
' ' => ' ', |
|
4283 |
'‌' => '‌', |
|
4284 |
'‍' => '‍', |
|
4285 |
'‎' => '‎', |
|
4286 |
'‏' => '‏', |
|
4287 |
'–' => '–', |
|
4288 |
'—' => '—', |
|
4289 |
'‘' => '‘', |
|
4290 |
'’' => '’', |
|
4291 |
'‚' => '‚', |
|
4292 |
'“' => '“', |
|
4293 |
'”' => '”', |
|
4294 |
'„' => '„', |
|
4295 |
'†' => '†', |
|
4296 |
'‡' => '‡', |
|
4297 |
'•' => '•', |
|
4298 |
'…' => '…', |
|
4299 |
'‰' => '‰', |
|
4300 |
'′' => '′', |
|
4301 |
'″' => '″', |
|
4302 |
'‹' => '‹', |
|
4303 |
'›' => '›', |
|
4304 |
'‾' => '‾', |
|
4305 |
'⁄' => '⁄', |
|
4306 |
'€' => '€', |
|
4307 |
'ℑ' => 'ℑ', |
|
4308 |
'℘' => '℘', |
|
4309 |
'ℜ' => 'ℜ', |
|
4310 |
'™' => '™', |
|
4311 |
'ℵ' => 'ℵ', |
|
4312 |
'↵' => '↵', |
|
4313 |
'⇐' => '⇐', |
|
4314 |
'⇑' => '⇑', |
|
4315 |
'⇒' => '⇒', |
|
4316 |
'⇓' => '⇓', |
|
4317 |
'⇔' => '⇔', |
|
4318 |
'∀' => '∀', |
|
4319 |
'∂' => '∂', |
|
4320 |
'∃' => '∃', |
|
4321 |
'∅' => '∅', |
|
4322 |
'∇' => '∇', |
|
4323 |
'∈' => '∈', |
|
4324 |
'∉' => '∉', |
|
4325 |
'∋' => '∋', |
|
4326 |
'∏' => '∏', |
|
4327 |
'∑' => '∑', |
|
4328 |
'−' => '−', |
|
4329 |
'∗' => '∗', |
|
4330 |
'√' => '√', |
|
4331 |
'∝' => '∝', |
|
4332 |
'∞' => '∞', |
|
4333 |
'∠' => '∠', |
|
4334 |
'∧' => '∧', |
|
4335 |
'∨' => '∨', |
|
4336 |
'∩' => '∩', |
|
4337 |
'∪' => '∪', |
|
4338 |
'∫' => '∫', |
|
4339 |
'∴' => '∴', |
|
4340 |
'∼' => '∼', |
|
4341 |
'≅' => '≅', |
|
4342 |
'≈' => '≈', |
|
4343 |
'≠' => '≠', |
|
4344 |
'≡' => '≡', |
|
4345 |
'≤' => '≤', |
|
4346 |
'≥' => '≥', |
|
4347 |
'⊂' => '⊂', |
|
4348 |
'⊃' => '⊃', |
|
4349 |
'⊄' => '⊄', |
|
4350 |
'⊆' => '⊆', |
|
4351 |
'⊇' => '⊇', |
|
4352 |
'⊕' => '⊕', |
|
4353 |
'⊗' => '⊗', |
|
4354 |
'⊥' => '⊥', |
|
4355 |
'⋅' => '⋅', |
|
4356 |
'⌈' => '⌈', |
|
4357 |
'⌉' => '⌉', |
|
4358 |
'⌊' => '⌊', |
|
4359 |
'⌋' => '⌋', |
|
4360 |
'⟨' => '〈', |
|
4361 |
'⟩' => '〉', |
|
4362 |
'←' => '←', |
|
4363 |
'↑' => '↑', |
|
4364 |
'→' => '→', |
|
4365 |
'↓' => '↓', |
|
4366 |
'↔' => '↔', |
|
4367 |
'◊' => '◊', |
|
4368 |
'♠' => '♠', |
|
4369 |
'♣' => '♣', |
|
4370 |
'♥' => '♥', |
|
4371 |
'♦' => '♦', |
|
0 | 4372 |
); |
4373 |
||
9 | 4374 |
return str_replace( array_keys( $to_ncr ), array_values( $to_ncr ), $text ); |
0 | 4375 |
} |
4376 |
||
4377 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4378 |
* Formats text for the editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4379 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4380 |
* Generally the browsers treat everything inside a textarea as text, but |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4381 |
* it is still a good idea to HTML entity encode `<`, `>` and `&` in the content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4382 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4383 |
* The filter {@see 'format_for_editor'} is applied here. If `$text` is empty the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4384 |
* filter will be applied to an empty string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4385 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4386 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4387 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4388 |
* @see _WP_Editors::editor() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4389 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4390 |
* @param string $text The text to be formatted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4391 |
* @param string $default_editor The default editor for the current user. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4392 |
* It is usually either 'html' or 'tinymce'. |
0 | 4393 |
* @return string The formatted text after filter is applied. |
4394 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4395 |
function format_for_editor( $text, $default_editor = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4396 |
if ( $text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4397 |
$text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) ); |
5 | 4398 |
} |
0 | 4399 |
|
5 | 4400 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4401 |
* Filters the text after it is formatted for the editor. |
5 | 4402 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4403 |
* @since 4.3.0 |
5 | 4404 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4405 |
* @param string $text The formatted text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4406 |
* @param string $default_editor The default editor for the current user. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4407 |
* It is usually either 'html' or 'tinymce'. |
5 | 4408 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4409 |
return apply_filters( 'format_for_editor', $text, $default_editor ); |
0 | 4410 |
} |
4411 |
||
4412 |
/** |
|
19 | 4413 |
* Performs a deep string replace operation to ensure the values in $search are no longer present. |
0 | 4414 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4415 |
* Repeats the replacement operation until it no longer replaces anything to remove "nested" values |
0 | 4416 |
* e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that |
4417 |
* str_replace would return |
|
4418 |
* |
|
4419 |
* @since 2.8.1 |
|
4420 |
* @access private |
|
4421 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4422 |
* @param string|array $search The value being searched for, otherwise known as the needle. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4423 |
* An array may be used to designate multiple needles. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4424 |
* @param string $subject The string being searched and replaced on, otherwise known as the haystack. |
9 | 4425 |
* @return string The string with the replaced values. |
0 | 4426 |
*/ |
4427 |
function _deep_replace( $search, $subject ) { |
|
4428 |
$subject = (string) $subject; |
|
4429 |
||
4430 |
$count = 1; |
|
4431 |
while ( $count ) { |
|
4432 |
$subject = str_replace( $search, '', $subject, $count ); |
|
4433 |
} |
|
4434 |
||
4435 |
return $subject; |
|
4436 |
} |
|
4437 |
||
4438 |
/** |
|
4439 |
* Escapes data for use in a MySQL query. |
|
4440 |
* |
|
4441 |
* Usually you should prepare queries using wpdb::prepare(). |
|
4442 |
* Sometimes, spot-escaping is required or useful. One example |
|
4443 |
* is preparing an array for use in an IN clause. |
|
4444 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4445 |
* NOTE: Since 4.8.3, '%' characters will be replaced with a placeholder string, |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4446 |
* this prevents certain SQLi attacks from taking place. This change in behavior |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4447 |
* may cause issues for code that expects the return value of esc_sql() to be usable |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4448 |
* for other purposes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4449 |
* |
0 | 4450 |
* @since 2.8.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4451 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4452 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4453 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4454 |
* @param string|array $data Unescaped data. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4455 |
* @return string|array Escaped data, in the same type as supplied. |
0 | 4456 |
*/ |
4457 |
function esc_sql( $data ) { |
|
4458 |
global $wpdb; |
|
4459 |
return $wpdb->_escape( $data ); |
|
4460 |
} |
|
4461 |
||
4462 |
/** |
|
4463 |
* Checks and cleans a URL. |
|
4464 |
* |
|
4465 |
* A number of characters are removed from the URL. If the URL is for displaying |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4466 |
* (the default behavior) ampersands are also replaced. The {@see 'clean_url'} filter |
0 | 4467 |
* is applied to the returned cleaned URL. |
4468 |
* |
|
4469 |
* @since 2.8.0 |
|
4470 |
* |
|
16 | 4471 |
* @param string $url The URL to be cleaned. |
4472 |
* @param string[] $protocols Optional. An array of acceptable protocols. |
|
4473 |
* Defaults to return value of wp_allowed_protocols(). |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4474 |
* @param string $_context Private. Use sanitize_url() for database usage. |
16 | 4475 |
* @return string The cleaned URL after the {@see 'clean_url'} filter is applied. |
18 | 4476 |
* An empty string is returned if `$url` specifies a protocol other than |
4477 |
* those in `$protocols`, or if `$url` contains an empty string. |
|
0 | 4478 |
*/ |
4479 |
function esc_url( $url, $protocols = null, $_context = 'display' ) { |
|
4480 |
$original_url = $url; |
|
4481 |
||
16 | 4482 |
if ( '' === $url ) { |
0 | 4483 |
return $url; |
9 | 4484 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4485 |
|
16 | 4486 |
$url = str_replace( ' ', '%20', ltrim( $url ) ); |
9 | 4487 |
$url = preg_replace( '|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4488 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4489 |
if ( '' === $url ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4490 |
return $url; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4491 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4492 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4493 |
if ( 0 !== stripos( $url, 'mailto:' ) ) { |
9 | 4494 |
$strip = array( '%0d', '%0a', '%0D', '%0A' ); |
4495 |
$url = _deep_replace( $strip, $url ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4496 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4497 |
|
9 | 4498 |
$url = str_replace( ';//', '://', $url ); |
16 | 4499 |
/* |
4500 |
* If the URL doesn't appear to contain a scheme, we presume |
|
4501 |
* it needs http:// prepended (unless it's a relative link |
|
4502 |
* starting with /, # or ?, or a PHP file). |
|
0 | 4503 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4504 |
if ( ! str_contains( $url, ':' ) && ! in_array( $url[0], array( '/', '#', '?' ), true ) && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4505 |
! preg_match( '/^[a-z0-9-]+?\.php/i', $url ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4506 |
) { |
0 | 4507 |
$url = 'http://' . $url; |
9 | 4508 |
} |
0 | 4509 |
|
4510 |
// Replace ampersands and single quotes only when displaying. |
|
16 | 4511 |
if ( 'display' === $_context ) { |
0 | 4512 |
$url = wp_kses_normalize_entities( $url ); |
4513 |
$url = str_replace( '&', '&', $url ); |
|
4514 |
$url = str_replace( "'", ''', $url ); |
|
4515 |
} |
|
4516 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4517 |
if ( str_contains( $url, '[' ) || str_contains( $url, ']' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4518 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4519 |
$parsed = wp_parse_url( $url ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4520 |
$front = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4521 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4522 |
if ( isset( $parsed['scheme'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4523 |
$front .= $parsed['scheme'] . '://'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4524 |
} elseif ( '/' === $url[0] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4525 |
$front .= '//'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4526 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4527 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4528 |
if ( isset( $parsed['user'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4529 |
$front .= $parsed['user']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4530 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4531 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4532 |
if ( isset( $parsed['pass'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4533 |
$front .= ':' . $parsed['pass']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4534 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4535 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4536 |
if ( isset( $parsed['user'] ) || isset( $parsed['pass'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4537 |
$front .= '@'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4538 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4539 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4540 |
if ( isset( $parsed['host'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4541 |
$front .= $parsed['host']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4542 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4543 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4544 |
if ( isset( $parsed['port'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4545 |
$front .= ':' . $parsed['port']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4546 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4547 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4548 |
$end_dirty = str_replace( $front, '', $url ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4549 |
$end_clean = str_replace( array( '[', ']' ), array( '%5B', '%5D' ), $end_dirty ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4550 |
$url = str_replace( $end_dirty, $end_clean, $url ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4551 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4552 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4553 |
|
0 | 4554 |
if ( '/' === $url[0] ) { |
4555 |
$good_protocol_url = $url; |
|
4556 |
} else { |
|
9 | 4557 |
if ( ! is_array( $protocols ) ) { |
0 | 4558 |
$protocols = wp_allowed_protocols(); |
9 | 4559 |
} |
0 | 4560 |
$good_protocol_url = wp_kses_bad_protocol( $url, $protocols ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4561 |
if ( strtolower( $good_protocol_url ) !== strtolower( $url ) ) { |
0 | 4562 |
return ''; |
9 | 4563 |
} |
0 | 4564 |
} |
4565 |
||
5 | 4566 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4567 |
* Filters a string cleaned and escaped for output as a URL. |
5 | 4568 |
* |
4569 |
* @since 2.3.0 |
|
4570 |
* |
|
4571 |
* @param string $good_protocol_url The cleaned URL to be returned. |
|
4572 |
* @param string $original_url The URL prior to cleaning. |
|
4573 |
* @param string $_context If 'display', replace ampersands and single quotes only. |
|
4574 |
*/ |
|
4575 |
return apply_filters( 'clean_url', $good_protocol_url, $original_url, $_context ); |
|
0 | 4576 |
} |
4577 |
||
4578 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4579 |
* Sanitizes a URL for database or redirect usage. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4580 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4581 |
* This function is an alias for sanitize_url(). |
0 | 4582 |
* |
4583 |
* @since 2.8.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4584 |
* @since 6.1.0 Turned into an alias for sanitize_url(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4585 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4586 |
* @see sanitize_url() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4587 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4588 |
* @param string $url The URL to be cleaned. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4589 |
* @param string[] $protocols Optional. An array of acceptable protocols. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4590 |
* Defaults to return value of wp_allowed_protocols(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4591 |
* @return string The cleaned URL after sanitize_url() is run. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4592 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4593 |
function esc_url_raw( $url, $protocols = null ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4594 |
return sanitize_url( $url, $protocols ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4595 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4596 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4597 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4598 |
* Sanitizes a URL for database or redirect usage. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4599 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4600 |
* @since 2.3.1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4601 |
* @since 2.8.0 Deprecated in favor of esc_url_raw(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4602 |
* @since 5.9.0 Restored (un-deprecated). |
0 | 4603 |
* |
18 | 4604 |
* @see esc_url() |
4605 |
* |
|
16 | 4606 |
* @param string $url The URL to be cleaned. |
4607 |
* @param string[] $protocols Optional. An array of acceptable protocols. |
|
4608 |
* Defaults to return value of wp_allowed_protocols(). |
|
18 | 4609 |
* @return string The cleaned URL after esc_url() is run with the 'db' context. |
0 | 4610 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4611 |
function sanitize_url( $url, $protocols = null ) { |
0 | 4612 |
return esc_url( $url, $protocols, 'db' ); |
4613 |
} |
|
4614 |
||
4615 |
/** |
|
19 | 4616 |
* Converts entities, while preserving already-encoded entities. |
0 | 4617 |
* |
16 | 4618 |
* @link https://www.php.net/htmlentities Borrowed from the PHP Manual user notes. |
0 | 4619 |
* |
4620 |
* @since 1.2.2 |
|
4621 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4622 |
* @param string $text The text to be converted. |
0 | 4623 |
* @return string Converted text. |
4624 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4625 |
function htmlentities2( $text ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4626 |
$translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4627 |
|
9 | 4628 |
$translation_table[ chr( 38 ) ] = '&'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4629 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4630 |
return preg_replace( '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', strtr( $text, $translation_table ) ); |
0 | 4631 |
} |
4632 |
||
4633 |
/** |
|
19 | 4634 |
* Escapes single quotes, `"`, `<`, `>`, `&`, and fixes line endings. |
0 | 4635 |
* |
4636 |
* Escapes text strings for echoing in JS. It is intended to be used for inline JS |
|
19 | 4637 |
* (in a tag attribute, for example `onclick="..."`). Note that the strings have to |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4638 |
* be in single quotes. The {@see 'js_escape'} filter is also applied here. |
0 | 4639 |
* |
4640 |
* @since 2.8.0 |
|
4641 |
* |
|
4642 |
* @param string $text The text to be escaped. |
|
4643 |
* @return string Escaped text. |
|
4644 |
*/ |
|
4645 |
function esc_js( $text ) { |
|
4646 |
$safe_text = wp_check_invalid_utf8( $text ); |
|
4647 |
$safe_text = _wp_specialchars( $safe_text, ENT_COMPAT ); |
|
4648 |
$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) ); |
|
4649 |
$safe_text = str_replace( "\r", '', $safe_text ); |
|
4650 |
$safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) ); |
|
5 | 4651 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4652 |
* Filters a string cleaned and escaped for output in JavaScript. |
5 | 4653 |
* |
4654 |
* Text passed to esc_js() is stripped of invalid or special characters, |
|
4655 |
* and properly slashed for output. |
|
4656 |
* |
|
4657 |
* @since 2.0.6 |
|
4658 |
* |
|
4659 |
* @param string $safe_text The text after it has been escaped. |
|
9 | 4660 |
* @param string $text The text prior to being escaped. |
5 | 4661 |
*/ |
0 | 4662 |
return apply_filters( 'js_escape', $safe_text, $text ); |
4663 |
} |
|
4664 |
||
4665 |
/** |
|
4666 |
* Escaping for HTML blocks. |
|
4667 |
* |
|
4668 |
* @since 2.8.0 |
|
4669 |
* |
|
4670 |
* @param string $text |
|
4671 |
* @return string |
|
4672 |
*/ |
|
4673 |
function esc_html( $text ) { |
|
4674 |
$safe_text = wp_check_invalid_utf8( $text ); |
|
4675 |
$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); |
|
5 | 4676 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4677 |
* Filters a string cleaned and escaped for output in HTML. |
5 | 4678 |
* |
4679 |
* Text passed to esc_html() is stripped of invalid or special characters |
|
4680 |
* before output. |
|
4681 |
* |
|
4682 |
* @since 2.8.0 |
|
4683 |
* |
|
4684 |
* @param string $safe_text The text after it has been escaped. |
|
9 | 4685 |
* @param string $text The text prior to being escaped. |
5 | 4686 |
*/ |
0 | 4687 |
return apply_filters( 'esc_html', $safe_text, $text ); |
4688 |
} |
|
4689 |
||
4690 |
/** |
|
4691 |
* Escaping for HTML attributes. |
|
4692 |
* |
|
4693 |
* @since 2.8.0 |
|
4694 |
* |
|
4695 |
* @param string $text |
|
4696 |
* @return string |
|
4697 |
*/ |
|
4698 |
function esc_attr( $text ) { |
|
4699 |
$safe_text = wp_check_invalid_utf8( $text ); |
|
4700 |
$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); |
|
5 | 4701 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4702 |
* Filters a string cleaned and escaped for output in an HTML attribute. |
5 | 4703 |
* |
4704 |
* Text passed to esc_attr() is stripped of invalid or special characters |
|
4705 |
* before output. |
|
4706 |
* |
|
4707 |
* @since 2.0.6 |
|
4708 |
* |
|
4709 |
* @param string $safe_text The text after it has been escaped. |
|
9 | 4710 |
* @param string $text The text prior to being escaped. |
5 | 4711 |
*/ |
0 | 4712 |
return apply_filters( 'attribute_escape', $safe_text, $text ); |
4713 |
} |
|
4714 |
||
4715 |
/** |
|
4716 |
* Escaping for textarea values. |
|
4717 |
* |
|
4718 |
* @since 3.1.0 |
|
4719 |
* |
|
4720 |
* @param string $text |
|
4721 |
* @return string |
|
4722 |
*/ |
|
4723 |
function esc_textarea( $text ) { |
|
4724 |
$safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( 'blog_charset' ) ); |
|
5 | 4725 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4726 |
* Filters a string cleaned and escaped for output in a textarea element. |
5 | 4727 |
* |
4728 |
* @since 3.1.0 |
|
4729 |
* |
|
4730 |
* @param string $safe_text The text after it has been escaped. |
|
9 | 4731 |
* @param string $text The text prior to being escaped. |
5 | 4732 |
*/ |
0 | 4733 |
return apply_filters( 'esc_textarea', $safe_text, $text ); |
4734 |
} |
|
4735 |
||
4736 |
/** |
|
16 | 4737 |
* Escaping for XML blocks. |
4738 |
* |
|
4739 |
* @since 5.5.0 |
|
4740 |
* |
|
4741 |
* @param string $text Text to escape. |
|
4742 |
* @return string Escaped text. |
|
4743 |
*/ |
|
4744 |
function esc_xml( $text ) { |
|
4745 |
$safe_text = wp_check_invalid_utf8( $text ); |
|
4746 |
||
4747 |
$cdata_regex = '\<\!\[CDATA\[.*?\]\]\>'; |
|
4748 |
$regex = <<<EOF |
|
4749 |
/ |
|
4750 |
(?=.*?{$cdata_regex}) # lookahead that will match anything followed by a CDATA Section |
|
4751 |
(?<non_cdata_followed_by_cdata>(.*?)) # the "anything" matched by the lookahead |
|
4752 |
(?<cdata>({$cdata_regex})) # the CDATA Section matched by the lookahead |
|
4753 |
||
4754 |
| # alternative |
|
4755 |
||
4756 |
(?<non_cdata>(.*)) # non-CDATA Section |
|
4757 |
/sx |
|
4758 |
EOF; |
|
4759 |
||
4760 |
$safe_text = (string) preg_replace_callback( |
|
4761 |
$regex, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4762 |
static function ( $matches ) { |
19 | 4763 |
if ( ! isset( $matches[0] ) ) { |
16 | 4764 |
return ''; |
4765 |
} |
|
4766 |
||
19 | 4767 |
if ( isset( $matches['non_cdata'] ) ) { |
16 | 4768 |
// escape HTML entities in the non-CDATA Section. |
4769 |
return _wp_specialchars( $matches['non_cdata'], ENT_XML1 ); |
|
4770 |
} |
|
4771 |
||
4772 |
// Return the CDATA Section unchanged, escape HTML entities in the rest. |
|
4773 |
return _wp_specialchars( $matches['non_cdata_followed_by_cdata'], ENT_XML1 ) . $matches['cdata']; |
|
4774 |
}, |
|
4775 |
$safe_text |
|
4776 |
); |
|
4777 |
||
4778 |
/** |
|
4779 |
* Filters a string cleaned and escaped for output in XML. |
|
4780 |
* |
|
4781 |
* Text passed to esc_xml() is stripped of invalid or special characters |
|
4782 |
* before output. HTML named character references are converted to their |
|
4783 |
* equivalent code points. |
|
4784 |
* |
|
4785 |
* @since 5.5.0 |
|
4786 |
* |
|
4787 |
* @param string $safe_text The text after it has been escaped. |
|
4788 |
* @param string $text The text prior to being escaped. |
|
4789 |
*/ |
|
4790 |
return apply_filters( 'esc_xml', $safe_text, $text ); |
|
4791 |
} |
|
4792 |
||
4793 |
/** |
|
19 | 4794 |
* Escapes an HTML tag name. |
0 | 4795 |
* |
4796 |
* @since 2.5.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4797 |
* @since 6.5.5 Allow hyphens in tag names (i.e. custom elements). |
0 | 4798 |
* |
4799 |
* @param string $tag_name |
|
4800 |
* @return string |
|
4801 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4802 |
function tag_escape( $tag_name ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4803 |
$safe_tag = strtolower( preg_replace( '/[^a-zA-Z0-9-_:]/', '', $tag_name ) ); |
5 | 4804 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4805 |
* Filters a string cleaned and escaped for output as an HTML tag. |
5 | 4806 |
* |
4807 |
* @since 2.8.0 |
|
4808 |
* |
|
4809 |
* @param string $safe_tag The tag name after it has been escaped. |
|
9 | 4810 |
* @param string $tag_name The text before it was escaped. |
5 | 4811 |
*/ |
4812 |
return apply_filters( 'tag_escape', $safe_tag, $tag_name ); |
|
0 | 4813 |
} |
4814 |
||
4815 |
/** |
|
19 | 4816 |
* Converts full URL paths to absolute paths. |
0 | 4817 |
* |
4818 |
* Removes the http or https protocols and the domain. Keeps the path '/' at the |
|
4819 |
* beginning, so it isn't a true relative link, but from the web root base. |
|
4820 |
* |
|
4821 |
* @since 2.1.0 |
|
5 | 4822 |
* @since 4.1.0 Support was added for relative URLs. |
0 | 4823 |
* |
4824 |
* @param string $link Full URL path. |
|
4825 |
* @return string Absolute path. |
|
4826 |
*/ |
|
4827 |
function wp_make_link_relative( $link ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4828 |
return preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', $link ); |
0 | 4829 |
} |
4830 |
||
4831 |
/** |
|
19 | 4832 |
* Sanitizes various option values based on the nature of the option. |
0 | 4833 |
* |
4834 |
* This is basically a switch statement which will pass $value through a number |
|
4835 |
* of functions depending on the $option. |
|
4836 |
* |
|
4837 |
* @since 2.0.5 |
|
4838 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4839 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4840 |
* |
0 | 4841 |
* @param string $option The name of the option. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4842 |
* @param mixed $value The unsanitized value. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4843 |
* @return mixed Sanitized value. |
0 | 4844 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4845 |
function sanitize_option( $option, $value ) { |
5 | 4846 |
global $wpdb; |
0 | 4847 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4848 |
$original_value = $value; |
19 | 4849 |
$error = null; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4850 |
|
0 | 4851 |
switch ( $option ) { |
9 | 4852 |
case 'admin_email': |
4853 |
case 'new_admin_email': |
|
5 | 4854 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4855 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4856 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4857 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4858 |
$value = sanitize_email( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4859 |
if ( ! is_email( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4860 |
$error = __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4861 |
} |
0 | 4862 |
} |
4863 |
break; |
|
4864 |
||
4865 |
case 'thumbnail_size_w': |
|
4866 |
case 'thumbnail_size_h': |
|
4867 |
case 'medium_size_w': |
|
4868 |
case 'medium_size_h': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4869 |
case 'medium_large_size_w': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4870 |
case 'medium_large_size_h': |
0 | 4871 |
case 'large_size_w': |
4872 |
case 'large_size_h': |
|
4873 |
case 'mailserver_port': |
|
4874 |
case 'comment_max_links': |
|
4875 |
case 'page_on_front': |
|
4876 |
case 'page_for_posts': |
|
4877 |
case 'rss_excerpt_length': |
|
4878 |
case 'default_category': |
|
4879 |
case 'default_email_category': |
|
4880 |
case 'default_link_category': |
|
4881 |
case 'close_comments_days_old': |
|
4882 |
case 'comments_per_page': |
|
4883 |
case 'thread_comments_depth': |
|
4884 |
case 'users_can_register': |
|
4885 |
case 'start_of_week': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4886 |
case 'site_icon': |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4887 |
case 'fileupload_maxk': |
0 | 4888 |
$value = absint( $value ); |
4889 |
break; |
|
4890 |
||
4891 |
case 'posts_per_page': |
|
4892 |
case 'posts_per_rss': |
|
4893 |
$value = (int) $value; |
|
9 | 4894 |
if ( empty( $value ) ) { |
0 | 4895 |
$value = 1; |
9 | 4896 |
} |
4897 |
if ( $value < -1 ) { |
|
4898 |
$value = abs( $value ); |
|
4899 |
} |
|
0 | 4900 |
break; |
4901 |
||
4902 |
case 'default_ping_status': |
|
4903 |
case 'default_comment_status': |
|
16 | 4904 |
// Options that if not there have 0 value but need to be something like "closed". |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4905 |
if ( '0' === (string) $value || '' === $value ) { |
0 | 4906 |
$value = 'closed'; |
9 | 4907 |
} |
0 | 4908 |
break; |
4909 |
||
4910 |
case 'blogdescription': |
|
4911 |
case 'blogname': |
|
5 | 4912 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4913 |
if ( $value !== $original_value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4914 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', wp_encode_emoji( $original_value ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4915 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4916 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4917 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4918 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4919 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4920 |
$value = esc_html( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4921 |
} |
0 | 4922 |
break; |
4923 |
||
4924 |
case 'blog_charset': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4925 |
if ( is_string( $value ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4926 |
$value = preg_replace( '/[^a-zA-Z0-9_-]/', '', $value ); // Strips slashes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4927 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4928 |
$value = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4929 |
} |
0 | 4930 |
break; |
4931 |
||
4932 |
case 'blog_public': |
|
4933 |
// This is the value if the settings checkbox is not checked on POST. Don't rely on this. |
|
9 | 4934 |
if ( null === $value ) { |
0 | 4935 |
$value = 1; |
9 | 4936 |
} else { |
18 | 4937 |
$value = (int) $value; |
9 | 4938 |
} |
0 | 4939 |
break; |
4940 |
||
4941 |
case 'date_format': |
|
4942 |
case 'time_format': |
|
4943 |
case 'mailserver_url': |
|
4944 |
case 'mailserver_login': |
|
4945 |
case 'mailserver_pass': |
|
4946 |
case 'upload_path': |
|
5 | 4947 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4948 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4949 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4950 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4951 |
$value = strip_tags( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4952 |
$value = wp_kses_data( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4953 |
} |
0 | 4954 |
break; |
4955 |
||
4956 |
case 'ping_sites': |
|
4957 |
$value = explode( "\n", $value ); |
|
4958 |
$value = array_filter( array_map( 'trim', $value ) ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4959 |
$value = array_filter( array_map( 'sanitize_url', $value ) ); |
0 | 4960 |
$value = implode( "\n", $value ); |
4961 |
break; |
|
4962 |
||
4963 |
case 'gmt_offset': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4964 |
if ( is_numeric( $value ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4965 |
$value = preg_replace( '/[^0-9:.-]/', '', $value ); // Strips slashes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4966 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4967 |
$value = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4968 |
} |
0 | 4969 |
break; |
4970 |
||
4971 |
case 'siteurl': |
|
5 | 4972 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4973 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4974 |
$error = $value->get_error_message(); |
0 | 4975 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4976 |
if ( preg_match( '#http(s?)://(.+)#i', $value ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4977 |
$value = sanitize_url( $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4978 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4979 |
$error = __( 'The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4980 |
} |
0 | 4981 |
} |
4982 |
break; |
|
4983 |
||
4984 |
case 'home': |
|
5 | 4985 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4986 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4987 |
$error = $value->get_error_message(); |
0 | 4988 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4989 |
if ( preg_match( '#http(s?)://(.+)#i', $value ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4990 |
$value = sanitize_url( $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4991 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4992 |
$error = __( 'The Site address you entered did not appear to be a valid URL. Please enter a valid URL.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4993 |
} |
0 | 4994 |
} |
4995 |
break; |
|
4996 |
||
4997 |
case 'WPLANG': |
|
4998 |
$allowed = get_available_languages(); |
|
5 | 4999 |
if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG ) { |
5000 |
$allowed[] = WPLANG; |
|
5001 |
} |
|
16 | 5002 |
if ( ! in_array( $value, $allowed, true ) && ! empty( $value ) ) { |
0 | 5003 |
$value = get_option( $option ); |
5 | 5004 |
} |
0 | 5005 |
break; |
5006 |
||
5007 |
case 'illegal_names': |
|
5 | 5008 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5009 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5010 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5011 |
} else { |
9 | 5012 |
if ( ! is_array( $value ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5013 |
$value = explode( ' ', $value ); |
9 | 5014 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5015 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5016 |
$value = array_values( array_filter( array_map( 'trim', $value ) ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5017 |
|
9 | 5018 |
if ( ! $value ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5019 |
$value = ''; |
9 | 5020 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5021 |
} |
0 | 5022 |
break; |
5023 |
||
5024 |
case 'limited_email_domains': |
|
5025 |
case 'banned_email_domains': |
|
5 | 5026 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5027 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5028 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5029 |
} else { |
9 | 5030 |
if ( ! is_array( $value ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5031 |
$value = explode( "\n", $value ); |
9 | 5032 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5033 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5034 |
$domains = array_values( array_filter( array_map( 'trim', $value ) ) ); |
9 | 5035 |
$value = array(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5036 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5037 |
foreach ( $domains as $domain ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5038 |
if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5039 |
$value[] = $domain; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5040 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5041 |
} |
9 | 5042 |
if ( ! $value ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5043 |
$value = ''; |
9 | 5044 |
} |
0 | 5045 |
} |
5046 |
break; |
|
5047 |
||
5048 |
case 'timezone_string': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5049 |
$allowed_zones = timezone_identifiers_list( DateTimeZone::ALL_WITH_BC ); |
16 | 5050 |
if ( ! in_array( $value, $allowed_zones, true ) && ! empty( $value ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5051 |
$error = __( 'The timezone you have entered is not valid. Please select a valid timezone.' ); |
0 | 5052 |
} |
5053 |
break; |
|
5054 |
||
5055 |
case 'permalink_structure': |
|
5056 |
case 'category_base': |
|
5057 |
case 'tag_base': |
|
5 | 5058 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5059 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5060 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5061 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5062 |
$value = sanitize_url( $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5063 |
$value = str_replace( 'http://', '', $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5064 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5065 |
|
19 | 5066 |
if ( 'permalink_structure' === $option && null === $error |
5067 |
&& '' !== $value && ! preg_match( '/%[^\/%]+%/', $value ) |
|
5068 |
) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5069 |
$error = sprintf( |
16 | 5070 |
/* translators: %s: Documentation URL. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5071 |
__( 'A structure tag is required when using custom permalinks. <a href="%s">Learn more</a>' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5072 |
__( 'https://wordpress.org/documentation/article/customize-permalinks/#choosing-your-permalink-structure' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5073 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5074 |
} |
0 | 5075 |
break; |
5076 |
||
9 | 5077 |
case 'default_role': |
5078 |
if ( ! get_role( $value ) && get_role( 'subscriber' ) ) { |
|
0 | 5079 |
$value = 'subscriber'; |
9 | 5080 |
} |
0 | 5081 |
break; |
5 | 5082 |
|
5083 |
case 'moderation_keys': |
|
16 | 5084 |
case 'disallowed_keys': |
5 | 5085 |
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5086 |
if ( is_wp_error( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5087 |
$error = $value->get_error_message(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5088 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5089 |
$value = explode( "\n", $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5090 |
$value = array_filter( array_map( 'trim', $value ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5091 |
$value = array_unique( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5092 |
$value = implode( "\n", $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5093 |
} |
5 | 5094 |
break; |
0 | 5095 |
} |
5096 |
||
19 | 5097 |
if ( null !== $error ) { |
5098 |
if ( '' === $error && is_wp_error( $value ) ) { |
|
5099 |
/* translators: 1: Option name, 2: Error code. */ |
|
5100 |
$error = sprintf( __( 'Could not sanitize the %1$s option. Error code: %2$s' ), $option, $value->get_error_code() ); |
|
5101 |
} |
|
5102 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5103 |
$value = get_option( $option ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5104 |
if ( function_exists( 'add_settings_error' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5105 |
add_settings_error( $option, "invalid_{$option}", $error ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5106 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5107 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5108 |
|
5 | 5109 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5110 |
* Filters an option value following sanitization. |
5 | 5111 |
* |
5112 |
* @since 2.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5113 |
* @since 4.3.0 Added the `$original_value` parameter. |
5 | 5114 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5115 |
* @param mixed $value The sanitized option value. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5116 |
* @param string $option The option name. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5117 |
* @param mixed $original_value The original value passed to the function. |
5 | 5118 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5119 |
return apply_filters( "sanitize_option_{$option}", $value, $option, $original_value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5120 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5121 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5122 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5123 |
* Maps a function to all non-iterable elements of an array or an object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5124 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5125 |
* This is similar to `array_walk_recursive()` but acts upon objects too. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5126 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5127 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5128 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5129 |
* @param mixed $value The array, object, or scalar. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5130 |
* @param callable $callback The function to map onto $value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5131 |
* @return mixed The value with the callback applied to all non-arrays and non-objects inside it. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5132 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5133 |
function map_deep( $value, $callback ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5134 |
if ( is_array( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5135 |
foreach ( $value as $index => $item ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5136 |
$value[ $index ] = map_deep( $item, $callback ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5137 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5138 |
} elseif ( is_object( $value ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5139 |
$object_vars = get_object_vars( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5140 |
foreach ( $object_vars as $property_name => $property_value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5141 |
$value->$property_name = map_deep( $property_value, $callback ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5142 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5143 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5144 |
$value = call_user_func( $callback, $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5145 |
} |
0 | 5146 |
|
5147 |
return $value; |
|
5148 |
} |
|
5149 |
||
5150 |
/** |
|
5151 |
* Parses a string into variables to be stored in an array. |
|
5152 |
* |
|
5153 |
* @since 2.2.1 |
|
5154 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5155 |
* @param string $input_string The string to be parsed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5156 |
* @param array $result Variables will be stored in this array. |
0 | 5157 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5158 |
function wp_parse_str( $input_string, &$result ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5159 |
parse_str( (string) $input_string, $result ); |
16 | 5160 |
|
5 | 5161 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5162 |
* Filters the array of variables derived from a parsed string. |
5 | 5163 |
* |
19 | 5164 |
* @since 2.2.1 |
5 | 5165 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5166 |
* @param array $result The array populated with variables. |
5 | 5167 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5168 |
$result = apply_filters( 'wp_parse_str', $result ); |
0 | 5169 |
} |
5170 |
||
5171 |
/** |
|
19 | 5172 |
* Converts lone less than signs. |
0 | 5173 |
* |
5174 |
* KSES already converts lone greater than signs. |
|
5175 |
* |
|
5176 |
* @since 2.3.0 |
|
5177 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5178 |
* @param string $content Text to be converted. |
0 | 5179 |
* @return string Converted text. |
5180 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5181 |
function wp_pre_kses_less_than( $content ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5182 |
return preg_replace_callback( '%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $content ); |
0 | 5183 |
} |
5184 |
||
5185 |
/** |
|
5186 |
* Callback function used by preg_replace. |
|
5187 |
* |
|
5188 |
* @since 2.3.0 |
|
5189 |
* |
|
19 | 5190 |
* @param string[] $matches Populated by matches to preg_replace. |
0 | 5191 |
* @return string The text returned after esc_html if needed. |
5192 |
*/ |
|
5193 |
function wp_pre_kses_less_than_callback( $matches ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5194 |
if ( ! str_contains( $matches[0], '>' ) ) { |
9 | 5195 |
return esc_html( $matches[0] ); |
5196 |
} |
|
0 | 5197 |
return $matches[0]; |
5198 |
} |
|
5199 |
||
5200 |
/** |
|
19 | 5201 |
* Removes non-allowable HTML from parsed block attribute values when filtering |
16 | 5202 |
* in the post context. |
5203 |
* |
|
5204 |
* @since 5.3.1 |
|
5205 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5206 |
* @param string $content Content to be run through KSES. |
16 | 5207 |
* @param array[]|string $allowed_html An array of allowed HTML elements |
5208 |
* and attributes, or a context name |
|
5209 |
* such as 'post'. |
|
5210 |
* @param string[] $allowed_protocols Array of allowed URL protocols. |
|
5211 |
* @return string Filtered text to run through KSES. |
|
5212 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5213 |
function wp_pre_kses_block_attributes( $content, $allowed_html, $allowed_protocols ) { |
16 | 5214 |
/* |
5215 |
* `filter_block_content` is expected to call `wp_kses`. Temporarily remove |
|
5216 |
* the filter to avoid recursion. |
|
5217 |
*/ |
|
5218 |
remove_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10 ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5219 |
$content = filter_block_content( $content, $allowed_html, $allowed_protocols ); |
16 | 5220 |
add_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10, 3 ); |
5221 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5222 |
return $content; |
16 | 5223 |
} |
5224 |
||
5225 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5226 |
* WordPress' implementation of PHP sprintf() with filters. |
0 | 5227 |
* |
5228 |
* @since 2.5.0 |
|
16 | 5229 |
* @since 5.3.0 Formalized the existing and already documented `...$args` parameter |
5230 |
* by adding it to the function signature. |
|
5231 |
* |
|
5232 |
* @link https://www.php.net/sprintf |
|
5233 |
* |
|
5234 |
* @param string $pattern The string which formatted args are inserted. |
|
5235 |
* @param mixed ...$args Arguments to be formatted into the $pattern string. |
|
0 | 5236 |
* @return string The formatted string. |
5237 |
*/ |
|
16 | 5238 |
function wp_sprintf( $pattern, ...$args ) { |
9 | 5239 |
$len = strlen( $pattern ); |
5240 |
$start = 0; |
|
5241 |
$result = ''; |
|
0 | 5242 |
$arg_index = 0; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5243 |
|
0 | 5244 |
while ( $len > $start ) { |
16 | 5245 |
// Last character: append and break. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5246 |
if ( strlen( $pattern ) - 1 === $start ) { |
9 | 5247 |
$result .= substr( $pattern, -1 ); |
0 | 5248 |
break; |
5249 |
} |
|
5250 |
||
16 | 5251 |
// Literal %: append and continue. |
5252 |
if ( '%%' === substr( $pattern, $start, 2 ) ) { |
|
9 | 5253 |
$start += 2; |
0 | 5254 |
$result .= '%'; |
5255 |
continue; |
|
5256 |
} |
|
5257 |
||
16 | 5258 |
// Get fragment before next %. |
9 | 5259 |
$end = strpos( $pattern, '%', $start + 1 ); |
5260 |
if ( false === $end ) { |
|
0 | 5261 |
$end = $len; |
9 | 5262 |
} |
5263 |
$fragment = substr( $pattern, $start, $end - $start ); |
|
0 | 5264 |
|
16 | 5265 |
// Fragment has a specifier. |
5266 |
if ( '%' === $pattern[ $start ] ) { |
|
5267 |
// Find numbered arguments or take the next one in order. |
|
9 | 5268 |
if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) { |
16 | 5269 |
$index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments. |
5270 |
$arg = isset( $args[ $index ] ) ? $args[ $index ] : ''; |
|
9 | 5271 |
$fragment = str_replace( "%{$matches[1]}$", '%', $fragment ); |
0 | 5272 |
} else { |
16 | 5273 |
$arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : ''; |
0 | 5274 |
++$arg_index; |
5275 |
} |
|
5276 |
||
5 | 5277 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5278 |
* Filters a fragment from the pattern passed to wp_sprintf(). |
5 | 5279 |
* |
5280 |
* If the fragment is unchanged, then sprintf() will be run on the fragment. |
|
5281 |
* |
|
5282 |
* @since 2.5.0 |
|
5283 |
* |
|
5284 |
* @param string $fragment A fragment from the pattern. |
|
5285 |
* @param string $arg The argument. |
|
5286 |
*/ |
|
0 | 5287 |
$_fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5288 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5289 |
if ( $_fragment !== $fragment ) { |
0 | 5290 |
$fragment = $_fragment; |
9 | 5291 |
} else { |
18 | 5292 |
$fragment = sprintf( $fragment, (string) $arg ); |
9 | 5293 |
} |
0 | 5294 |
} |
5295 |
||
16 | 5296 |
// Append to result and move to next fragment. |
0 | 5297 |
$result .= $fragment; |
9 | 5298 |
$start = $end; |
0 | 5299 |
} |
16 | 5300 |
|
0 | 5301 |
return $result; |
5302 |
} |
|
5303 |
||
5304 |
/** |
|
19 | 5305 |
* Localizes list items before the rest of the content. |
0 | 5306 |
* |
5307 |
* The '%l' must be at the first characters can then contain the rest of the |
|
5308 |
* content. The list items will have ', ', ', and', and ' and ' added depending |
|
5309 |
* on the amount of list items in the $args parameter. |
|
5310 |
* |
|
5311 |
* @since 2.5.0 |
|
5312 |
* |
|
5313 |
* @param string $pattern Content containing '%l' at the beginning. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5314 |
* @param array $args List items to prepend to the content and replace '%l'. |
0 | 5315 |
* @return string Localized list items and rest of the content. |
5316 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5317 |
function wp_sprintf_l( $pattern, $args ) { |
16 | 5318 |
// Not a match. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5319 |
if ( ! str_starts_with( $pattern, '%l' ) ) { |
0 | 5320 |
return $pattern; |
9 | 5321 |
} |
0 | 5322 |
|
16 | 5323 |
// Nothing to work with. |
9 | 5324 |
if ( empty( $args ) ) { |
0 | 5325 |
return ''; |
9 | 5326 |
} |
0 | 5327 |
|
5 | 5328 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5329 |
* Filters the translated delimiters used by wp_sprintf_l(). |
5 | 5330 |
* Placeholders (%s) are included to assist translators and then |
5331 |
* removed before the array of strings reaches the filter. |
|
5332 |
* |
|
5333 |
* Please note: Ampersands and entities should be avoided here. |
|
5334 |
* |
|
5335 |
* @since 2.5.0 |
|
5336 |
* |
|
5337 |
* @param array $delimiters An array of translated delimiters. |
|
5338 |
*/ |
|
9 | 5339 |
$l = apply_filters( |
5340 |
'wp_sprintf_l', |
|
5341 |
array( |
|
16 | 5342 |
/* translators: Used to join items in a list with more than 2 items. */ |
9 | 5343 |
'between' => sprintf( __( '%1$s, %2$s' ), '', '' ), |
16 | 5344 |
/* translators: Used to join last two items in a list with more than 2 times. */ |
9 | 5345 |
'between_last_two' => sprintf( __( '%1$s, and %2$s' ), '', '' ), |
16 | 5346 |
/* translators: Used to join items in a list with only 2 items. */ |
9 | 5347 |
'between_only_two' => sprintf( __( '%1$s and %2$s' ), '', '' ), |
5348 |
) |
|
5349 |
); |
|
5350 |
||
5351 |
$args = (array) $args; |
|
5352 |
$result = array_shift( $args ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5353 |
if ( count( $args ) === 1 ) { |
9 | 5354 |
$result .= $l['between_only_two'] . array_shift( $args ); |
5355 |
} |
|
16 | 5356 |
|
5357 |
// Loop when more than two args. |
|
9 | 5358 |
$i = count( $args ); |
0 | 5359 |
while ( $i ) { |
9 | 5360 |
$arg = array_shift( $args ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5361 |
--$i; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5362 |
if ( 0 === $i ) { |
0 | 5363 |
$result .= $l['between_last_two'] . $arg; |
9 | 5364 |
} else { |
0 | 5365 |
$result .= $l['between'] . $arg; |
9 | 5366 |
} |
0 | 5367 |
} |
16 | 5368 |
|
9 | 5369 |
return $result . substr( $pattern, 2 ); |
0 | 5370 |
} |
5371 |
||
5372 |
/** |
|
16 | 5373 |
* Safely extracts not more than the first $count characters from HTML string. |
0 | 5374 |
* |
5375 |
* UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* |
|
5376 |
* be counted as one character. For example & will be counted as 4, < as |
|
5377 |
* 3, etc. |
|
5378 |
* |
|
5379 |
* @since 2.5.0 |
|
5380 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5381 |
* @param string $str String to get the excerpt from. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5382 |
* @param int $count Maximum number of characters to take. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5383 |
* @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string. |
0 | 5384 |
* @return string The excerpt. |
5385 |
*/ |
|
5386 |
function wp_html_excerpt( $str, $count, $more = null ) { |
|
9 | 5387 |
if ( null === $more ) { |
0 | 5388 |
$more = ''; |
9 | 5389 |
} |
16 | 5390 |
|
9 | 5391 |
$str = wp_strip_all_tags( $str, true ); |
0 | 5392 |
$excerpt = mb_substr( $str, 0, $count ); |
16 | 5393 |
|
5394 |
// Remove part of an entity at the end. |
|
0 | 5395 |
$excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5396 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5397 |
if ( $str !== $excerpt ) { |
0 | 5398 |
$excerpt = trim( $excerpt ) . $more; |
9 | 5399 |
} |
16 | 5400 |
|
0 | 5401 |
return $excerpt; |
5402 |
} |
|
5403 |
||
5404 |
/** |
|
19 | 5405 |
* Adds a base URL to relative links in passed content. |
0 | 5406 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5407 |
* By default, this function supports the 'src' and 'href' attributes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5408 |
* However, this can be modified via the `$attrs` parameter. |
0 | 5409 |
* |
5410 |
* @since 2.7.0 |
|
5411 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5412 |
* @global string $_links_add_base |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5413 |
* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
5414 |
* @param string $content String to search for links in. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
5415 |
* @param string $base The base URL to prefix to links. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
5416 |
* @param string[] $attrs The attributes which should be processed. |
0 | 5417 |
* @return string The processed content. |
5418 |
*/ |
|
9 | 5419 |
function links_add_base_url( $content, $base, $attrs = array( 'src', 'href' ) ) { |
0 | 5420 |
global $_links_add_base; |
5421 |
$_links_add_base = $base; |
|
9 | 5422 |
$attrs = implode( '|', (array) $attrs ); |
0 | 5423 |
return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content ); |
5424 |
} |
|
5425 |
||
5426 |
/** |
|
19 | 5427 |
* Callback to add a base URL to relative links in passed content. |
0 | 5428 |
* |
5429 |
* @since 2.7.0 |
|
5430 |
* @access private |
|
5431 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5432 |
* @global string $_links_add_base |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5433 |
* |
0 | 5434 |
* @param string $m The matched link. |
5435 |
* @return string The processed link. |
|
5436 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5437 |
function _links_add_base( $m ) { |
0 | 5438 |
global $_links_add_base; |
16 | 5439 |
// 1 = attribute name 2 = quotation mark 3 = URL. |
0 | 5440 |
return $m[1] . '=' . $m[2] . |
16 | 5441 |
( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols(), true ) ? |
0 | 5442 |
$m[3] : |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5443 |
WP_Http::make_absolute_url( $m[3], $_links_add_base ) |
5 | 5444 |
) |
0 | 5445 |
. $m[2]; |
5446 |
} |
|
5447 |
||
5448 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5449 |
* Adds a target attribute to all links in passed content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5450 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5451 |
* By default, this function only applies to `<a>` tags. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5452 |
* However, this can be modified via the `$tags` parameter. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5453 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5454 |
* *NOTE:* Any current target attribute will be stripped and replaced. |
0 | 5455 |
* |
5456 |
* @since 2.7.0 |
|
5457 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5458 |
* @global string $_links_add_target |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5459 |
* |
16 | 5460 |
* @param string $content String to search for links in. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5461 |
* @param string $target The target to add to the links. |
16 | 5462 |
* @param string[] $tags An array of tags to apply to. |
0 | 5463 |
* @return string The processed content. |
5464 |
*/ |
|
9 | 5465 |
function links_add_target( $content, $target = '_blank', $tags = array( 'a' ) ) { |
0 | 5466 |
global $_links_add_target; |
5467 |
$_links_add_target = $target; |
|
9 | 5468 |
$tags = implode( '|', (array) $tags ); |
18 | 5469 |
return preg_replace_callback( "!<($tags)((\s[^>]*)?)>!i", '_links_add_target', $content ); |
0 | 5470 |
} |
5471 |
||
5472 |
/** |
|
5473 |
* Callback to add a target attribute to all links in passed content. |
|
5474 |
* |
|
5475 |
* @since 2.7.0 |
|
5476 |
* @access private |
|
5477 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5478 |
* @global string $_links_add_target |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5479 |
* |
0 | 5480 |
* @param string $m The matched link. |
5481 |
* @return string The processed link. |
|
5482 |
*/ |
|
5483 |
function _links_add_target( $m ) { |
|
5484 |
global $_links_add_target; |
|
9 | 5485 |
$tag = $m[1]; |
5486 |
$link = preg_replace( '|( target=([\'"])(.*?)\2)|i', '', $m[2] ); |
|
0 | 5487 |
return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">'; |
5488 |
} |
|
5489 |
||
5490 |
/** |
|
19 | 5491 |
* Normalizes EOL characters and strips duplicate whitespace. |
0 | 5492 |
* |
5493 |
* @since 2.7.0 |
|
5494 |
* |
|
5495 |
* @param string $str The string to normalize. |
|
5496 |
* @return string The normalized string. |
|
5497 |
*/ |
|
5498 |
function normalize_whitespace( $str ) { |
|
9 | 5499 |
$str = trim( $str ); |
5500 |
$str = str_replace( "\r", "\n", $str ); |
|
5501 |
$str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str ); |
|
0 | 5502 |
return $str; |
5503 |
} |
|
5504 |
||
5505 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
5506 |
* Properly strips all HTML tags including 'script' and 'style'. |
0 | 5507 |
* |
5 | 5508 |
* This differs from strip_tags() because it removes the contents of |
5509 |
* the `<script>` and `<style>` tags. E.g. `strip_tags( '<script>something</script>' )` |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
5510 |
* will return 'something'. wp_strip_all_tags() will return an empty string. |
5 | 5511 |
* |
0 | 5512 |
* @since 2.9.0 |
5513 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5514 |
* @param string $text String containing HTML tags |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5515 |
* @param bool $remove_breaks Optional. Whether to remove left over line breaks and white space chars |
0 | 5516 |
* @return string The processed string. |
5517 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5518 |
function wp_strip_all_tags( $text, $remove_breaks = false ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5519 |
if ( is_null( $text ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5520 |
return ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5521 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5522 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5523 |
if ( ! is_scalar( $text ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5524 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5525 |
* To maintain consistency with pre-PHP 8 error levels, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5526 |
* wp_trigger_error() is used to trigger an E_USER_WARNING, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5527 |
* rather than _doing_it_wrong(), which triggers an E_USER_NOTICE. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5528 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5529 |
wp_trigger_error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5530 |
'', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5531 |
sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5532 |
/* translators: 1: The function name, 2: The argument number, 3: The argument name, 4: The expected type, 5: The provided type. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5533 |
__( 'Warning: %1$s expects parameter %2$s (%3$s) to be a %4$s, %5$s given.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5534 |
__FUNCTION__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5535 |
'#1', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5536 |
'$text', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5537 |
'string', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5538 |
gettype( $text ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5539 |
), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5540 |
E_USER_WARNING |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5541 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5542 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5543 |
return ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5544 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5545 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5546 |
$text = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $text ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5547 |
$text = strip_tags( $text ); |
9 | 5548 |
|
5549 |
if ( $remove_breaks ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5550 |
$text = preg_replace( '/[\r\n\t ]+/', ' ', $text ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5551 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5552 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5553 |
return trim( $text ); |
0 | 5554 |
} |
5555 |
||
5556 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5557 |
* Sanitizes a string from user input or from the database. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5558 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5559 |
* - Checks for invalid UTF-8, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5560 |
* - Converts single `<` characters to entities |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5561 |
* - Strips all tags |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5562 |
* - Removes line breaks, tabs, and extra whitespace |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5563 |
* - Strips percent-encoded characters |
0 | 5564 |
* |
5565 |
* @since 2.9.0 |
|
5566 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5567 |
* @see sanitize_textarea_field() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5568 |
* @see wp_check_invalid_utf8() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5569 |
* @see wp_strip_all_tags() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5570 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5571 |
* @param string $str String to sanitize. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5572 |
* @return string Sanitized string. |
0 | 5573 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5574 |
function sanitize_text_field( $str ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5575 |
$filtered = _sanitize_text_fields( $str, false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5576 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5577 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5578 |
* Filters a sanitized text field string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5579 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5580 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5581 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5582 |
* @param string $filtered The sanitized string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5583 |
* @param string $str The string prior to being sanitized. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5584 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5585 |
return apply_filters( 'sanitize_text_field', $filtered, $str ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5586 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5587 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5588 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5589 |
* Sanitizes a multiline string from user input or from the database. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5590 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5591 |
* The function is like sanitize_text_field(), but preserves |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5592 |
* new lines (\n) and other whitespace, which are legitimate |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5593 |
* input in textarea elements. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5594 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5595 |
* @see sanitize_text_field() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5596 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5597 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5598 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5599 |
* @param string $str String to sanitize. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5600 |
* @return string Sanitized string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5601 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5602 |
function sanitize_textarea_field( $str ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5603 |
$filtered = _sanitize_text_fields( $str, true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5604 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5605 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5606 |
* Filters a sanitized textarea field string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5607 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5608 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5609 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5610 |
* @param string $filtered The sanitized string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5611 |
* @param string $str The string prior to being sanitized. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5612 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5613 |
return apply_filters( 'sanitize_textarea_field', $filtered, $str ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5614 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5615 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5616 |
/** |
19 | 5617 |
* Internal helper function to sanitize a string from user input or from the database. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5618 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5619 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5620 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5621 |
* |
16 | 5622 |
* @param string $str String to sanitize. |
5623 |
* @param bool $keep_newlines Optional. Whether to keep newlines. Default: false. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5624 |
* @return string Sanitized string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5625 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5626 |
function _sanitize_text_fields( $str, $keep_newlines = false ) { |
9 | 5627 |
if ( is_object( $str ) || is_array( $str ) ) { |
5628 |
return ''; |
|
5629 |
} |
|
5630 |
||
5631 |
$str = (string) $str; |
|
5632 |
||
0 | 5633 |
$filtered = wp_check_invalid_utf8( $str ); |
5634 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5635 |
if ( str_contains( $filtered, '<' ) ) { |
0 | 5636 |
$filtered = wp_pre_kses_less_than( $filtered ); |
5637 |
// This will strip extra whitespace for us. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5638 |
$filtered = wp_strip_all_tags( $filtered, false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5639 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5640 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5641 |
* Use HTML entities in a special case to make sure that |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5642 |
* later newline stripping stages cannot lead to a functional tag. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5643 |
*/ |
9 | 5644 |
$filtered = str_replace( "<\n", "<\n", $filtered ); |
0 | 5645 |
} |
5646 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5647 |
if ( ! $keep_newlines ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5648 |
$filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5649 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5650 |
$filtered = trim( $filtered ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5651 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5652 |
// Remove percent-encoded characters. |
0 | 5653 |
$found = false; |
9 | 5654 |
while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $match ) ) { |
5655 |
$filtered = str_replace( $match[0], '', $filtered ); |
|
5656 |
$found = true; |
|
0 | 5657 |
} |
5658 |
||
5659 |
if ( $found ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5660 |
// Strip out the whitespace that may now exist after removing percent-encoded characters. |
9 | 5661 |
$filtered = trim( preg_replace( '/ +/', ' ', $filtered ) ); |
0 | 5662 |
} |
5663 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5664 |
return $filtered; |
0 | 5665 |
} |
5666 |
||
5667 |
/** |
|
19 | 5668 |
* i18n-friendly version of basename(). |
0 | 5669 |
* |
5670 |
* @since 3.1.0 |
|
5671 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5672 |
* @param string $path A path. |
0 | 5673 |
* @param string $suffix If the filename ends in suffix this will also be cut off. |
5674 |
* @return string |
|
5675 |
*/ |
|
5676 |
function wp_basename( $path, $suffix = '' ) { |
|
5677 |
return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) ); |
|
5678 |
} |
|
5679 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5680 |
// phpcs:disable WordPress.WP.CapitalPDangit.MisspelledInComment,WordPress.WP.CapitalPDangit.MisspelledInText,WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid -- 8-) |
0 | 5681 |
/** |
5682 |
* Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence). |
|
5683 |
* |
|
5684 |
* Violating our coding standards for a good function name. |
|
5685 |
* |
|
5686 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5687 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5688 |
* @param string $text The text to be modified. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5689 |
* @return string The modified text. |
0 | 5690 |
*/ |
5691 |
function capital_P_dangit( $text ) { |
|
16 | 5692 |
// Simple replacement for titles. |
5 | 5693 |
$current_filter = current_filter(); |
9 | 5694 |
if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) { |
0 | 5695 |
return str_replace( 'Wordpress', 'WordPress', $text ); |
9 | 5696 |
} |
16 | 5697 |
// Still here? Use the more judicious replacement. |
0 | 5698 |
static $dblq = false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5699 |
if ( false === $dblq ) { |
0 | 5700 |
$dblq = _x( '“', 'opening curly double quote' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5701 |
} |
0 | 5702 |
return str_replace( |
5703 |
array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ), |
|
5704 |
array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ), |
|
9 | 5705 |
$text |
5706 |
); |
|
0 | 5707 |
} |
9 | 5708 |
// phpcs:enable |
0 | 5709 |
|
5710 |
/** |
|
19 | 5711 |
* Sanitizes a mime type |
0 | 5712 |
* |
5713 |
* @since 3.1.3 |
|
5714 |
* |
|
19 | 5715 |
* @param string $mime_type Mime type. |
5716 |
* @return string Sanitized mime type. |
|
0 | 5717 |
*/ |
5718 |
function sanitize_mime_type( $mime_type ) { |
|
5719 |
$sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type ); |
|
5 | 5720 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5721 |
* Filters a mime type following sanitization. |
5 | 5722 |
* |
5723 |
* @since 3.1.3 |
|
5724 |
* |
|
5725 |
* @param string $sani_mime_type The sanitized mime type. |
|
5726 |
* @param string $mime_type The mime type prior to sanitization. |
|
5727 |
*/ |
|
0 | 5728 |
return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type ); |
5729 |
} |
|
5730 |
||
5731 |
/** |
|
19 | 5732 |
* Sanitizes space or carriage return separated URLs that are used to send trackbacks. |
0 | 5733 |
* |
5734 |
* @since 3.4.0 |
|
5735 |
* |
|
5736 |
* @param string $to_ping Space or carriage return separated URLs |
|
5737 |
* @return string URLs starting with the http or https protocol, separated by a carriage return. |
|
5738 |
*/ |
|
5739 |
function sanitize_trackback_urls( $to_ping ) { |
|
5740 |
$urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY ); |
|
5741 |
foreach ( $urls_to_ping as $k => $url ) { |
|
9 | 5742 |
if ( ! preg_match( '#^https?://.#i', $url ) ) { |
5743 |
unset( $urls_to_ping[ $k ] ); |
|
5744 |
} |
|
0 | 5745 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5746 |
$urls_to_ping = array_map( 'sanitize_url', $urls_to_ping ); |
0 | 5747 |
$urls_to_ping = implode( "\n", $urls_to_ping ); |
5 | 5748 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5749 |
* Filters a list of trackback URLs following sanitization. |
5 | 5750 |
* |
5751 |
* The string returned here consists of a space or carriage return-delimited list |
|
5752 |
* of trackback URLs. |
|
5753 |
* |
|
5754 |
* @since 3.4.0 |
|
5755 |
* |
|
5756 |
* @param string $urls_to_ping Sanitized space or carriage return separated URLs. |
|
5757 |
* @param string $to_ping Space or carriage return separated URLs before sanitization. |
|
5758 |
*/ |
|
0 | 5759 |
return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping ); |
5760 |
} |
|
5761 |
||
5762 |
/** |
|
18 | 5763 |
* Adds slashes to a string or recursively adds slashes to strings within an array. |
0 | 5764 |
* |
5765 |
* This should be used when preparing data for core API that expects slashed data. |
|
5766 |
* This should not be used to escape data going directly into an SQL query. |
|
5767 |
* |
|
5768 |
* @since 3.6.0 |
|
16 | 5769 |
* @since 5.5.0 Non-string values are left untouched. |
5770 |
* |
|
18 | 5771 |
* @param string|array $value String or array of data to slash. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5772 |
* @return string|array Slashed `$value`, in the same type as supplied. |
0 | 5773 |
*/ |
5774 |
function wp_slash( $value ) { |
|
5775 |
if ( is_array( $value ) ) { |
|
16 | 5776 |
$value = array_map( 'wp_slash', $value ); |
5777 |
} |
|
5778 |
||
5779 |
if ( is_string( $value ) ) { |
|
5780 |
return addslashes( $value ); |
|
0 | 5781 |
} |
5782 |
||
5783 |
return $value; |
|
5784 |
} |
|
5785 |
||
5786 |
/** |
|
18 | 5787 |
* Removes slashes from a string or recursively removes slashes from strings within an array. |
0 | 5788 |
* |
5789 |
* This should be used to remove slashes from data passed to core API that |
|
5790 |
* expects data to be unslashed. |
|
5791 |
* |
|
5792 |
* @since 3.6.0 |
|
5793 |
* |
|
18 | 5794 |
* @param string|array $value String or array of data to unslash. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5795 |
* @return string|array Unslashed `$value`, in the same type as supplied. |
0 | 5796 |
*/ |
5797 |
function wp_unslash( $value ) { |
|
5798 |
return stripslashes_deep( $value ); |
|
5799 |
} |
|
5800 |
||
5801 |
/** |
|
19 | 5802 |
* Extracts and returns the first URL from passed content. |
0 | 5803 |
* |
5804 |
* @since 3.6.0 |
|
5805 |
* |
|
5806 |
* @param string $content A string which might contain a URL. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5807 |
* @return string|false The found URL. |
0 | 5808 |
*/ |
5809 |
function get_url_in_content( $content ) { |
|
5 | 5810 |
if ( empty( $content ) ) { |
5811 |
return false; |
|
5812 |
} |
|
5813 |
||
5814 |
if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5815 |
return sanitize_url( $matches[2] ); |
5 | 5816 |
} |
0 | 5817 |
|
5818 |
return false; |
|
5819 |
} |
|
5 | 5820 |
|
5821 |
/** |
|
5822 |
* Returns the regexp for common whitespace characters. |
|
5823 |
* |
|
5824 |
* By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp. |
|
16 | 5825 |
* This is designed to replace the PCRE \s sequence. In ticket #22692, that |
5 | 5826 |
* sequence was found to be unreliable due to random inclusion of the A0 byte. |
5827 |
* |
|
5828 |
* @since 4.0.0 |
|
5829 |
* |
|
5830 |
* @return string The spaces regexp. |
|
5831 |
*/ |
|
5832 |
function wp_spaces_regexp() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5833 |
static $spaces = ''; |
5 | 5834 |
|
5835 |
if ( empty( $spaces ) ) { |
|
5836 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5837 |
* Filters the regexp for common whitespace characters. |
5 | 5838 |
* |
5839 |
* This string is substituted for the \s sequence as needed in regular |
|
5840 |
* expressions. For websites not written in English, different characters |
|
5841 |
* may represent whitespace. For websites not encoded in UTF-8, the 0xC2 0xA0 |
|
5842 |
* sequence may not be in use. |
|
5843 |
* |
|
5844 |
* @since 4.0.0 |
|
5845 |
* |
|
5846 |
* @param string $spaces Regexp pattern for matching common whitespace characters. |
|
5847 |
*/ |
|
5848 |
$spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0| ' ); |
|
5849 |
} |
|
5850 |
||
5851 |
return $spaces; |
|
5852 |
} |
|
5853 |
||
5854 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5855 |
* Enqueues the important emoji-related styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5856 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5857 |
* @since 6.4.0 |
5 | 5858 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5859 |
function wp_enqueue_emoji_styles() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5860 |
// Back-compat for plugins that disable functionality by unhooking this action. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5861 |
$action = is_admin() ? 'admin_print_styles' : 'wp_print_styles'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5862 |
if ( ! has_action( $action, 'print_emoji_styles' ) ) { |
5 | 5863 |
return; |
5864 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5865 |
remove_action( $action, 'print_emoji_styles' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5866 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5867 |
$emoji_styles = ' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5868 |
img.wp-smiley, img.emoji { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5869 |
display: inline !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5870 |
border: none !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5871 |
box-shadow: none !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5872 |
height: 1em !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5873 |
width: 1em !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5874 |
margin: 0 0.07em !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5875 |
vertical-align: -0.1em !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5876 |
background: none !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5877 |
padding: 0 !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5878 |
}'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5879 |
$handle = 'wp-emoji-styles'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5880 |
wp_register_style( $handle, false ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5881 |
wp_add_inline_style( $handle, $emoji_styles ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5882 |
wp_enqueue_style( $handle ); |
5 | 5883 |
} |
5884 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5885 |
/** |
19 | 5886 |
* Prints the inline Emoji detection script if it is not already printed. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5887 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5888 |
* @since 4.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5889 |
*/ |
5 | 5890 |
function print_emoji_detection_script() { |
5891 |
static $printed = false; |
|
5892 |
||
5893 |
if ( $printed ) { |
|
5894 |
return; |
|
5895 |
} |
|
5896 |
||
5897 |
$printed = true; |
|
5898 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5899 |
_print_emoji_detection_script(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5900 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5901 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5902 |
/** |
16 | 5903 |
* Prints inline Emoji detection script. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5904 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5905 |
* @ignore |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5906 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5907 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5908 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5909 |
function _print_emoji_detection_script() { |
5 | 5910 |
$settings = array( |
5911 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5912 |
* Filters the URL where emoji png images are hosted. |
5 | 5913 |
* |
5914 |
* @since 4.2.0 |
|
5915 |
* |
|
16 | 5916 |
* @param string $url The emoji base URL for png images. |
5 | 5917 |
*/ |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
5918 |
'baseUrl' => apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/16.0.1/72x72/' ), |
5 | 5919 |
|
5920 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5921 |
* Filters the extension of the emoji png files. |
5 | 5922 |
* |
5923 |
* @since 4.2.0 |
|
5924 |
* |
|
16 | 5925 |
* @param string $extension The emoji extension for png files. Default .png. |
5 | 5926 |
*/ |
9 | 5927 |
'ext' => apply_filters( 'emoji_ext', '.png' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5928 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5929 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5930 |
* Filters the URL where emoji SVG images are hosted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5931 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5932 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5933 |
* |
16 | 5934 |
* @param string $url The emoji base URL for svg images. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5935 |
*/ |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
5936 |
'svgUrl' => apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/16.0.1/svg/' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5937 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5938 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5939 |
* Filters the extension of the emoji SVG files. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5940 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5941 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5942 |
* |
16 | 5943 |
* @param string $extension The emoji extension for svg files. Default .svg. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5944 |
*/ |
9 | 5945 |
'svgExt' => apply_filters( 'emoji_svg_ext', '.svg' ), |
5 | 5946 |
); |
5947 |
||
19 | 5948 |
$version = 'ver=' . get_bloginfo( 'version' ); |
5 | 5949 |
|
5950 |
if ( SCRIPT_DEBUG ) { |
|
5951 |
$settings['source'] = array( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5952 |
/** This filter is documented in wp-includes/class-wp-scripts.php */ |
5 | 5953 |
'wpemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji.js?$version" ), 'wpemoji' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5954 |
/** This filter is documented in wp-includes/class-wp-scripts.php */ |
5 | 5955 |
'twemoji' => apply_filters( 'script_loader_src', includes_url( "js/twemoji.js?$version" ), 'twemoji' ), |
5956 |
); |
|
5957 |
} else { |
|
5958 |
$settings['source'] = array( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5959 |
/** This filter is documented in wp-includes/class-wp-scripts.php */ |
5 | 5960 |
'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ), |
5961 |
); |
|
19 | 5962 |
} |
5963 |
||
5964 |
wp_print_inline_script_tag( |
|
5965 |
sprintf( 'window._wpemojiSettings = %s;', wp_json_encode( $settings ) ) . "\n" . |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5966 |
file_get_contents( ABSPATH . WPINC . '/js/wp-emoji-loader' . wp_scripts_get_suffix() . '.js' ) |
19 | 5967 |
); |
5 | 5968 |
} |
5969 |
||
5970 |
/** |
|
19 | 5971 |
* Converts emoji characters to their equivalent HTML entity. |
5 | 5972 |
* |
5973 |
* This allows us to store emoji in a DB using the utf8 character set. |
|
5974 |
* |
|
5975 |
* @since 4.2.0 |
|
5976 |
* |
|
5977 |
* @param string $content The content to encode. |
|
5978 |
* @return string The encoded content. |
|
5979 |
*/ |
|
5980 |
function wp_encode_emoji( $content ) { |
|
16 | 5981 |
$emoji = _wp_emoji_list( 'partials' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5982 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5983 |
foreach ( $emoji as $emojum ) { |
16 | 5984 |
$emoji_char = html_entity_decode( $emojum ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5985 |
if ( str_contains( $content, $emoji_char ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5986 |
$content = preg_replace( "/$emoji_char/", $emojum, $content ); |
5 | 5987 |
} |
5988 |
} |
|
5989 |
||
5990 |
return $content; |
|
5991 |
} |
|
5992 |
||
5993 |
/** |
|
19 | 5994 |
* Converts emoji to a static img element. |
5 | 5995 |
* |
5996 |
* @since 4.2.0 |
|
5997 |
* |
|
5998 |
* @param string $text The content to encode. |
|
5999 |
* @return string The encoded content. |
|
6000 |
*/ |
|
6001 |
function wp_staticize_emoji( $text ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6002 |
if ( ! str_contains( $text, '&#x' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6003 |
if ( ( function_exists( 'mb_check_encoding' ) && mb_check_encoding( $text, 'ASCII' ) ) || ! preg_match( '/[^\x00-\x7F]/', $text ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6004 |
// The text doesn't contain anything that might be emoji, so we can return early. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6005 |
return $text; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6006 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6007 |
$encoded_text = wp_encode_emoji( $text ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6008 |
if ( $encoded_text === $text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6009 |
return $encoded_text; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6010 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6011 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6012 |
$text = $encoded_text; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6013 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6014 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6015 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6016 |
$emoji = _wp_emoji_list( 'entities' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6017 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6018 |
// Quickly narrow down the list of emoji that might be in the text and need replacing. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6019 |
$possible_emoji = array(); |
9 | 6020 |
foreach ( $emoji as $emojum ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6021 |
if ( str_contains( $text, $emojum ) ) { |
16 | 6022 |
$possible_emoji[ $emojum ] = html_entity_decode( $emojum ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6023 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6024 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6025 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6026 |
if ( ! $possible_emoji ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6027 |
return $text; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6028 |
} |
5 | 6029 |
|
6030 |
/** This filter is documented in wp-includes/formatting.php */ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
6031 |
$cdn_url = apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/16.0.1/72x72/' ); |
5 | 6032 |
|
6033 |
/** This filter is documented in wp-includes/formatting.php */ |
|
6034 |
$ext = apply_filters( 'emoji_ext', '.png' ); |
|
6035 |
||
6036 |
$output = ''; |
|
6037 |
/* |
|
6038 |
* HTML loop taken from smiley function, which was taken from texturize function. |
|
6039 |
* It'll never be consolidated. |
|
6040 |
* |
|
6041 |
* First, capture the tags as well as in between. |
|
6042 |
*/ |
|
6043 |
$textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
|
9 | 6044 |
$stop = count( $textarr ); |
5 | 6045 |
|
6046 |
// Ignore processing of specific tags. |
|
9 | 6047 |
$tags_to_ignore = 'code|pre|style|script|textarea'; |
5 | 6048 |
$ignore_block_element = ''; |
6049 |
||
6050 |
for ( $i = 0; $i < $stop; $i++ ) { |
|
9 | 6051 |
$content = $textarr[ $i ]; |
5 | 6052 |
|
6053 |
// If we're in an ignore block, wait until we find its closing tag. |
|
16 | 6054 |
if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) { |
5 | 6055 |
$ignore_block_element = $matches[1]; |
6056 |
} |
|
6057 |
||
6058 |
// If it's not a tag and not in ignore block. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6059 |
if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] && str_contains( $content, '&#x' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6060 |
foreach ( $possible_emoji as $emojum => $emoji_char ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6061 |
if ( ! str_contains( $content, $emojum ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6062 |
continue; |
5 | 6063 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6064 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6065 |
$file = str_replace( ';&#x', '-', $emojum ); |
9 | 6066 |
$file = str_replace( array( '&#x', ';' ), '', $file ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6067 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6068 |
$entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $file . $ext, $emoji_char ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6069 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6070 |
$content = str_replace( $emojum, $entity, $content ); |
5 | 6071 |
} |
6072 |
} |
|
6073 |
||
16 | 6074 |
// Did we exit ignore block? |
6075 |
if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) { |
|
5 | 6076 |
$ignore_block_element = ''; |
6077 |
} |
|
6078 |
||
6079 |
$output .= $content; |
|
6080 |
} |
|
6081 |
||
16 | 6082 |
// Finally, remove any stray U+FE0F characters. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6083 |
$output = str_replace( '️', '', $output ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6084 |
|
5 | 6085 |
return $output; |
6086 |
} |
|
6087 |
||
6088 |
/** |
|
19 | 6089 |
* Converts emoji in emails into static images. |
5 | 6090 |
* |
6091 |
* @since 4.2.0 |
|
6092 |
* |
|
6093 |
* @param array $mail The email data array. |
|
6094 |
* @return array The email data array, with emoji in the message staticized. |
|
6095 |
*/ |
|
6096 |
function wp_staticize_emoji_for_email( $mail ) { |
|
6097 |
if ( ! isset( $mail['message'] ) ) { |
|
6098 |
return $mail; |
|
6099 |
} |
|
6100 |
||
6101 |
/* |
|
19 | 6102 |
* We can only transform the emoji into images if it's a `text/html` email. |
5 | 6103 |
* To do that, here's a cut down version of the same process that happens |
19 | 6104 |
* in wp_mail() - get the `Content-Type` from the headers, if there is one, |
6105 |
* then pass it through the {@see 'wp_mail_content_type'} filter, in case |
|
6106 |
* a plugin is handling changing the `Content-Type`. |
|
5 | 6107 |
*/ |
6108 |
$headers = array(); |
|
6109 |
if ( isset( $mail['headers'] ) ) { |
|
6110 |
if ( is_array( $mail['headers'] ) ) { |
|
6111 |
$headers = $mail['headers']; |
|
6112 |
} else { |
|
6113 |
$headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) ); |
|
6114 |
} |
|
6115 |
} |
|
6116 |
||
6117 |
foreach ( $headers as $header ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6118 |
if ( ! str_contains( $header, ':' ) ) { |
5 | 6119 |
continue; |
6120 |
} |
|
6121 |
||
6122 |
// Explode them out. |
|
6123 |
list( $name, $content ) = explode( ':', trim( $header ), 2 ); |
|
6124 |
||
6125 |
// Cleanup crew. |
|
9 | 6126 |
$name = trim( $name ); |
5 | 6127 |
$content = trim( $content ); |
6128 |
||
6129 |
if ( 'content-type' === strtolower( $name ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6130 |
if ( str_contains( $content, ';' ) ) { |
5 | 6131 |
list( $type, $charset ) = explode( ';', $content ); |
9 | 6132 |
$content_type = trim( $type ); |
5 | 6133 |
} else { |
6134 |
$content_type = trim( $content ); |
|
6135 |
} |
|
6136 |
break; |
|
6137 |
} |
|
6138 |
} |
|
6139 |
||
6140 |
// Set Content-Type if we don't have a content-type from the input headers. |
|
6141 |
if ( ! isset( $content_type ) ) { |
|
6142 |
$content_type = 'text/plain'; |
|
6143 |
} |
|
6144 |
||
6145 |
/** This filter is documented in wp-includes/pluggable.php */ |
|
6146 |
$content_type = apply_filters( 'wp_mail_content_type', $content_type ); |
|
6147 |
||
6148 |
if ( 'text/html' === $content_type ) { |
|
6149 |
$mail['message'] = wp_staticize_emoji( $mail['message'] ); |
|
6150 |
} |
|
6151 |
||
6152 |
return $mail; |
|
6153 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6154 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6155 |
/** |
9 | 6156 |
* Returns arrays of emoji data. |
6157 |
* |
|
6158 |
* These arrays are automatically built from the regex in twemoji.js - if they need to be updated, |
|
16 | 6159 |
* you should update the regex there, then run the `npm run grunt precommit:emoji` job. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6160 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6161 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6162 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6163 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6164 |
* @param string $type Optional. Which array type to return. Accepts 'partials' or 'entities', default 'entities'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6165 |
* @return array An array to match all emoji that WordPress recognises. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6166 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6167 |
function _wp_emoji_list( $type = 'entities' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6168 |
// Do not remove the START/END comments - they're used to find where to insert the arrays. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6169 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6170 |
// START: emoji arrays |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
6171 |
$entities = array( '👨🏻‍❤️‍💋‍👨🏻', '👨🏻‍❤️‍💋‍👨🏼', '👨🏻‍❤️‍💋‍👨🏽', '👨🏻‍❤️‍💋‍👨🏾', '👨🏻‍❤️‍💋‍👨🏿', '👨🏼‍❤️‍💋‍👨🏻', '👨🏼‍❤️‍💋‍👨🏼', '👨🏼‍❤️‍💋‍👨🏽', '👨🏼‍❤️‍💋‍👨🏾', '👨🏼‍❤️‍💋‍👨🏿', '👨🏽‍❤️‍💋‍👨🏻', '👨🏽‍❤️‍💋‍👨🏼', '👨🏽‍❤️‍💋‍👨🏽', '👨🏽‍❤️‍💋‍👨🏾', '👨🏽‍❤️‍💋‍👨🏿', '👨🏾‍❤️‍💋‍👨🏻', '👨🏾‍❤️‍💋‍👨🏼', '👨🏾‍❤️‍💋‍👨🏽', '👨🏾‍❤️‍💋‍👨🏾', '👨🏾‍❤️‍💋‍👨🏿', '👨🏿‍❤️‍💋‍👨🏻', '👨🏿‍❤️‍💋‍👨🏼', '👨🏿‍❤️‍💋‍👨🏽', '👨🏿‍❤️‍💋‍👨🏾', '👨🏿‍❤️‍💋‍👨🏿', '👩🏻‍❤️‍💋‍👨🏻', '👩🏻‍❤️‍💋‍👨🏼', '👩🏻‍❤️‍💋‍👨🏽', '👩🏻‍❤️‍💋‍👨🏾', '👩🏻‍❤️‍💋‍👨🏿', '👩🏻‍❤️‍💋‍👩🏻', '👩🏻‍❤️‍💋‍👩🏼', '👩🏻‍❤️‍💋‍👩🏽', '👩🏻‍❤️‍💋‍👩🏾', '👩🏻‍❤️‍💋‍👩🏿', '👩🏼‍❤️‍💋‍👨🏻', '👩🏼‍❤️‍💋‍👨🏼', '👩🏼‍❤️‍💋‍👨🏽', '👩🏼‍❤️‍💋‍👨🏾', '👩🏼‍❤️‍💋‍👨🏿', '👩🏼‍❤️‍💋‍👩🏻', '👩🏼‍❤️‍💋‍👩🏼', '👩🏼‍❤️‍💋‍👩🏽', '👩🏼‍❤️‍💋‍👩🏾', '👩🏼‍❤️‍💋‍👩🏿', '👩🏽‍❤️‍💋‍👨🏻', '👩🏽‍❤️‍💋‍👨🏼', '👩🏽‍❤️‍💋‍👨🏽', '👩🏽‍❤️‍💋‍👨🏾', '👩🏽‍❤️‍💋‍👨🏿', '👩🏽‍❤️‍💋‍👩🏻', '👩🏽‍❤️‍💋‍👩🏼', '👩🏽‍❤️‍💋‍👩🏽', '👩🏽‍❤️‍💋‍👩🏾', '👩🏽‍❤️‍💋‍👩🏿', '👩🏾‍❤️‍💋‍👨🏻', '👩🏾‍❤️‍💋‍👨🏼', '👩🏾‍❤️‍💋‍👨🏽', '👩🏾‍❤️‍💋‍👨🏾', '👩🏾‍❤️‍💋‍👨🏿', '👩🏾‍❤️‍💋‍👩🏻', '👩🏾‍❤️‍💋‍👩🏼', '👩🏾‍❤️‍💋‍👩🏽', '👩🏾‍❤️‍💋‍👩🏾', '👩🏾‍❤️‍💋‍👩🏿', '👩🏿‍❤️‍💋‍👨🏻', '👩🏿‍❤️‍💋‍👨🏼', '👩🏿‍❤️‍💋‍👨🏽', '👩🏿‍❤️‍💋‍👨🏾', '👩🏿‍❤️‍💋‍👨🏿', '👩🏿‍❤️‍💋‍👩🏻', '👩🏿‍❤️‍💋‍👩🏼', '👩🏿‍❤️‍💋‍👩🏽', '👩🏿‍❤️‍💋‍👩🏾', '👩🏿‍❤️‍💋‍👩🏿', '🧑🏻‍❤️‍💋‍🧑🏼', '🧑🏻‍❤️‍💋‍🧑🏽', '🧑🏻‍❤️‍💋‍🧑🏾', '🧑🏻‍❤️‍💋‍🧑🏿', '🧑🏼‍❤️‍💋‍🧑🏻', '🧑🏼‍❤️‍💋‍🧑🏽', '🧑🏼‍❤️‍💋‍🧑🏾', '🧑🏼‍❤️‍💋‍🧑🏿', '🧑🏽‍❤️‍💋‍🧑🏻', '🧑🏽‍❤️‍💋‍🧑🏼', '🧑🏽‍❤️‍💋‍🧑🏾', '🧑🏽‍❤️‍💋‍🧑🏿', '🧑🏾‍❤️‍💋‍🧑🏻', '🧑🏾‍❤️‍💋‍🧑🏼', '🧑🏾‍❤️‍💋‍🧑🏽', '🧑🏾‍❤️‍💋‍🧑🏿', '🧑🏿‍❤️‍💋‍🧑🏻', '🧑🏿‍❤️‍💋‍🧑🏼', '🧑🏿‍❤️‍💋‍🧑🏽', '🧑🏿‍❤️‍💋‍🧑🏾', '👨🏻‍❤️‍👨🏻', '👨🏻‍❤️‍👨🏼', '👨🏻‍❤️‍👨🏽', '👨🏻‍❤️‍👨🏾', '👨🏻‍❤️‍👨🏿', '👨🏼‍❤️‍👨🏻', '👨🏼‍❤️‍👨🏼', '👨🏼‍❤️‍👨🏽', '👨🏼‍❤️‍👨🏾', '👨🏼‍❤️‍👨🏿', '👨🏽‍❤️‍👨🏻', '👨🏽‍❤️‍👨🏼', '👨🏽‍❤️‍👨🏽', '👨🏽‍❤️‍👨🏾', '👨🏽‍❤️‍👨🏿', '👨🏾‍❤️‍👨🏻', '👨🏾‍❤️‍👨🏼', '👨🏾‍❤️‍👨🏽', '👨🏾‍❤️‍👨🏾', '👨🏾‍❤️‍👨🏿', '👨🏿‍❤️‍👨🏻', '👨🏿‍❤️‍👨🏼', '👨🏿‍❤️‍👨🏽', '👨🏿‍❤️‍👨🏾', '👨🏿‍❤️‍👨🏿', '👩🏻‍❤️‍👨🏻', '👩🏻‍❤️‍👨🏼', '👩🏻‍❤️‍👨🏽', '👩🏻‍❤️‍👨🏾', '👩🏻‍❤️‍👨🏿', '👩🏻‍❤️‍👩🏻', '👩🏻‍❤️‍👩🏼', '👩🏻‍❤️‍👩🏽', '👩🏻‍❤️‍👩🏾', '👩🏻‍❤️‍👩🏿', '👩🏼‍❤️‍👨🏻', '👩🏼‍❤️‍👨🏼', '👩🏼‍❤️‍👨🏽', '👩🏼‍❤️‍👨🏾', '👩🏼‍❤️‍👨🏿', '👩🏼‍❤️‍👩🏻', '👩🏼‍❤️‍👩🏼', '👩🏼‍❤️‍👩🏽', '👩🏼‍❤️‍👩🏾', '👩🏼‍❤️‍👩🏿', '👩🏽‍❤️‍👨🏻', '👩🏽‍❤️‍👨🏼', '👩🏽‍❤️‍👨🏽', '👩🏽‍❤️‍👨🏾', '👩🏽‍❤️‍👨🏿', '👩🏽‍❤️‍👩🏻', '👩🏽‍❤️‍👩🏼', '👩🏽‍❤️‍👩🏽', '👩🏽‍❤️‍👩🏾', '👩🏽‍❤️‍👩🏿', '👩🏾‍❤️‍👨🏻', '👩🏾‍❤️‍👨🏼', '👩🏾‍❤️‍👨🏽', '👩🏾‍❤️‍👨🏾', '👩🏾‍❤️‍👨🏿', '👩🏾‍❤️‍👩🏻', '👩🏾‍❤️‍👩🏼', '👩🏾‍❤️‍👩🏽', '👩🏾‍❤️‍👩🏾', '👩🏾‍❤️‍👩🏿', '👩🏿‍❤️‍👨🏻', '👩🏿‍❤️‍👨🏼', '👩🏿‍❤️‍👨🏽', '👩🏿‍❤️‍👨🏾', '👩🏿‍❤️‍👨🏿', '👩🏿‍❤️‍👩🏻', '👩🏿‍❤️‍👩🏼', '👩🏿‍❤️‍👩🏽', '👩🏿‍❤️‍👩🏾', '👩🏿‍❤️‍👩🏿', '🧑🏻‍❤️‍🧑🏼', '🧑🏻‍❤️‍🧑🏽', '🧑🏻‍❤️‍🧑🏾', '🧑🏻‍❤️‍🧑🏿', '🧑🏼‍❤️‍🧑🏻', '🧑🏼‍❤️‍🧑🏽', '🧑🏼‍❤️‍🧑🏾', '🧑🏼‍❤️‍🧑🏿', '🧑🏽‍❤️‍🧑🏻', '🧑🏽‍❤️‍🧑🏼', '🧑🏽‍❤️‍🧑🏾', '🧑🏽‍❤️‍🧑🏿', '🧑🏾‍❤️‍🧑🏻', '🧑🏾‍❤️‍🧑🏼', '🧑🏾‍❤️‍🧑🏽', '🧑🏾‍❤️‍🧑🏿', '🧑🏿‍❤️‍🧑🏻', '🧑🏿‍❤️‍🧑🏼', '🧑🏿‍❤️‍🧑🏽', '🧑🏿‍❤️‍🧑🏾', '👨‍❤️‍💋‍👨', '👩‍❤️‍💋‍👨', '👩‍❤️‍💋‍👩', '🏃🏻‍♀️‍➡️', '🏃🏻‍♂️‍➡️', '🏃🏼‍♀️‍➡️', '🏃🏼‍♂️‍➡️', '🏃🏽‍♀️‍➡️', '🏃🏽‍♂️‍➡️', '🏃🏾‍♀️‍➡️', '🏃🏾‍♂️‍➡️', '🏃🏿‍♀️‍➡️', '🏃🏿‍♂️‍➡️', '🚶🏻‍♀️‍➡️', '🚶🏻‍♂️‍➡️', '🚶🏼‍♀️‍➡️', '🚶🏼‍♂️‍➡️', '🚶🏽‍♀️‍➡️', '🚶🏽‍♂️‍➡️', '🚶🏾‍♀️‍➡️', '🚶🏾‍♂️‍➡️', '🚶🏿‍♀️‍➡️', '🚶🏿‍♂️‍➡️', '🧎🏻‍♀️‍➡️', '🧎🏻‍♂️‍➡️', '🧎🏼‍♀️‍➡️', '🧎🏼‍♂️‍➡️', '🧎🏽‍♀️‍➡️', '🧎🏽‍♂️‍➡️', '🧎🏾‍♀️‍➡️', '🧎🏾‍♂️‍➡️', '🧎🏿‍♀️‍➡️', '🧎🏿‍♂️‍➡️', '🏴󠁧󠁢󠁥󠁮󠁧󠁿', '🏴󠁧󠁢󠁳󠁣󠁴󠁿', '🏴󠁧󠁢󠁷󠁬󠁳󠁿', '👨🏻‍🤝‍👨🏼', '👨🏻‍🤝‍👨🏽', '👨🏻‍🤝‍👨🏾', '👨🏻‍🤝‍👨🏿', '👨🏼‍🤝‍👨🏻', '👨🏼‍🤝‍👨🏽', '👨🏼‍🤝‍👨🏾', '👨🏼‍🤝‍👨🏿', '👨🏽‍🤝‍👨🏻', '👨🏽‍🤝‍👨🏼', '👨🏽‍🤝‍👨🏾', '👨🏽‍🤝‍👨🏿', '👨🏾‍🤝‍👨🏻', '👨🏾‍🤝‍👨🏼', '👨🏾‍🤝‍👨🏽', '👨🏾‍🤝‍👨🏿', '👨🏿‍🤝‍👨🏻', '👨🏿‍🤝‍👨🏼', '👨🏿‍🤝‍👨🏽', '👨🏿‍🤝‍👨🏾', '👩🏻‍🤝‍👨🏼', '👩🏻‍🤝‍👨🏽', '👩🏻‍🤝‍👨🏾', '👩🏻‍🤝‍👨🏿', '👩🏻‍🤝‍👩🏼', '👩🏻‍🤝‍👩🏽', '👩🏻‍🤝‍👩🏾', '👩🏻‍🤝‍👩🏿', '👩🏼‍🤝‍👨🏻', '👩🏼‍🤝‍👨🏽', '👩🏼‍🤝‍👨🏾', '👩🏼‍🤝‍👨🏿', '👩🏼‍🤝‍👩🏻', '👩🏼‍🤝‍👩🏽', '👩🏼‍🤝‍👩🏾', '👩🏼‍🤝‍👩🏿', '👩🏽‍🤝‍👨🏻', '👩🏽‍🤝‍👨🏼', '👩🏽‍🤝‍👨🏾', '👩🏽‍🤝‍👨🏿', '👩🏽‍🤝‍👩🏻', '👩🏽‍🤝‍👩🏼', '👩🏽‍🤝‍👩🏾', '👩🏽‍🤝‍👩🏿', '👩🏾‍🤝‍👨🏻', '👩🏾‍🤝‍👨🏼', '👩🏾‍🤝‍👨🏽', '👩🏾‍🤝‍👨🏿', '👩🏾‍🤝‍👩🏻', '👩🏾‍🤝‍👩🏼', '👩🏾‍🤝‍👩🏽', '👩🏾‍🤝‍👩🏿', '👩🏿‍🤝‍👨🏻', '👩🏿‍🤝‍👨🏼', '👩🏿‍🤝‍👨🏽', '👩🏿‍🤝‍👨🏾', '👩🏿‍🤝‍👩🏻', '👩🏿‍🤝‍👩🏼', '👩🏿‍🤝‍👩🏽', '👩🏿‍🤝‍👩🏾', '🧑🏻‍🤝‍🧑🏻', '🧑🏻‍🤝‍🧑🏼', '🧑🏻‍🤝‍🧑🏽', '🧑🏻‍🤝‍🧑🏾', '🧑🏻‍🤝‍🧑🏿', '🧑🏼‍🤝‍🧑🏻', '🧑🏼‍🤝‍🧑🏼', '🧑🏼‍🤝‍🧑🏽', '🧑🏼‍🤝‍🧑🏾', '🧑🏼‍🤝‍🧑🏿', '🧑🏽‍🤝‍🧑🏻', '🧑🏽‍🤝‍🧑🏼', '🧑🏽‍🤝‍🧑🏽', '🧑🏽‍🤝‍🧑🏾', '🧑🏽‍🤝‍🧑🏿', '🧑🏾‍🤝‍🧑🏻', '🧑🏾‍🤝‍🧑🏼', '🧑🏾‍🤝‍🧑🏽', '🧑🏾‍🤝‍🧑🏾', '🧑🏾‍🤝‍🧑🏿', '🧑🏿‍🤝‍🧑🏻', '🧑🏿‍🤝‍🧑🏼', '🧑🏿‍🤝‍🧑🏽', '🧑🏿‍🤝‍🧑🏾', '🧑🏿‍🤝‍🧑🏿', '👨‍👨‍👦‍👦', '👨‍👨‍👧‍👦', '👨‍👨‍👧‍👧', '👨‍👩‍👦‍👦', '👨‍👩‍👧‍👦', '👨‍👩‍👧‍👧', '👩‍👩‍👦‍👦', '👩‍👩‍👧‍👦', '👩‍👩‍👧‍👧', '🧑‍🧑‍🧒‍🧒', '👨🏻‍🦯‍➡️', '👨🏻‍🦼‍➡️', '👨🏻‍🦽‍➡️', '👨🏼‍🦯‍➡️', '👨🏼‍🦼‍➡️', '👨🏼‍🦽‍➡️', '👨🏽‍🦯‍➡️', '👨🏽‍🦼‍➡️', '👨🏽‍🦽‍➡️', '👨🏾‍🦯‍➡️', '👨🏾‍🦼‍➡️', '👨🏾‍🦽‍➡️', '👨🏿‍🦯‍➡️', '👨🏿‍🦼‍➡️', '👨🏿‍🦽‍➡️', '👩🏻‍🦯‍➡️', '👩🏻‍🦼‍➡️', '👩🏻‍🦽‍➡️', '👩🏼‍🦯‍➡️', '👩🏼‍🦼‍➡️', '👩🏼‍🦽‍➡️', '👩🏽‍🦯‍➡️', '👩🏽‍🦼‍➡️', '👩🏽‍🦽‍➡️', '👩🏾‍🦯‍➡️', '👩🏾‍🦼‍➡️', '👩🏾‍🦽‍➡️', '👩🏿‍🦯‍➡️', '👩🏿‍🦼‍➡️', '👩🏿‍🦽‍➡️', '🧑🏻‍🦯‍➡️', '🧑🏻‍🦼‍➡️', '🧑🏻‍🦽‍➡️', '🧑🏼‍🦯‍➡️', '🧑🏼‍🦼‍➡️', '🧑🏼‍🦽‍➡️', '🧑🏽‍🦯‍➡️', '🧑🏽‍🦼‍➡️', '🧑🏽‍🦽‍➡️', '🧑🏾‍🦯‍➡️', '🧑🏾‍🦼‍➡️', '🧑🏾‍🦽‍➡️', '🧑🏿‍🦯‍➡️', '🧑🏿‍🦼‍➡️', '🧑🏿‍🦽‍➡️', '🏃‍♀️‍➡️', '🏃‍♂️‍➡️', '🚶‍♀️‍➡️', '🚶‍♂️‍➡️', '🧎‍♀️‍➡️', '🧎‍♂️‍➡️', '👨‍🦯‍➡️', '👨‍🦼‍➡️', '👨‍🦽‍➡️', '👨‍❤️‍👨', '👩‍🦯‍➡️', '👩‍🦼‍➡️', '👩‍🦽‍➡️', '👩‍❤️‍👨', '👩‍❤️‍👩', '🧑‍🦯‍➡️', '🧑‍🦼‍➡️', '🧑‍🦽‍➡️', '🫱🏻‍🫲🏼', '🫱🏻‍🫲🏽', '🫱🏻‍🫲🏾', '🫱🏻‍🫲🏿', '🫱🏼‍🫲🏻', '🫱🏼‍🫲🏽', '🫱🏼‍🫲🏾', '🫱🏼‍🫲🏿', '🫱🏽‍🫲🏻', '🫱🏽‍🫲🏼', '🫱🏽‍🫲🏾', '🫱🏽‍🫲🏿', '🫱🏾‍🫲🏻', '🫱🏾‍🫲🏼', '🫱🏾‍🫲🏽', '🫱🏾‍🫲🏿', '🫱🏿‍🫲🏻', '🫱🏿‍🫲🏼', '🫱🏿‍🫲🏽', '🫱🏿‍🫲🏾', '👨‍👦‍👦', '👨‍👧‍👦', '👨‍👧‍👧', '👨‍👨‍👦', '👨‍👨‍👧', '👨‍👩‍👦', '👨‍👩‍👧', '👩‍👦‍👦', '👩‍👧‍👦', '👩‍👧‍👧', '👩‍👩‍👦', '👩‍👩‍👧', '🧑‍🤝‍🧑', '🧑‍🧑‍🧒', '🧑‍🧒‍🧒', '🏃🏻‍♀️', '🏃🏻‍♂️', '🏃🏻‍➡️', '🏃🏼‍♀️', '🏃🏼‍♂️', '🏃🏼‍➡️', '🏃🏽‍♀️', '🏃🏽‍♂️', '🏃🏽‍➡️', '🏃🏾‍♀️', '🏃🏾‍♂️', '🏃🏾‍➡️', '🏃🏿‍♀️', '🏃🏿‍♂️', '🏃🏿‍➡️', '🏄🏻‍♀️', '🏄🏻‍♂️', '🏄🏼‍♀️', '🏄🏼‍♂️', '🏄🏽‍♀️', '🏄🏽‍♂️', '🏄🏾‍♀️', '🏄🏾‍♂️', '🏄🏿‍♀️', '🏄🏿‍♂️', '🏊🏻‍♀️', '🏊🏻‍♂️', '🏊🏼‍♀️', '🏊🏼‍♂️', '🏊🏽‍♀️', '🏊🏽‍♂️', '🏊🏾‍♀️', '🏊🏾‍♂️', '🏊🏿‍♀️', '🏊🏿‍♂️', '🏋🏻‍♀️', '🏋🏻‍♂️', '🏋🏼‍♀️', '🏋🏼‍♂️', '🏋🏽‍♀️', '🏋🏽‍♂️', '🏋🏾‍♀️', '🏋🏾‍♂️', '🏋🏿‍♀️', '🏋🏿‍♂️', '🏌🏻‍♀️', '🏌🏻‍♂️', '🏌🏼‍♀️', '🏌🏼‍♂️', '🏌🏽‍♀️', '🏌🏽‍♂️', '🏌🏾‍♀️', '🏌🏾‍♂️', '🏌🏿‍♀️', '🏌🏿‍♂️', '👨🏻‍⚕️', '👨🏻‍⚖️', '👨🏻‍✈️', '👨🏼‍⚕️', '👨🏼‍⚖️', '👨🏼‍✈️', '👨🏽‍⚕️', '👨🏽‍⚖️', '👨🏽‍✈️', '👨🏾‍⚕️', '👨🏾‍⚖️', '👨🏾‍✈️', '👨🏿‍⚕️', '👨🏿‍⚖️', '👨🏿‍✈️', '👩🏻‍⚕️', '👩🏻‍⚖️', '👩🏻‍✈️', '👩🏼‍⚕️', '👩🏼‍⚖️', '👩🏼‍✈️', '👩🏽‍⚕️', '👩🏽‍⚖️', '👩🏽‍✈️', '👩🏾‍⚕️', '👩🏾‍⚖️', '👩🏾‍✈️', '👩🏿‍⚕️', '👩🏿‍⚖️', '👩🏿‍✈️', '👮🏻‍♀️', '👮🏻‍♂️', '👮🏼‍♀️', '👮🏼‍♂️', '👮🏽‍♀️', '👮🏽‍♂️', '👮🏾‍♀️', '👮🏾‍♂️', '👮🏿‍♀️', '👮🏿‍♂️', '👰🏻‍♀️', '👰🏻‍♂️', '👰🏼‍♀️', '👰🏼‍♂️', '👰🏽‍♀️', '👰🏽‍♂️', '👰🏾‍♀️', '👰🏾‍♂️', '👰🏿‍♀️', '👰🏿‍♂️', '👱🏻‍♀️', '👱🏻‍♂️', '👱🏼‍♀️', '👱🏼‍♂️', '👱🏽‍♀️', '👱🏽‍♂️', '👱🏾‍♀️', '👱🏾‍♂️', '👱🏿‍♀️', '👱🏿‍♂️', '👳🏻‍♀️', '👳🏻‍♂️', '👳🏼‍♀️', '👳🏼‍♂️', '👳🏽‍♀️', '👳🏽‍♂️', '👳🏾‍♀️', '👳🏾‍♂️', '👳🏿‍♀️', '👳🏿‍♂️', '👷🏻‍♀️', '👷🏻‍♂️', '👷🏼‍♀️', '👷🏼‍♂️', '👷🏽‍♀️', '👷🏽‍♂️', '👷🏾‍♀️', '👷🏾‍♂️', '👷🏿‍♀️', '👷🏿‍♂️', '💁🏻‍♀️', '💁🏻‍♂️', '💁🏼‍♀️', '💁🏼‍♂️', '💁🏽‍♀️', '💁🏽‍♂️', '💁🏾‍♀️', '💁🏾‍♂️', '💁🏿‍♀️', '💁🏿‍♂️', '💂🏻‍♀️', '💂🏻‍♂️', '💂🏼‍♀️', '💂🏼‍♂️', '💂🏽‍♀️', '💂🏽‍♂️', '💂🏾‍♀️', '💂🏾‍♂️', '💂🏿‍♀️', '💂🏿‍♂️', '💆🏻‍♀️', '💆🏻‍♂️', '💆🏼‍♀️', '💆🏼‍♂️', '💆🏽‍♀️', '💆🏽‍♂️', '💆🏾‍♀️', '💆🏾‍♂️', '💆🏿‍♀️', '💆🏿‍♂️', '💇🏻‍♀️', '💇🏻‍♂️', '💇🏼‍♀️', '💇🏼‍♂️', '💇🏽‍♀️', '💇🏽‍♂️', '💇🏾‍♀️', '💇🏾‍♂️', '💇🏿‍♀️', '💇🏿‍♂️', '🕴🏻‍♀️', '🕴🏻‍♂️', '🕴🏼‍♀️', '🕴🏼‍♂️', '🕴🏽‍♀️', '🕴🏽‍♂️', '🕴🏾‍♀️', '🕴🏾‍♂️', '🕴🏿‍♀️', '🕴🏿‍♂️', '🕵🏻‍♀️', '🕵🏻‍♂️', '🕵🏼‍♀️', '🕵🏼‍♂️', '🕵🏽‍♀️', '🕵🏽‍♂️', '🕵🏾‍♀️', '🕵🏾‍♂️', '🕵🏿‍♀️', '🕵🏿‍♂️', '🙅🏻‍♀️', '🙅🏻‍♂️', '🙅🏼‍♀️', '🙅🏼‍♂️', '🙅🏽‍♀️', '🙅🏽‍♂️', '🙅🏾‍♀️', '🙅🏾‍♂️', '🙅🏿‍♀️', '🙅🏿‍♂️', '🙆🏻‍♀️', '🙆🏻‍♂️', '🙆🏼‍♀️', '🙆🏼‍♂️', '🙆🏽‍♀️', '🙆🏽‍♂️', '🙆🏾‍♀️', '🙆🏾‍♂️', '🙆🏿‍♀️', '🙆🏿‍♂️', '🙇🏻‍♀️', '🙇🏻‍♂️', '🙇🏼‍♀️', '🙇🏼‍♂️', '🙇🏽‍♀️', '🙇🏽‍♂️', '🙇🏾‍♀️', '🙇🏾‍♂️', '🙇🏿‍♀️', '🙇🏿‍♂️', '🙋🏻‍♀️', '🙋🏻‍♂️', '🙋🏼‍♀️', '🙋🏼‍♂️', '🙋🏽‍♀️', '🙋🏽‍♂️', '🙋🏾‍♀️', '🙋🏾‍♂️', '🙋🏿‍♀️', '🙋🏿‍♂️', '🙍🏻‍♀️', '🙍🏻‍♂️', '🙍🏼‍♀️', '🙍🏼‍♂️', '🙍🏽‍♀️', '🙍🏽‍♂️', '🙍🏾‍♀️', '🙍🏾‍♂️', '🙍🏿‍♀️', '🙍🏿‍♂️', '🙎🏻‍♀️', '🙎🏻‍♂️', '🙎🏼‍♀️', '🙎🏼‍♂️', '🙎🏽‍♀️', '🙎🏽‍♂️', '🙎🏾‍♀️', '🙎🏾‍♂️', '🙎🏿‍♀️', '🙎🏿‍♂️', '🚣🏻‍♀️', '🚣🏻‍♂️', '🚣🏼‍♀️', '🚣🏼‍♂️', '🚣🏽‍♀️', '🚣🏽‍♂️', '🚣🏾‍♀️', '🚣🏾‍♂️', '🚣🏿‍♀️', '🚣🏿‍♂️', '🚴🏻‍♀️', '🚴🏻‍♂️', '🚴🏼‍♀️', '🚴🏼‍♂️', '🚴🏽‍♀️', '🚴🏽‍♂️', '🚴🏾‍♀️', '🚴🏾‍♂️', '🚴🏿‍♀️', '🚴🏿‍♂️', '🚵🏻‍♀️', '🚵🏻‍♂️', '🚵🏼‍♀️', '🚵🏼‍♂️', '🚵🏽‍♀️', '🚵🏽‍♂️', '🚵🏾‍♀️', '🚵🏾‍♂️', '🚵🏿‍♀️', '🚵🏿‍♂️', '🚶🏻‍♀️', '🚶🏻‍♂️', '🚶🏻‍➡️', '🚶🏼‍♀️', '🚶🏼‍♂️', '🚶🏼‍➡️', '🚶🏽‍♀️', '🚶🏽‍♂️', '🚶🏽‍➡️', '🚶🏾‍♀️', '🚶🏾‍♂️', '🚶🏾‍➡️', '🚶🏿‍♀️', '🚶🏿‍♂️', '🚶🏿‍➡️', '🤦🏻‍♀️', '🤦🏻‍♂️', '🤦🏼‍♀️', '🤦🏼‍♂️', '🤦🏽‍♀️', '🤦🏽‍♂️', '🤦🏾‍♀️', '🤦🏾‍♂️', '🤦🏿‍♀️', '🤦🏿‍♂️', '🤵🏻‍♀️', '🤵🏻‍♂️', '🤵🏼‍♀️', '🤵🏼‍♂️', '🤵🏽‍♀️', '🤵🏽‍♂️', '🤵🏾‍♀️', '🤵🏾‍♂️', '🤵🏿‍♀️', '🤵🏿‍♂️', '🤷🏻‍♀️', '🤷🏻‍♂️', '🤷🏼‍♀️', '🤷🏼‍♂️', '🤷🏽‍♀️', '🤷🏽‍♂️', '🤷🏾‍♀️', '🤷🏾‍♂️', '🤷🏿‍♀️', '🤷🏿‍♂️', '🤸🏻‍♀️', '🤸🏻‍♂️', '🤸🏼‍♀️', '🤸🏼‍♂️', '🤸🏽‍♀️', '🤸🏽‍♂️', '🤸🏾‍♀️', '🤸🏾‍♂️', '🤸🏿‍♀️', '🤸🏿‍♂️', '🤹🏻‍♀️', '🤹🏻‍♂️', '🤹🏼‍♀️', '🤹🏼‍♂️', '🤹🏽‍♀️', '🤹🏽‍♂️', '🤹🏾‍♀️', '🤹🏾‍♂️', '🤹🏿‍♀️', '🤹🏿‍♂️', '🤽🏻‍♀️', '🤽🏻‍♂️', '🤽🏼‍♀️', '🤽🏼‍♂️', '🤽🏽‍♀️', '🤽🏽‍♂️', '🤽🏾‍♀️', '🤽🏾‍♂️', '🤽🏿‍♀️', '🤽🏿‍♂️', '🤾🏻‍♀️', '🤾🏻‍♂️', '🤾🏼‍♀️', '🤾🏼‍♂️', '🤾🏽‍♀️', '🤾🏽‍♂️', '🤾🏾‍♀️', '🤾🏾‍♂️', '🤾🏿‍♀️', '🤾🏿‍♂️', '🦸🏻‍♀️', '🦸🏻‍♂️', '🦸🏼‍♀️', '🦸🏼‍♂️', '🦸🏽‍♀️', '🦸🏽‍♂️', '🦸🏾‍♀️', '🦸🏾‍♂️', '🦸🏿‍♀️', '🦸🏿‍♂️', '🦹🏻‍♀️', '🦹🏻‍♂️', '🦹🏼‍♀️', '🦹🏼‍♂️', '🦹🏽‍♀️', '🦹🏽‍♂️', '🦹🏾‍♀️', '🦹🏾‍♂️', '🦹🏿‍♀️', '🦹🏿‍♂️', '🧍🏻‍♀️', '🧍🏻‍♂️', '🧍🏼‍♀️', '🧍🏼‍♂️', '🧍🏽‍♀️', '🧍🏽‍♂️', '🧍🏾‍♀️', '🧍🏾‍♂️', '🧍🏿‍♀️', '🧍🏿‍♂️', '🧎🏻‍♀️', '🧎🏻‍♂️', '🧎🏻‍➡️', '🧎🏼‍♀️', '🧎🏼‍♂️', '🧎🏼‍➡️', '🧎🏽‍♀️', '🧎🏽‍♂️', '🧎🏽‍➡️', '🧎🏾‍♀️', '🧎🏾‍♂️', '🧎🏾‍➡️', '🧎🏿‍♀️', '🧎🏿‍♂️', '🧎🏿‍➡️', '🧏🏻‍♀️', '🧏🏻‍♂️', '🧏🏼‍♀️', '🧏🏼‍♂️', '🧏🏽‍♀️', '🧏🏽‍♂️', '🧏🏾‍♀️', '🧏🏾‍♂️', '🧏🏿‍♀️', '🧏🏿‍♂️', '🧑🏻‍⚕️', '🧑🏻‍⚖️', '🧑🏻‍✈️', '🧑🏼‍⚕️', '🧑🏼‍⚖️', '🧑🏼‍✈️', '🧑🏽‍⚕️', '🧑🏽‍⚖️', '🧑🏽‍✈️', '🧑🏾‍⚕️', '🧑🏾‍⚖️', '🧑🏾‍✈️', '🧑🏿‍⚕️', '🧑🏿‍⚖️', '🧑🏿‍✈️', '🧔🏻‍♀️', '🧔🏻‍♂️', '🧔🏼‍♀️', '🧔🏼‍♂️', '🧔🏽‍♀️', '🧔🏽‍♂️', '🧔🏾‍♀️', '🧔🏾‍♂️', '🧔🏿‍♀️', '🧔🏿‍♂️', '🧖🏻‍♀️', '🧖🏻‍♂️', '🧖🏼‍♀️', '🧖🏼‍♂️', '🧖🏽‍♀️', '🧖🏽‍♂️', '🧖🏾‍♀️', '🧖🏾‍♂️', '🧖🏿‍♀️', '🧖🏿‍♂️', '🧗🏻‍♀️', '🧗🏻‍♂️', '🧗🏼‍♀️', '🧗🏼‍♂️', '🧗🏽‍♀️', '🧗🏽‍♂️', '🧗🏾‍♀️', '🧗🏾‍♂️', '🧗🏿‍♀️', '🧗🏿‍♂️', '🧘🏻‍♀️', '🧘🏻‍♂️', '🧘🏼‍♀️', '🧘🏼‍♂️', '🧘🏽‍♀️', '🧘🏽‍♂️', '🧘🏾‍♀️', '🧘🏾‍♂️', '🧘🏿‍♀️', '🧘🏿‍♂️', '🧙🏻‍♀️', '🧙🏻‍♂️', '🧙🏼‍♀️', '🧙🏼‍♂️', '🧙🏽‍♀️', '🧙🏽‍♂️', '🧙🏾‍♀️', '🧙🏾‍♂️', '🧙🏿‍♀️', '🧙🏿‍♂️', '🧚🏻‍♀️', '🧚🏻‍♂️', '🧚🏼‍♀️', '🧚🏼‍♂️', '🧚🏽‍♀️', '🧚🏽‍♂️', '🧚🏾‍♀️', '🧚🏾‍♂️', '🧚🏿‍♀️', '🧚🏿‍♂️', '🧛🏻‍♀️', '🧛🏻‍♂️', '🧛🏼‍♀️', '🧛🏼‍♂️', '🧛🏽‍♀️', '🧛🏽‍♂️', '🧛🏾‍♀️', '🧛🏾‍♂️', '🧛🏿‍♀️', '🧛🏿‍♂️', '🧜🏻‍♀️', '🧜🏻‍♂️', '🧜🏼‍♀️', '🧜🏼‍♂️', '🧜🏽‍♀️', '🧜🏽‍♂️', '🧜🏾‍♀️', '🧜🏾‍♂️', '🧜🏿‍♀️', '🧜🏿‍♂️', '🧝🏻‍♀️', '🧝🏻‍♂️', '🧝🏼‍♀️', '🧝🏼‍♂️', '🧝🏽‍♀️', '🧝🏽‍♂️', '🧝🏾‍♀️', '🧝🏾‍♂️', '🧝🏿‍♀️', '🧝🏿‍♂️', '🏋️‍♀️', '🏋️‍♂️', '🏌️‍♀️', '🏌️‍♂️', '🏳️‍⚧️', '🕴️‍♀️', '🕴️‍♂️', '🕵️‍♀️', '🕵️‍♂️', '⛹🏻‍♀️', '⛹🏻‍♂️', '⛹🏼‍♀️', '⛹🏼‍♂️', '⛹🏽‍♀️', '⛹🏽‍♂️', '⛹🏾‍♀️', '⛹🏾‍♂️', '⛹🏿‍♀️', '⛹🏿‍♂️', '⛹️‍♀️', '⛹️‍♂️', '👨🏻‍🌾', '👨🏻‍🍳', '👨🏻‍🍼', '👨🏻‍🎄', '👨🏻‍🎓', '👨🏻‍🎤', '👨🏻‍🎨', '👨🏻‍🏫', '👨🏻‍🏭', '👨🏻‍💻', '👨🏻‍💼', '👨🏻‍🔧', '👨🏻‍🔬', '👨🏻‍🚀', '👨🏻‍🚒', '👨🏻‍🦯', '👨🏻‍🦰', '👨🏻‍🦱', '👨🏻‍🦲', '👨🏻‍🦳', '👨🏻‍🦼', '👨🏻‍🦽', '👨🏼‍🌾', '👨🏼‍🍳', '👨🏼‍🍼', '👨🏼‍🎄', '👨🏼‍🎓', '👨🏼‍🎤', '👨🏼‍🎨', '👨🏼‍🏫', '👨🏼‍🏭', '👨🏼‍💻', '👨🏼‍💼', '👨🏼‍🔧', '👨🏼‍🔬', '👨🏼‍🚀', '👨🏼‍🚒', '👨🏼‍🦯', '👨🏼‍🦰', '👨🏼‍🦱', '👨🏼‍🦲', '👨🏼‍🦳', '👨🏼‍🦼', '👨🏼‍🦽', '👨🏽‍🌾', '👨🏽‍🍳', '👨🏽‍🍼', '👨🏽‍🎄', '👨🏽‍🎓', '👨🏽‍🎤', '👨🏽‍🎨', '👨🏽‍🏫', '👨🏽‍🏭', '👨🏽‍💻', '👨🏽‍💼', '👨🏽‍🔧', '👨🏽‍🔬', '👨🏽‍🚀', '👨🏽‍🚒', '👨🏽‍🦯', '👨🏽‍🦰', '👨🏽‍🦱', '👨🏽‍🦲', '👨🏽‍🦳', '👨🏽‍🦼', '👨🏽‍🦽', '👨🏾‍🌾', '👨🏾‍🍳', '👨🏾‍🍼', '👨🏾‍🎄', '👨🏾‍🎓', '👨🏾‍🎤', '👨🏾‍🎨', '👨🏾‍🏫', '👨🏾‍🏭', '👨🏾‍💻', '👨🏾‍💼', '👨🏾‍🔧', '👨🏾‍🔬', '👨🏾‍🚀', '👨🏾‍🚒', '👨🏾‍🦯', '👨🏾‍🦰', '👨🏾‍🦱', '👨🏾‍🦲', '👨🏾‍🦳', '👨🏾‍🦼', '👨🏾‍🦽', '👨🏿‍🌾', '👨🏿‍🍳', '👨🏿‍🍼', '👨🏿‍🎄', '👨🏿‍🎓', '👨🏿‍🎤', '👨🏿‍🎨', '👨🏿‍🏫', '👨🏿‍🏭', '👨🏿‍💻', '👨🏿‍💼', '👨🏿‍🔧', '👨🏿‍🔬', '👨🏿‍🚀', '👨🏿‍🚒', '👨🏿‍🦯', '👨🏿‍🦰', '👨🏿‍🦱', '👨🏿‍🦲', '👨🏿‍🦳', '👨🏿‍🦼', '👨🏿‍🦽', '👩🏻‍🌾', '👩🏻‍🍳', '👩🏻‍🍼', '👩🏻‍🎄', '👩🏻‍🎓', '👩🏻‍🎤', '👩🏻‍🎨', '👩🏻‍🏫', '👩🏻‍🏭', '👩🏻‍💻', '👩🏻‍💼', '👩🏻‍🔧', '👩🏻‍🔬', '👩🏻‍🚀', '👩🏻‍🚒', '👩🏻‍🦯', '👩🏻‍🦰', '👩🏻‍🦱', '👩🏻‍🦲', '👩🏻‍🦳', '👩🏻‍🦼', '👩🏻‍🦽', '👩🏼‍🌾', '👩🏼‍🍳', '👩🏼‍🍼', '👩🏼‍🎄', '👩🏼‍🎓', '👩🏼‍🎤', '👩🏼‍🎨', '👩🏼‍🏫', '👩🏼‍🏭', '👩🏼‍💻', '👩🏼‍💼', '👩🏼‍🔧', '👩🏼‍🔬', '👩🏼‍🚀', '👩🏼‍🚒', '👩🏼‍🦯', '👩🏼‍🦰', '👩🏼‍🦱', '👩🏼‍🦲', '👩🏼‍🦳', '👩🏼‍🦼', '👩🏼‍🦽', '👩🏽‍🌾', '👩🏽‍🍳', '👩🏽‍🍼', '👩🏽‍🎄', '👩🏽‍🎓', '👩🏽‍🎤', '👩🏽‍🎨', '👩🏽‍🏫', '👩🏽‍🏭', '👩🏽‍💻', '👩🏽‍💼', '👩🏽‍🔧', '👩🏽‍🔬', '👩🏽‍🚀', '👩🏽‍🚒', '👩🏽‍🦯', '👩🏽‍🦰', '👩🏽‍🦱', '👩🏽‍🦲', '👩🏽‍🦳', '👩🏽‍🦼', '👩🏽‍🦽', '👩🏾‍🌾', '👩🏾‍🍳', '👩🏾‍🍼', '👩🏾‍🎄', '👩🏾‍🎓', '👩🏾‍🎤', '👩🏾‍🎨', '👩🏾‍🏫', '👩🏾‍🏭', '👩🏾‍💻', '👩🏾‍💼', '👩🏾‍🔧', '👩🏾‍🔬', '👩🏾‍🚀', '👩🏾‍🚒', '👩🏾‍🦯', '👩🏾‍🦰', '👩🏾‍🦱', '👩🏾‍🦲', '👩🏾‍🦳', '👩🏾‍🦼', '👩🏾‍🦽', '👩🏿‍🌾', '👩🏿‍🍳', '👩🏿‍🍼', '👩🏿‍🎄', '👩🏿‍🎓', '👩🏿‍🎤', '👩🏿‍🎨', '👩🏿‍🏫', '👩🏿‍🏭', '👩🏿‍💻', '👩🏿‍💼', '👩🏿‍🔧', '👩🏿‍🔬', '👩🏿‍🚀', '👩🏿‍🚒', '👩🏿‍🦯', '👩🏿‍🦰', '👩🏿‍🦱', '👩🏿‍🦲', '👩🏿‍🦳', '👩🏿‍🦼', '👩🏿‍🦽', '🧑🏻‍🌾', '🧑🏻‍🍳', '🧑🏻‍🍼', '🧑🏻‍🎄', '🧑🏻‍🎓', '🧑🏻‍🎤', '🧑🏻‍🎨', '🧑🏻‍🏫', '🧑🏻‍🏭', '🧑🏻‍💻', '🧑🏻‍💼', '🧑🏻‍🔧', '🧑🏻‍🔬', '🧑🏻‍🚀', '🧑🏻‍🚒', '🧑🏻‍🦯', '🧑🏻‍🦰', '🧑🏻‍🦱', '🧑🏻‍🦲', '🧑🏻‍🦳', '🧑🏻‍🦼', '🧑🏻‍🦽', '🧑🏼‍🌾', '🧑🏼‍🍳', '🧑🏼‍🍼', '🧑🏼‍🎄', '🧑🏼‍🎓', '🧑🏼‍🎤', '🧑🏼‍🎨', '🧑🏼‍🏫', '🧑🏼‍🏭', '🧑🏼‍💻', '🧑🏼‍💼', '🧑🏼‍🔧', '🧑🏼‍🔬', '🧑🏼‍🚀', '🧑🏼‍🚒', '🧑🏼‍🦯', '🧑🏼‍🦰', '🧑🏼‍🦱', '🧑🏼‍🦲', '🧑🏼‍🦳', '🧑🏼‍🦼', '🧑🏼‍🦽', '🧑🏽‍🌾', '🧑🏽‍🍳', '🧑🏽‍🍼', '🧑🏽‍🎄', '🧑🏽‍🎓', '🧑🏽‍🎤', '🧑🏽‍🎨', '🧑🏽‍🏫', '🧑🏽‍🏭', '🧑🏽‍💻', '🧑🏽‍💼', '🧑🏽‍🔧', '🧑🏽‍🔬', '🧑🏽‍🚀', '🧑🏽‍🚒', '🧑🏽‍🦯', '🧑🏽‍🦰', '🧑🏽‍🦱', '🧑🏽‍🦲', '🧑🏽‍🦳', '🧑🏽‍🦼', '🧑🏽‍🦽', '🧑🏾‍🌾', '🧑🏾‍🍳', '🧑🏾‍🍼', '🧑🏾‍🎄', '🧑🏾‍🎓', '🧑🏾‍🎤', '🧑🏾‍🎨', '🧑🏾‍🏫', '🧑🏾‍🏭', '🧑🏾‍💻', '🧑🏾‍💼', '🧑🏾‍🔧', '🧑🏾‍🔬', '🧑🏾‍🚀', '🧑🏾‍🚒', '🧑🏾‍🦯', '🧑🏾‍🦰', '🧑🏾‍🦱', '🧑🏾‍🦲', '🧑🏾‍🦳', '🧑🏾‍🦼', '🧑🏾‍🦽', '🧑🏿‍🌾', '🧑🏿‍🍳', '🧑🏿‍🍼', '🧑🏿‍🎄', '🧑🏿‍🎓', '🧑🏿‍🎤', '🧑🏿‍🎨', '🧑🏿‍🏫', '🧑🏿‍🏭', '🧑🏿‍💻', '🧑🏿‍💼', '🧑🏿‍🔧', '🧑🏿‍🔬', '🧑🏿‍🚀', '🧑🏿‍🚒', '🧑🏿‍🦯', '🧑🏿‍🦰', '🧑🏿‍🦱', '🧑🏿‍🦲', '🧑🏿‍🦳', '🧑🏿‍🦼', '🧑🏿‍🦽', '🏳️‍🌈', '😶‍🌫️', '🏃‍♀️', '🏃‍♂️', '🏃‍➡️', '🏄‍♀️', '🏄‍♂️', '🏊‍♀️', '🏊‍♂️', '🏴‍☠️', '🐻‍❄️', '👨‍⚕️', '👨‍⚖️', '👨‍✈️', '👩‍⚕️', '👩‍⚖️', '👩‍✈️', '👮‍♀️', '👮‍♂️', '👯‍♀️', '👯‍♂️', '👰‍♀️', '👰‍♂️', '👱‍♀️', '👱‍♂️', '👳‍♀️', '👳‍♂️', '👷‍♀️', '👷‍♂️', '💁‍♀️', '💁‍♂️', '💂‍♀️', '💂‍♂️', '💆‍♀️', '💆‍♂️', '💇‍♀️', '💇‍♂️', '🙂‍↔️', '🙂‍↕️', '🙅‍♀️', '🙅‍♂️', '🙆‍♀️', '🙆‍♂️', '🙇‍♀️', '🙇‍♂️', '🙋‍♀️', '🙋‍♂️', '🙍‍♀️', '🙍‍♂️', '🙎‍♀️', '🙎‍♂️', '🚣‍♀️', '🚣‍♂️', '🚴‍♀️', '🚴‍♂️', '🚵‍♀️', '🚵‍♂️', '🚶‍♀️', '🚶‍♂️', '🚶‍➡️', '🤦‍♀️', '🤦‍♂️', '🤵‍♀️', '🤵‍♂️', '🤷‍♀️', '🤷‍♂️', '🤸‍♀️', '🤸‍♂️', '🤹‍♀️', '🤹‍♂️', '🤼‍♀️', '🤼‍♂️', '🤽‍♀️', '🤽‍♂️', '🤾‍♀️', '🤾‍♂️', '🦸‍♀️', '🦸‍♂️', '🦹‍♀️', '🦹‍♂️', '🧍‍♀️', '🧍‍♂️', '🧎‍♀️', '🧎‍♂️', '🧎‍➡️', '🧏‍♀️', '🧏‍♂️', '🧑‍⚕️', '🧑‍⚖️', '🧑‍✈️', '🧔‍♀️', '🧔‍♂️', '🧖‍♀️', '🧖‍♂️', '🧗‍♀️', '🧗‍♂️', '🧘‍♀️', '🧘‍♂️', '🧙‍♀️', '🧙‍♂️', '🧚‍♀️', '🧚‍♂️', '🧛‍♀️', '🧛‍♂️', '🧜‍♀️', '🧜‍♂️', '🧝‍♀️', '🧝‍♂️', '🧞‍♀️', '🧞‍♂️', '🧟‍♀️', '🧟‍♂️', '⛓️‍💥', '❤️‍🔥', '❤️‍🩹', '🍄‍🟫', '🍋‍🟩', '🐕‍🦺', '🐦‍🔥', '👁‍🗨', '👨‍🌾', '👨‍🍳', '👨‍🍼', '👨‍🎄', '👨‍🎓', '👨‍🎤', '👨‍🎨', '👨‍🏫', '👨‍🏭', '👨‍👦', '👨‍👧', '👨‍💻', '👨‍💼', '👨‍🔧', '👨‍🔬', '👨‍🚀', '👨‍🚒', '👨‍🦯', '👨‍🦰', '👨‍🦱', '👨‍🦲', '👨‍🦳', '👨‍🦼', '👨‍🦽', '👩‍🌾', '👩‍🍳', '👩‍🍼', '👩‍🎄', '👩‍🎓', '👩‍🎤', '👩‍🎨', '👩‍🏫', '👩‍🏭', '👩‍👦', '👩‍👧', '👩‍💻', '👩‍💼', '👩‍🔧', '👩‍🔬', '👩‍🚀', '👩‍🚒', '👩‍🦯', '👩‍🦰', '👩‍🦱', '👩‍🦲', '👩‍🦳', '👩‍🦼', '👩‍🦽', '😮‍💨', '😵‍💫', '🧑‍🌾', '🧑‍🍳', '🧑‍🍼', '🧑‍🎄', '🧑‍🎓', '🧑‍🎤', '🧑‍🎨', '🧑‍🏫', '🧑‍🏭', '🧑‍💻', '🧑‍💼', '🧑‍🔧', '🧑‍🔬', '🧑‍🚀', '🧑‍🚒', '🧑‍🦯', '🧑‍🦰', '🧑‍🦱', '🧑‍🦲', '🧑‍🦳', '🧑‍🦼', '🧑‍🦽', '🧑‍🧒', '🐈‍⬛', '🐦‍⬛', '🇦🇨', '🇦🇩', '🇦🇪', '🇦🇫', '🇦🇬', '🇦🇮', '🇦🇱', '🇦🇲', '🇦🇴', '🇦🇶', '🇦🇷', '🇦🇸', '🇦🇹', '🇦🇺', '🇦🇼', '🇦🇽', '🇦🇿', '🇧🇦', '🇧🇧', '🇧🇩', '🇧🇪', '🇧🇫', '🇧🇬', '🇧🇭', '🇧🇮', '🇧🇯', '🇧🇱', '🇧🇲', '🇧🇳', '🇧🇴', '🇧🇶', '🇧🇷', '🇧🇸', '🇧🇹', '🇧🇻', '🇧🇼', '🇧🇾', '🇧🇿', '🇨🇦', '🇨🇨', '🇨🇩', '🇨🇫', '🇨🇬', '🇨🇭', '🇨🇮', '🇨🇰', '🇨🇱', '🇨🇲', '🇨🇳', '🇨🇴', '🇨🇵', '🇨🇶', '🇨🇷', '🇨🇺', '🇨🇻', '🇨🇼', '🇨🇽', '🇨🇾', '🇨🇿', '🇩🇪', '🇩🇬', '🇩🇯', '🇩🇰', '🇩🇲', '🇩🇴', '🇩🇿', '🇪🇦', '🇪🇨', '🇪🇪', '🇪🇬', '🇪🇭', '🇪🇷', '🇪🇸', '🇪🇹', '🇪🇺', '🇫🇮', '🇫🇯', '🇫🇰', '🇫🇲', '🇫🇴', '🇫🇷', '🇬🇦', '🇬🇧', '🇬🇩', '🇬🇪', '🇬🇫', '🇬🇬', '🇬🇭', '🇬🇮', '🇬🇱', '🇬🇲', '🇬🇳', '🇬🇵', '🇬🇶', '🇬🇷', '🇬🇸', '🇬🇹', '🇬🇺', '🇬🇼', '🇬🇾', '🇭🇰', '🇭🇲', '🇭🇳', '🇭🇷', '🇭🇹', '🇭🇺', '🇮🇨', '🇮🇩', '🇮🇪', '🇮🇱', '🇮🇲', '🇮🇳', '🇮🇴', '🇮🇶', '🇮🇷', '🇮🇸', '🇮🇹', '🇯🇪', '🇯🇲', '🇯🇴', '🇯🇵', '🇰🇪', '🇰🇬', '🇰🇭', '🇰🇮', '🇰🇲', '🇰🇳', '🇰🇵', '🇰🇷', '🇰🇼', '🇰🇾', '🇰🇿', '🇱🇦', '🇱🇧', '🇱🇨', '🇱🇮', '🇱🇰', '🇱🇷', '🇱🇸', '🇱🇹', '🇱🇺', '🇱🇻', '🇱🇾', '🇲🇦', '🇲🇨', '🇲🇩', '🇲🇪', '🇲🇫', '🇲🇬', '🇲🇭', '🇲🇰', '🇲🇱', '🇲🇲', '🇲🇳', '🇲🇴', '🇲🇵', '🇲🇶', '🇲🇷', '🇲🇸', '🇲🇹', '🇲🇺', '🇲🇻', '🇲🇼', '🇲🇽', '🇲🇾', '🇲🇿', '🇳🇦', '🇳🇨', '🇳🇪', '🇳🇫', '🇳🇬', '🇳🇮', '🇳🇱', '🇳🇴', '🇳🇵', '🇳🇷', '🇳🇺', '🇳🇿', '🇴🇲', '🇵🇦', '🇵🇪', '🇵🇫', '🇵🇬', '🇵🇭', '🇵🇰', '🇵🇱', '🇵🇲', '🇵🇳', '🇵🇷', '🇵🇸', '🇵🇹', '🇵🇼', '🇵🇾', '🇶🇦', '🇷🇪', '🇷🇴', '🇷🇸', '🇷🇺', '🇷🇼', '🇸🇦', '🇸🇧', '🇸🇨', '🇸🇩', '🇸🇪', '🇸🇬', '🇸🇭', '🇸🇮', '🇸🇯', '🇸🇰', '🇸🇱', '🇸🇲', '🇸🇳', '🇸🇴', '🇸🇷', '🇸🇸', '🇸🇹', '🇸🇻', '🇸🇽', '🇸🇾', '🇸🇿', '🇹🇦', '🇹🇨', '🇹🇩', '🇹🇫', '🇹🇬', '🇹🇭', '🇹🇯', '🇹🇰', '🇹🇱', '🇹🇲', '🇹🇳', '🇹🇴', '🇹🇷', '🇹🇹', '🇹🇻', '🇹🇼', '🇹🇿', '🇺🇦', '🇺🇬', '🇺🇲', '🇺🇳', '🇺🇸', '🇺🇾', '🇺🇿', '🇻🇦', '🇻🇨', '🇻🇪', '🇻🇬', '🇻🇮', '🇻🇳', '🇻🇺', '🇼🇫', '🇼🇸', '🇽🇰', '🇾🇪', '🇾🇹', '🇿🇦', '🇿🇲', '🇿🇼', '🎅🏻', '🎅🏼', '🎅🏽', '🎅🏾', '🎅🏿', '🏂🏻', '🏂🏼', '🏂🏽', '🏂🏾', '🏂🏿', '🏃🏻', '🏃🏼', '🏃🏽', '🏃🏾', '🏃🏿', '🏄🏻', '🏄🏼', '🏄🏽', '🏄🏾', '🏄🏿', '🏇🏻', '🏇🏼', '🏇🏽', '🏇🏾', '🏇🏿', '🏊🏻', '🏊🏼', '🏊🏽', '🏊🏾', '🏊🏿', '🏋🏻', '🏋🏼', '🏋🏽', '🏋🏾', '🏋🏿', '🏌🏻', '🏌🏼', '🏌🏽', '🏌🏾', '🏌🏿', '👂🏻', '👂🏼', '👂🏽', '👂🏾', '👂🏿', '👃🏻', '👃🏼', '👃🏽', '👃🏾', '👃🏿', '👆🏻', '👆🏼', '👆🏽', '👆🏾', '👆🏿', '👇🏻', '👇🏼', '👇🏽', '👇🏾', '👇🏿', '👈🏻', '👈🏼', '👈🏽', '👈🏾', '👈🏿', '👉🏻', '👉🏼', '👉🏽', '👉🏾', '👉🏿', '👊🏻', '👊🏼', '👊🏽', '👊🏾', '👊🏿', '👋🏻', '👋🏼', '👋🏽', '👋🏾', '👋🏿', '👌🏻', '👌🏼', '👌🏽', '👌🏾', '👌🏿', '👍🏻', '👍🏼', '👍🏽', '👍🏾', '👍🏿', '👎🏻', '👎🏼', '👎🏽', '👎🏾', '👎🏿', '👏🏻', '👏🏼', '👏🏽', '👏🏾', '👏🏿', '👐🏻', '👐🏼', '👐🏽', '👐🏾', '👐🏿', '👦🏻', '👦🏼', '👦🏽', '👦🏾', '👦🏿', '👧🏻', '👧🏼', '👧🏽', '👧🏾', '👧🏿', '👨🏻', '👨🏼', '👨🏽', '👨🏾', '👨🏿', '👩🏻', '👩🏼', '👩🏽', '👩🏾', '👩🏿', '👫🏻', '👫🏼', '👫🏽', '👫🏾', '👫🏿', '👬🏻', '👬🏼', '👬🏽', '👬🏾', '👬🏿', '👭🏻', '👭🏼', '👭🏽', '👭🏾', '👭🏿', '👮🏻', '👮🏼', '👮🏽', '👮🏾', '👮🏿', '👰🏻', '👰🏼', '👰🏽', '👰🏾', '👰🏿', '👱🏻', '👱🏼', '👱🏽', '👱🏾', '👱🏿', '👲🏻', '👲🏼', '👲🏽', '👲🏾', '👲🏿', '👳🏻', '👳🏼', '👳🏽', '👳🏾', '👳🏿', '👴🏻', '👴🏼', '👴🏽', '👴🏾', '👴🏿', '👵🏻', '👵🏼', '👵🏽', '👵🏾', '👵🏿', '👶🏻', '👶🏼', '👶🏽', '👶🏾', '👶🏿', '👷🏻', '👷🏼', '👷🏽', '👷🏾', '👷🏿', '👸🏻', '👸🏼', '👸🏽', '👸🏾', '👸🏿', '👼🏻', '👼🏼', '👼🏽', '👼🏾', '👼🏿', '💁🏻', '💁🏼', '💁🏽', '💁🏾', '💁🏿', '💂🏻', '💂🏼', '💂🏽', '💂🏾', '💂🏿', '💃🏻', '💃🏼', '💃🏽', '💃🏾', '💃🏿', '💅🏻', '💅🏼', '💅🏽', '💅🏾', '💅🏿', '💆🏻', '💆🏼', '💆🏽', '💆🏾', '💆🏿', '💇🏻', '💇🏼', '💇🏽', '💇🏾', '💇🏿', '💏🏻', '💏🏼', '💏🏽', '💏🏾', '💏🏿', '💑🏻', '💑🏼', '💑🏽', '💑🏾', '💑🏿', '💪🏻', '💪🏼', '💪🏽', '💪🏾', '💪🏿', '🕴🏻', '🕴🏼', '🕴🏽', '🕴🏾', '🕴🏿', '🕵🏻', '🕵🏼', '🕵🏽', '🕵🏾', '🕵🏿', '🕺🏻', '🕺🏼', '🕺🏽', '🕺🏾', '🕺🏿', '🖐🏻', '🖐🏼', '🖐🏽', '🖐🏾', '🖐🏿', '🖕🏻', '🖕🏼', '🖕🏽', '🖕🏾', '🖕🏿', '🖖🏻', '🖖🏼', '🖖🏽', '🖖🏾', '🖖🏿', '🙅🏻', '🙅🏼', '🙅🏽', '🙅🏾', '🙅🏿', '🙆🏻', '🙆🏼', '🙆🏽', '🙆🏾', '🙆🏿', '🙇🏻', '🙇🏼', '🙇🏽', '🙇🏾', '🙇🏿', '🙋🏻', '🙋🏼', '🙋🏽', '🙋🏾', '🙋🏿', '🙌🏻', '🙌🏼', '🙌🏽', '🙌🏾', '🙌🏿', '🙍🏻', '🙍🏼', '🙍🏽', '🙍🏾', '🙍🏿', '🙎🏻', '🙎🏼', '🙎🏽', '🙎🏾', '🙎🏿', '🙏🏻', '🙏🏼', '🙏🏽', '🙏🏾', '🙏🏿', '🚣🏻', '🚣🏼', '🚣🏽', '🚣🏾', '🚣🏿', '🚴🏻', '🚴🏼', '🚴🏽', '🚴🏾', '🚴🏿', '🚵🏻', '🚵🏼', '🚵🏽', '🚵🏾', '🚵🏿', '🚶🏻', '🚶🏼', '🚶🏽', '🚶🏾', '🚶🏿', '🛀🏻', '🛀🏼', '🛀🏽', '🛀🏾', '🛀🏿', '🛌🏻', '🛌🏼', '🛌🏽', '🛌🏾', '🛌🏿', '🤌🏻', '🤌🏼', '🤌🏽', '🤌🏾', '🤌🏿', '🤏🏻', '🤏🏼', '🤏🏽', '🤏🏾', '🤏🏿', '🤘🏻', '🤘🏼', '🤘🏽', '🤘🏾', '🤘🏿', '🤙🏻', '🤙🏼', '🤙🏽', '🤙🏾', '🤙🏿', '🤚🏻', '🤚🏼', '🤚🏽', '🤚🏾', '🤚🏿', '🤛🏻', '🤛🏼', '🤛🏽', '🤛🏾', '🤛🏿', '🤜🏻', '🤜🏼', '🤜🏽', '🤜🏾', '🤜🏿', '🤝🏻', '🤝🏼', '🤝🏽', '🤝🏾', '🤝🏿', '🤞🏻', '🤞🏼', '🤞🏽', '🤞🏾', '🤞🏿', '🤟🏻', '🤟🏼', '🤟🏽', '🤟🏾', '🤟🏿', '🤦🏻', '🤦🏼', '🤦🏽', '🤦🏾', '🤦🏿', '🤰🏻', '🤰🏼', '🤰🏽', '🤰🏾', '🤰🏿', '🤱🏻', '🤱🏼', '🤱🏽', '🤱🏾', '🤱🏿', '🤲🏻', '🤲🏼', '🤲🏽', '🤲🏾', '🤲🏿', '🤳🏻', '🤳🏼', '🤳🏽', '🤳🏾', '🤳🏿', '🤴🏻', '🤴🏼', '🤴🏽', '🤴🏾', '🤴🏿', '🤵🏻', '🤵🏼', '🤵🏽', '🤵🏾', '🤵🏿', '🤶🏻', '🤶🏼', '🤶🏽', '🤶🏾', '🤶🏿', '🤷🏻', '🤷🏼', '🤷🏽', '🤷🏾', '🤷🏿', '🤸🏻', '🤸🏼', '🤸🏽', '🤸🏾', '🤸🏿', '🤹🏻', '🤹🏼', '🤹🏽', '🤹🏾', '🤹🏿', '🤽🏻', '🤽🏼', '🤽🏽', '🤽🏾', '🤽🏿', '🤾🏻', '🤾🏼', '🤾🏽', '🤾🏾', '🤾🏿', '🥷🏻', '🥷🏼', '🥷🏽', '🥷🏾', '🥷🏿', '🦵🏻', '🦵🏼', '🦵🏽', '🦵🏾', '🦵🏿', '🦶🏻', '🦶🏼', '🦶🏽', '🦶🏾', '🦶🏿', '🦸🏻', '🦸🏼', '🦸🏽', '🦸🏾', '🦸🏿', '🦹🏻', '🦹🏼', '🦹🏽', '🦹🏾', '🦹🏿', '🦻🏻', '🦻🏼', '🦻🏽', '🦻🏾', '🦻🏿', '🧍🏻', '🧍🏼', '🧍🏽', '🧍🏾', '🧍🏿', '🧎🏻', '🧎🏼', '🧎🏽', '🧎🏾', '🧎🏿', '🧏🏻', '🧏🏼', '🧏🏽', '🧏🏾', '🧏🏿', '🧑🏻', '🧑🏼', '🧑🏽', '🧑🏾', '🧑🏿', '🧒🏻', '🧒🏼', '🧒🏽', '🧒🏾', '🧒🏿', '🧓🏻', '🧓🏼', '🧓🏽', '🧓🏾', '🧓🏿', '🧔🏻', '🧔🏼', '🧔🏽', '🧔🏾', '🧔🏿', '🧕🏻', '🧕🏼', '🧕🏽', '🧕🏾', '🧕🏿', '🧖🏻', '🧖🏼', '🧖🏽', '🧖🏾', '🧖🏿', '🧗🏻', '🧗🏼', '🧗🏽', '🧗🏾', '🧗🏿', '🧘🏻', '🧘🏼', '🧘🏽', '🧘🏾', '🧘🏿', '🧙🏻', '🧙🏼', '🧙🏽', '🧙🏾', '🧙🏿', '🧚🏻', '🧚🏼', '🧚🏽', '🧚🏾', '🧚🏿', '🧛🏻', '🧛🏼', '🧛🏽', '🧛🏾', '🧛🏿', '🧜🏻', '🧜🏼', '🧜🏽', '🧜🏾', '🧜🏿', '🧝🏻', '🧝🏼', '🧝🏽', '🧝🏾', '🧝🏿', '🫃🏻', '🫃🏼', '🫃🏽', '🫃🏾', '🫃🏿', '🫄🏻', '🫄🏼', '🫄🏽', '🫄🏾', '🫄🏿', '🫅🏻', '🫅🏼', '🫅🏽', '🫅🏾', '🫅🏿', '🫰🏻', '🫰🏼', '🫰🏽', '🫰🏾', '🫰🏿', '🫱🏻', '🫱🏼', '🫱🏽', '🫱🏾', '🫱🏿', '🫲🏻', '🫲🏼', '🫲🏽', '🫲🏾', '🫲🏿', '🫳🏻', '🫳🏼', '🫳🏽', '🫳🏾', '🫳🏿', '🫴🏻', '🫴🏼', '🫴🏽', '🫴🏾', '🫴🏿', '🫵🏻', '🫵🏼', '🫵🏽', '🫵🏾', '🫵🏿', '🫶🏻', '🫶🏼', '🫶🏽', '🫶🏾', '🫶🏿', '🫷🏻', '🫷🏼', '🫷🏽', '🫷🏾', '🫷🏿', '🫸🏻', '🫸🏼', '🫸🏽', '🫸🏾', '🫸🏿', '☝🏻', '☝🏼', '☝🏽', '☝🏾', '☝🏿', '⛷🏻', '⛷🏼', '⛷🏽', '⛷🏾', '⛷🏿', '⛹🏻', '⛹🏼', '⛹🏽', '⛹🏾', '⛹🏿', '✊🏻', '✊🏼', '✊🏽', '✊🏾', '✊🏿', '✋🏻', '✋🏼', '✋🏽', '✋🏾', '✋🏿', '✌🏻', '✌🏼', '✌🏽', '✌🏾', '✌🏿', '✍🏻', '✍🏼', '✍🏽', '✍🏾', '✍🏿', '#⃣', '*⃣', '0⃣', '1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🀄', '🃏', '🅰', '🅱', '🅾', '🅿', '🆎', '🆑', '🆒', '🆓', '🆔', '🆕', '🆖', '🆗', '🆘', '🆙', '🆚', '🇦', '🇧', '🇨', '🇩', '🇪', '🇫', '🇬', '🇭', '🇮', '🇯', '🇰', '🇱', '🇲', '🇳', '🇴', '🇵', '🇶', '🇷', '🇸', '🇹', '🇺', '🇻', '🇼', '🇽', '🇾', '🇿', '🈁', '🈂', '🈚', '🈯', '🈲', '🈳', '🈴', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '🌄', '🌅', '🌆', '🌇', '🌈', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘', '🌙', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🌫', '🌬', '🌭', '🌮', '🌯', '🌰', '🌱', '🌲', '🌳', '🌴', '🌵', '🌶', '🌷', '🌸', '🌹', '🌺', '🌻', '🌼', '🌽', '🌾', '🌿', '🍀', '🍁', '🍂', '🍃', '🍄', '🍅', '🍆', '🍇', '🍈', '🍉', '🍊', '🍋', '🍌', '🍍', '🍎', '🍏', '🍐', '🍑', '🍒', '🍓', '🍔', '🍕', '🍖', '🍗', '🍘', '🍙', '🍚', '🍛', '🍜', '🍝', '🍞', '🍟', '🍠', '🍡', '🍢', '🍣', '🍤', '🍥', '🍦', '🍧', '🍨', '🍩', '🍪', '🍫', '🍬', '🍭', '🍮', '🍯', '🍰', '🍱', '🍲', '🍳', '🍴', '🍵', '🍶', '🍷', '🍸', '🍹', '🍺', '🍻', '🍼', '🍽', '🍾', '🍿', '🎀', '🎁', '🎂', '🎃', '🎄', '🎅', '🎆', '🎇', '🎈', '🎉', '🎊', '🎋', '🎌', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '🎙', '🎚', '🎛', '🎞', '🎟', '🎠', '🎡', '🎢', '🎣', '🎤', '🎥', '🎦', '🎧', '🎨', '🎩', '🎪', '🎫', '🎬', '🎭', '🎮', '🎯', '🎰', '🎱', '🎲', '🎳', '🎴', '🎵', '🎶', '🎷', '🎸', '🎹', '🎺', '🎻', '🎼', '🎽', '🎾', '🎿', '🏀', '🏁', '🏂', '🏃', '🏄', '🏅', '🏆', '🏇', '🏈', '🏉', '🏊', '🏋', '🏌', '🏍', '🏎', '🏏', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🏚', '🏛', '🏜', '🏝', '🏞', '🏟', '🏠', '🏡', '🏢', '🏣', '🏤', '🏥', '🏦', '🏧', '🏨', '🏩', '🏪', '🏫', '🏬', '🏭', '🏮', '🏯', '🏰', '🏳', '🏴', '🏵', '🏷', '🏸', '🏹', '🏺', '🏻', '🏼', '🏽', '🏾', '🏿', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '🐉', '🐊', '🐋', '🐌', '🐍', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🐕', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🐯', '🐰', '🐱', '🐲', '🐳', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '🐼', '🐽', '🐾', '🐿', '👀', '👁', '👂', '👃', '👄', '👅', '👆', '👇', '👈', '👉', '👊', '👋', '👌', '👍', '👎', '👏', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '👘', '👙', '👚', '👛', '👜', '👝', '👞', '👟', '👠', '👡', '👢', '👣', '👤', '👥', '👦', '👧', '👨', '👩', '👪', '👫', '👬', '👭', '👮', '👯', '👰', '👱', '👲', '👳', '👴', '👵', '👶', '👷', '👸', '👹', '👺', '👻', '👼', '👽', '👾', '👿', '💀', '💁', '💂', '💃', '💄', '💅', '💆', '💇', '💈', '💉', '💊', '💋', '💌', '💍', '💎', '💏', '💐', '💑', '💒', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '💤', '💥', '💦', '💧', '💨', '💩', '💪', '💫', '💬', '💭', '💮', '💯', '💰', '💱', '💲', '💳', '💴', '💵', '💶', '💷', '💸', '💹', '💺', '💻', '💼', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '📽', '📿', '🔀', '🔁', '🔂', '🔃', '🔄', '🔅', '🔆', '🔇', '🔈', '🔉', '🔊', '🔋', '🔌', '🔍', '🔎', '🔏', '🔐', '🔑', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🔣', '🔤', '🔥', '🔦', '🔧', '🔨', '🔩', '🔪', '🔫', '🔬', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🕴', '🕵', '🕶', '🕷', '🕸', '🕹', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🖐', '🖕', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗨', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '🙃', '🙄', '🙅', '🙆', '🙇', '🙈', '🙉', '🙊', '🙋', '🙌', '🙍', '🙎', '🙏', '🚀', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚒', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🚴', '🚵', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛖', '🛗', '🛜', '🛝', '🛞', '🛟', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🛻', '🛼', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟩', '🟪', '🟫', '🟰', '🤌', '🤍', '🤎', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '🤘', '🤙', '🤚', '🤛', '🤜', '🤝', '🤞', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🤰', '🤱', '🤲', '🤳', '🤴', '🤵', '🤶', '🤷', '🤸', '🤹', '🤺', '🤼', '🤽', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥲', '🥳', '🥴', '🥵', '🥶', '🥷', '🥸', '🥹', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦣', '🦤', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦫', '🦬', '🦭', '🦮', '🦯', '🦰', '🦱', '🦲', '🦳', '🦴', '🦵', '🦶', '🦷', '🦸', '🦹', '🦺', '🦻', '🦼', '🦽', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '🧋', '🧌', '🧍', '🧎', '🧏', '🧐', '🧑', '🧒', '🧓', '🧔', '🧕', '🧖', '🧗', '🧘', '🧙', '🧚', '🧛', '🧜', '🧝', '🧞', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩰', '🩱', '🩲', '🩳', '🩴', '🩵', '🩶', '🩷', '🩸', '🩹', '🩺', '🩻', '🩼', '🪀', '🪁', '🪂', '🪃', '🪄', '🪅', '🪆', '🪇', '🪈', '🪉', '🪏', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '🪖', '🪗', '🪘', '🪙', '🪚', '🪛', '🪜', '🪝', '🪞', '🪟', '🪠', '🪡', '🪢', '🪣', '🪤', '🪥', '🪦', '🪧', '🪨', '🪩', '🪪', '🪫', '🪬', '🪭', '🪮', '🪯', '🪰', '🪱', '🪲', '🪳', '🪴', '🪵', '🪶', '🪷', '🪸', '🪹', '🪺', '🪻', '🪼', '🪽', '🪾', '🪿', '🫀', '🫁', '🫂', '🫃', '🫄', '🫅', '🫆', '🫎', '🫏', '🫐', '🫑', '🫒', '🫓', '🫔', '🫕', '🫖', '🫗', '🫘', '🫙', '🫚', '🫛', '🫜', '🫟', '🫠', '🫡', '🫢', '🫣', '🫤', '🫥', '🫦', '🫧', '🫨', '🫩', '🫰', '🫱', '🫲', '🫳', '🫴', '🫵', '🫶', '🫷', '🫸', '‼', '⁉', '™', 'ℹ', '↔', '↕', '↖', '↗', '↘', '↙', '↩', '↪', '⌚', '⌛', '⌨', '⏏', '⏩', '⏪', '⏫', '⏬', '⏭', '⏮', '⏯', '⏰', '⏱', '⏲', '⏳', '⏸', '⏹', '⏺', 'Ⓜ', '▪', '▫', '▶', '◀', '◻', '◼', '◽', '◾', '☀', '☁', '☂', '☃', '☄', '☎', '☑', '☔', '☕', '☘', '☝', '☠', '☢', '☣', '☦', '☪', '☮', '☯', '☸', '☹', '☺', '♀', '♂', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚕', '⚖', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚧', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '⛷', '⛸', '⛹', '⛺', '⛽', '✂', '✅', '✈', '✉', '✊', '✋', '✌', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❄', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '❤', '➕', '➖', '➗', '➡', '➰', '➿', '⤴', '⤵', '⬅', '⬆', '⬇', '⬛', '⬜', '⭐', '⭕', '〰', '〽', '㊗', '㊙', '' ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
6172 |
$partials = array( '🀄', '🃏', '🅰', '🅱', '🅾', '🅿', '🆎', '🆑', '🆒', '🆓', '🆔', '🆕', '🆖', '🆗', '🆘', '🆙', '🆚', '🇦', '🇨', '🇩', '🇪', '🇫', '🇬', '🇮', '🇱', '🇲', '🇴', '🇶', '🇷', '🇸', '🇹', '🇺', '🇼', '🇽', '🇿', '🇧', '🇭', '🇯', '🇳', '🇻', '🇾', '🇰', '🇵', '🈁', '🈂', '🈚', '🈯', '🈲', '🈳', '🈴', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '🌄', '🌅', '🌆', '🌇', '🌈', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘', '🌙', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🌫', '🌬', '🌭', '🌮', '🌯', '🌰', '🌱', '🌲', '🌳', '🌴', '🌵', '🌶', '🌷', '🌸', '🌹', '🌺', '🌻', '🌼', '🌽', '🌾', '🌿', '🍀', '🍁', '🍂', '🍃', '🍄', '‍', '🟫', '🍅', '🍆', '🍇', '🍈', '🍉', '🍊', '🍋', '🟩', '🍌', '🍍', '🍎', '🍏', '🍐', '🍑', '🍒', '🍓', '🍔', '🍕', '🍖', '🍗', '🍘', '🍙', '🍚', '🍛', '🍜', '🍝', '🍞', '🍟', '🍠', '🍡', '🍢', '🍣', '🍤', '🍥', '🍦', '🍧', '🍨', '🍩', '🍪', '🍫', '🍬', '🍭', '🍮', '🍯', '🍰', '🍱', '🍲', '🍳', '🍴', '🍵', '🍶', '🍷', '🍸', '🍹', '🍺', '🍻', '🍼', '🍽', '🍾', '🍿', '🎀', '🎁', '🎂', '🎃', '🎄', '🎅', '🏻', '🏼', '🏽', '🏾', '🏿', '🎆', '🎇', '🎈', '🎉', '🎊', '🎋', '🎌', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '🎙', '🎚', '🎛', '🎞', '🎟', '🎠', '🎡', '🎢', '🎣', '🎤', '🎥', '🎦', '🎧', '🎨', '🎩', '🎪', '🎫', '🎬', '🎭', '🎮', '🎯', '🎰', '🎱', '🎲', '🎳', '🎴', '🎵', '🎶', '🎷', '🎸', '🎹', '🎺', '🎻', '🎼', '🎽', '🎾', '🎿', '🏀', '🏁', '🏂', '🏃', '♀', '️', '➡', '♂', '🏄', '🏅', '🏆', '🏇', '🏈', '🏉', '🏊', '🏋', '🏌', '🏍', '🏎', '🏏', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🏚', '🏛', '🏜', '🏝', '🏞', '🏟', '🏠', '🏡', '🏢', '🏣', '🏤', '🏥', '🏦', '🏧', '🏨', '🏩', '🏪', '🏫', '🏬', '🏭', '🏮', '🏯', '🏰', '🏳', '⚧', '🏴', '☠', '󠁧', '󠁢', '󠁥', '󠁮', '󠁿', '󠁳', '󠁣', '󠁴', '󠁷', '󠁬', '🏵', '🏷', '🏸', '🏹', '🏺', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '⬛', '🐉', '🐊', '🐋', '🐌', '🐍', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🐕', '🦺', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🔥', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🐯', '🐰', '🐱', '🐲', '🐳', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '❄', '🐼', '🐽', '🐾', '🐿', '👀', '👁', '🗨', '👂', '👃', '👄', '👅', '👆', '👇', '👈', '👉', '👊', '👋', '👌', '👍', '👎', '👏', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '👘', '👙', '👚', '👛', '👜', '👝', '👞', '👟', '👠', '👡', '👢', '👣', '👤', '👥', '👦', '👧', '👨', '💻', '💼', '🔧', '🔬', '🚀', '🚒', '🤝', '🦯', '🦰', '🦱', '🦲', '🦳', '🦼', '🦽', '⚕', '⚖', '✈', '❤', '💋', '👩', '👪', '👫', '👬', '👭', '👮', '👯', '👰', '👱', '👲', '👳', '👴', '👵', '👶', '👷', '👸', '👹', '👺', '👻', '👼', '👽', '👾', '👿', '💀', '💁', '💂', '💃', '💄', '💅', '💆', '💇', '💈', '💉', '💊', '💌', '💍', '💎', '💏', '💐', '💑', '💒', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '💤', '💥', '💦', '💧', '💨', '💩', '💪', '💫', '💬', '💭', '💮', '💯', '💰', '💱', '💲', '💳', '💴', '💵', '💶', '💷', '💸', '💹', '💺', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '📽', '📿', '🔀', '🔁', '🔂', '🔃', '🔄', '🔅', '🔆', '🔇', '🔈', '🔉', '🔊', '🔋', '🔌', '🔍', '🔎', '🔏', '🔐', '🔑', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🔣', '🔤', '🔦', '🔨', '🔩', '🔪', '🔫', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🕴', '🕵', '🕶', '🕷', '🕸', '🕹', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🖐', '🖕', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '↔', '↕', '🙃', '🙄', '🙅', '🙆', '🙇', '🙈', '🙉', '🙊', '🙋', '🙌', '🙍', '🙎', '🙏', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🚴', '🚵', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛖', '🛗', '🛜', '🛝', '🛞', '🛟', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🛻', '🛼', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟪', '🟰', '🤌', '🤍', '🤎', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '🤘', '🤙', '🤚', '🤛', '🤜', '🤞', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🤰', '🤱', '🤲', '🤳', '🤴', '🤵', '🤶', '🤷', '🤸', '🤹', '🤺', '🤼', '🤽', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥲', '🥳', '🥴', '🥵', '🥶', '🥷', '🥸', '🥹', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦣', '🦤', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦫', '🦬', '🦭', '🦮', '🦴', '🦵', '🦶', '🦷', '🦸', '🦹', '🦻', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '🧋', '🧌', '🧍', '🧎', '🧏', '🧐', '🧑', '🧒', '🧓', '🧔', '🧕', '🧖', '🧗', '🧘', '🧙', '🧚', '🧛', '🧜', '🧝', '🧞', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩰', '🩱', '🩲', '🩳', '🩴', '🩵', '🩶', '🩷', '🩸', '🩹', '🩺', '🩻', '🩼', '🪀', '🪁', '🪂', '🪃', '🪄', '🪅', '🪆', '🪇', '🪈', '🪉', '🪏', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '🪖', '🪗', '🪘', '🪙', '🪚', '🪛', '🪜', '🪝', '🪞', '🪟', '🪠', '🪡', '🪢', '🪣', '🪤', '🪥', '🪦', '🪧', '🪨', '🪩', '🪪', '🪫', '🪬', '🪭', '🪮', '🪯', '🪰', '🪱', '🪲', '🪳', '🪴', '🪵', '🪶', '🪷', '🪸', '🪹', '🪺', '🪻', '🪼', '🪽', '🪾', '🪿', '🫀', '🫁', '🫂', '🫃', '🫄', '🫅', '🫆', '🫎', '🫏', '🫐', '🫑', '🫒', '🫓', '🫔', '🫕', '🫖', '🫗', '🫘', '🫙', '🫚', '🫛', '🫜', '🫟', '🫠', '🫡', '🫢', '🫣', '🫤', '🫥', '🫦', '🫧', '🫨', '🫩', '🫰', '🫱', '🫲', '🫳', '🫴', '🫵', '🫶', '🫷', '🫸', '‼', '⁉', '™', 'ℹ', '↖', '↗', '↘', '↙', '↩', '↪', '⃣', '⌚', '⌛', '⌨', '⏏', '⏩', '⏪', '⏫', '⏬', '⏭', '⏮', '⏯', '⏰', '⏱', '⏲', '⏳', '⏸', '⏹', '⏺', 'Ⓜ', '▪', '▫', '▶', '◀', '◻', '◼', '◽', '◾', '☀', '☁', '☂', '☃', '☄', '☎', '☑', '☔', '☕', '☘', '☝', '☢', '☣', '☦', '☪', '☮', '☯', '☸', '☹', '☺', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '⛷', '⛸', '⛹', '⛺', '⛽', '✂', '✅', '✉', '✊', '✋', '✌', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '➕', '➖', '➗', '➰', '➿', '⤴', '⤵', '⬅', '⬆', '⬇', '⬜', '⭐', '⭕', '〰', '〽', '㊗', '㊙', '' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6173 |
// END: emoji arrays |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6174 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6175 |
if ( 'entities' === $type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6176 |
return $entities; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6177 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6178 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6179 |
return $partials; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6180 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6181 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6182 |
/** |
19 | 6183 |
* Shortens a URL, to be used as link text. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6184 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6185 |
* @since 1.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6186 |
* @since 4.4.0 Moved to wp-includes/formatting.php from wp-admin/includes/misc.php and added $length param. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6187 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6188 |
* @param string $url URL to shorten. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6189 |
* @param int $length Optional. Maximum length of the shortened URL. Default 35 characters. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6190 |
* @return string Shortened URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6191 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6192 |
function url_shorten( $url, $length = 35 ) { |
9 | 6193 |
$stripped = str_replace( array( 'https://', 'http://', 'www.' ), '', $url ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6194 |
$short_url = untrailingslashit( $stripped ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6195 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6196 |
if ( strlen( $short_url ) > $length ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6197 |
$short_url = substr( $short_url, 0, $length - 3 ) . '…'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6198 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6199 |
return $short_url; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6200 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6201 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6202 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6203 |
* Sanitizes a hex color. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6204 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6205 |
* Returns either '', a 3 or 6 digit hex color (with #), or nothing. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6206 |
* For sanitizing values without a #, see sanitize_hex_color_no_hash(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6207 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6208 |
* @since 3.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6209 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6210 |
* @param string $color |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6211 |
* @return string|void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6212 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6213 |
function sanitize_hex_color( $color ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6214 |
if ( '' === $color ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6215 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6216 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6217 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6218 |
// 3 or 6 hex digits, or the empty string. |
9 | 6219 |
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6220 |
return $color; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6221 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6222 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6223 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6224 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6225 |
* Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6226 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6227 |
* Saving hex colors without a hash puts the burden of adding the hash on the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6228 |
* UI, which makes it difficult to use or upgrade to other color types such as |
16 | 6229 |
* rgba, hsl, rgb, and HTML color names. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6230 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6231 |
* Returns either '', a 3 or 6 digit hex color (without a #), or null. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6232 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6233 |
* @since 3.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6234 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6235 |
* @param string $color |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6236 |
* @return string|null |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6237 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6238 |
function sanitize_hex_color_no_hash( $color ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6239 |
$color = ltrim( $color, '#' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6240 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6241 |
if ( '' === $color ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6242 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6243 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6244 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6245 |
return sanitize_hex_color( '#' . $color ) ? $color : null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6246 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6247 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6248 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6249 |
* Ensures that any hex color is properly hashed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6250 |
* Otherwise, returns value untouched. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6251 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6252 |
* This method should only be necessary if using sanitize_hex_color_no_hash(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6253 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6254 |
* @since 3.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6255 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6256 |
* @param string $color |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6257 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6258 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6259 |
function maybe_hash_hex_color( $color ) { |
16 | 6260 |
$unhashed = sanitize_hex_color_no_hash( $color ); |
6261 |
if ( $unhashed ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6262 |
return '#' . $unhashed; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6263 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6264 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6265 |
return $color; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6266 |
} |