author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Deprecated functions from past WordPress versions. You shouldn't use these |
|
4 |
* functions and look for the alternatives instead. The functions will be |
|
5 |
* removed in a later version. |
|
6 |
* |
|
7 |
* @package WordPress |
|
8 |
* @subpackage Deprecated |
|
9 |
*/ |
|
10 |
||
11 |
/* |
|
12 |
* Deprecated functions come here to die. |
|
13 |
*/ |
|
14 |
||
15 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
* Retrieves all post data for a given post. |
0 | 17 |
* |
18 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
* @deprecated 1.5.1 Use get_post() |
0 | 20 |
* @see get_post() |
21 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
* @param int $postid Post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
* @return array Post data. |
0 | 24 |
*/ |
25 |
function get_postdata($postid) { |
|
26 |
_deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' ); |
|
27 |
||
28 |
$post = get_post($postid); |
|
29 |
||
30 |
$postdata = array ( |
|
31 |
'ID' => $post->ID, |
|
32 |
'Author_ID' => $post->post_author, |
|
33 |
'Date' => $post->post_date, |
|
34 |
'Content' => $post->post_content, |
|
35 |
'Excerpt' => $post->post_excerpt, |
|
36 |
'Title' => $post->post_title, |
|
37 |
'Category' => $post->post_category, |
|
38 |
'post_status' => $post->post_status, |
|
39 |
'comment_status' => $post->comment_status, |
|
40 |
'ping_status' => $post->ping_status, |
|
41 |
'post_password' => $post->post_password, |
|
42 |
'to_ping' => $post->to_ping, |
|
43 |
'pinged' => $post->pinged, |
|
44 |
'post_type' => $post->post_type, |
|
45 |
'post_name' => $post->post_name |
|
46 |
); |
|
47 |
||
48 |
return $postdata; |
|
49 |
} |
|
50 |
||
51 |
/** |
|
52 |
* Sets up the WordPress Loop. |
|
53 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
* Use The Loop instead. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
* |
16 | 56 |
* @link https://developer.wordpress.org/themes/basics/the-loop/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
* |
0 | 58 |
* @since 1.0.1 |
5 | 59 |
* @deprecated 1.5.0 |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
60 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
61 |
* @global WP_Query $wp_query WordPress Query object. |
0 | 62 |
*/ |
63 |
function start_wp() { |
|
64 |
global $wp_query; |
|
65 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
_deprecated_function( __FUNCTION__, '1.5.0', __('new WordPress Loop') ); |
0 | 67 |
|
68 |
// Since the old style loop is being used, advance the query iterator here. |
|
69 |
$wp_query->next_post(); |
|
70 |
||
71 |
setup_postdata( get_post() ); |
|
72 |
} |
|
73 |
||
74 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
* Returns or prints a category ID. |
0 | 76 |
* |
77 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
* @deprecated 0.71 Use get_the_category() |
0 | 79 |
* @see get_the_category() |
80 |
* |
|
19 | 81 |
* @param bool $display Optional. Whether to display the output. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
* @return int Category ID. |
0 | 83 |
*/ |
19 | 84 |
function the_category_ID($display = true) { |
0 | 85 |
_deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' ); |
86 |
||
87 |
// Grab the first cat in the list. |
|
88 |
$categories = get_the_category(); |
|
89 |
$cat = $categories[0]->term_id; |
|
90 |
||
19 | 91 |
if ( $display ) |
0 | 92 |
echo $cat; |
93 |
||
94 |
return $cat; |
|
95 |
} |
|
96 |
||
97 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
* Prints a category with optional text before and after. |
0 | 99 |
* |
100 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
* @deprecated 0.71 Use get_the_category_by_ID() |
0 | 102 |
* @see get_the_category_by_ID() |
103 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
* @param string $before Optional. Text to display before the category. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
* @param string $after Optional. Text to display after the category. Default empty. |
0 | 106 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
function the_category_head( $before = '', $after = '' ) { |
0 | 108 |
global $currentcat, $previouscat; |
109 |
||
110 |
_deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' ); |
|
111 |
||
112 |
// Grab the first cat in the list. |
|
113 |
$categories = get_the_category(); |
|
114 |
$currentcat = $categories[0]->category_id; |
|
115 |
if ( $currentcat != $previouscat ) { |
|
116 |
echo $before; |
|
117 |
echo get_the_category_by_ID($currentcat); |
|
118 |
echo $after; |
|
119 |
$previouscat = $currentcat; |
|
120 |
} |
|
121 |
} |
|
122 |
||
123 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
124 |
* Prints a link to the previous post. |
0 | 125 |
* |
5 | 126 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
* @deprecated 2.0.0 Use previous_post_link() |
0 | 128 |
* @see previous_post_link() |
129 |
* |
|
130 |
* @param string $format |
|
131 |
* @param string $previous |
|
132 |
* @param string $title |
|
133 |
* @param string $in_same_cat |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
* @param int $limitprev |
0 | 135 |
* @param string $excluded_categories |
136 |
*/ |
|
137 |
function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { |
|
138 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
_deprecated_function( __FUNCTION__, '2.0.0', 'previous_post_link()' ); |
0 | 140 |
|
141 |
if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
142 |
$in_same_cat = false; |
|
143 |
else |
|
144 |
$in_same_cat = true; |
|
145 |
||
146 |
$post = get_previous_post($in_same_cat, $excluded_categories); |
|
147 |
||
148 |
if ( !$post ) |
|
149 |
return; |
|
150 |
||
151 |
$string = '<a href="'.get_permalink($post->ID).'">'.$previous; |
|
152 |
if ( 'yes' == $title ) |
|
153 |
$string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
154 |
$string .= '</a>'; |
|
155 |
$format = str_replace('%', $string, $format); |
|
156 |
echo $format; |
|
157 |
} |
|
158 |
||
159 |
/** |
|
160 |
* Prints link to the next post. |
|
161 |
* |
|
162 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
* @deprecated 2.0.0 Use next_post_link() |
0 | 164 |
* @see next_post_link() |
165 |
* |
|
166 |
* @param string $format |
|
167 |
* @param string $next |
|
168 |
* @param string $title |
|
169 |
* @param string $in_same_cat |
|
170 |
* @param int $limitnext |
|
171 |
* @param string $excluded_categories |
|
172 |
*/ |
|
173 |
function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
_deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' ); |
0 | 175 |
|
176 |
if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
177 |
$in_same_cat = false; |
|
178 |
else |
|
179 |
$in_same_cat = true; |
|
180 |
||
181 |
$post = get_next_post($in_same_cat, $excluded_categories); |
|
182 |
||
183 |
if ( !$post ) |
|
184 |
return; |
|
185 |
||
186 |
$string = '<a href="'.get_permalink($post->ID).'">'.$next; |
|
187 |
if ( 'yes' == $title ) |
|
188 |
$string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
189 |
$string .= '</a>'; |
|
190 |
$format = str_replace('%', $string, $format); |
|
191 |
echo $format; |
|
192 |
} |
|
193 |
||
194 |
/** |
|
195 |
* Whether user can create a post. |
|
196 |
* |
|
5 | 197 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
* @deprecated 2.0.0 Use current_user_can() |
0 | 199 |
* @see current_user_can() |
200 |
* |
|
201 |
* @param int $user_id |
|
202 |
* @param int $blog_id Not Used |
|
203 |
* @param int $category_id Not Used |
|
204 |
* @return bool |
|
205 |
*/ |
|
206 |
function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
207 |
_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
0 | 208 |
|
209 |
$author_data = get_userdata($user_id); |
|
210 |
return ($author_data->user_level > 1); |
|
211 |
} |
|
212 |
||
213 |
/** |
|
214 |
* Whether user can create a post. |
|
215 |
* |
|
5 | 216 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
217 |
* @deprecated 2.0.0 Use current_user_can() |
0 | 218 |
* @see current_user_can() |
219 |
* |
|
220 |
* @param int $user_id |
|
221 |
* @param int $blog_id Not Used |
|
222 |
* @param int $category_id Not Used |
|
223 |
* @return bool |
|
224 |
*/ |
|
225 |
function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
0 | 227 |
|
228 |
$author_data = get_userdata($user_id); |
|
229 |
return ($author_data->user_level >= 1); |
|
230 |
} |
|
231 |
||
232 |
/** |
|
233 |
* Whether user can edit a post. |
|
234 |
* |
|
5 | 235 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
* @deprecated 2.0.0 Use current_user_can() |
0 | 237 |
* @see current_user_can() |
238 |
* |
|
239 |
* @param int $user_id |
|
240 |
* @param int $post_id |
|
241 |
* @param int $blog_id Not Used |
|
242 |
* @return bool |
|
243 |
*/ |
|
244 |
function user_can_edit_post($user_id, $post_id, $blog_id = 1) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
245 |
_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
0 | 246 |
|
247 |
$author_data = get_userdata($user_id); |
|
248 |
$post = get_post($post_id); |
|
249 |
$post_author_data = get_userdata($post->post_author); |
|
250 |
||
251 |
if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) |
|
16 | 252 |
|| ($author_data->user_level > $post_author_data->user_level) |
253 |
|| ($author_data->user_level >= 10) ) { |
|
0 | 254 |
return true; |
255 |
} else { |
|
256 |
return false; |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
/** |
|
261 |
* Whether user can delete a post. |
|
262 |
* |
|
5 | 263 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
* @deprecated 2.0.0 Use current_user_can() |
0 | 265 |
* @see current_user_can() |
266 |
* |
|
267 |
* @param int $user_id |
|
268 |
* @param int $post_id |
|
269 |
* @param int $blog_id Not Used |
|
270 |
* @return bool |
|
271 |
*/ |
|
272 |
function user_can_delete_post($user_id, $post_id, $blog_id = 1) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
0 | 274 |
|
16 | 275 |
// Right now if one can edit, one can delete. |
0 | 276 |
return user_can_edit_post($user_id, $post_id, $blog_id); |
277 |
} |
|
278 |
||
279 |
/** |
|
280 |
* Whether user can set new posts' dates. |
|
281 |
* |
|
5 | 282 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
283 |
* @deprecated 2.0.0 Use current_user_can() |
0 | 284 |
* @see current_user_can() |
285 |
* |
|
286 |
* @param int $user_id |
|
287 |
* @param int $blog_id Not Used |
|
288 |
* @param int $category_id Not Used |
|
289 |
* @return bool |
|
290 |
*/ |
|
291 |
function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
0 | 293 |
|
294 |
$author_data = get_userdata($user_id); |
|
295 |
return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); |
|
296 |
} |
|
297 |
||
298 |
/** |
|
299 |
* Whether user can delete a post. |
|
300 |
* |
|
5 | 301 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
* @deprecated 2.0.0 Use current_user_can() |
0 | 303 |
* @see current_user_can() |
304 |
* |
|
305 |
* @param int $user_id |
|
306 |
* @param int $post_id |
|
307 |
* @param int $blog_id Not Used |
|
308 |
* @return bool returns true if $user_id can edit $post_id's date |
|
309 |
*/ |
|
310 |
function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
0 | 312 |
|
313 |
$author_data = get_userdata($user_id); |
|
314 |
return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); |
|
315 |
} |
|
316 |
||
317 |
/** |
|
318 |
* Whether user can delete a post. |
|
319 |
* |
|
5 | 320 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
* @deprecated 2.0.0 Use current_user_can() |
0 | 322 |
* @see current_user_can() |
323 |
* |
|
324 |
* @param int $user_id |
|
325 |
* @param int $post_id |
|
326 |
* @param int $blog_id Not Used |
|
327 |
* @return bool returns true if $user_id can edit $post_id's comments |
|
328 |
*/ |
|
329 |
function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
0 | 331 |
|
16 | 332 |
// Right now if one can edit a post, one can edit comments made on it. |
0 | 333 |
return user_can_edit_post($user_id, $post_id, $blog_id); |
334 |
} |
|
335 |
||
336 |
/** |
|
337 |
* Whether user can delete a post. |
|
338 |
* |
|
5 | 339 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
* @deprecated 2.0.0 Use current_user_can() |
0 | 341 |
* @see current_user_can() |
342 |
* |
|
343 |
* @param int $user_id |
|
344 |
* @param int $post_id |
|
345 |
* @param int $blog_id Not Used |
|
346 |
* @return bool returns true if $user_id can delete $post_id's comments |
|
347 |
*/ |
|
348 |
function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
0 | 350 |
|
16 | 351 |
// Right now if one can edit comments, one can delete comments. |
0 | 352 |
return user_can_edit_post_comments($user_id, $post_id, $blog_id); |
353 |
} |
|
354 |
||
355 |
/** |
|
356 |
* Can user can edit other user. |
|
357 |
* |
|
5 | 358 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
* @deprecated 2.0.0 Use current_user_can() |
0 | 360 |
* @see current_user_can() |
361 |
* |
|
362 |
* @param int $user_id |
|
363 |
* @param int $other_user |
|
364 |
* @return bool |
|
365 |
*/ |
|
366 |
function user_can_edit_user($user_id, $other_user) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); |
0 | 368 |
|
369 |
$user = get_userdata($user_id); |
|
370 |
$other = get_userdata($other_user); |
|
371 |
if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) |
|
372 |
return true; |
|
373 |
else |
|
374 |
return false; |
|
375 |
} |
|
376 |
||
377 |
/** |
|
378 |
* Gets the links associated with category $cat_name. |
|
379 |
* |
|
380 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
* @deprecated 2.1.0 Use get_bookmarks() |
0 | 382 |
* @see get_bookmarks() |
383 |
* |
|
16 | 384 |
* @param string $cat_name Optional. The category name to use. If no match is found, uses all. |
385 |
* Default 'noname'. |
|
386 |
* @param string $before Optional. The HTML to output before the link. Default empty. |
|
387 |
* @param string $after Optional. The HTML to output after the link. Default '<br />'. |
|
388 |
* @param string $between Optional. The HTML to output between the link/image and its description. |
|
389 |
* Not used if no image or $show_images is true. Default ' '. |
|
390 |
* @param bool $show_images Optional. Whether to show images (if defined). Default true. |
|
391 |
* @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', |
|
392 |
* 'description', 'rating', or 'owner'. Default 'id'. |
|
393 |
* If you start the name with an underscore, the order will be reversed. |
|
394 |
* Specifying 'rand' as the order will return links in a random order. |
|
395 |
* @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. |
|
396 |
* Default true. |
|
397 |
* @param bool $show_rating Optional. Show rating stars/chars. Default false. |
|
398 |
* @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. |
|
399 |
* Default -1. |
|
400 |
* @param int $show_updated Optional. Whether to show last updated timestamp. Default 0. |
|
0 | 401 |
*/ |
402 |
function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id', |
|
16 | 403 |
$show_description = true, $show_rating = false, |
404 |
$limit = -1, $show_updated = 0) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
0 | 406 |
|
407 |
$cat_id = -1; |
|
408 |
$cat = get_term_by('name', $cat_name, 'link_category'); |
|
409 |
if ( $cat ) |
|
410 |
$cat_id = $cat->term_id; |
|
411 |
||
412 |
get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); |
|
413 |
} |
|
414 |
||
415 |
/** |
|
416 |
* Gets the links associated with the named category. |
|
417 |
* |
|
418 |
* @since 1.0.1 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
* @deprecated 2.1.0 Use wp_list_bookmarks() |
0 | 420 |
* @see wp_list_bookmarks() |
421 |
* |
|
422 |
* @param string $category The category to use. |
|
423 |
* @param string $args |
|
5 | 424 |
* @return string|null |
0 | 425 |
*/ |
426 |
function wp_get_linksbyname($category, $args = '') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
_deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_bookmarks()'); |
0 | 428 |
|
429 |
$defaults = array( |
|
430 |
'after' => '<br />', |
|
431 |
'before' => '', |
|
432 |
'categorize' => 0, |
|
433 |
'category_after' => '', |
|
434 |
'category_before' => '', |
|
435 |
'category_name' => $category, |
|
436 |
'show_description' => 1, |
|
437 |
'title_li' => '', |
|
438 |
); |
|
439 |
||
16 | 440 |
$parsed_args = wp_parse_args( $args, $defaults ); |
441 |
||
442 |
return wp_list_bookmarks($parsed_args); |
|
0 | 443 |
} |
444 |
||
445 |
/** |
|
446 |
* Gets an array of link objects associated with category $cat_name. |
|
447 |
* |
|
5 | 448 |
* $links = get_linkobjectsbyname( 'fred' ); |
449 |
* foreach ( $links as $link ) { |
|
450 |
* echo '<li>' . $link->link_name . '</li>'; |
|
451 |
* } |
|
0 | 452 |
* |
453 |
* @since 1.0.1 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
* @deprecated 2.1.0 Use get_bookmarks() |
0 | 455 |
* @see get_bookmarks() |
456 |
* |
|
16 | 457 |
* @param string $cat_name Optional. The category name to use. If no match is found, uses all. |
458 |
* Default 'noname'. |
|
459 |
* @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', |
|
460 |
* 'description', 'rating', or 'owner'. Default 'name'. |
|
461 |
* If you start the name with an underscore, the order will be reversed. |
|
462 |
* Specifying 'rand' as the order will return links in a random order. |
|
463 |
* @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. |
|
464 |
* Default -1. |
|
5 | 465 |
* @return array |
0 | 466 |
*/ |
467 |
function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
0 | 469 |
|
470 |
$cat_id = -1; |
|
471 |
$cat = get_term_by('name', $cat_name, 'link_category'); |
|
472 |
if ( $cat ) |
|
473 |
$cat_id = $cat->term_id; |
|
474 |
||
475 |
return get_linkobjects($cat_id, $orderby, $limit); |
|
476 |
} |
|
477 |
||
478 |
/** |
|
479 |
* Gets an array of link objects associated with category n. |
|
480 |
* |
|
481 |
* Usage: |
|
5 | 482 |
* |
483 |
* $links = get_linkobjects(1); |
|
484 |
* if ($links) { |
|
485 |
* foreach ($links as $link) { |
|
486 |
* echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>'; |
|
487 |
* } |
|
488 |
* } |
|
0 | 489 |
* |
490 |
* Fields are: |
|
5 | 491 |
* |
492 |
* - link_id |
|
493 |
* - link_url |
|
494 |
* - link_name |
|
495 |
* - link_image |
|
496 |
* - link_target |
|
497 |
* - link_category |
|
498 |
* - link_description |
|
499 |
* - link_visible |
|
500 |
* - link_owner |
|
501 |
* - link_rating |
|
502 |
* - link_updated |
|
503 |
* - link_rel |
|
504 |
* - link_notes |
|
0 | 505 |
* |
506 |
* @since 1.0.1 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
507 |
* @deprecated 2.1.0 Use get_bookmarks() |
0 | 508 |
* @see get_bookmarks() |
509 |
* |
|
16 | 510 |
* @param int $category Optional. The category to use. If no category supplied, uses all. |
511 |
* Default 0. |
|
512 |
* @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', |
|
513 |
* 'description', 'rating', or 'owner'. Default 'name'. |
|
514 |
* If you start the name with an underscore, the order will be reversed. |
|
515 |
* Specifying 'rand' as the order will return links in a random order. |
|
516 |
* @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. |
|
517 |
* Default 0. |
|
5 | 518 |
* @return array |
0 | 519 |
*/ |
520 |
function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
0 | 522 |
|
523 |
$links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; |
|
524 |
||
525 |
$links_array = array(); |
|
526 |
foreach ($links as $link) |
|
527 |
$links_array[] = $link; |
|
528 |
||
529 |
return $links_array; |
|
530 |
} |
|
531 |
||
532 |
/** |
|
533 |
* Gets the links associated with category 'cat_name' and display rating stars/chars. |
|
534 |
* |
|
535 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
* @deprecated 2.1.0 Use get_bookmarks() |
0 | 537 |
* @see get_bookmarks() |
538 |
* |
|
16 | 539 |
* @param string $cat_name Optional. The category name to use. If no match is found, uses all. |
540 |
* Default 'noname'. |
|
541 |
* @param string $before Optional. The HTML to output before the link. Default empty. |
|
542 |
* @param string $after Optional. The HTML to output after the link. Default '<br />'. |
|
543 |
* @param string $between Optional. The HTML to output between the link/image and its description. |
|
544 |
* Not used if no image or $show_images is true. Default ' '. |
|
545 |
* @param bool $show_images Optional. Whether to show images (if defined). Default true. |
|
546 |
* @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', |
|
547 |
* 'description', 'rating', or 'owner'. Default 'id'. |
|
548 |
* If you start the name with an underscore, the order will be reversed. |
|
549 |
* Specifying 'rand' as the order will return links in a random order. |
|
550 |
* @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. |
|
551 |
* Default true. |
|
552 |
* @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. |
|
553 |
* Default -1. |
|
554 |
* @param int $show_updated Optional. Whether to show last updated timestamp. Default 0. |
|
0 | 555 |
*/ |
556 |
function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ", |
|
557 |
$show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
0 | 559 |
|
560 |
get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); |
|
561 |
} |
|
562 |
||
563 |
/** |
|
564 |
* Gets the links associated with category n and display rating stars/chars. |
|
565 |
* |
|
566 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
567 |
* @deprecated 2.1.0 Use get_bookmarks() |
0 | 568 |
* @see get_bookmarks() |
569 |
* |
|
16 | 570 |
* @param int $category Optional. The category to use. If no category supplied, uses all. |
571 |
* Default 0. |
|
572 |
* @param string $before Optional. The HTML to output before the link. Default empty. |
|
573 |
* @param string $after Optional. The HTML to output after the link. Default '<br />'. |
|
574 |
* @param string $between Optional. The HTML to output between the link/image and its description. |
|
575 |
* Not used if no image or $show_images is true. Default ' '. |
|
576 |
* @param bool $show_images Optional. Whether to show images (if defined). Default true. |
|
577 |
* @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', |
|
578 |
* 'description', 'rating', or 'owner'. Default 'id'. |
|
579 |
* If you start the name with an underscore, the order will be reversed. |
|
580 |
* Specifying 'rand' as the order will return links in a random order. |
|
581 |
* @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. |
|
582 |
* Default true. |
|
583 |
* @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. |
|
584 |
* Default -1. |
|
585 |
* @param int $show_updated Optional. Whether to show last updated timestamp. Default 0. |
|
0 | 586 |
*/ |
587 |
function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true, |
|
16 | 588 |
$orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
589 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
0 | 590 |
|
591 |
get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); |
|
592 |
} |
|
593 |
||
594 |
/** |
|
595 |
* Gets the auto_toggle setting. |
|
596 |
* |
|
597 |
* @since 0.71 |
|
5 | 598 |
* @deprecated 2.1.0 |
0 | 599 |
* |
600 |
* @param int $id The category to get. If no category supplied uses 0 |
|
601 |
* @return int Only returns 0. |
|
602 |
*/ |
|
603 |
function get_autotoggle($id = 0) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
_deprecated_function( __FUNCTION__, '2.1.0' ); |
0 | 605 |
return 0; |
606 |
} |
|
607 |
||
608 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
* Lists categories. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
* |
0 | 611 |
* @since 0.71 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
* @deprecated 2.1.0 Use wp_list_categories() |
0 | 613 |
* @see wp_list_categories() |
614 |
* |
|
615 |
* @param int $optionall |
|
616 |
* @param string $all |
|
617 |
* @param string $sort_column |
|
618 |
* @param string $sort_order |
|
619 |
* @param string $file |
|
620 |
* @param bool $list |
|
621 |
* @param int $optiondates |
|
622 |
* @param int $optioncount |
|
623 |
* @param int $hide_empty |
|
624 |
* @param int $use_desc_for_title |
|
625 |
* @param bool $children |
|
626 |
* @param int $child_of |
|
627 |
* @param int $categories |
|
628 |
* @param int $recurse |
|
629 |
* @param string $feed |
|
630 |
* @param string $feed_image |
|
631 |
* @param string $exclude |
|
632 |
* @param bool $hierarchical |
|
16 | 633 |
* @return null|false |
0 | 634 |
*/ |
635 |
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, |
|
16 | 636 |
$optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, |
637 |
$recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
638 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); |
0 | 639 |
|
640 |
$query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', |
|
641 |
'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical'); |
|
642 |
return wp_list_cats($query); |
|
643 |
} |
|
644 |
||
645 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
* Lists categories. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
647 |
* |
5 | 648 |
* @since 1.2.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
649 |
* @deprecated 2.1.0 Use wp_list_categories() |
0 | 650 |
* @see wp_list_categories() |
651 |
* |
|
652 |
* @param string|array $args |
|
16 | 653 |
* @return null|string|false |
0 | 654 |
*/ |
655 |
function wp_list_cats($args = '') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
656 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); |
0 | 657 |
|
16 | 658 |
$parsed_args = wp_parse_args( $args ); |
0 | 659 |
|
660 |
// Map to new names. |
|
16 | 661 |
if ( isset($parsed_args['optionall']) && isset($parsed_args['all'])) |
662 |
$parsed_args['show_option_all'] = $parsed_args['all']; |
|
663 |
if ( isset($parsed_args['sort_column']) ) |
|
664 |
$parsed_args['orderby'] = $parsed_args['sort_column']; |
|
665 |
if ( isset($parsed_args['sort_order']) ) |
|
666 |
$parsed_args['order'] = $parsed_args['sort_order']; |
|
667 |
if ( isset($parsed_args['optiondates']) ) |
|
668 |
$parsed_args['show_last_update'] = $parsed_args['optiondates']; |
|
669 |
if ( isset($parsed_args['optioncount']) ) |
|
670 |
$parsed_args['show_count'] = $parsed_args['optioncount']; |
|
671 |
if ( isset($parsed_args['list']) ) |
|
672 |
$parsed_args['style'] = $parsed_args['list'] ? 'list' : 'break'; |
|
673 |
$parsed_args['title_li'] = ''; |
|
674 |
||
675 |
return wp_list_categories($parsed_args); |
|
0 | 676 |
} |
677 |
||
678 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
* Deprecated method for generating a drop-down of categories. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
680 |
* |
0 | 681 |
* @since 0.71 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
* @deprecated 2.1.0 Use wp_dropdown_categories() |
0 | 683 |
* @see wp_dropdown_categories() |
684 |
* |
|
685 |
* @param int $optionall |
|
686 |
* @param string $all |
|
687 |
* @param string $orderby |
|
688 |
* @param string $order |
|
689 |
* @param int $show_last_update |
|
690 |
* @param int $show_count |
|
691 |
* @param int $hide_empty |
|
692 |
* @param bool $optionnone |
|
693 |
* @param int $selected |
|
694 |
* @param int $exclude |
|
5 | 695 |
* @return string |
0 | 696 |
*/ |
697 |
function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc', |
|
698 |
$show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false, |
|
699 |
$selected = 0, $exclude = 0) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_dropdown_categories()' ); |
0 | 701 |
|
702 |
$show_option_all = ''; |
|
703 |
if ( $optionall ) |
|
704 |
$show_option_all = $all; |
|
705 |
||
706 |
$show_option_none = ''; |
|
707 |
if ( $optionnone ) |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
708 |
$show_option_none = _x( 'None', 'Categories dropdown (show_option_none parameter)' ); |
0 | 709 |
|
710 |
$vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', |
|
711 |
'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude'); |
|
712 |
$query = add_query_arg($vars, ''); |
|
713 |
return wp_dropdown_categories($query); |
|
714 |
} |
|
715 |
||
716 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
* Lists authors. |
5 | 718 |
* |
719 |
* @since 1.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
* @deprecated 2.1.0 Use wp_list_authors() |
0 | 721 |
* @see wp_list_authors() |
722 |
* |
|
723 |
* @param bool $optioncount |
|
724 |
* @param bool $exclude_admin |
|
725 |
* @param bool $show_fullname |
|
726 |
* @param bool $hide_empty |
|
727 |
* @param string $feed |
|
728 |
* @param string $feed_image |
|
5 | 729 |
* @return null|string |
0 | 730 |
*/ |
731 |
function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_authors()' ); |
0 | 733 |
|
734 |
$args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image'); |
|
735 |
return wp_list_authors($args); |
|
736 |
} |
|
737 |
||
738 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
* Retrieves a list of post categories. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
740 |
* |
0 | 741 |
* @since 1.0.1 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
742 |
* @deprecated 2.1.0 Use wp_get_post_categories() |
0 | 743 |
* @see wp_get_post_categories() |
744 |
* |
|
745 |
* @param int $blogid Not Used |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
746 |
* @param int $post_id |
5 | 747 |
* @return array |
0 | 748 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
749 |
function wp_get_post_cats($blogid = '1', $post_id = 0) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
750 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
751 |
return wp_get_post_categories($post_id); |
0 | 752 |
} |
753 |
||
754 |
/** |
|
16 | 755 |
* Sets the categories that the post ID belongs to. |
0 | 756 |
* |
757 |
* @since 1.0.1 |
|
5 | 758 |
* @deprecated 2.1.0 |
0 | 759 |
* @deprecated Use wp_set_post_categories() |
760 |
* @see wp_set_post_categories() |
|
761 |
* |
|
762 |
* @param int $blogid Not used |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
763 |
* @param int $post_id |
0 | 764 |
* @param array $post_categories |
5 | 765 |
* @return bool|mixed |
0 | 766 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
767 |
function wp_set_post_cats($blogid = '1', $post_id = 0, $post_categories = array()) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
768 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
769 |
return wp_set_post_categories($post_id, $post_categories); |
0 | 770 |
} |
771 |
||
772 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
773 |
* Retrieves a list of archives. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
774 |
* |
0 | 775 |
* @since 0.71 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
* @deprecated 2.1.0 Use wp_get_archives() |
0 | 777 |
* @see wp_get_archives() |
778 |
* |
|
779 |
* @param string $type |
|
780 |
* @param string $limit |
|
781 |
* @param string $format |
|
782 |
* @param string $before |
|
783 |
* @param string $after |
|
784 |
* @param bool $show_post_count |
|
5 | 785 |
* @return string|null |
0 | 786 |
*/ |
787 |
function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_archives()' ); |
0 | 789 |
$args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count'); |
790 |
return wp_get_archives($args); |
|
791 |
} |
|
792 |
||
793 |
/** |
|
794 |
* Returns or Prints link to the author's posts. |
|
795 |
* |
|
5 | 796 |
* @since 1.2.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
* @deprecated 2.1.0 Use get_author_posts_url() |
0 | 798 |
* @see get_author_posts_url() |
799 |
* |
|
19 | 800 |
* @param bool $display |
0 | 801 |
* @param int $author_id |
802 |
* @param string $author_nicename Optional. |
|
803 |
* @return string|null |
|
804 |
*/ |
|
19 | 805 |
function get_author_link($display, $author_id, $author_nicename = '') { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
806 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_author_posts_url()' ); |
0 | 807 |
|
808 |
$link = get_author_posts_url($author_id, $author_nicename); |
|
809 |
||
19 | 810 |
if ( $display ) |
0 | 811 |
echo $link; |
812 |
return $link; |
|
813 |
} |
|
814 |
||
815 |
/** |
|
816 |
* Print list of pages based on arguments. |
|
817 |
* |
|
818 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
819 |
* @deprecated 2.1.0 Use wp_link_pages() |
0 | 820 |
* @see wp_link_pages() |
821 |
* |
|
822 |
* @param string $before |
|
823 |
* @param string $after |
|
824 |
* @param string $next_or_number |
|
825 |
* @param string $nextpagelink |
|
826 |
* @param string $previouspagelink |
|
827 |
* @param string $pagelink |
|
828 |
* @param string $more_file |
|
829 |
* @return string |
|
830 |
*/ |
|
831 |
function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', |
|
832 |
$pagelink='%', $more_file='') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
833 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_link_pages()' ); |
0 | 834 |
|
835 |
$args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); |
|
836 |
return wp_link_pages($args); |
|
837 |
} |
|
838 |
||
839 |
/** |
|
840 |
* Get value based on option. |
|
841 |
* |
|
842 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
843 |
* @deprecated 2.1.0 Use get_option() |
0 | 844 |
* @see get_option() |
845 |
* |
|
846 |
* @param string $option |
|
847 |
* @return string |
|
848 |
*/ |
|
849 |
function get_settings($option) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
850 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_option()' ); |
0 | 851 |
|
852 |
return get_option($option); |
|
853 |
} |
|
854 |
||
855 |
/** |
|
856 |
* Print the permalink of the current post in the loop. |
|
857 |
* |
|
858 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
859 |
* @deprecated 1.2.0 Use the_permalink() |
0 | 860 |
* @see the_permalink() |
861 |
*/ |
|
862 |
function permalink_link() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
863 |
_deprecated_function( __FUNCTION__, '1.2.0', 'the_permalink()' ); |
0 | 864 |
the_permalink(); |
865 |
} |
|
866 |
||
867 |
/** |
|
868 |
* Print the permalink to the RSS feed. |
|
869 |
* |
|
870 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
871 |
* @deprecated 2.3.0 Use the_permalink_rss() |
0 | 872 |
* @see the_permalink_rss() |
873 |
* |
|
874 |
* @param string $deprecated |
|
875 |
*/ |
|
876 |
function permalink_single_rss($deprecated = '') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
877 |
_deprecated_function( __FUNCTION__, '2.3.0', 'the_permalink_rss()' ); |
0 | 878 |
the_permalink_rss(); |
879 |
} |
|
880 |
||
881 |
/** |
|
882 |
* Gets the links associated with category. |
|
883 |
* |
|
884 |
* @since 1.0.1 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
885 |
* @deprecated 2.1.0 Use wp_list_bookmarks() |
0 | 886 |
* @see wp_list_bookmarks() |
887 |
* |
|
888 |
* @param string $args a query string |
|
889 |
* @return null|string |
|
890 |
*/ |
|
891 |
function wp_get_links($args = '') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
892 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); |
0 | 893 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
894 |
if ( ! str_contains( $args, '=' ) ) { |
0 | 895 |
$cat_id = $args; |
896 |
$args = add_query_arg( 'category', $cat_id, $args ); |
|
897 |
} |
|
898 |
||
899 |
$defaults = array( |
|
900 |
'after' => '<br />', |
|
901 |
'before' => '', |
|
902 |
'between' => ' ', |
|
903 |
'categorize' => 0, |
|
904 |
'category' => '', |
|
905 |
'echo' => true, |
|
906 |
'limit' => -1, |
|
907 |
'orderby' => 'name', |
|
908 |
'show_description' => true, |
|
909 |
'show_images' => true, |
|
910 |
'show_rating' => false, |
|
911 |
'show_updated' => true, |
|
912 |
'title_li' => '', |
|
913 |
); |
|
914 |
||
16 | 915 |
$parsed_args = wp_parse_args( $args, $defaults ); |
916 |
||
917 |
return wp_list_bookmarks($parsed_args); |
|
0 | 918 |
} |
919 |
||
920 |
/** |
|
16 | 921 |
* Gets the links associated with category by ID. |
0 | 922 |
* |
923 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
924 |
* @deprecated 2.1.0 Use get_bookmarks() |
0 | 925 |
* @see get_bookmarks() |
926 |
* |
|
16 | 927 |
* @param int $category Optional. The category to use. If no category supplied uses all. |
928 |
* Default 0. |
|
929 |
* @param string $before Optional. The HTML to output before the link. Default empty. |
|
930 |
* @param string $after Optional. The HTML to output after the link. Default '<br />'. |
|
931 |
* @param string $between Optional. The HTML to output between the link/image and its description. |
|
932 |
* Not used if no image or $show_images is true. Default ' '. |
|
933 |
* @param bool $show_images Optional. Whether to show images (if defined). Default true. |
|
934 |
* @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', |
|
935 |
* 'description', 'rating', or 'owner'. Default 'name'. |
|
936 |
* If you start the name with an underscore, the order will be reversed. |
|
937 |
* Specifying 'rand' as the order will return links in a random order. |
|
938 |
* @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. |
|
939 |
* Default true. |
|
940 |
* @param bool $show_rating Optional. Show rating stars/chars. Default false. |
|
941 |
* @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. |
|
942 |
* Default -1. |
|
943 |
* @param int $show_updated Optional. Whether to show last updated timestamp. Default 1. |
|
19 | 944 |
* @param bool $display Whether to display the results, or return them instead. |
0 | 945 |
* @return null|string |
946 |
*/ |
|
947 |
function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name', |
|
19 | 948 |
$show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $display = true) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
949 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); |
0 | 950 |
|
951 |
$order = 'ASC'; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
952 |
if ( str_starts_with($orderby, '_') ) { |
0 | 953 |
$order = 'DESC'; |
954 |
$orderby = substr($orderby, 1); |
|
955 |
} |
|
956 |
||
16 | 957 |
if ( $category == -1 ) // get_bookmarks() uses '' to signify all categories. |
0 | 958 |
$category = ''; |
959 |
||
960 |
$results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); |
|
961 |
||
962 |
if ( !$results ) |
|
963 |
return; |
|
964 |
||
965 |
$output = ''; |
|
966 |
||
967 |
foreach ( (array) $results as $row ) { |
|
968 |
if ( !isset($row->recently_updated) ) |
|
969 |
$row->recently_updated = false; |
|
970 |
$output .= $before; |
|
971 |
if ( $show_updated && $row->recently_updated ) |
|
972 |
$output .= get_option('links_recently_updated_prepend'); |
|
973 |
$the_link = '#'; |
|
974 |
if ( !empty($row->link_url) ) |
|
975 |
$the_link = esc_url($row->link_url); |
|
976 |
$rel = $row->link_rel; |
|
977 |
if ( '' != $rel ) |
|
978 |
$rel = ' rel="' . $rel . '"'; |
|
979 |
||
980 |
$desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); |
|
981 |
$name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); |
|
982 |
$title = $desc; |
|
983 |
||
984 |
if ( $show_updated ) |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
985 |
if ( !str_starts_with($row->link_updated_f, '00') ) |
16 | 986 |
$title .= ' ('.__('Last updated') . ' ' . gmdate(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; |
0 | 987 |
|
988 |
if ( '' != $title ) |
|
989 |
$title = ' title="' . $title . '"'; |
|
990 |
||
991 |
$alt = ' alt="' . $name . '"'; |
|
992 |
||
993 |
$target = $row->link_target; |
|
994 |
if ( '' != $target ) |
|
995 |
$target = ' target="' . $target . '"'; |
|
996 |
||
997 |
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; |
|
998 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
999 |
if ( '' != $row->link_image && $show_images ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1000 |
if ( str_contains( $row->link_image, 'http' ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1001 |
$output .= '<img src="' . $row->link_image . '"' . $alt . $title . ' />'; |
16 | 1002 |
else // If it's a relative path. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1003 |
$output .= '<img src="' . get_option('siteurl') . $row->link_image . '"' . $alt . $title . ' />'; |
0 | 1004 |
} else { |
1005 |
$output .= $name; |
|
1006 |
} |
|
1007 |
||
1008 |
$output .= '</a>'; |
|
1009 |
||
1010 |
if ( $show_updated && $row->recently_updated ) |
|
1011 |
$output .= get_option('links_recently_updated_append'); |
|
1012 |
||
1013 |
if ( $show_description && '' != $desc ) |
|
1014 |
$output .= $between . $desc; |
|
1015 |
||
1016 |
if ($show_rating) { |
|
1017 |
$output .= $between . get_linkrating($row); |
|
1018 |
} |
|
1019 |
||
1020 |
$output .= "$after\n"; |
|
16 | 1021 |
} // End while. |
0 | 1022 |
|
19 | 1023 |
if ( !$display ) |
0 | 1024 |
return $output; |
1025 |
echo $output; |
|
1026 |
} |
|
1027 |
||
1028 |
/** |
|
1029 |
* Output entire list of links by category. |
|
1030 |
* |
|
1031 |
* Output a list of all links, listed by category, using the settings in |
|
1032 |
* $wpdb->linkcategories and output it as a nested HTML unordered list. |
|
1033 |
* |
|
1034 |
* @since 1.0.1 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1035 |
* @deprecated 2.1.0 Use wp_list_bookmarks() |
0 | 1036 |
* @see wp_list_bookmarks() |
1037 |
* |
|
1038 |
* @param string $order Sort link categories by 'name' or 'id' |
|
1039 |
*/ |
|
1040 |
function get_links_list($order = 'name') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1041 |
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); |
0 | 1042 |
|
1043 |
$order = strtolower($order); |
|
1044 |
||
16 | 1045 |
// Handle link category sorting. |
0 | 1046 |
$direction = 'ASC'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1047 |
if ( str_starts_with( $order, '_' ) ) { |
0 | 1048 |
$direction = 'DESC'; |
1049 |
$order = substr($order,1); |
|
1050 |
} |
|
1051 |
||
1052 |
if ( !isset($direction) ) |
|
1053 |
$direction = ''; |
|
1054 |
||
1055 |
$cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); |
|
1056 |
||
16 | 1057 |
// Display each category. |
0 | 1058 |
if ( $cats ) { |
1059 |
foreach ( (array) $cats as $cat ) { |
|
1060 |
// Handle each category. |
|
1061 |
||
16 | 1062 |
// Display the category name. |
0 | 1063 |
echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n"; |
16 | 1064 |
// Call get_links() with all the appropriate params. |
0 | 1065 |
get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false); |
1066 |
||
16 | 1067 |
// Close the last category. |
0 | 1068 |
echo "\n\t</ul>\n</li>\n"; |
1069 |
} |
|
1070 |
} |
|
1071 |
} |
|
1072 |
||
1073 |
/** |
|
1074 |
* Show the link to the links popup and the number of links. |
|
1075 |
* |
|
1076 |
* @since 0.71 |
|
5 | 1077 |
* @deprecated 2.1.0 |
0 | 1078 |
* |
1079 |
* @param string $text the text of the link |
|
1080 |
* @param int $width the width of the popup window |
|
1081 |
* @param int $height the height of the popup window |
|
1082 |
* @param string $file the page to open in the popup window |
|
1083 |
* @param bool $count the number of links in the db |
|
1084 |
*/ |
|
1085 |
function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
_deprecated_function( __FUNCTION__, '2.1.0' ); |
0 | 1087 |
} |
1088 |
||
1089 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1090 |
* Legacy function that retrieved the value of a link's link_rating field. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1091 |
* |
0 | 1092 |
* @since 1.0.1 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1093 |
* @deprecated 2.1.0 Use sanitize_bookmark_field() |
0 | 1094 |
* @see sanitize_bookmark_field() |
1095 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
* @param object $link Link object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
* @return mixed Value of the 'link_rating' field, false otherwise. |
0 | 1098 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1099 |
function get_linkrating( $link ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1100 |
_deprecated_function( __FUNCTION__, '2.1.0', 'sanitize_bookmark_field()' ); |
0 | 1101 |
return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); |
1102 |
} |
|
1103 |
||
1104 |
/** |
|
16 | 1105 |
* Gets the name of category by ID. |
0 | 1106 |
* |
1107 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
* @deprecated 2.1.0 Use get_category() |
0 | 1109 |
* @see get_category() |
1110 |
* |
|
1111 |
* @param int $id The category to get. If no category supplied uses 0 |
|
1112 |
* @return string |
|
1113 |
*/ |
|
1114 |
function get_linkcatname($id = 0) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1115 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' ); |
0 | 1116 |
|
1117 |
$id = (int) $id; |
|
1118 |
||
1119 |
if ( empty($id) ) |
|
1120 |
return ''; |
|
1121 |
||
1122 |
$cats = wp_get_link_cats($id); |
|
1123 |
||
1124 |
if ( empty($cats) || ! is_array($cats) ) |
|
1125 |
return ''; |
|
1126 |
||
1127 |
$cat_id = (int) $cats[0]; // Take the first cat. |
|
1128 |
||
1129 |
$cat = get_category($cat_id); |
|
1130 |
return $cat->name; |
|
1131 |
} |
|
1132 |
||
1133 |
/** |
|
1134 |
* Print RSS comment feed link. |
|
1135 |
* |
|
1136 |
* @since 1.0.1 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1137 |
* @deprecated 2.5.0 Use post_comments_feed_link() |
0 | 1138 |
* @see post_comments_feed_link() |
1139 |
* |
|
1140 |
* @param string $link_text |
|
1141 |
*/ |
|
1142 |
function comments_rss_link($link_text = 'Comments RSS') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1143 |
_deprecated_function( __FUNCTION__, '2.5.0', 'post_comments_feed_link()' ); |
0 | 1144 |
post_comments_feed_link($link_text); |
1145 |
} |
|
1146 |
||
1147 |
/** |
|
1148 |
* Print/Return link to category RSS2 feed. |
|
1149 |
* |
|
5 | 1150 |
* @since 1.2.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1151 |
* @deprecated 2.5.0 Use get_category_feed_link() |
0 | 1152 |
* @see get_category_feed_link() |
1153 |
* |
|
19 | 1154 |
* @param bool $display |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1155 |
* @param int $cat_id |
5 | 1156 |
* @return string |
0 | 1157 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1158 |
function get_category_rss_link($display = false, $cat_id = 1) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
_deprecated_function( __FUNCTION__, '2.5.0', 'get_category_feed_link()' ); |
0 | 1160 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1161 |
$link = get_category_feed_link($cat_id, 'rss2'); |
0 | 1162 |
|
19 | 1163 |
if ( $display ) |
0 | 1164 |
echo $link; |
1165 |
return $link; |
|
1166 |
} |
|
1167 |
||
1168 |
/** |
|
1169 |
* Print/Return link to author RSS feed. |
|
1170 |
* |
|
5 | 1171 |
* @since 1.2.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1172 |
* @deprecated 2.5.0 Use get_author_feed_link() |
0 | 1173 |
* @see get_author_feed_link() |
1174 |
* |
|
19 | 1175 |
* @param bool $display |
0 | 1176 |
* @param int $author_id |
5 | 1177 |
* @return string |
0 | 1178 |
*/ |
19 | 1179 |
function get_author_rss_link($display = false, $author_id = 1) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1180 |
_deprecated_function( __FUNCTION__, '2.5.0', 'get_author_feed_link()' ); |
0 | 1181 |
|
1182 |
$link = get_author_feed_link($author_id); |
|
19 | 1183 |
if ( $display ) |
0 | 1184 |
echo $link; |
1185 |
return $link; |
|
1186 |
} |
|
1187 |
||
1188 |
/** |
|
1189 |
* Return link to the post RSS feed. |
|
1190 |
* |
|
5 | 1191 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1192 |
* @deprecated 2.2.0 Use get_post_comments_feed_link() |
0 | 1193 |
* @see get_post_comments_feed_link() |
1194 |
* |
|
1195 |
* @return string |
|
1196 |
*/ |
|
1197 |
function comments_rss() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1198 |
_deprecated_function( __FUNCTION__, '2.2.0', 'get_post_comments_feed_link()' ); |
0 | 1199 |
return esc_url( get_post_comments_feed_link() ); |
1200 |
} |
|
1201 |
||
1202 |
/** |
|
1203 |
* An alias of wp_create_user(). |
|
1204 |
* |
|
5 | 1205 |
* @since 2.0.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1206 |
* @deprecated 2.0.0 Use wp_create_user() |
0 | 1207 |
* @see wp_create_user() |
1208 |
* |
|
1209 |
* @param string $username The user's username. |
|
1210 |
* @param string $password The user's password. |
|
5 | 1211 |
* @param string $email The user's email. |
0 | 1212 |
* @return int The new user's ID. |
1213 |
*/ |
|
1214 |
function create_user($username, $password, $email) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1215 |
_deprecated_function( __FUNCTION__, '2.0.0', 'wp_create_user()' ); |
0 | 1216 |
return wp_create_user($username, $password, $email); |
1217 |
} |
|
1218 |
||
1219 |
/** |
|
1220 |
* Unused function. |
|
1221 |
* |
|
5 | 1222 |
* @deprecated 2.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1223 |
*/ |
0 | 1224 |
function gzip_compression() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
_deprecated_function( __FUNCTION__, '2.5.0' ); |
0 | 1226 |
return false; |
1227 |
} |
|
1228 |
||
1229 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1230 |
* Retrieve an array of comment data about comment $comment_id. |
0 | 1231 |
* |
1232 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1233 |
* @deprecated 2.7.0 Use get_comment() |
0 | 1234 |
* @see get_comment() |
1235 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1236 |
* @param int $comment_id The ID of the comment |
0 | 1237 |
* @param int $no_cache Whether to use the cache (cast to bool) |
1238 |
* @param bool $include_unapproved Whether to include unapproved comments |
|
1239 |
* @return array The comment data |
|
1240 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1241 |
function get_commentdata( $comment_id, $no_cache = 0, $include_unapproved = false ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
_deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1243 |
return get_comment($comment_id, ARRAY_A); |
0 | 1244 |
} |
1245 |
||
1246 |
/** |
|
1247 |
* Retrieve the category name by the category ID. |
|
1248 |
* |
|
1249 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
* @deprecated 2.8.0 Use get_cat_name() |
0 | 1251 |
* @see get_cat_name() |
1252 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1253 |
* @param int $cat_id Category ID |
0 | 1254 |
* @return string category name |
1255 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1256 |
function get_catname( $cat_id ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_cat_name()' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1258 |
return get_cat_name( $cat_id ); |
0 | 1259 |
} |
1260 |
||
1261 |
/** |
|
1262 |
* Retrieve category children list separated before and after the term IDs. |
|
1263 |
* |
|
1264 |
* @since 1.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1265 |
* @deprecated 2.8.0 Use get_term_children() |
0 | 1266 |
* @see get_term_children() |
1267 |
* |
|
16 | 1268 |
* @param int $id Category ID to retrieve children. |
1269 |
* @param string $before Optional. Prepend before category term ID. Default '/'. |
|
1270 |
* @param string $after Optional. Append after category term ID. Default empty string. |
|
1271 |
* @param array $visited Optional. Category Term IDs that have already been added. |
|
1272 |
* Default empty array. |
|
0 | 1273 |
* @return string |
1274 |
*/ |
|
1275 |
function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' ); |
0 | 1277 |
if ( 0 == $id ) |
1278 |
return ''; |
|
1279 |
||
1280 |
$chain = ''; |
|
16 | 1281 |
/** TODO: Consult hierarchy */ |
0 | 1282 |
$cat_ids = get_all_category_ids(); |
1283 |
foreach ( (array) $cat_ids as $cat_id ) { |
|
1284 |
if ( $cat_id == $id ) |
|
1285 |
continue; |
|
1286 |
||
1287 |
$category = get_category( $cat_id ); |
|
1288 |
if ( is_wp_error( $category ) ) |
|
1289 |
return $category; |
|
1290 |
if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { |
|
1291 |
$visited[] = $category->term_id; |
|
1292 |
$chain .= $before.$category->term_id.$after; |
|
1293 |
$chain .= get_category_children( $category->term_id, $before, $after ); |
|
1294 |
} |
|
1295 |
} |
|
1296 |
return $chain; |
|
1297 |
} |
|
1298 |
||
1299 |
/** |
|
5 | 1300 |
* Retrieves all category IDs. |
1301 |
* |
|
1302 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
* @deprecated 4.0.0 Use get_terms() |
5 | 1304 |
* @see get_terms() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1305 |
* |
16 | 1306 |
* @link https://developer.wordpress.org/reference/functions/get_all_category_ids/ |
5 | 1307 |
* |
18 | 1308 |
* @return int[] List of all of the category IDs. |
5 | 1309 |
*/ |
1310 |
function get_all_category_ids() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1311 |
_deprecated_function( __FUNCTION__, '4.0.0', 'get_terms()' ); |
5 | 1312 |
|
16 | 1313 |
$cat_ids = get_terms( |
1314 |
array( |
|
1315 |
'taxonomy' => 'category', |
|
1316 |
'fields' => 'ids', |
|
1317 |
'get' => 'all', |
|
1318 |
) |
|
1319 |
); |
|
5 | 1320 |
|
1321 |
return $cat_ids; |
|
1322 |
} |
|
1323 |
||
1324 |
/** |
|
0 | 1325 |
* Retrieve the description of the author of the current post. |
1326 |
* |
|
5 | 1327 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1328 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1329 |
* @see get_the_author_meta() |
1330 |
* |
|
1331 |
* @return string The author's description. |
|
1332 |
*/ |
|
1333 |
function get_the_author_description() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1334 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')' ); |
0 | 1335 |
return get_the_author_meta('description'); |
1336 |
} |
|
1337 |
||
1338 |
/** |
|
1339 |
* Display the description of the author of the current post. |
|
1340 |
* |
|
1341 |
* @since 1.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1342 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1343 |
* @see the_author_meta() |
1344 |
*/ |
|
1345 |
function the_author_description() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1346 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'description\')' ); |
0 | 1347 |
the_author_meta('description'); |
1348 |
} |
|
1349 |
||
1350 |
/** |
|
1351 |
* Retrieve the login name of the author of the current post. |
|
1352 |
* |
|
5 | 1353 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1355 |
* @see get_the_author_meta() |
1356 |
* |
|
1357 |
* @return string The author's login name (username). |
|
1358 |
*/ |
|
1359 |
function get_the_author_login() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1360 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'login\')' ); |
0 | 1361 |
return get_the_author_meta('login'); |
1362 |
} |
|
1363 |
||
1364 |
/** |
|
1365 |
* Display the login name of the author of the current post. |
|
1366 |
* |
|
1367 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1368 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1369 |
* @see the_author_meta() |
1370 |
*/ |
|
1371 |
function the_author_login() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1372 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'login\')' ); |
0 | 1373 |
the_author_meta('login'); |
1374 |
} |
|
1375 |
||
1376 |
/** |
|
1377 |
* Retrieve the first name of the author of the current post. |
|
1378 |
* |
|
5 | 1379 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1380 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1381 |
* @see get_the_author_meta() |
1382 |
* |
|
1383 |
* @return string The author's first name. |
|
1384 |
*/ |
|
1385 |
function get_the_author_firstname() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1386 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'first_name\')' ); |
0 | 1387 |
return get_the_author_meta('first_name'); |
1388 |
} |
|
1389 |
||
1390 |
/** |
|
1391 |
* Display the first name of the author of the current post. |
|
1392 |
* |
|
1393 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1395 |
* @see the_author_meta() |
1396 |
*/ |
|
1397 |
function the_author_firstname() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1398 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'first_name\')' ); |
0 | 1399 |
the_author_meta('first_name'); |
1400 |
} |
|
1401 |
||
1402 |
/** |
|
1403 |
* Retrieve the last name of the author of the current post. |
|
1404 |
* |
|
5 | 1405 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1406 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1407 |
* @see get_the_author_meta() |
1408 |
* |
|
1409 |
* @return string The author's last name. |
|
1410 |
*/ |
|
1411 |
function get_the_author_lastname() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1412 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'last_name\')' ); |
0 | 1413 |
return get_the_author_meta('last_name'); |
1414 |
} |
|
1415 |
||
1416 |
/** |
|
1417 |
* Display the last name of the author of the current post. |
|
1418 |
* |
|
1419 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1420 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1421 |
* @see the_author_meta() |
1422 |
*/ |
|
1423 |
function the_author_lastname() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1424 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'last_name\')' ); |
0 | 1425 |
the_author_meta('last_name'); |
1426 |
} |
|
1427 |
||
1428 |
/** |
|
1429 |
* Retrieve the nickname of the author of the current post. |
|
1430 |
* |
|
5 | 1431 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1432 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1433 |
* @see get_the_author_meta() |
1434 |
* |
|
1435 |
* @return string The author's nickname. |
|
1436 |
*/ |
|
1437 |
function get_the_author_nickname() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1438 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'nickname\')' ); |
0 | 1439 |
return get_the_author_meta('nickname'); |
1440 |
} |
|
1441 |
||
1442 |
/** |
|
1443 |
* Display the nickname of the author of the current post. |
|
1444 |
* |
|
1445 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1446 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1447 |
* @see the_author_meta() |
1448 |
*/ |
|
1449 |
function the_author_nickname() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'nickname\')' ); |
0 | 1451 |
the_author_meta('nickname'); |
1452 |
} |
|
1453 |
||
1454 |
/** |
|
1455 |
* Retrieve the email of the author of the current post. |
|
1456 |
* |
|
5 | 1457 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1458 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1459 |
* @see get_the_author_meta() |
1460 |
* |
|
1461 |
* @return string The author's username. |
|
1462 |
*/ |
|
1463 |
function get_the_author_email() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'email\')' ); |
0 | 1465 |
return get_the_author_meta('email'); |
1466 |
} |
|
1467 |
||
1468 |
/** |
|
1469 |
* Display the email of the author of the current post. |
|
1470 |
* |
|
1471 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1472 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1473 |
* @see the_author_meta() |
1474 |
*/ |
|
1475 |
function the_author_email() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1476 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'email\')' ); |
0 | 1477 |
the_author_meta('email'); |
1478 |
} |
|
1479 |
||
1480 |
/** |
|
1481 |
* Retrieve the ICQ number of the author of the current post. |
|
1482 |
* |
|
5 | 1483 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1484 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1485 |
* @see get_the_author_meta() |
1486 |
* |
|
1487 |
* @return string The author's ICQ number. |
|
1488 |
*/ |
|
1489 |
function get_the_author_icq() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1490 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'icq\')' ); |
0 | 1491 |
return get_the_author_meta('icq'); |
1492 |
} |
|
1493 |
||
1494 |
/** |
|
1495 |
* Display the ICQ number of the author of the current post. |
|
1496 |
* |
|
1497 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1498 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1499 |
* @see the_author_meta() |
1500 |
*/ |
|
1501 |
function the_author_icq() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1502 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'icq\')' ); |
0 | 1503 |
the_author_meta('icq'); |
1504 |
} |
|
1505 |
||
1506 |
/** |
|
1507 |
* Retrieve the Yahoo! IM name of the author of the current post. |
|
1508 |
* |
|
5 | 1509 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1510 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1511 |
* @see get_the_author_meta() |
1512 |
* |
|
1513 |
* @return string The author's Yahoo! IM name. |
|
1514 |
*/ |
|
1515 |
function get_the_author_yim() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1516 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'yim\')' ); |
0 | 1517 |
return get_the_author_meta('yim'); |
1518 |
} |
|
1519 |
||
1520 |
/** |
|
1521 |
* Display the Yahoo! IM name of the author of the current post. |
|
1522 |
* |
|
1523 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1524 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1525 |
* @see the_author_meta() |
1526 |
*/ |
|
1527 |
function the_author_yim() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1528 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'yim\')' ); |
0 | 1529 |
the_author_meta('yim'); |
1530 |
} |
|
1531 |
||
1532 |
/** |
|
1533 |
* Retrieve the MSN address of the author of the current post. |
|
1534 |
* |
|
5 | 1535 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1536 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1537 |
* @see get_the_author_meta() |
1538 |
* |
|
1539 |
* @return string The author's MSN address. |
|
1540 |
*/ |
|
1541 |
function get_the_author_msn() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1542 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'msn\')' ); |
0 | 1543 |
return get_the_author_meta('msn'); |
1544 |
} |
|
1545 |
||
1546 |
/** |
|
1547 |
* Display the MSN address of the author of the current post. |
|
1548 |
* |
|
1549 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1550 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1551 |
* @see the_author_meta() |
1552 |
*/ |
|
1553 |
function the_author_msn() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1554 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'msn\')' ); |
0 | 1555 |
the_author_meta('msn'); |
1556 |
} |
|
1557 |
||
1558 |
/** |
|
1559 |
* Retrieve the AIM address of the author of the current post. |
|
1560 |
* |
|
5 | 1561 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1562 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1563 |
* @see get_the_author_meta() |
1564 |
* |
|
1565 |
* @return string The author's AIM address. |
|
1566 |
*/ |
|
1567 |
function get_the_author_aim() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1568 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'aim\')' ); |
0 | 1569 |
return get_the_author_meta('aim'); |
1570 |
} |
|
1571 |
||
1572 |
/** |
|
1573 |
* Display the AIM address of the author of the current post. |
|
1574 |
* |
|
1575 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1576 |
* @deprecated 2.8.0 Use the_author_meta('aim') |
0 | 1577 |
* @see the_author_meta() |
1578 |
*/ |
|
1579 |
function the_author_aim() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1580 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'aim\')' ); |
0 | 1581 |
the_author_meta('aim'); |
1582 |
} |
|
1583 |
||
1584 |
/** |
|
1585 |
* Retrieve the specified author's preferred display name. |
|
1586 |
* |
|
1587 |
* @since 1.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1588 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1589 |
* @see get_the_author_meta() |
1590 |
* |
|
1591 |
* @param int $auth_id The ID of the author. |
|
1592 |
* @return string The author's display name. |
|
1593 |
*/ |
|
1594 |
function get_author_name( $auth_id = false ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1595 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'display_name\')' ); |
0 | 1596 |
return get_the_author_meta('display_name', $auth_id); |
1597 |
} |
|
1598 |
||
1599 |
/** |
|
1600 |
* Retrieve the URL to the home page of the author of the current post. |
|
1601 |
* |
|
5 | 1602 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1603 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1604 |
* @see get_the_author_meta() |
1605 |
* |
|
1606 |
* @return string The URL to the author's page. |
|
1607 |
*/ |
|
1608 |
function get_the_author_url() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1609 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'url\')' ); |
0 | 1610 |
return get_the_author_meta('url'); |
1611 |
} |
|
1612 |
||
1613 |
/** |
|
1614 |
* Display the URL to the home page of the author of the current post. |
|
1615 |
* |
|
1616 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1617 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1618 |
* @see the_author_meta() |
1619 |
*/ |
|
1620 |
function the_author_url() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1621 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'url\')' ); |
0 | 1622 |
the_author_meta('url'); |
1623 |
} |
|
1624 |
||
1625 |
/** |
|
1626 |
* Retrieve the ID of the author of the current post. |
|
1627 |
* |
|
5 | 1628 |
* @since 1.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1629 |
* @deprecated 2.8.0 Use get_the_author_meta() |
0 | 1630 |
* @see get_the_author_meta() |
1631 |
* |
|
5 | 1632 |
* @return string|int The author's ID. |
0 | 1633 |
*/ |
1634 |
function get_the_author_ID() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1635 |
_deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'ID\')' ); |
0 | 1636 |
return get_the_author_meta('ID'); |
1637 |
} |
|
1638 |
||
1639 |
/** |
|
1640 |
* Display the ID of the author of the current post. |
|
1641 |
* |
|
1642 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1643 |
* @deprecated 2.8.0 Use the_author_meta() |
0 | 1644 |
* @see the_author_meta() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1645 |
*/ |
0 | 1646 |
function the_author_ID() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1647 |
_deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'ID\')' ); |
0 | 1648 |
the_author_meta('ID'); |
1649 |
} |
|
1650 |
||
1651 |
/** |
|
1652 |
* Display the post content for the feed. |
|
1653 |
* |
|
16 | 1654 |
* For encoding the HTML or the $encode_html parameter, there are three possible values: |
1655 |
* - '0' will make urls footnotes and use make_url_footnote(). |
|
1656 |
* - '1' will encode special characters and automatically display all of the content. |
|
1657 |
* - '2' will strip all HTML tags from the content. |
|
1658 |
* |
|
1659 |
* Also note that you cannot set the amount of words and not set the HTML encoding. |
|
1660 |
* If that is the case, then the HTML encoding will default to 2, which will strip |
|
1661 |
* all HTML tags. |
|
1662 |
* |
|
1663 |
* To restrict the amount of words of the content, you can use the cut parameter. |
|
1664 |
* If the content is less than the amount, then there won't be any dots added to the end. |
|
1665 |
* If there is content left over, then dots will be added and the rest of the content |
|
1666 |
* will be removed. |
|
0 | 1667 |
* |
1668 |
* @since 0.71 |
|
1669 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1670 |
* @deprecated 2.9.0 Use the_content_feed() |
0 | 1671 |
* @see the_content_feed() |
1672 |
* |
|
16 | 1673 |
* @param string $more_link_text Optional. Text to display when more content is available |
1674 |
* but not displayed. Default '(more...)'. |
|
1675 |
* @param int $stripteaser Optional. Default 0. |
|
1676 |
* @param string $more_file Optional. |
|
1677 |
* @param int $cut Optional. Amount of words to keep for the content. |
|
1678 |
* @param int $encode_html Optional. How to encode the content. |
|
0 | 1679 |
*/ |
1680 |
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1681 |
_deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed()' ); |
0 | 1682 |
$content = get_the_content($more_link_text, $stripteaser); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1683 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1684 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1685 |
* Filters the post content in the context of an RSS feed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1686 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1687 |
* @since 0.71 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1688 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1689 |
* @param string $content Content of the current post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1690 |
*/ |
0 | 1691 |
$content = apply_filters('the_content_rss', $content); |
1692 |
if ( $cut && !$encode_html ) |
|
1693 |
$encode_html = 2; |
|
1694 |
if ( 1== $encode_html ) { |
|
1695 |
$content = esc_html($content); |
|
1696 |
$cut = 0; |
|
1697 |
} elseif ( 0 == $encode_html ) { |
|
1698 |
$content = make_url_footnote($content); |
|
1699 |
} elseif ( 2 == $encode_html ) { |
|
1700 |
$content = strip_tags($content); |
|
1701 |
} |
|
1702 |
if ( $cut ) { |
|
1703 |
$blah = explode(' ', $content); |
|
1704 |
if ( count($blah) > $cut ) { |
|
1705 |
$k = $cut; |
|
1706 |
$use_dotdotdot = 1; |
|
1707 |
} else { |
|
1708 |
$k = count($blah); |
|
1709 |
$use_dotdotdot = 0; |
|
1710 |
} |
|
1711 |
||
1712 |
/** @todo Check performance, might be faster to use array slice instead. */ |
|
1713 |
for ( $i=0; $i<$k; $i++ ) |
|
1714 |
$excerpt .= $blah[$i].' '; |
|
1715 |
$excerpt .= ($use_dotdotdot) ? '...' : ''; |
|
1716 |
$content = $excerpt; |
|
1717 |
} |
|
1718 |
$content = str_replace(']]>', ']]>', $content); |
|
1719 |
echo $content; |
|
1720 |
} |
|
1721 |
||
1722 |
/** |
|
1723 |
* Strip HTML and put links at the bottom of stripped content. |
|
1724 |
* |
|
1725 |
* Searches for all of the links, strips them out of the content, and places |
|
1726 |
* them at the bottom of the content with numbers. |
|
1727 |
* |
|
1728 |
* @since 0.71 |
|
1729 |
* @deprecated 2.9.0 |
|
1730 |
* |
|
16 | 1731 |
* @param string $content Content to get links. |
0 | 1732 |
* @return string HTML stripped out of content with links at the bottom. |
1733 |
*/ |
|
1734 |
function make_url_footnote( $content ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1735 |
_deprecated_function( __FUNCTION__, '2.9.0', '' ); |
0 | 1736 |
preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches ); |
1737 |
$links_summary = "\n"; |
|
5 | 1738 |
for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) { |
0 | 1739 |
$link_match = $matches[0][$i]; |
1740 |
$link_number = '['.($i+1).']'; |
|
1741 |
$link_url = $matches[2][$i]; |
|
1742 |
$link_text = $matches[4][$i]; |
|
1743 |
$content = str_replace( $link_match, $link_text . ' ' . $link_number, $content ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1744 |
$link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) !== 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) !== 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url; |
0 | 1745 |
$links_summary .= "\n" . $link_number . ' ' . $link_url; |
1746 |
} |
|
1747 |
$content = strip_tags( $content ); |
|
1748 |
$content .= $links_summary; |
|
1749 |
return $content; |
|
1750 |
} |
|
1751 |
||
1752 |
/** |
|
1753 |
* Retrieve translated string with vertical bar context |
|
1754 |
* |
|
1755 |
* Quite a few times, there will be collisions with similar translatable text |
|
1756 |
* found in more than two places but with different translated context. |
|
1757 |
* |
|
1758 |
* In order to use the separate contexts, the _c() function is used and the |
|
1759 |
* translatable string uses a pipe ('|') which has the context the string is in. |
|
1760 |
* |
|
1761 |
* When the translated string is returned, it is everything before the pipe, not |
|
1762 |
* including the pipe character. If there is no pipe in the translated text then |
|
1763 |
* everything is returned. |
|
1764 |
* |
|
1765 |
* @since 2.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1766 |
* @deprecated 2.9.0 Use _x() |
0 | 1767 |
* @see _x() |
1768 |
* |
|
16 | 1769 |
* @param string $text Text to translate. |
1770 |
* @param string $domain Optional. Domain to retrieve the translated text. |
|
1771 |
* @return string Translated context string without pipe. |
|
0 | 1772 |
*/ |
1773 |
function _c( $text, $domain = 'default' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1774 |
_deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); |
0 | 1775 |
return before_last_bar( translate( $text, $domain ) ); |
1776 |
} |
|
1777 |
||
1778 |
/** |
|
1779 |
* Translates $text like translate(), but assumes that the text |
|
1780 |
* contains a context after its last vertical bar. |
|
1781 |
* |
|
5 | 1782 |
* @since 2.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1783 |
* @deprecated 3.0.0 Use _x() |
0 | 1784 |
* @see _x() |
1785 |
* |
|
16 | 1786 |
* @param string $text Text to translate. |
1787 |
* @param string $domain Domain to retrieve the translated text. |
|
1788 |
* @return string Translated text. |
|
0 | 1789 |
*/ |
1790 |
function translate_with_context( $text, $domain = 'default' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1791 |
_deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); |
0 | 1792 |
return before_last_bar( translate( $text, $domain ) ); |
1793 |
} |
|
1794 |
||
1795 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1796 |
* Legacy version of _n(), which supports contexts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1797 |
* |
0 | 1798 |
* Strips everything from the translation after the last bar. |
1799 |
* |
|
1800 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1801 |
* @deprecated 3.0.0 Use _nx() |
0 | 1802 |
* @see _nx() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1803 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1804 |
* @param string $single The text to be used if the number is singular. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1805 |
* @param string $plural The text to be used if the number is plural. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1806 |
* @param int $number The number to compare against to use either the singular or plural form. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1807 |
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1808 |
* Default 'default'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1809 |
* @return string The translated singular or plural form. |
0 | 1810 |
*/ |
1811 |
function _nc( $single, $plural, $number, $domain = 'default' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1812 |
_deprecated_function( __FUNCTION__, '2.9.0', '_nx()' ); |
0 | 1813 |
return before_last_bar( _n( $single, $plural, $number, $domain ) ); |
1814 |
} |
|
1815 |
||
1816 |
/** |
|
1817 |
* Retrieve the plural or single form based on the amount. |
|
1818 |
* |
|
1819 |
* @since 1.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1820 |
* @deprecated 2.8.0 Use _n() |
0 | 1821 |
* @see _n() |
1822 |
*/ |
|
16 | 1823 |
function __ngettext( ...$args ) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1824 |
_deprecated_function( __FUNCTION__, '2.8.0', '_n()' ); |
16 | 1825 |
return _n( ...$args ); |
0 | 1826 |
} |
1827 |
||
1828 |
/** |
|
1829 |
* Register plural strings in POT file, but don't translate them. |
|
1830 |
* |
|
5 | 1831 |
* @since 2.5.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1832 |
* @deprecated 2.8.0 Use _n_noop() |
0 | 1833 |
* @see _n_noop() |
1834 |
*/ |
|
16 | 1835 |
function __ngettext_noop( ...$args ) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1836 |
_deprecated_function( __FUNCTION__, '2.8.0', '_n_noop()' ); |
16 | 1837 |
return _n_noop( ...$args ); |
0 | 1838 |
|
1839 |
} |
|
1840 |
||
1841 |
/** |
|
1842 |
* Retrieve all autoload options, or all options if no autoloaded ones exist. |
|
1843 |
* |
|
1844 |
* @since 1.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1845 |
* @deprecated 3.0.0 Use wp_load_alloptions()) |
0 | 1846 |
* @see wp_load_alloptions() |
1847 |
* |
|
1848 |
* @return array List of all options. |
|
1849 |
*/ |
|
1850 |
function get_alloptions() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1851 |
_deprecated_function( __FUNCTION__, '3.0.0', 'wp_load_alloptions()' ); |
0 | 1852 |
return wp_load_alloptions(); |
1853 |
} |
|
1854 |
||
1855 |
/** |
|
1856 |
* Retrieve HTML content of attachment image with link. |
|
1857 |
* |
|
1858 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1859 |
* @deprecated 2.5.0 Use wp_get_attachment_link() |
0 | 1860 |
* @see wp_get_attachment_link() |
1861 |
* |
|
16 | 1862 |
* @param int $id Optional. Post ID. |
1863 |
* @param bool $fullsize Optional. Whether to use full size image. Default false. |
|
0 | 1864 |
* @param array $max_dims Optional. Max image dimensions. |
16 | 1865 |
* @param bool $permalink Optional. Whether to include permalink to image. Default false. |
0 | 1866 |
* @return string |
1867 |
*/ |
|
1868 |
function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1869 |
_deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' ); |
0 | 1870 |
$id = (int) $id; |
1871 |
$_post = get_post($id); |
|
1872 |
||
1873 |
if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) |
|
1874 |
return __('Missing Attachment'); |
|
1875 |
||
1876 |
if ( $permalink ) |
|
1877 |
$url = get_attachment_link($_post->ID); |
|
1878 |
||
1879 |
$post_title = esc_attr($_post->post_title); |
|
1880 |
||
1881 |
$innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims); |
|
1882 |
return "<a href='$url' title='$post_title'>$innerHTML</a>"; |
|
1883 |
} |
|
1884 |
||
1885 |
/** |
|
1886 |
* Retrieve icon URL and Path. |
|
1887 |
* |
|
1888 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1889 |
* @deprecated 2.5.0 Use wp_get_attachment_image_src() |
0 | 1890 |
* @see wp_get_attachment_image_src() |
1891 |
* |
|
16 | 1892 |
* @param int $id Optional. Post ID. |
1893 |
* @param bool $fullsize Optional. Whether to have full image. Default false. |
|
0 | 1894 |
* @return array Icon URL and full path to file, respectively. |
1895 |
*/ |
|
1896 |
function get_attachment_icon_src( $id = 0, $fullsize = false ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1897 |
_deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' ); |
0 | 1898 |
$id = (int) $id; |
1899 |
if ( !$post = get_post($id) ) |
|
1900 |
return false; |
|
1901 |
||
1902 |
$file = get_attached_file( $post->ID ); |
|
1903 |
||
1904 |
if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) { |
|
16 | 1905 |
// We have a thumbnail desired, specified and existing. |
0 | 1906 |
|
9 | 1907 |
$src_file = wp_basename($src); |
0 | 1908 |
} elseif ( wp_attachment_is_image( $post->ID ) ) { |
16 | 1909 |
// We have an image without a thumbnail. |
0 | 1910 |
|
1911 |
$src = wp_get_attachment_url( $post->ID ); |
|
1912 |
$src_file = & $file; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1913 |
} elseif ( $src = wp_mime_type_icon( $post->ID, '.svg' ) ) { |
0 | 1914 |
// No thumb, no image. We'll look for a mime-related icon instead. |
1915 |
||
18 | 1916 |
/** This filter is documented in wp-includes/post.php */ |
0 | 1917 |
$icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); |
9 | 1918 |
$src_file = $icon_dir . '/' . wp_basename($src); |
0 | 1919 |
} |
1920 |
||
1921 |
if ( !isset($src) || !$src ) |
|
1922 |
return false; |
|
1923 |
||
1924 |
return array($src, $src_file); |
|
1925 |
} |
|
1926 |
||
1927 |
/** |
|
1928 |
* Retrieve HTML content of icon attachment image element. |
|
1929 |
* |
|
1930 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1931 |
* @deprecated 2.5.0 Use wp_get_attachment_image() |
0 | 1932 |
* @see wp_get_attachment_image() |
1933 |
* |
|
16 | 1934 |
* @param int $id Optional. Post ID. |
1935 |
* @param bool $fullsize Optional. Whether to have full size image. Default false. |
|
0 | 1936 |
* @param array $max_dims Optional. Dimensions of image. |
16 | 1937 |
* @return string|false HTML content. |
0 | 1938 |
*/ |
1939 |
function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1940 |
_deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); |
0 | 1941 |
$id = (int) $id; |
1942 |
if ( !$post = get_post($id) ) |
|
1943 |
return false; |
|
1944 |
||
1945 |
if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) |
|
1946 |
return false; |
|
1947 |
||
1948 |
list($src, $src_file) = $src; |
|
1949 |
||
1950 |
// Do we need to constrain the image? |
|
1951 |
if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { |
|
1952 |
||
18 | 1953 |
$imagesize = wp_getimagesize($src_file); |
0 | 1954 |
|
1955 |
if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { |
|
1956 |
$actual_aspect = $imagesize[0] / $imagesize[1]; |
|
1957 |
$desired_aspect = $max_dims[0] / $max_dims[1]; |
|
1958 |
||
1959 |
if ( $actual_aspect >= $desired_aspect ) { |
|
1960 |
$height = $actual_aspect * $max_dims[0]; |
|
1961 |
$constraint = "width='{$max_dims[0]}' "; |
|
1962 |
$post->iconsize = array($max_dims[0], $height); |
|
1963 |
} else { |
|
1964 |
$width = $max_dims[1] / $actual_aspect; |
|
1965 |
$constraint = "height='{$max_dims[1]}' "; |
|
1966 |
$post->iconsize = array($width, $max_dims[1]); |
|
1967 |
} |
|
1968 |
} else { |
|
1969 |
$post->iconsize = array($imagesize[0], $imagesize[1]); |
|
1970 |
$constraint = ''; |
|
1971 |
} |
|
1972 |
} else { |
|
1973 |
$constraint = ''; |
|
1974 |
} |
|
1975 |
||
1976 |
$post_title = esc_attr($post->post_title); |
|
1977 |
||
1978 |
$icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>"; |
|
1979 |
||
1980 |
return apply_filters( 'attachment_icon', $icon, $post->ID ); |
|
1981 |
} |
|
1982 |
||
1983 |
/** |
|
1984 |
* Retrieve HTML content of image element. |
|
1985 |
* |
|
1986 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1987 |
* @deprecated 2.5.0 Use wp_get_attachment_image() |
0 | 1988 |
* @see wp_get_attachment_image() |
1989 |
* |
|
16 | 1990 |
* @param int $id Optional. Post ID. |
1991 |
* @param bool $fullsize Optional. Whether to have full size image. Default false. |
|
0 | 1992 |
* @param array $max_dims Optional. Dimensions of image. |
16 | 1993 |
* @return string|false |
0 | 1994 |
*/ |
1995 |
function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1996 |
_deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); |
0 | 1997 |
$id = (int) $id; |
1998 |
if ( !$post = get_post($id) ) |
|
1999 |
return false; |
|
2000 |
||
2001 |
if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) |
|
2002 |
return $innerHTML; |
|
2003 |
||
2004 |
$innerHTML = esc_attr($post->post_title); |
|
2005 |
||
2006 |
return apply_filters('attachment_innerHTML', $innerHTML, $post->ID); |
|
2007 |
} |
|
2008 |
||
2009 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2010 |
* Retrieves bookmark data based on ID. |
0 | 2011 |
* |
2012 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2013 |
* @deprecated 2.1.0 Use get_bookmark() |
0 | 2014 |
* @see get_bookmark() |
2015 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2016 |
* @param int $bookmark_id ID of link |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2017 |
* @param string $output Optional. Type of output. Accepts OBJECT, ARRAY_N, or ARRAY_A. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2018 |
* Default OBJECT. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2019 |
* @param string $filter Optional. How to filter the link for output. Accepts 'raw', 'edit', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2020 |
* 'attribute', 'js', 'db', or 'display'. Default 'raw'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2021 |
* @return object|array Bookmark object or array, depending on the type specified by `$output`. |
0 | 2022 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2023 |
function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2024 |
_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' ); |
0 | 2025 |
return get_bookmark($bookmark_id, $output, $filter); |
2026 |
} |
|
2027 |
||
2028 |
/** |
|
2029 |
* Checks and cleans a URL. |
|
2030 |
* |
|
2031 |
* 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
|
2032 |
* (the default behavior) ampersands are also replaced. The 'clean_url' filter |
0 | 2033 |
* is applied to the returned cleaned URL. |
2034 |
* |
|
2035 |
* @since 1.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2036 |
* @deprecated 3.0.0 Use esc_url() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2037 |
* @see esc_url() |
0 | 2038 |
* |
2039 |
* @param string $url The URL to be cleaned. |
|
2040 |
* @param array $protocols Optional. An array of acceptable protocols. |
|
2041 |
* @param string $context Optional. How the URL will be used. Default is 'display'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2042 |
* @return string The cleaned $url after the {@see 'clean_url'} filter is applied. |
0 | 2043 |
*/ |
2044 |
function clean_url( $url, $protocols = null, $context = 'display' ) { |
|
2045 |
if ( $context == 'db' ) |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2046 |
_deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'sanitize_url()' ); |
0 | 2047 |
else |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2048 |
_deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' ); |
0 | 2049 |
return esc_url( $url, $protocols, $context ); |
2050 |
} |
|
2051 |
||
2052 |
/** |
|
2053 |
* Escape single quotes, specialchar double quotes, and fix line endings. |
|
2054 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2055 |
* The filter {@see 'js_escape'} is also applied by esc_js(). |
0 | 2056 |
* |
2057 |
* @since 2.0.4 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2058 |
* @deprecated 2.8.0 Use esc_js() |
0 | 2059 |
* @see esc_js() |
2060 |
* |
|
2061 |
* @param string $text The text to be escaped. |
|
2062 |
* @return string Escaped text. |
|
2063 |
*/ |
|
2064 |
function js_escape( $text ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2065 |
_deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' ); |
0 | 2066 |
return esc_js( $text ); |
2067 |
} |
|
2068 |
||
2069 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2070 |
* Legacy escaping for HTML blocks. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2071 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2072 |
* @deprecated 2.8.0 Use esc_html() |
0 | 2073 |
* @see esc_html() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2074 |
* |
19 | 2075 |
* @param string $text Text to escape. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2076 |
* @param string $quote_style Unused. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2077 |
* @param false|string $charset Unused. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2078 |
* @param false $double_encode Whether to double encode. Unused. |
19 | 2079 |
* @return string Escaped `$text`. |
0 | 2080 |
*/ |
19 | 2081 |
function wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2082 |
_deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2083 |
if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments. |
19 | 2084 |
return _wp_specialchars( $text, $quote_style, $charset, $double_encode ); |
0 | 2085 |
} else { |
19 | 2086 |
return esc_html( $text ); |
0 | 2087 |
} |
2088 |
} |
|
2089 |
||
2090 |
/** |
|
2091 |
* Escaping for HTML attributes. |
|
2092 |
* |
|
2093 |
* @since 2.0.6 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2094 |
* @deprecated 2.8.0 Use esc_attr() |
0 | 2095 |
* @see esc_attr() |
2096 |
* |
|
2097 |
* @param string $text |
|
2098 |
* @return string |
|
2099 |
*/ |
|
2100 |
function attribute_escape( $text ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2101 |
_deprecated_function( __FUNCTION__, '2.8.0', 'esc_attr()' ); |
0 | 2102 |
return esc_attr( $text ); |
2103 |
} |
|
2104 |
||
2105 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2106 |
* Register widget for sidebar with backward compatibility. |
0 | 2107 |
* |
2108 |
* Allows $name to be an array that accepts either three elements to grab the |
|
2109 |
* first element and the third for the name or just uses the first element of |
|
2110 |
* the array for the name. |
|
2111 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2112 |
* Passes to wp_register_sidebar_widget() after argument list and backward |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2113 |
* compatibility is complete. |
0 | 2114 |
* |
2115 |
* @since 2.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2116 |
* @deprecated 2.8.0 Use wp_register_sidebar_widget() |
0 | 2117 |
* @see wp_register_sidebar_widget() |
2118 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2119 |
* @param string|int $name Widget ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2120 |
* @param callable $output_callback Run when widget is called. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2121 |
* @param string $classname Optional. Classname widget option. Default empty. |
16 | 2122 |
* @param mixed ...$params Widget parameters. |
0 | 2123 |
*/ |
16 | 2124 |
function register_sidebar_widget($name, $output_callback, $classname = '', ...$params) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2125 |
_deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' ); |
16 | 2126 |
// Compat. |
2127 |
if ( is_array( $name ) ) { |
|
2128 |
if ( count( $name ) === 3 ) { |
|
2129 |
$name = sprintf( $name[0], $name[2] ); |
|
2130 |
} else { |
|
0 | 2131 |
$name = $name[0]; |
16 | 2132 |
} |
0 | 2133 |
} |
2134 |
||
16 | 2135 |
$id = sanitize_title( $name ); |
0 | 2136 |
$options = array(); |
16 | 2137 |
if ( ! empty( $classname ) && is_string( $classname ) ) { |
0 | 2138 |
$options['classname'] = $classname; |
16 | 2139 |
} |
2140 |
||
2141 |
wp_register_sidebar_widget( $id, $name, $output_callback, $options, ...$params ); |
|
0 | 2142 |
} |
2143 |
||
2144 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2145 |
* Serves as an alias of wp_unregister_sidebar_widget(). |
0 | 2146 |
* |
2147 |
* @since 2.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2148 |
* @deprecated 2.8.0 Use wp_unregister_sidebar_widget() |
0 | 2149 |
* @see wp_unregister_sidebar_widget() |
2150 |
* |
|
2151 |
* @param int|string $id Widget ID. |
|
2152 |
*/ |
|
2153 |
function unregister_sidebar_widget($id) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2154 |
_deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_sidebar_widget()' ); |
0 | 2155 |
return wp_unregister_sidebar_widget($id); |
2156 |
} |
|
2157 |
||
2158 |
/** |
|
2159 |
* Registers widget control callback for customizing options. |
|
2160 |
* |
|
2161 |
* Allows $name to be an array that accepts either three elements to grab the |
|
2162 |
* first element and the third for the name or just uses the first element of |
|
2163 |
* the array for the name. |
|
2164 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2165 |
* Passes to wp_register_widget_control() after the argument list has |
0 | 2166 |
* been compiled. |
2167 |
* |
|
2168 |
* @since 2.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2169 |
* @deprecated 2.8.0 Use wp_register_widget_control() |
0 | 2170 |
* @see wp_register_widget_control() |
2171 |
* |
|
16 | 2172 |
* @param int|string $name Sidebar ID. |
2173 |
* @param callable $control_callback Widget control callback to display and process form. |
|
2174 |
* @param int $width Widget width. |
|
2175 |
* @param int $height Widget height. |
|
2176 |
* @param mixed ...$params Widget parameters. |
|
0 | 2177 |
*/ |
16 | 2178 |
function register_widget_control($name, $control_callback, $width = '', $height = '', ...$params) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2179 |
_deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' ); |
16 | 2180 |
// Compat. |
2181 |
if ( is_array( $name ) ) { |
|
2182 |
if ( count( $name ) === 3 ) { |
|
2183 |
$name = sprintf( $name[0], $name[2] ); |
|
2184 |
} else { |
|
0 | 2185 |
$name = $name[0]; |
16 | 2186 |
} |
0 | 2187 |
} |
2188 |
||
16 | 2189 |
$id = sanitize_title( $name ); |
0 | 2190 |
$options = array(); |
16 | 2191 |
if ( ! empty( $width ) ) { |
0 | 2192 |
$options['width'] = $width; |
16 | 2193 |
} |
2194 |
if ( ! empty( $height ) ) { |
|
0 | 2195 |
$options['height'] = $height; |
16 | 2196 |
} |
2197 |
||
2198 |
wp_register_widget_control( $id, $name, $control_callback, $options, ...$params ); |
|
0 | 2199 |
} |
2200 |
||
2201 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2202 |
* Alias of wp_unregister_widget_control(). |
0 | 2203 |
* |
2204 |
* @since 2.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2205 |
* @deprecated 2.8.0 Use wp_unregister_widget_control() |
0 | 2206 |
* @see wp_unregister_widget_control() |
2207 |
* |
|
2208 |
* @param int|string $id Widget ID. |
|
2209 |
*/ |
|
2210 |
function unregister_widget_control($id) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2211 |
_deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_widget_control()' ); |
0 | 2212 |
return wp_unregister_widget_control($id); |
2213 |
} |
|
2214 |
||
2215 |
/** |
|
2216 |
* Remove user meta data. |
|
2217 |
* |
|
2218 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2219 |
* @deprecated 3.0.0 Use delete_user_meta() |
0 | 2220 |
* @see delete_user_meta() |
2221 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2222 |
* @global wpdb $wpdb WordPress database abstraction object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2223 |
* |
0 | 2224 |
* @param int $user_id User ID. |
2225 |
* @param string $meta_key Metadata key. |
|
16 | 2226 |
* @param mixed $meta_value Optional. Metadata value. Default empty. |
0 | 2227 |
* @return bool True deletion completed and false if user_id is not a number. |
2228 |
*/ |
|
2229 |
function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2230 |
_deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' ); |
0 | 2231 |
global $wpdb; |
2232 |
if ( !is_numeric( $user_id ) ) |
|
2233 |
return false; |
|
2234 |
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
|
2235 |
||
2236 |
if ( is_array($meta_value) || is_object($meta_value) ) |
|
2237 |
$meta_value = serialize($meta_value); |
|
2238 |
$meta_value = trim( $meta_value ); |
|
2239 |
||
2240 |
$cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2241 |
||
2242 |
if ( $cur && $cur->umeta_id ) |
|
2243 |
do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2244 |
||
2245 |
if ( ! empty($meta_value) ) |
|
2246 |
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); |
|
2247 |
else |
|
2248 |
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2249 |
||
2250 |
clean_user_cache( $user_id ); |
|
2251 |
wp_cache_delete( $user_id, 'user_meta' ); |
|
2252 |
||
2253 |
if ( $cur && $cur->umeta_id ) |
|
2254 |
do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2255 |
||
2256 |
return true; |
|
2257 |
} |
|
2258 |
||
2259 |
/** |
|
2260 |
* Retrieve user metadata. |
|
2261 |
* |
|
2262 |
* If $user_id is not a number, then the function will fail over with a 'false' |
|
2263 |
* boolean return value. Other returned values depend on whether there is only |
|
2264 |
* one item to be returned, which be that single item type. If there is more |
|
2265 |
* than one metadata value, then it will be list of metadata values. |
|
2266 |
* |
|
2267 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2268 |
* @deprecated 3.0.0 Use get_user_meta() |
0 | 2269 |
* @see get_user_meta() |
2270 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2271 |
* @global wpdb $wpdb WordPress database abstraction object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2272 |
* |
0 | 2273 |
* @param int $user_id User ID |
16 | 2274 |
* @param string $meta_key Optional. Metadata key. Default empty. |
0 | 2275 |
* @return mixed |
2276 |
*/ |
|
2277 |
function get_usermeta( $user_id, $meta_key = '' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2278 |
_deprecated_function( __FUNCTION__, '3.0.0', 'get_user_meta()' ); |
0 | 2279 |
global $wpdb; |
2280 |
$user_id = (int) $user_id; |
|
2281 |
||
2282 |
if ( !$user_id ) |
|
2283 |
return false; |
|
2284 |
||
2285 |
if ( !empty($meta_key) ) { |
|
2286 |
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
|
2287 |
$user = wp_cache_get($user_id, 'users'); |
|
16 | 2288 |
// Check the cached user object. |
0 | 2289 |
if ( false !== $user && isset($user->$meta_key) ) |
2290 |
$metas = array($user->$meta_key); |
|
2291 |
else |
|
2292 |
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2293 |
} else { |
|
2294 |
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); |
|
2295 |
} |
|
2296 |
||
2297 |
if ( empty($metas) ) { |
|
2298 |
if ( empty($meta_key) ) |
|
2299 |
return array(); |
|
2300 |
else |
|
2301 |
return ''; |
|
2302 |
} |
|
2303 |
||
2304 |
$metas = array_map('maybe_unserialize', $metas); |
|
2305 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2306 |
if ( count($metas) === 1 ) |
0 | 2307 |
return $metas[0]; |
2308 |
else |
|
2309 |
return $metas; |
|
2310 |
} |
|
2311 |
||
2312 |
/** |
|
2313 |
* Update metadata of user. |
|
2314 |
* |
|
2315 |
* There is no need to serialize values, they will be serialized if it is |
|
2316 |
* needed. The metadata key can only be a string with underscores. All else will |
|
2317 |
* be removed. |
|
2318 |
* |
|
2319 |
* Will remove the metadata, if the meta value is empty. |
|
2320 |
* |
|
2321 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2322 |
* @deprecated 3.0.0 Use update_user_meta() |
0 | 2323 |
* @see update_user_meta() |
2324 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2325 |
* @global wpdb $wpdb WordPress database abstraction object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2326 |
* |
0 | 2327 |
* @param int $user_id User ID |
2328 |
* @param string $meta_key Metadata key. |
|
2329 |
* @param mixed $meta_value Metadata value. |
|
2330 |
* @return bool True on successful update, false on failure. |
|
2331 |
*/ |
|
2332 |
function update_usermeta( $user_id, $meta_key, $meta_value ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2333 |
_deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' ); |
0 | 2334 |
global $wpdb; |
2335 |
if ( !is_numeric( $user_id ) ) |
|
2336 |
return false; |
|
2337 |
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
|
2338 |
||
2339 |
/** @todo Might need fix because usermeta data is assumed to be already escaped */ |
|
2340 |
if ( is_string($meta_value) ) |
|
2341 |
$meta_value = stripslashes($meta_value); |
|
2342 |
$meta_value = maybe_serialize($meta_value); |
|
2343 |
||
2344 |
if (empty($meta_value)) { |
|
2345 |
return delete_usermeta($user_id, $meta_key); |
|
2346 |
} |
|
2347 |
||
2348 |
$cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
2349 |
||
2350 |
if ( $cur ) |
|
2351 |
do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2352 |
||
2353 |
if ( !$cur ) |
|
2354 |
$wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); |
|
5 | 2355 |
elseif ( $cur->meta_value != $meta_value ) |
0 | 2356 |
$wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); |
2357 |
else |
|
2358 |
return false; |
|
2359 |
||
2360 |
clean_user_cache( $user_id ); |
|
2361 |
wp_cache_delete( $user_id, 'user_meta' ); |
|
2362 |
||
2363 |
if ( !$cur ) |
|
2364 |
do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); |
|
2365 |
else |
|
2366 |
do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
2367 |
||
2368 |
return true; |
|
2369 |
} |
|
2370 |
||
2371 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2372 |
* Get users for the site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2373 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2374 |
* For setups that use the multisite feature. Can be used outside of the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2375 |
* multisite feature. |
0 | 2376 |
* |
2377 |
* @since 2.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2378 |
* @deprecated 3.1.0 Use get_users() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2379 |
* @see get_users() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2380 |
* |
16 | 2381 |
* @global wpdb $wpdb WordPress database abstraction object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2382 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2383 |
* @param int $id Site ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2384 |
* @return array List of users that are part of that site ID |
0 | 2385 |
*/ |
2386 |
function get_users_of_blog( $id = '' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2387 |
_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2388 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2389 |
global $wpdb; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2390 |
if ( empty( $id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2391 |
$id = get_current_blog_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2392 |
} |
0 | 2393 |
$blog_prefix = $wpdb->get_blog_prefix($id); |
2394 |
$users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); |
|
2395 |
return $users; |
|
2396 |
} |
|
2397 |
||
2398 |
/** |
|
2399 |
* Enable/disable automatic general feed link outputting. |
|
2400 |
* |
|
2401 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2402 |
* @deprecated 3.0.0 Use add_theme_support() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2403 |
* @see add_theme_support() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2404 |
* |
16 | 2405 |
* @param bool $add Optional. Add or remove links. Default true. |
0 | 2406 |
*/ |
2407 |
function automatic_feed_links( $add = true ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2408 |
_deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" ); |
0 | 2409 |
|
2410 |
if ( $add ) |
|
2411 |
add_theme_support( 'automatic-feed-links' ); |
|
2412 |
else |
|
16 | 2413 |
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+. |
0 | 2414 |
} |
2415 |
||
2416 |
/** |
|
2417 |
* Retrieve user data based on field. |
|
2418 |
* |
|
2419 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2420 |
* @deprecated 3.0.0 Use get_the_author_meta() |
0 | 2421 |
* @see get_the_author_meta() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2422 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2423 |
* @param string $field User meta field. |
16 | 2424 |
* @param false|int $user Optional. User ID to retrieve the field for. Default false (current user). |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2425 |
* @return string The author's field from the current author's DB object. |
0 | 2426 |
*/ |
2427 |
function get_profile( $field, $user = false ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2428 |
_deprecated_function( __FUNCTION__, '3.0.0', 'get_the_author_meta()' ); |
0 | 2429 |
if ( $user ) { |
2430 |
$user = get_user_by( 'login', $user ); |
|
2431 |
$user = $user->ID; |
|
2432 |
} |
|
2433 |
return get_the_author_meta( $field, $user ); |
|
2434 |
} |
|
2435 |
||
2436 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2437 |
* Retrieves the number of posts a user has written. |
0 | 2438 |
* |
2439 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2440 |
* @deprecated 3.0.0 Use count_user_posts() |
0 | 2441 |
* @see count_user_posts() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2442 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2443 |
* @param int $userid User to count posts for. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2444 |
* @return int Number of posts the given user has written. |
0 | 2445 |
*/ |
2446 |
function get_usernumposts( $userid ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2447 |
_deprecated_function( __FUNCTION__, '3.0.0', 'count_user_posts()' ); |
0 | 2448 |
return count_user_posts( $userid ); |
2449 |
} |
|
2450 |
||
2451 |
/** |
|
2452 |
* Callback used to change %uXXXX to &#YYY; syntax |
|
2453 |
* |
|
2454 |
* @since 2.8.0 |
|
2455 |
* @access private |
|
2456 |
* @deprecated 3.0.0 |
|
2457 |
* |
|
2458 |
* @param array $matches Single Match |
|
2459 |
* @return string An HTML entity |
|
2460 |
*/ |
|
2461 |
function funky_javascript_callback($matches) { |
|
2462 |
return "&#".base_convert($matches[1],16,10).";"; |
|
2463 |
} |
|
2464 |
||
2465 |
/** |
|
5 | 2466 |
* Fixes JavaScript bugs in browsers. |
0 | 2467 |
* |
2468 |
* Converts unicode characters to HTML numbered entities. |
|
2469 |
* |
|
2470 |
* @since 1.5.0 |
|
2471 |
* @deprecated 3.0.0 |
|
2472 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2473 |
* @global $is_macIE |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2474 |
* @global $is_winIE |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2475 |
* |
0 | 2476 |
* @param string $text Text to be made safe. |
2477 |
* @return string Fixed text. |
|
2478 |
*/ |
|
2479 |
function funky_javascript_fix($text) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2480 |
_deprecated_function( __FUNCTION__, '3.0.0' ); |
5 | 2481 |
// Fixes for browsers' JavaScript bugs. |
0 | 2482 |
global $is_macIE, $is_winIE; |
2483 |
||
2484 |
if ( $is_winIE || $is_macIE ) |
|
2485 |
$text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", |
|
2486 |
"funky_javascript_callback", |
|
2487 |
$text); |
|
2488 |
||
2489 |
return $text; |
|
2490 |
} |
|
2491 |
||
2492 |
/** |
|
2493 |
* Checks that the taxonomy name exists. |
|
2494 |
* |
|
2495 |
* @since 2.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2496 |
* @deprecated 3.0.0 Use taxonomy_exists() |
0 | 2497 |
* @see taxonomy_exists() |
2498 |
* |
|
2499 |
* @param string $taxonomy Name of taxonomy object |
|
2500 |
* @return bool Whether the taxonomy exists. |
|
2501 |
*/ |
|
2502 |
function is_taxonomy( $taxonomy ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2503 |
_deprecated_function( __FUNCTION__, '3.0.0', 'taxonomy_exists()' ); |
0 | 2504 |
return taxonomy_exists( $taxonomy ); |
2505 |
} |
|
2506 |
||
2507 |
/** |
|
2508 |
* Check if Term exists. |
|
2509 |
* |
|
2510 |
* @since 2.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2511 |
* @deprecated 3.0.0 Use term_exists() |
0 | 2512 |
* @see term_exists() |
2513 |
* |
|
2514 |
* @param int|string $term The term to check |
|
2515 |
* @param string $taxonomy The taxonomy name to use |
|
2516 |
* @param int $parent ID of parent term under which to confine the exists search. |
|
16 | 2517 |
* @return mixed Get the term ID or term object, if exists. |
0 | 2518 |
*/ |
2519 |
function is_term( $term, $taxonomy = '', $parent = 0 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2520 |
_deprecated_function( __FUNCTION__, '3.0.0', 'term_exists()' ); |
0 | 2521 |
return term_exists( $term, $taxonomy, $parent ); |
2522 |
} |
|
2523 |
||
2524 |
/** |
|
9 | 2525 |
* Determines whether the current admin page is generated by a plugin. |
0 | 2526 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2527 |
* Use global $plugin_page and/or get_plugin_page_hookname() hooks. |
16 | 2528 |
* |
9 | 2529 |
* For more information on this and similar theme functions, check out |
16 | 2530 |
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
9 | 2531 |
* Conditional Tags} article in the Theme Developer Handbook. |
16 | 2532 |
* |
0 | 2533 |
* @since 1.5.0 |
2534 |
* @deprecated 3.1.0 |
|
2535 |
* |
|
2536 |
* @global $plugin_page |
|
2537 |
* |
|
2538 |
* @return bool |
|
2539 |
*/ |
|
2540 |
function is_plugin_page() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2541 |
_deprecated_function( __FUNCTION__, '3.1.0' ); |
0 | 2542 |
|
2543 |
global $plugin_page; |
|
2544 |
||
2545 |
if ( isset($plugin_page) ) |
|
2546 |
return true; |
|
2547 |
||
2548 |
return false; |
|
2549 |
} |
|
2550 |
||
2551 |
/** |
|
2552 |
* Update the categories cache. |
|
2553 |
* |
|
2554 |
* This function does not appear to be used anymore or does not appear to be |
|
2555 |
* needed. It might be a legacy function left over from when there was a need |
|
2556 |
* for updating the category cache. |
|
2557 |
* |
|
2558 |
* @since 1.5.0 |
|
2559 |
* @deprecated 3.1.0 |
|
2560 |
* |
|
2561 |
* @return bool Always return True |
|
2562 |
*/ |
|
2563 |
function update_category_cache() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2564 |
_deprecated_function( __FUNCTION__, '3.1.0' ); |
0 | 2565 |
|
2566 |
return true; |
|
2567 |
} |
|
2568 |
||
2569 |
/** |
|
2570 |
* Check for PHP timezone support |
|
2571 |
* |
|
2572 |
* @since 2.9.0 |
|
2573 |
* @deprecated 3.2.0 |
|
2574 |
* |
|
2575 |
* @return bool |
|
2576 |
*/ |
|
2577 |
function wp_timezone_supported() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2578 |
_deprecated_function( __FUNCTION__, '3.2.0' ); |
0 | 2579 |
|
2580 |
return true; |
|
2581 |
} |
|
2582 |
||
2583 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2584 |
* Displays an editor: TinyMCE, HTML, or both. |
0 | 2585 |
* |
2586 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2587 |
* @deprecated 3.3.0 Use wp_editor() |
0 | 2588 |
* @see wp_editor() |
2589 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2590 |
* @param string $content Textarea content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2591 |
* @param string $id Optional. HTML ID attribute value. Default 'content'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2592 |
* @param string $prev_id Optional. Unused. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2593 |
* @param bool $media_buttons Optional. Whether to display media buttons. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2594 |
* @param int $tab_index Optional. Unused. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2595 |
* @param bool $extended Optional. Unused. |
0 | 2596 |
*/ |
2597 |
function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2598 |
_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' ); |
0 | 2599 |
|
2600 |
wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) ); |
|
2601 |
} |
|
2602 |
||
2603 |
/** |
|
2604 |
* Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users |
|
2605 |
* |
|
2606 |
* @since 3.0.0 |
|
2607 |
* @deprecated 3.3.0 |
|
2608 |
* |
|
2609 |
* @param array $ids User ID numbers list. |
|
2610 |
* @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays. |
|
2611 |
*/ |
|
2612 |
function get_user_metavalues($ids) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2613 |
_deprecated_function( __FUNCTION__, '3.3.0' ); |
0 | 2614 |
|
2615 |
$objects = array(); |
|
2616 |
||
2617 |
$ids = array_map('intval', $ids); |
|
2618 |
foreach ( $ids as $id ) |
|
2619 |
$objects[$id] = array(); |
|
2620 |
||
2621 |
$metas = update_meta_cache('user', $ids); |
|
2622 |
||
2623 |
foreach ( $metas as $id => $meta ) { |
|
2624 |
foreach ( $meta as $key => $metavalues ) { |
|
2625 |
foreach ( $metavalues as $value ) { |
|
2626 |
$objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value); |
|
2627 |
} |
|
2628 |
} |
|
2629 |
} |
|
2630 |
||
2631 |
return $objects; |
|
2632 |
} |
|
2633 |
||
2634 |
/** |
|
2635 |
* Sanitize every user field. |
|
2636 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2637 |
* If the context is 'raw', then the user object or array will get minimal sanitization of the int fields. |
0 | 2638 |
* |
2639 |
* @since 2.3.0 |
|
2640 |
* @deprecated 3.3.0 |
|
2641 |
* |
|
16 | 2642 |
* @param object|array $user The user object or array. |
2643 |
* @param string $context Optional. How to sanitize user fields. Default 'display'. |
|
2644 |
* @return object|array The now sanitized user object or array (will be the same type as $user). |
|
0 | 2645 |
*/ |
2646 |
function sanitize_user_object($user, $context = 'display') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2647 |
_deprecated_function( __FUNCTION__, '3.3.0' ); |
0 | 2648 |
|
2649 |
if ( is_object($user) ) { |
|
2650 |
if ( !isset($user->ID) ) |
|
2651 |
$user->ID = 0; |
|
5 | 2652 |
if ( ! ( $user instanceof WP_User ) ) { |
0 | 2653 |
$vars = get_object_vars($user); |
2654 |
foreach ( array_keys($vars) as $field ) { |
|
2655 |
if ( is_string($user->$field) || is_numeric($user->$field) ) |
|
2656 |
$user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); |
|
2657 |
} |
|
2658 |
} |
|
2659 |
$user->filter = $context; |
|
2660 |
} else { |
|
2661 |
if ( !isset($user['ID']) ) |
|
2662 |
$user['ID'] = 0; |
|
2663 |
foreach ( array_keys($user) as $field ) |
|
2664 |
$user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); |
|
2665 |
$user['filter'] = $context; |
|
2666 |
} |
|
2667 |
||
2668 |
return $user; |
|
2669 |
} |
|
2670 |
||
2671 |
/** |
|
2672 |
* Get boundary post relational link. |
|
2673 |
* |
|
2674 |
* Can either be start or end post relational link. |
|
2675 |
* |
|
2676 |
* @since 2.8.0 |
|
2677 |
* @deprecated 3.3.0 |
|
2678 |
* |
|
16 | 2679 |
* @param string $title Optional. Link title format. Default '%title'. |
2680 |
* @param bool $in_same_cat Optional. Whether link should be in a same category. |
|
2681 |
* Default false. |
|
2682 |
* @param string $excluded_categories Optional. Excluded categories IDs. Default empty. |
|
2683 |
* @param bool $start Optional. Whether to display link to first or last post. |
|
2684 |
* Default true. |
|
0 | 2685 |
* @return string |
2686 |
*/ |
|
2687 |
function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2688 |
_deprecated_function( __FUNCTION__, '3.3.0' ); |
0 | 2689 |
|
2690 |
$posts = get_boundary_post($in_same_cat, $excluded_categories, $start); |
|
16 | 2691 |
// If there is no post, stop. |
0 | 2692 |
if ( empty($posts) ) |
2693 |
return; |
|
2694 |
||
16 | 2695 |
// Even though we limited get_posts() to return only 1 item it still returns an array of objects. |
0 | 2696 |
$post = $posts[0]; |
2697 |
||
2698 |
if ( empty($post->post_title) ) |
|
2699 |
$post->post_title = $start ? __('First Post') : __('Last Post'); |
|
2700 |
||
2701 |
$date = mysql2date(get_option('date_format'), $post->post_date); |
|
2702 |
||
2703 |
$title = str_replace('%title', $post->post_title, $title); |
|
2704 |
$title = str_replace('%date', $date, $title); |
|
2705 |
$title = apply_filters('the_title', $title, $post->ID); |
|
2706 |
||
2707 |
$link = $start ? "<link rel='start' title='" : "<link rel='end' title='"; |
|
2708 |
$link .= esc_attr($title); |
|
2709 |
$link .= "' href='" . get_permalink($post) . "' />\n"; |
|
2710 |
||
2711 |
$boundary = $start ? 'start' : 'end'; |
|
2712 |
return apply_filters( "{$boundary}_post_rel_link", $link ); |
|
2713 |
} |
|
2714 |
||
2715 |
/** |
|
2716 |
* Display relational link for the first post. |
|
2717 |
* |
|
2718 |
* @since 2.8.0 |
|
2719 |
* @deprecated 3.3.0 |
|
2720 |
* |
|
2721 |
* @param string $title Optional. Link title format. |
|
2722 |
* @param bool $in_same_cat Optional. Whether link should be in a same category. |
|
2723 |
* @param string $excluded_categories Optional. Excluded categories IDs. |
|
2724 |
*/ |
|
2725 |
function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2726 |
_deprecated_function( __FUNCTION__, '3.3.0' ); |
0 | 2727 |
|
2728 |
echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true); |
|
2729 |
} |
|
2730 |
||
2731 |
/** |
|
2732 |
* Get site index relational link. |
|
2733 |
* |
|
2734 |
* @since 2.8.0 |
|
2735 |
* @deprecated 3.3.0 |
|
2736 |
* |
|
2737 |
* @return string |
|
2738 |
*/ |
|
2739 |
function get_index_rel_link() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2740 |
_deprecated_function( __FUNCTION__, '3.3.0' ); |
0 | 2741 |
|
2742 |
$link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n"; |
|
2743 |
return apply_filters( "index_rel_link", $link ); |
|
2744 |
} |
|
2745 |
||
2746 |
/** |
|
2747 |
* Display relational link for the site index. |
|
2748 |
* |
|
2749 |
* @since 2.8.0 |
|
2750 |
* @deprecated 3.3.0 |
|
2751 |
*/ |
|
2752 |
function index_rel_link() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2753 |
_deprecated_function( __FUNCTION__, '3.3.0' ); |
0 | 2754 |
|
2755 |
echo get_index_rel_link(); |
|
2756 |
} |
|
2757 |
||
2758 |
/** |
|
2759 |
* Get parent post relational link. |
|
2760 |
* |
|
2761 |
* @since 2.8.0 |
|
2762 |
* @deprecated 3.3.0 |
|
2763 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2764 |
* @global WP_Post $post Global post object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2765 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2766 |
* @param string $title Optional. Link title format. Default '%title'. |
0 | 2767 |
* @return string |
2768 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2769 |
function get_parent_post_rel_link( $title = '%title' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2770 |
_deprecated_function( __FUNCTION__, '3.3.0' ); |
0 | 2771 |
|
2772 |
if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) |
|
2773 |
$post = get_post($GLOBALS['post']->post_parent); |
|
2774 |
||
2775 |
if ( empty($post) ) |
|
2776 |
return; |
|
2777 |
||
2778 |
$date = mysql2date(get_option('date_format'), $post->post_date); |
|
2779 |
||
2780 |
$title = str_replace('%title', $post->post_title, $title); |
|
2781 |
$title = str_replace('%date', $date, $title); |
|
2782 |
$title = apply_filters('the_title', $title, $post->ID); |
|
2783 |
||
2784 |
$link = "<link rel='up' title='"; |
|
2785 |
$link .= esc_attr( $title ); |
|
2786 |
$link .= "' href='" . get_permalink($post) . "' />\n"; |
|
2787 |
||
2788 |
return apply_filters( "parent_post_rel_link", $link ); |
|
2789 |
} |
|
2790 |
||
2791 |
/** |
|
2792 |
* Display relational link for parent item |
|
2793 |
* |
|
2794 |
* @since 2.8.0 |
|
2795 |
* @deprecated 3.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2796 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2797 |
* @param string $title Optional. Link title format. Default '%title'. |
0 | 2798 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2799 |
function parent_post_rel_link( $title = '%title' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2800 |
_deprecated_function( __FUNCTION__, '3.3.0' ); |
0 | 2801 |
|
2802 |
echo get_parent_post_rel_link($title); |
|
2803 |
} |
|
2804 |
||
2805 |
/** |
|
2806 |
* Add the "Dashboard"/"Visit Site" menu. |
|
2807 |
* |
|
2808 |
* @since 3.2.0 |
|
2809 |
* @deprecated 3.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2810 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2811 |
* @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance. |
0 | 2812 |
*/ |
2813 |
function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2814 |
_deprecated_function( __FUNCTION__, '3.3.0' ); |
0 | 2815 |
|
2816 |
$user_id = get_current_user_id(); |
|
2817 |
||
2818 |
if ( 0 != $user_id ) { |
|
2819 |
if ( is_admin() ) |
|
2820 |
$wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); |
|
2821 |
elseif ( is_multisite() ) |
|
2822 |
$wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); |
|
2823 |
else |
|
2824 |
$wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); |
|
2825 |
} |
|
2826 |
} |
|
2827 |
||
2828 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2829 |
* Checks if the current user belong to a given site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2830 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2831 |
* @since MU (3.0.0) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2832 |
* @deprecated 3.3.0 Use is_user_member_of_blog() |
0 | 2833 |
* @see is_user_member_of_blog() |
2834 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2835 |
* @param int $blog_id Site ID |
0 | 2836 |
* @return bool True if the current users belong to $blog_id, false if not. |
2837 |
*/ |
|
2838 |
function is_blog_user( $blog_id = 0 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2839 |
_deprecated_function( __FUNCTION__, '3.3.0', 'is_user_member_of_blog()' ); |
0 | 2840 |
|
2841 |
return is_user_member_of_blog( get_current_user_id(), $blog_id ); |
|
2842 |
} |
|
2843 |
||
2844 |
/** |
|
2845 |
* Open the file handle for debugging. |
|
2846 |
* |
|
2847 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2848 |
* @deprecated 3.4.0 Use error_log() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2849 |
* @see error_log() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2850 |
* |
16 | 2851 |
* @link https://www.php.net/manual/en/function.error-log.php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2852 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2853 |
* @param string $filename File name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2854 |
* @param string $mode Type of access you required to the stream. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2855 |
* @return false Always false. |
0 | 2856 |
*/ |
2857 |
function debug_fopen( $filename, $mode ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2858 |
_deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); |
0 | 2859 |
return false; |
2860 |
} |
|
2861 |
||
2862 |
/** |
|
2863 |
* Write contents to the file used for debugging. |
|
2864 |
* |
|
2865 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2866 |
* @deprecated 3.4.0 Use error_log() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2867 |
* @see error_log() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2868 |
* |
16 | 2869 |
* @link https://www.php.net/manual/en/function.error-log.php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2870 |
* |
19 | 2871 |
* @param mixed $fp Unused. |
2872 |
* @param string $message Message to log. |
|
0 | 2873 |
*/ |
19 | 2874 |
function debug_fwrite( $fp, $message ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2875 |
_deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); |
0 | 2876 |
if ( ! empty( $GLOBALS['debug'] ) ) |
19 | 2877 |
error_log( $message ); |
0 | 2878 |
} |
2879 |
||
2880 |
/** |
|
2881 |
* Close the debugging file handle. |
|
2882 |
* |
|
2883 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2884 |
* @deprecated 3.4.0 Use error_log() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2885 |
* @see error_log() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2886 |
* |
16 | 2887 |
* @link https://www.php.net/manual/en/function.error-log.php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2888 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2889 |
* @param mixed $fp Unused. |
0 | 2890 |
*/ |
2891 |
function debug_fclose( $fp ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2892 |
_deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); |
0 | 2893 |
} |
2894 |
||
2895 |
/** |
|
2896 |
* Retrieve list of themes with theme data in theme directory. |
|
2897 |
* |
|
2898 |
* The theme is broken, if it doesn't have a parent theme and is missing either |
|
2899 |
* style.css and, or index.php. If the theme has a parent theme then it is |
|
2900 |
* broken, if it is missing style.css; index.php is optional. |
|
2901 |
* |
|
2902 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2903 |
* @deprecated 3.4.0 Use wp_get_themes() |
0 | 2904 |
* @see wp_get_themes() |
2905 |
* |
|
2906 |
* @return array Theme list with theme data. |
|
2907 |
*/ |
|
2908 |
function get_themes() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2909 |
_deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_themes()' ); |
0 | 2910 |
|
2911 |
global $wp_themes; |
|
2912 |
if ( isset( $wp_themes ) ) |
|
2913 |
return $wp_themes; |
|
2914 |
||
2915 |
$themes = wp_get_themes(); |
|
2916 |
$wp_themes = array(); |
|
2917 |
||
2918 |
foreach ( $themes as $theme ) { |
|
2919 |
$name = $theme->get('Name'); |
|
2920 |
if ( isset( $wp_themes[ $name ] ) ) |
|
2921 |
$wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; |
|
2922 |
else |
|
2923 |
$wp_themes[ $name ] = $theme; |
|
2924 |
} |
|
2925 |
||
2926 |
return $wp_themes; |
|
2927 |
} |
|
2928 |
||
2929 |
/** |
|
2930 |
* Retrieve theme data. |
|
2931 |
* |
|
2932 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2933 |
* @deprecated 3.4.0 Use wp_get_theme() |
0 | 2934 |
* @see wp_get_theme() |
2935 |
* |
|
2936 |
* @param string $theme Theme name. |
|
2937 |
* @return array|null Null, if theme name does not exist. Theme data, if exists. |
|
2938 |
*/ |
|
2939 |
function get_theme( $theme ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2940 |
_deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )' ); |
0 | 2941 |
|
2942 |
$themes = get_themes(); |
|
2943 |
if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) |
|
2944 |
return $themes[ $theme ]; |
|
2945 |
return null; |
|
2946 |
} |
|
2947 |
||
2948 |
/** |
|
2949 |
* Retrieve current theme name. |
|
2950 |
* |
|
2951 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2952 |
* @deprecated 3.4.0 Use wp_get_theme() |
0 | 2953 |
* @see wp_get_theme() |
2954 |
* |
|
2955 |
* @return string |
|
2956 |
*/ |
|
2957 |
function get_current_theme() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2958 |
_deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); |
0 | 2959 |
|
2960 |
if ( $theme = get_option( 'current_theme' ) ) |
|
2961 |
return $theme; |
|
2962 |
||
2963 |
return wp_get_theme()->get('Name'); |
|
2964 |
} |
|
2965 |
||
2966 |
/** |
|
2967 |
* Accepts matches array from preg_replace_callback in wpautop() or a string. |
|
2968 |
* |
|
5 | 2969 |
* Ensures that the contents of a `<pre>...</pre>` HTML block are not |
16 | 2970 |
* converted into paragraphs or line breaks. |
0 | 2971 |
* |
2972 |
* @since 1.2.0 |
|
2973 |
* @deprecated 3.4.0 |
|
2974 |
* |
|
2975 |
* @param array|string $matches The array or string |
|
16 | 2976 |
* @return string The pre block without paragraph/line break conversion. |
0 | 2977 |
*/ |
2978 |
function clean_pre($matches) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2979 |
_deprecated_function( __FUNCTION__, '3.4.0' ); |
0 | 2980 |
|
2981 |
if ( is_array($matches) ) |
|
2982 |
$text = $matches[1] . $matches[2] . "</pre>"; |
|
2983 |
else |
|
2984 |
$text = $matches; |
|
2985 |
||
2986 |
$text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text); |
|
2987 |
$text = str_replace('<p>', "\n", $text); |
|
2988 |
$text = str_replace('</p>', '', $text); |
|
2989 |
||
2990 |
return $text; |
|
2991 |
} |
|
2992 |
||
2993 |
||
2994 |
/** |
|
2995 |
* Add callbacks for image header display. |
|
2996 |
* |
|
2997 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2998 |
* @deprecated 3.4.0 Use add_theme_support() |
0 | 2999 |
* @see add_theme_support() |
3000 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3001 |
* @param callable $wp_head_callback Call on the {@see 'wp_head'} action. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3002 |
* @param callable $admin_head_callback Call on custom header administration screen. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3003 |
* @param callable $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional. |
0 | 3004 |
*/ |
3005 |
function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3006 |
_deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-header\', $args )' ); |
0 | 3007 |
$args = array( |
3008 |
'wp-head-callback' => $wp_head_callback, |
|
3009 |
'admin-head-callback' => $admin_head_callback, |
|
3010 |
); |
|
3011 |
if ( $admin_preview_callback ) |
|
3012 |
$args['admin-preview-callback'] = $admin_preview_callback; |
|
3013 |
return add_theme_support( 'custom-header', $args ); |
|
3014 |
} |
|
3015 |
||
3016 |
/** |
|
3017 |
* Remove image header support. |
|
3018 |
* |
|
3019 |
* @since 3.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3020 |
* @deprecated 3.4.0 Use remove_theme_support() |
0 | 3021 |
* @see remove_theme_support() |
3022 |
* |
|
5 | 3023 |
* @return null|bool Whether support was removed. |
0 | 3024 |
*/ |
3025 |
function remove_custom_image_header() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3026 |
_deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-header\' )' ); |
0 | 3027 |
return remove_theme_support( 'custom-header' ); |
3028 |
} |
|
3029 |
||
3030 |
/** |
|
3031 |
* Add callbacks for background image display. |
|
3032 |
* |
|
3033 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3034 |
* @deprecated 3.4.0 Use add_theme_support() |
0 | 3035 |
* @see add_theme_support() |
3036 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3037 |
* @param callable $wp_head_callback Call on the {@see 'wp_head'} action. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3038 |
* @param callable $admin_head_callback Call on custom background administration screen. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3039 |
* @param callable $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional. |
0 | 3040 |
*/ |
3041 |
function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3042 |
_deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' ); |
0 | 3043 |
$args = array(); |
3044 |
if ( $wp_head_callback ) |
|
3045 |
$args['wp-head-callback'] = $wp_head_callback; |
|
3046 |
if ( $admin_head_callback ) |
|
3047 |
$args['admin-head-callback'] = $admin_head_callback; |
|
3048 |
if ( $admin_preview_callback ) |
|
3049 |
$args['admin-preview-callback'] = $admin_preview_callback; |
|
3050 |
return add_theme_support( 'custom-background', $args ); |
|
3051 |
} |
|
3052 |
||
3053 |
/** |
|
3054 |
* Remove custom background support. |
|
3055 |
* |
|
3056 |
* @since 3.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3057 |
* @deprecated 3.4.0 Use add_custom_background() |
0 | 3058 |
* @see add_custom_background() |
3059 |
* |
|
5 | 3060 |
* @return null|bool Whether support was removed. |
0 | 3061 |
*/ |
3062 |
function remove_custom_background() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3063 |
_deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-background\' )' ); |
0 | 3064 |
return remove_theme_support( 'custom-background' ); |
3065 |
} |
|
3066 |
||
3067 |
/** |
|
3068 |
* Retrieve theme data from parsed theme file. |
|
3069 |
* |
|
3070 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3071 |
* @deprecated 3.4.0 Use wp_get_theme() |
0 | 3072 |
* @see wp_get_theme() |
3073 |
* |
|
3074 |
* @param string $theme_file Theme file path. |
|
3075 |
* @return array Theme data. |
|
3076 |
*/ |
|
3077 |
function get_theme_data( $theme_file ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3078 |
_deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); |
9 | 3079 |
$theme = new WP_Theme( wp_basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) ); |
0 | 3080 |
|
3081 |
$theme_data = array( |
|
3082 |
'Name' => $theme->get('Name'), |
|
3083 |
'URI' => $theme->display('ThemeURI', true, false), |
|
3084 |
'Description' => $theme->display('Description', true, false), |
|
3085 |
'Author' => $theme->display('Author', true, false), |
|
3086 |
'AuthorURI' => $theme->display('AuthorURI', true, false), |
|
3087 |
'Version' => $theme->get('Version'), |
|
3088 |
'Template' => $theme->get('Template'), |
|
3089 |
'Status' => $theme->get('Status'), |
|
3090 |
'Tags' => $theme->get('Tags'), |
|
3091 |
'Title' => $theme->get('Name'), |
|
3092 |
'AuthorName' => $theme->get('Author'), |
|
3093 |
); |
|
3094 |
||
3095 |
foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) { |
|
3096 |
if ( ! isset( $theme_data[ $extra_header ] ) ) |
|
3097 |
$theme_data[ $extra_header ] = $theme->get( $extra_header ); |
|
3098 |
} |
|
3099 |
||
3100 |
return $theme_data; |
|
3101 |
} |
|
3102 |
||
3103 |
/** |
|
3104 |
* Alias of update_post_cache(). |
|
3105 |
* |
|
3106 |
* @see update_post_cache() Posts and pages are the same, alias is intentional |
|
3107 |
* |
|
3108 |
* @since 1.5.1 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3109 |
* @deprecated 3.4.0 Use update_post_cache() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3110 |
* @see update_post_cache() |
0 | 3111 |
* |
3112 |
* @param array $pages list of page objects |
|
3113 |
*/ |
|
3114 |
function update_page_cache( &$pages ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3115 |
_deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' ); |
0 | 3116 |
|
3117 |
update_post_cache( $pages ); |
|
3118 |
} |
|
3119 |
||
3120 |
/** |
|
3121 |
* Will clean the page in the cache. |
|
3122 |
* |
|
3123 |
* Clean (read: delete) page from cache that matches $id. Will also clean cache |
|
3124 |
* associated with 'all_page_ids' and 'get_pages'. |
|
3125 |
* |
|
3126 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3127 |
* @deprecated 3.4.0 Use clean_post_cache |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3128 |
* @see clean_post_cache() |
0 | 3129 |
* |
3130 |
* @param int $id Page ID to clean |
|
3131 |
*/ |
|
3132 |
function clean_page_cache( $id ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3133 |
_deprecated_function( __FUNCTION__, '3.4.0', 'clean_post_cache()' ); |
0 | 3134 |
|
3135 |
clean_post_cache( $id ); |
|
3136 |
} |
|
3137 |
||
3138 |
/** |
|
3139 |
* Retrieve nonce action "Are you sure" message. |
|
3140 |
* |
|
3141 |
* Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3. |
|
3142 |
* |
|
3143 |
* @since 2.0.4 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3144 |
* @deprecated 3.4.1 Use wp_nonce_ays() |
0 | 3145 |
* @see wp_nonce_ays() |
3146 |
* |
|
3147 |
* @param string $action Nonce action. |
|
3148 |
* @return string Are you sure message. |
|
3149 |
*/ |
|
3150 |
function wp_explain_nonce( $action ) { |
|
3151 |
_deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' ); |
|
3152 |
return __( 'Are you sure you want to do this?' ); |
|
3153 |
} |
|
3154 |
||
3155 |
/** |
|
3156 |
* Display "sticky" CSS class, if a post is sticky. |
|
3157 |
* |
|
3158 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3159 |
* @deprecated 3.5.0 Use post_class() |
0 | 3160 |
* @see post_class() |
3161 |
* |
|
3162 |
* @param int $post_id An optional post ID. |
|
3163 |
*/ |
|
3164 |
function sticky_class( $post_id = null ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3165 |
_deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' ); |
0 | 3166 |
if ( is_sticky( $post_id ) ) |
3167 |
echo ' sticky'; |
|
3168 |
} |
|
3169 |
||
3170 |
/** |
|
3171 |
* Retrieve post ancestors. |
|
3172 |
* |
|
3173 |
* This is no longer needed as WP_Post lazy-loads the ancestors |
|
3174 |
* property with get_post_ancestors(). |
|
3175 |
* |
|
3176 |
* @since 2.3.4 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3177 |
* @deprecated 3.5.0 Use get_post_ancestors() |
0 | 3178 |
* @see get_post_ancestors() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3179 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3180 |
* @param WP_Post $post Post object, passed by reference (unused). |
0 | 3181 |
*/ |
3182 |
function _get_post_ancestors( &$post ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3183 |
_deprecated_function( __FUNCTION__, '3.5.0' ); |
0 | 3184 |
} |
3185 |
||
3186 |
/** |
|
3187 |
* Load an image from a string, if PHP supports it. |
|
3188 |
* |
|
3189 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3190 |
* @deprecated 3.5.0 Use wp_get_image_editor() |
0 | 3191 |
* @see wp_get_image_editor() |
3192 |
* |
|
3193 |
* @param string $file Filename of the image to load. |
|
18 | 3194 |
* @return resource|GdImage|string The resulting image resource or GdImage instance on success, |
3195 |
* error string on failure. |
|
0 | 3196 |
*/ |
3197 |
function wp_load_image( $file ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3198 |
_deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); |
0 | 3199 |
|
3200 |
if ( is_numeric( $file ) ) |
|
3201 |
$file = get_attached_file( $file ); |
|
3202 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3203 |
if ( ! is_file( $file ) ) { |
16 | 3204 |
/* translators: %s: File name. */ |
19 | 3205 |
return sprintf( __( 'File “%s” does not exist?' ), $file ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3206 |
} |
0 | 3207 |
|
3208 |
if ( ! function_exists('imagecreatefromstring') ) |
|
3209 |
return __('The GD image library is not installed.'); |
|
3210 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3211 |
// Set artificially high because GD uses uncompressed images in memory. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3212 |
wp_raise_memory_limit( 'image' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3213 |
|
0 | 3214 |
$image = imagecreatefromstring( file_get_contents( $file ) ); |
3215 |
||
18 | 3216 |
if ( ! is_gd_image( $image ) ) { |
16 | 3217 |
/* translators: %s: File name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3218 |
return sprintf( __( 'File “%s” is not an image.' ), $file ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3219 |
} |
0 | 3220 |
|
3221 |
return $image; |
|
3222 |
} |
|
3223 |
||
3224 |
/** |
|
3225 |
* Scale down an image to fit a particular size and save a new copy of the image. |
|
3226 |
* |
|
3227 |
* The PNG transparency will be preserved using the function, as well as the |
|
3228 |
* image type. If the file going in is PNG, then the resized image is going to |
|
3229 |
* be PNG. The only supported image types are PNG, GIF, and JPEG. |
|
3230 |
* |
|
3231 |
* Some functionality requires API to exist, so some PHP version may lose out |
|
3232 |
* support. This is not the fault of WordPress (where functionality is |
|
3233 |
* downgraded, not actual defects), but of your PHP version. |
|
3234 |
* |
|
3235 |
* @since 2.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3236 |
* @deprecated 3.5.0 Use wp_get_image_editor() |
0 | 3237 |
* @see wp_get_image_editor() |
3238 |
* |
|
16 | 3239 |
* @param string $file Image file path. |
3240 |
* @param int $max_w Maximum width to resize to. |
|
3241 |
* @param int $max_h Maximum height to resize to. |
|
3242 |
* @param bool $crop Optional. Whether to crop image or resize. Default false. |
|
3243 |
* @param string $suffix Optional. File suffix. Default null. |
|
3244 |
* @param string $dest_path Optional. New image file path. Default null. |
|
3245 |
* @param int $jpeg_quality Optional. Image quality percentage. Default 90. |
|
0 | 3246 |
* @return mixed WP_Error on failure. String with new destination path. |
3247 |
*/ |
|
3248 |
function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3249 |
_deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); |
0 | 3250 |
|
3251 |
$editor = wp_get_image_editor( $file ); |
|
3252 |
if ( is_wp_error( $editor ) ) |
|
3253 |
return $editor; |
|
3254 |
$editor->set_quality( $jpeg_quality ); |
|
3255 |
||
3256 |
$resized = $editor->resize( $max_w, $max_h, $crop ); |
|
3257 |
if ( is_wp_error( $resized ) ) |
|
3258 |
return $resized; |
|
3259 |
||
3260 |
$dest_file = $editor->generate_filename( $suffix, $dest_path ); |
|
3261 |
$saved = $editor->save( $dest_file ); |
|
3262 |
||
3263 |
if ( is_wp_error( $saved ) ) |
|
3264 |
return $saved; |
|
3265 |
||
3266 |
return $dest_file; |
|
3267 |
} |
|
3268 |
||
3269 |
/** |
|
3270 |
* Retrieve a single post, based on post ID. |
|
3271 |
* |
|
3272 |
* Has categories in 'post_category' property or key. Has tags in 'tags_input' |
|
3273 |
* property or key. |
|
3274 |
* |
|
3275 |
* @since 1.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3276 |
* @deprecated 3.5.0 Use get_post() |
0 | 3277 |
* @see get_post() |
3278 |
* |
|
3279 |
* @param int $postid Post ID. |
|
3280 |
* @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A. |
|
5 | 3281 |
* @return WP_Post|null Post object or array holding post contents and information |
0 | 3282 |
*/ |
3283 |
function wp_get_single_post( $postid = 0, $mode = OBJECT ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3284 |
_deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' ); |
0 | 3285 |
return get_post( $postid, $mode ); |
3286 |
} |
|
3287 |
||
3288 |
/** |
|
3289 |
* Check that the user login name and password is correct. |
|
3290 |
* |
|
3291 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3292 |
* @deprecated 3.5.0 Use wp_authenticate() |
0 | 3293 |
* @see wp_authenticate() |
3294 |
* |
|
3295 |
* @param string $user_login User name. |
|
3296 |
* @param string $user_pass User password. |
|
3297 |
* @return bool False if does not authenticate, true if username and password authenticates. |
|
3298 |
*/ |
|
3299 |
function user_pass_ok($user_login, $user_pass) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3300 |
_deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' ); |
0 | 3301 |
$user = wp_authenticate( $user_login, $user_pass ); |
3302 |
if ( is_wp_error( $user ) ) |
|
3303 |
return false; |
|
3304 |
||
3305 |
return true; |
|
3306 |
} |
|
3307 |
||
3308 |
/** |
|
3309 |
* Callback formerly fired on the save_post hook. No longer needed. |
|
3310 |
* |
|
3311 |
* @since 2.3.0 |
|
3312 |
* @deprecated 3.5.0 |
|
3313 |
*/ |
|
3314 |
function _save_post_hook() {} |
|
3315 |
||
3316 |
/** |
|
3317 |
* Check if the installed version of GD supports particular image type |
|
3318 |
* |
|
3319 |
* @since 2.9.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3320 |
* @deprecated 3.5.0 Use wp_image_editor_supports() |
0 | 3321 |
* @see wp_image_editor_supports() |
3322 |
* |
|
3323 |
* @param string $mime_type |
|
3324 |
* @return bool |
|
3325 |
*/ |
|
3326 |
function gd_edit_image_support($mime_type) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3327 |
_deprecated_function( __FUNCTION__, '3.5.0', 'wp_image_editor_supports()' ); |
0 | 3328 |
|
3329 |
if ( function_exists('imagetypes') ) { |
|
3330 |
switch( $mime_type ) { |
|
3331 |
case 'image/jpeg': |
|
3332 |
return (imagetypes() & IMG_JPG) != 0; |
|
3333 |
case 'image/png': |
|
3334 |
return (imagetypes() & IMG_PNG) != 0; |
|
3335 |
case 'image/gif': |
|
3336 |
return (imagetypes() & IMG_GIF) != 0; |
|
18 | 3337 |
case 'image/webp': |
19 | 3338 |
return (imagetypes() & IMG_WEBP) != 0; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3339 |
case 'image/avif': |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3340 |
return (imagetypes() & IMG_AVIF) != 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3341 |
} |
0 | 3342 |
} else { |
3343 |
switch( $mime_type ) { |
|
3344 |
case 'image/jpeg': |
|
3345 |
return function_exists('imagecreatefromjpeg'); |
|
3346 |
case 'image/png': |
|
3347 |
return function_exists('imagecreatefrompng'); |
|
3348 |
case 'image/gif': |
|
3349 |
return function_exists('imagecreatefromgif'); |
|
18 | 3350 |
case 'image/webp': |
3351 |
return function_exists('imagecreatefromwebp'); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3352 |
case 'image/avif': |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3353 |
return function_exists('imagecreatefromavif'); |
0 | 3354 |
} |
3355 |
} |
|
3356 |
return false; |
|
3357 |
} |
|
3358 |
||
3359 |
/** |
|
3360 |
* Converts an integer byte value to a shorthand byte value. |
|
3361 |
* |
|
3362 |
* @since 2.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3363 |
* @deprecated 3.6.0 Use size_format() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3364 |
* @see size_format() |
0 | 3365 |
* |
3366 |
* @param int $bytes An integer byte value. |
|
3367 |
* @return string A shorthand byte value. |
|
3368 |
*/ |
|
3369 |
function wp_convert_bytes_to_hr( $bytes ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3370 |
_deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3371 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3372 |
$units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3373 |
$log = log( $bytes, KB_IN_BYTES ); |
0 | 3374 |
$power = (int) $log; |
16 | 3375 |
$size = KB_IN_BYTES ** ( $log - $power ); |
0 | 3376 |
|
3377 |
if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) { |
|
3378 |
$unit = $units[ $power ]; |
|
3379 |
} else { |
|
3380 |
$size = $bytes; |
|
3381 |
$unit = $units[0]; |
|
3382 |
} |
|
3383 |
||
3384 |
return $size . $unit; |
|
3385 |
} |
|
3386 |
||
3387 |
/** |
|
3388 |
* Formerly used internally to tidy up the search terms. |
|
3389 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3390 |
* @since 2.9.0 |
0 | 3391 |
* @access private |
3392 |
* @deprecated 3.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3393 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3394 |
* @param string $t Search terms to "tidy", e.g. trim. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3395 |
* @return string Trimmed search terms. |
0 | 3396 |
*/ |
3397 |
function _search_terms_tidy( $t ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3398 |
_deprecated_function( __FUNCTION__, '3.7.0' ); |
0 | 3399 |
return trim( $t, "\"'\n\r " ); |
3400 |
} |
|
5 | 3401 |
|
3402 |
/** |
|
3403 |
* Determine if TinyMCE is available. |
|
3404 |
* |
|
3405 |
* Checks to see if the user has deleted the tinymce files to slim down |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3406 |
* their WordPress installation. |
5 | 3407 |
* |
3408 |
* @since 2.1.0 |
|
3409 |
* @deprecated 3.9.0 |
|
3410 |
* |
|
3411 |
* @return bool Whether TinyMCE exists. |
|
3412 |
*/ |
|
3413 |
function rich_edit_exists() { |
|
3414 |
global $wp_rich_edit_exists; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3415 |
_deprecated_function( __FUNCTION__, '3.9.0' ); |
5 | 3416 |
|
3417 |
if ( ! isset( $wp_rich_edit_exists ) ) |
|
3418 |
$wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); |
|
3419 |
||
3420 |
return $wp_rich_edit_exists; |
|
3421 |
} |
|
3422 |
||
3423 |
/** |
|
3424 |
* Old callback for tag link tooltips. |
|
3425 |
* |
|
3426 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3427 |
* @access private |
5 | 3428 |
* @deprecated 3.9.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3429 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3430 |
* @param int $count Number of topics. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3431 |
* @return int Number of topics. |
5 | 3432 |
*/ |
3433 |
function default_topic_count_text( $count ) { |
|
3434 |
return $count; |
|
3435 |
} |
|
3436 |
||
3437 |
/** |
|
3438 |
* Formerly used to escape strings before inserting into the DB. |
|
3439 |
* |
|
3440 |
* Has not performed this function for many, many years. Use wpdb::prepare() instead. |
|
3441 |
* |
|
3442 |
* @since 0.71 |
|
3443 |
* @deprecated 3.9.0 |
|
3444 |
* |
|
3445 |
* @param string $content The text to format. |
|
3446 |
* @return string The very same text. |
|
3447 |
*/ |
|
3448 |
function format_to_post( $content ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3449 |
_deprecated_function( __FUNCTION__, '3.9.0' ); |
5 | 3450 |
return $content; |
3451 |
} |
|
3452 |
||
3453 |
/** |
|
3454 |
* Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described. |
|
3455 |
* |
|
3456 |
* @since 2.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3457 |
* @deprecated 4.0.0 Use wpdb::esc_like() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3458 |
* @see wpdb::esc_like() |
5 | 3459 |
* |
3460 |
* @param string $text The text to be escaped. |
|
3461 |
* @return string text, safe for inclusion in LIKE query. |
|
3462 |
*/ |
|
3463 |
function like_escape($text) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3464 |
_deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' ); |
5 | 3465 |
return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text ); |
3466 |
} |
|
3467 |
||
3468 |
/** |
|
3469 |
* Determines if the URL can be accessed over SSL. |
|
3470 |
* |
|
3471 |
* Determines if the URL can be accessed over SSL by using the WordPress HTTP API to access |
|
3472 |
* the URL using https as the scheme. |
|
3473 |
* |
|
3474 |
* @since 2.5.0 |
|
3475 |
* @deprecated 4.0.0 |
|
3476 |
* |
|
3477 |
* @param string $url The URL to test. |
|
3478 |
* @return bool Whether SSL access is available. |
|
3479 |
*/ |
|
3480 |
function url_is_accessable_via_ssl( $url ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3481 |
_deprecated_function( __FUNCTION__, '4.0.0' ); |
5 | 3482 |
|
3483 |
$response = wp_remote_get( set_url_scheme( $url, 'https' ) ); |
|
3484 |
||
3485 |
if ( !is_wp_error( $response ) ) { |
|
3486 |
$status = wp_remote_retrieve_response_code( $response ); |
|
3487 |
if ( 200 == $status || 401 == $status ) { |
|
3488 |
return true; |
|
3489 |
} |
|
3490 |
} |
|
3491 |
||
3492 |
return false; |
|
3493 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3494 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3495 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3496 |
* Start preview theme output buffer. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3497 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3498 |
* Will only perform task if the user has permissions and template and preview |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3499 |
* query variables exist. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3500 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3501 |
* @since 2.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3502 |
* @deprecated 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3503 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3504 |
function preview_theme() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3505 |
_deprecated_function( __FUNCTION__, '4.3.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3506 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3507 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3508 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3509 |
* Private function to modify the current template when previewing a theme |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3510 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3511 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3512 |
* @deprecated 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3513 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3514 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3515 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3516 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3517 |
function _preview_theme_template_filter() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3518 |
_deprecated_function( __FUNCTION__, '4.3.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3519 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3520 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3521 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3522 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3523 |
* Private function to modify the current stylesheet when previewing a theme |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3524 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3525 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3526 |
* @deprecated 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3527 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3528 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3529 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3530 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3531 |
function _preview_theme_stylesheet_filter() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3532 |
_deprecated_function( __FUNCTION__, '4.3.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3533 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3534 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3535 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3536 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3537 |
* Callback function for ob_start() to capture all links in the theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3538 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3539 |
* @since 2.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3540 |
* @deprecated 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3541 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3542 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3543 |
* @param string $content |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3544 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3545 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3546 |
function preview_theme_ob_filter( $content ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3547 |
_deprecated_function( __FUNCTION__, '4.3.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3548 |
return $content; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3549 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3550 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3551 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3552 |
* Manipulates preview theme links in order to control and maintain location. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3553 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3554 |
* Callback function for preg_replace_callback() to accept and filter matches. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3555 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3556 |
* @since 2.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3557 |
* @deprecated 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3558 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3559 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3560 |
* @param array $matches |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3561 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3562 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3563 |
function preview_theme_ob_filter_callback( $matches ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3564 |
_deprecated_function( __FUNCTION__, '4.3.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3565 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3566 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3567 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3568 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3569 |
* Formats text for the rich text editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3570 |
* |
18 | 3571 |
* The {@see 'richedit_pre'} filter is applied here. If `$text` is empty the filter will |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3572 |
* be applied to an empty string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3573 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3574 |
* @since 2.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3575 |
* @deprecated 4.3.0 Use format_for_editor() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3576 |
* @see format_for_editor() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3577 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3578 |
* @param string $text The text to be formatted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3579 |
* @return string The formatted text after filter is applied. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3580 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3581 |
function wp_richedit_pre($text) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3582 |
_deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3583 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3584 |
if ( empty( $text ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3585 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3586 |
* Filters text returned for the rich text editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3587 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3588 |
* This filter is first evaluated, and the value returned, if an empty string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3589 |
* is passed to wp_richedit_pre(). If an empty string is passed, it results |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3590 |
* in a break tag and line feed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3591 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3592 |
* If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3593 |
* return after being formatted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3594 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3595 |
* @since 2.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3596 |
* @deprecated 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3597 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3598 |
* @param string $output Text for the rich text editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3599 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3600 |
return apply_filters( 'richedit_pre', '' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3601 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3602 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3603 |
$output = convert_chars($text); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3604 |
$output = wpautop($output); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3605 |
$output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3606 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3607 |
/** This filter is documented in wp-includes/deprecated.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3608 |
return apply_filters( 'richedit_pre', $output ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3609 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3610 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3611 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3612 |
* Formats text for the HTML editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3613 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3614 |
* Unless $output is empty it will pass through htmlspecialchars before the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3615 |
* {@see 'htmledit_pre'} filter is applied. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3616 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3617 |
* @since 2.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3618 |
* @deprecated 4.3.0 Use format_for_editor() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3619 |
* @see format_for_editor() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3620 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3621 |
* @param string $output The text to be formatted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3622 |
* @return string Formatted text after filter applied. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3623 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3624 |
function wp_htmledit_pre($output) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3625 |
_deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3626 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3627 |
if ( !empty($output) ) |
16 | 3628 |
$output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // Convert only '< > &'. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3629 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3630 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3631 |
* Filters the text before it is formatted for the HTML editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3632 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3633 |
* @since 2.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3634 |
* @deprecated 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3635 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3636 |
* @param string $output The HTML-formatted text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3637 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3638 |
return apply_filters( 'htmledit_pre', $output ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3639 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3640 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3641 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3642 |
* Retrieve permalink from post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3643 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3644 |
* @since 1.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3645 |
* @deprecated 4.4.0 Use get_permalink() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3646 |
* @see get_permalink() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3647 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3648 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3649 |
* @return string|false |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3650 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3651 |
function post_permalink( $post = 0 ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3652 |
_deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3653 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3654 |
return get_permalink( $post ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3655 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3656 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3657 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3658 |
* Perform a HTTP HEAD or GET request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3659 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3660 |
* If $file_path is a writable filename, this will do a GET request and write |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3661 |
* the file to that path. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3662 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3663 |
* @since 2.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3664 |
* @deprecated 4.4.0 Use WP_Http |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3665 |
* @see WP_Http |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3666 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3667 |
* @param string $url URL to fetch. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3668 |
* @param string|bool $file_path Optional. File path to write request to. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3669 |
* @param int $red Optional. The number of Redirects followed, Upon 5 being hit, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3670 |
* returns false. Default 1. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3671 |
* @return \WpOrg\Requests\Utility\CaseInsensitiveDictionary|false Headers on success, false on failure. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3672 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3673 |
function wp_get_http( $url, $file_path = false, $red = 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3674 |
_deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3675 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3676 |
if ( function_exists( 'set_time_limit' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3677 |
@set_time_limit( 60 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3678 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3679 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3680 |
if ( $red > 5 ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3681 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3682 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3683 |
$options = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3684 |
$options['redirection'] = 5; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3685 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3686 |
if ( false == $file_path ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3687 |
$options['method'] = 'HEAD'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3688 |
else |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3689 |
$options['method'] = 'GET'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3690 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3691 |
$response = wp_safe_remote_request( $url, $options ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3692 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3693 |
if ( is_wp_error( $response ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3694 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3695 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3696 |
$headers = wp_remote_retrieve_headers( $response ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3697 |
$headers['response'] = wp_remote_retrieve_response_code( $response ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3698 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3699 |
// WP_HTTP no longer follows redirects for HEAD requests. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3700 |
if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3701 |
return wp_get_http( $headers['location'], $file_path, ++$red ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3702 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3703 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3704 |
if ( false == $file_path ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3705 |
return $headers; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3706 |
|
16 | 3707 |
// GET request - write it to the supplied filename. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3708 |
$out_fp = fopen($file_path, 'w'); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3709 |
if ( !$out_fp ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3710 |
return $headers; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3711 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3712 |
fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3713 |
fclose($out_fp); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3714 |
clearstatcache(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3715 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3716 |
return $headers; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3717 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3718 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3719 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3720 |
* Whether SSL login should be forced. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3721 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3722 |
* @since 2.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3723 |
* @deprecated 4.4.0 Use force_ssl_admin() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3724 |
* @see force_ssl_admin() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3725 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3726 |
* @param string|bool $force Optional Whether to force SSL login. Default null. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3727 |
* @return bool True if forced, false if not forced. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3728 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3729 |
function force_ssl_login( $force = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3730 |
_deprecated_function( __FUNCTION__, '4.4.0', 'force_ssl_admin()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3731 |
return force_ssl_admin( $force ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3732 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3733 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3734 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3735 |
* Retrieve path of comment popup template in current or parent template. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3736 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3737 |
* @since 1.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3738 |
* @deprecated 4.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3739 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3740 |
* @return string Full path to comments popup template file. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3741 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3742 |
function get_comments_popup_template() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3743 |
_deprecated_function( __FUNCTION__, '4.5.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3744 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3745 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3746 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3747 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3748 |
/** |
9 | 3749 |
* Determines whether the current URL is within the comments popup window. |
16 | 3750 |
* |
9 | 3751 |
* For more information on this and similar theme functions, check out |
16 | 3752 |
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
9 | 3753 |
* Conditional Tags} article in the Theme Developer Handbook. |
16 | 3754 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3755 |
* @since 1.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3756 |
* @deprecated 4.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3757 |
* |
16 | 3758 |
* @return false Always returns false. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3759 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3760 |
function is_comments_popup() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3761 |
_deprecated_function( __FUNCTION__, '4.5.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3762 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3763 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3764 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3765 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3766 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3767 |
* Display the JS popup script to show a comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3768 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3769 |
* @since 0.71 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3770 |
* @deprecated 4.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3771 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3772 |
function comments_popup_script() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3773 |
_deprecated_function( __FUNCTION__, '4.5.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3774 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3775 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3776 |
/** |
9 | 3777 |
* Adds element attributes to open links in new tabs. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3778 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3779 |
* @since 0.71 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3780 |
* @deprecated 4.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3781 |
* |
9 | 3782 |
* @param string $text Content to replace links to open in a new tab. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3783 |
* @return string Content that has filtered links. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3784 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3785 |
function popuplinks( $text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3786 |
_deprecated_function( __FUNCTION__, '4.5.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3787 |
$text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3788 |
return $text; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3789 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3790 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3791 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3792 |
* The Google Video embed handler callback. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3793 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3794 |
* Deprecated function that previously assisted in turning Google Video URLs |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3795 |
* into embeds but that service has since been shut down. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3796 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3797 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3798 |
* @deprecated 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3799 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3800 |
* @return string An empty string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3801 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3802 |
function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3803 |
_deprecated_function( __FUNCTION__, '4.6.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3804 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3805 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3806 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3807 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3808 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3809 |
* Retrieve path of paged template in current or parent template. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3810 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3811 |
* @since 1.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3812 |
* @deprecated 4.7.0 The paged.php template is no longer part of the theme template hierarchy. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3813 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3814 |
* @return string Full path to paged template file. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3815 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3816 |
function get_paged_template() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3817 |
_deprecated_function( __FUNCTION__, '4.7.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3818 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3819 |
return get_query_template( 'paged' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3820 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3821 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3822 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3823 |
* Removes the HTML JavaScript entities found in early versions of Netscape 4. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3824 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3825 |
* Previously, this function was pulled in from the original |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3826 |
* import of kses and removed a specific vulnerability only |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3827 |
* existent in early version of Netscape 4. However, this |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3828 |
* vulnerability never affected any other browsers and can |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3829 |
* be considered safe for the modern web. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3830 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3831 |
* The regular expression which sanitized this vulnerability |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3832 |
* has been removed in consideration of the performance and |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3833 |
* energy demands it placed, now merely passing through its |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3834 |
* input to the return. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3835 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3836 |
* @since 1.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3837 |
* @deprecated 4.7.0 Officially dropped security support for Netscape 4. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3838 |
* |
19 | 3839 |
* @param string $content |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3840 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3841 |
*/ |
19 | 3842 |
function wp_kses_js_entities( $content ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3843 |
_deprecated_function( __FUNCTION__, '4.7.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3844 |
|
19 | 3845 |
return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $content ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3846 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3847 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3848 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3849 |
* Sort categories by ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3850 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3851 |
* Used by usort() as a callback, should not be used directly. Can actually be |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3852 |
* used to sort any term object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3853 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3854 |
* @since 2.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3855 |
* @deprecated 4.7.0 Use wp_list_sort() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3856 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3857 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3858 |
* @param object $a |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3859 |
* @param object $b |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3860 |
* @return int |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3861 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3862 |
function _usort_terms_by_ID( $a, $b ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3863 |
_deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3864 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3865 |
if ( $a->term_id > $b->term_id ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3866 |
return 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3867 |
elseif ( $a->term_id < $b->term_id ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3868 |
return -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3869 |
else |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3870 |
return 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3871 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3872 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3873 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3874 |
* Sort categories by name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3875 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3876 |
* Used by usort() as a callback, should not be used directly. Can actually be |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3877 |
* used to sort any term object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3878 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3879 |
* @since 2.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3880 |
* @deprecated 4.7.0 Use wp_list_sort() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3881 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3882 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3883 |
* @param object $a |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3884 |
* @param object $b |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3885 |
* @return int |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3886 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3887 |
function _usort_terms_by_name( $a, $b ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3888 |
_deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3889 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3890 |
return strcmp( $a->name, $b->name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3891 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3892 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3893 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3894 |
* Sort menu items by the desired key. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3895 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3896 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3897 |
* @deprecated 4.7.0 Use wp_list_sort() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3898 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3899 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3900 |
* @global string $_menu_item_sort_prop |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3901 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3902 |
* @param object $a The first object to compare |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3903 |
* @param object $b The second object to compare |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3904 |
* @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3905 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3906 |
function _sort_nav_menu_items( $a, $b ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3907 |
global $_menu_item_sort_prop; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3908 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3909 |
_deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3910 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3911 |
if ( empty( $_menu_item_sort_prop ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3912 |
return 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3913 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3914 |
if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3915 |
return 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3916 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3917 |
$_a = (int) $a->$_menu_item_sort_prop; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3918 |
$_b = (int) $b->$_menu_item_sort_prop; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3919 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3920 |
if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3921 |
return 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3922 |
elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3923 |
return $_a < $_b ? -1 : 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3924 |
else |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3925 |
return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3926 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3927 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3928 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3929 |
* Retrieves the Press This bookmarklet link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3930 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3931 |
* @since 2.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3932 |
* @deprecated 4.9.0 |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3933 |
* @return string |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3934 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3935 |
function get_shortcut_link() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3936 |
_deprecated_function( __FUNCTION__, '4.9.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3937 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3938 |
$link = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3939 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3940 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3941 |
* Filters the Press This bookmarklet link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3942 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3943 |
* @since 2.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3944 |
* @deprecated 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3945 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3946 |
* @param string $link The Press This bookmarklet link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3947 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3948 |
return apply_filters( 'shortcut_link', $link ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3949 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3950 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3951 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3952 |
* Ajax handler for saving a post from Press This. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3953 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3954 |
* @since 4.2.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3955 |
* @deprecated 4.9.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3956 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3957 |
function wp_ajax_press_this_save_post() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3958 |
_deprecated_function( __FUNCTION__, '4.9.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3959 |
if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) { |
16 | 3960 |
include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3961 |
$wp_press_this = new WP_Press_This_Plugin(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3962 |
$wp_press_this->save_post(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3963 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3964 |
wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3965 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3966 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3967 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3968 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3969 |
* Ajax handler for creating new category from Press This. |
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 |
* @since 4.2.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3972 |
* @deprecated 4.9.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3973 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3974 |
function wp_ajax_press_this_add_category() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3975 |
_deprecated_function( __FUNCTION__, '4.9.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3976 |
if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) { |
16 | 3977 |
include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3978 |
$wp_press_this = new WP_Press_This_Plugin(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3979 |
$wp_press_this->add_category(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3980 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3981 |
wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3982 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3983 |
} |
16 | 3984 |
|
3985 |
/** |
|
3986 |
* Return the user request object for the specified request ID. |
|
3987 |
* |
|
3988 |
* @since 4.9.6 |
|
3989 |
* @deprecated 5.4.0 Use wp_get_user_request() |
|
3990 |
* @see wp_get_user_request() |
|
3991 |
* |
|
3992 |
* @param int $request_id The ID of the user request. |
|
3993 |
* @return WP_User_Request|false |
|
3994 |
*/ |
|
3995 |
function wp_get_user_request_data( $request_id ) { |
|
3996 |
_deprecated_function( __FUNCTION__, '5.4.0', 'wp_get_user_request()' ); |
|
3997 |
return wp_get_user_request( $request_id ); |
|
3998 |
} |
|
3999 |
||
4000 |
/** |
|
4001 |
* Filters 'img' elements in post content to add 'srcset' and 'sizes' attributes. |
|
4002 |
* |
|
4003 |
* @since 4.4.0 |
|
4004 |
* @deprecated 5.5.0 |
|
4005 |
* |
|
4006 |
* @see wp_image_add_srcset_and_sizes() |
|
4007 |
* |
|
4008 |
* @param string $content The raw post content to be filtered. |
|
4009 |
* @return string Converted content with 'srcset' and 'sizes' attributes added to images. |
|
4010 |
*/ |
|
4011 |
function wp_make_content_images_responsive( $content ) { |
|
4012 |
_deprecated_function( __FUNCTION__, '5.5.0', 'wp_filter_content_tags()' ); |
|
4013 |
||
4014 |
// This will also add the `loading` attribute to `img` tags, if enabled. |
|
4015 |
return wp_filter_content_tags( $content ); |
|
4016 |
} |
|
4017 |
||
4018 |
/** |
|
4019 |
* Turn register globals off. |
|
4020 |
* |
|
4021 |
* @since 2.1.0 |
|
4022 |
* @access private |
|
4023 |
* @deprecated 5.5.0 |
|
4024 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4025 |
function wp_unregister_GLOBALS() { |
16 | 4026 |
// register_globals was deprecated in PHP 5.3 and removed entirely in PHP 5.4. |
4027 |
_deprecated_function( __FUNCTION__, '5.5.0' ); |
|
4028 |
} |
|
4029 |
||
4030 |
/** |
|
4031 |
* Does comment contain disallowed characters or words. |
|
4032 |
* |
|
4033 |
* @since 1.5.0 |
|
4034 |
* @deprecated 5.5.0 Use wp_check_comment_disallowed_list() instead. |
|
4035 |
* Please consider writing more inclusive code. |
|
4036 |
* |
|
4037 |
* @param string $author The author of the comment |
|
4038 |
* @param string $email The email of the comment |
|
4039 |
* @param string $url The url used in the comment |
|
4040 |
* @param string $comment The comment content |
|
4041 |
* @param string $user_ip The comment author's IP address |
|
4042 |
* @param string $user_agent The author's browser user agent |
|
4043 |
* @return bool True if comment contains disallowed content, false if comment does not |
|
4044 |
*/ |
|
4045 |
function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) { |
|
4046 |
_deprecated_function( __FUNCTION__, '5.5.0', 'wp_check_comment_disallowed_list()' ); |
|
4047 |
||
4048 |
return wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent ); |
|
4049 |
} |
|
4050 |
||
4051 |
/** |
|
4052 |
* Filters out `register_meta()` args based on an allowed list. |
|
4053 |
* |
|
4054 |
* `register_meta()` args may change over time, so requiring the allowed list |
|
4055 |
* to be explicitly turned off is a warranty seal of sorts. |
|
4056 |
* |
|
4057 |
* @access private |
|
4058 |
* @since 4.6.0 |
|
4059 |
* @deprecated 5.5.0 Use _wp_register_meta_args_allowed_list() instead. |
|
4060 |
* Please consider writing more inclusive code. |
|
4061 |
* |
|
4062 |
* @param array $args Arguments from `register_meta()`. |
|
4063 |
* @param array $default_args Default arguments for `register_meta()`. |
|
4064 |
* @return array Filtered arguments. |
|
4065 |
*/ |
|
4066 |
function _wp_register_meta_args_whitelist( $args, $default_args ) { |
|
4067 |
_deprecated_function( __FUNCTION__, '5.5.0', '_wp_register_meta_args_allowed_list()' ); |
|
4068 |
||
4069 |
return _wp_register_meta_args_allowed_list( $args, $default_args ); |
|
4070 |
} |
|
4071 |
||
4072 |
/** |
|
4073 |
* Adds an array of options to the list of allowed options. |
|
4074 |
* |
|
4075 |
* @since 2.7.0 |
|
4076 |
* @deprecated 5.5.0 Use add_allowed_options() instead. |
|
4077 |
* Please consider writing more inclusive code. |
|
4078 |
* |
|
4079 |
* @param array $new_options |
|
4080 |
* @param string|array $options |
|
4081 |
* @return array |
|
4082 |
*/ |
|
4083 |
function add_option_whitelist( $new_options, $options = '' ) { |
|
4084 |
_deprecated_function( __FUNCTION__, '5.5.0', 'add_allowed_options()' ); |
|
4085 |
||
4086 |
return add_allowed_options( $new_options, $options ); |
|
4087 |
} |
|
4088 |
||
4089 |
/** |
|
4090 |
* Removes a list of options from the allowed options list. |
|
4091 |
* |
|
4092 |
* @since 2.7.0 |
|
4093 |
* @deprecated 5.5.0 Use remove_allowed_options() instead. |
|
4094 |
* Please consider writing more inclusive code. |
|
4095 |
* |
|
4096 |
* @param array $del_options |
|
4097 |
* @param string|array $options |
|
4098 |
* @return array |
|
4099 |
*/ |
|
4100 |
function remove_option_whitelist( $del_options, $options = '' ) { |
|
4101 |
_deprecated_function( __FUNCTION__, '5.5.0', 'remove_allowed_options()' ); |
|
4102 |
||
4103 |
return remove_allowed_options( $del_options, $options ); |
|
4104 |
} |
|
18 | 4105 |
|
4106 |
/** |
|
4107 |
* Adds slashes to only string values in an array of values. |
|
4108 |
* |
|
4109 |
* This should be used when preparing data for core APIs that expect slashed data. |
|
4110 |
* This should not be used to escape data going directly into an SQL query. |
|
4111 |
* |
|
4112 |
* @since 5.3.0 |
|
4113 |
* @deprecated 5.6.0 Use wp_slash() |
|
4114 |
* |
|
4115 |
* @see wp_slash() |
|
4116 |
* |
|
4117 |
* @param mixed $value Scalar or array of scalars. |
|
4118 |
* @return mixed Slashes $value |
|
4119 |
*/ |
|
4120 |
function wp_slash_strings_only( $value ) { |
|
4121 |
return map_deep( $value, 'addslashes_strings_only' ); |
|
4122 |
} |
|
4123 |
||
4124 |
/** |
|
4125 |
* Adds slashes only if the provided value is a string. |
|
4126 |
* |
|
4127 |
* @since 5.3.0 |
|
4128 |
* @deprecated 5.6.0 |
|
4129 |
* |
|
4130 |
* @see wp_slash() |
|
4131 |
* |
|
4132 |
* @param mixed $value |
|
4133 |
* @return mixed |
|
4134 |
*/ |
|
4135 |
function addslashes_strings_only( $value ) { |
|
4136 |
return is_string( $value ) ? addslashes( $value ) : $value; |
|
4137 |
} |
|
4138 |
||
4139 |
/** |
|
19 | 4140 |
* Displays a `noindex` meta tag if required by the blog configuration. |
4141 |
* |
|
4142 |
* If a blog is marked as not being public then the `noindex` meta tag will be |
|
4143 |
* output to tell web robots not to index the page content. |
|
18 | 4144 |
* |
4145 |
* Typical usage is as a {@see 'wp_head'} callback: |
|
4146 |
* |
|
4147 |
* add_action( 'wp_head', 'noindex' ); |
|
4148 |
* |
|
4149 |
* @see wp_no_robots() |
|
4150 |
* |
|
4151 |
* @since 2.1.0 |
|
4152 |
* @deprecated 5.7.0 Use wp_robots_noindex() instead on 'wp_robots' filter. |
|
4153 |
*/ |
|
4154 |
function noindex() { |
|
4155 |
_deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_noindex()' ); |
|
4156 |
||
4157 |
// If the blog is not public, tell robots to go away. |
|
4158 |
if ( '0' == get_option( 'blog_public' ) ) { |
|
4159 |
wp_no_robots(); |
|
4160 |
} |
|
4161 |
} |
|
4162 |
||
4163 |
/** |
|
19 | 4164 |
* Display a `noindex` meta tag. |
4165 |
* |
|
4166 |
* Outputs a `noindex` meta tag that tells web robots not to index the page content. |
|
4167 |
* |
|
4168 |
* Typical usage is as a {@see 'wp_head'} callback: |
|
4169 |
* |
|
4170 |
* add_action( 'wp_head', 'wp_no_robots' ); |
|
18 | 4171 |
* |
4172 |
* @since 3.3.0 |
|
19 | 4173 |
* @since 5.3.0 Echo `noindex,nofollow` if search engine visibility is discouraged. |
18 | 4174 |
* @deprecated 5.7.0 Use wp_robots_no_robots() instead on 'wp_robots' filter. |
4175 |
*/ |
|
4176 |
function wp_no_robots() { |
|
4177 |
_deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_no_robots()' ); |
|
4178 |
||
4179 |
if ( get_option( 'blog_public' ) ) { |
|
4180 |
echo "<meta name='robots' content='noindex,follow' />\n"; |
|
4181 |
return; |
|
4182 |
} |
|
4183 |
||
4184 |
echo "<meta name='robots' content='noindex,nofollow' />\n"; |
|
4185 |
} |
|
4186 |
||
4187 |
/** |
|
19 | 4188 |
* Display a `noindex,noarchive` meta tag and referrer `strict-origin-when-cross-origin` meta tag. |
4189 |
* |
|
4190 |
* Outputs a `noindex,noarchive` meta tag that tells web robots not to index or cache the page content. |
|
4191 |
* Outputs a referrer `strict-origin-when-cross-origin` meta tag that tells the browser not to send |
|
4192 |
* the full URL as a referrer to other sites when cross-origin assets are loaded. |
|
4193 |
* |
|
4194 |
* Typical usage is as a {@see 'wp_head'} callback: |
|
4195 |
* |
|
4196 |
* add_action( 'wp_head', 'wp_sensitive_page_meta' ); |
|
18 | 4197 |
* |
4198 |
* @since 5.0.1 |
|
4199 |
* @deprecated 5.7.0 Use wp_robots_sensitive_page() instead on 'wp_robots' filter |
|
4200 |
* and wp_strict_cross_origin_referrer() on 'wp_head' action. |
|
19 | 4201 |
* |
4202 |
* @see wp_robots_sensitive_page() |
|
18 | 4203 |
*/ |
4204 |
function wp_sensitive_page_meta() { |
|
4205 |
_deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_sensitive_page()' ); |
|
4206 |
||
4207 |
?> |
|
4208 |
<meta name='robots' content='noindex,noarchive' /> |
|
4209 |
<?php |
|
4210 |
wp_strict_cross_origin_referrer(); |
|
4211 |
} |
|
4212 |
||
4213 |
/** |
|
4214 |
* Render inner blocks from the `core/columns` block for generating an excerpt. |
|
4215 |
* |
|
4216 |
* @since 5.2.0 |
|
4217 |
* @access private |
|
19 | 4218 |
* @deprecated 5.8.0 Use _excerpt_render_inner_blocks() introduced in 5.8.0. |
4219 |
* |
|
4220 |
* @see _excerpt_render_inner_blocks() |
|
18 | 4221 |
* |
4222 |
* @param array $columns The parsed columns block. |
|
4223 |
* @param array $allowed_blocks The list of allowed inner blocks. |
|
4224 |
* @return string The rendered inner blocks. |
|
4225 |
*/ |
|
4226 |
function _excerpt_render_inner_columns_blocks( $columns, $allowed_blocks ) { |
|
4227 |
_deprecated_function( __FUNCTION__, '5.8.0', '_excerpt_render_inner_blocks()' ); |
|
19 | 4228 |
|
18 | 4229 |
return _excerpt_render_inner_blocks( $columns, $allowed_blocks ); |
4230 |
} |
|
19 | 4231 |
|
4232 |
/** |
|
4233 |
* Renders the duotone filter SVG and returns the CSS filter property to |
|
4234 |
* reference the rendered SVG. |
|
4235 |
* |
|
4236 |
* @since 5.9.0 |
|
4237 |
* @deprecated 5.9.1 Use wp_get_duotone_filter_property() introduced in 5.9.1. |
|
4238 |
* |
|
4239 |
* @see wp_get_duotone_filter_property() |
|
4240 |
* |
|
4241 |
* @param array $preset Duotone preset value as seen in theme.json. |
|
4242 |
* @return string Duotone CSS filter property. |
|
4243 |
*/ |
|
4244 |
function wp_render_duotone_filter_preset( $preset ) { |
|
4245 |
_deprecated_function( __FUNCTION__, '5.9.1', 'wp_get_duotone_filter_property()' ); |
|
4246 |
||
4247 |
return wp_get_duotone_filter_property( $preset ); |
|
4248 |
} |
|
4249 |
||
4250 |
/** |
|
4251 |
* Checks whether serialization of the current block's border properties should occur. |
|
4252 |
* |
|
4253 |
* @since 5.8.0 |
|
4254 |
* @access private |
|
4255 |
* @deprecated 6.0.0 Use wp_should_skip_block_supports_serialization() introduced in 6.0.0. |
|
4256 |
* |
|
4257 |
* @see wp_should_skip_block_supports_serialization() |
|
4258 |
* |
|
4259 |
* @param WP_Block_Type $block_type Block type. |
|
4260 |
* @return bool Whether serialization of the current block's border properties |
|
4261 |
* should occur. |
|
4262 |
*/ |
|
4263 |
function wp_skip_border_serialization( $block_type ) { |
|
4264 |
_deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' ); |
|
4265 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4266 |
$border_support = isset( $block_type->supports['__experimentalBorder'] ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4267 |
? $block_type->supports['__experimentalBorder'] |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4268 |
: false; |
19 | 4269 |
|
4270 |
return is_array( $border_support ) && |
|
4271 |
array_key_exists( '__experimentalSkipSerialization', $border_support ) && |
|
4272 |
$border_support['__experimentalSkipSerialization']; |
|
4273 |
} |
|
4274 |
||
4275 |
/** |
|
4276 |
* Checks whether serialization of the current block's dimensions properties should occur. |
|
4277 |
* |
|
4278 |
* @since 5.9.0 |
|
4279 |
* @access private |
|
4280 |
* @deprecated 6.0.0 Use wp_should_skip_block_supports_serialization() introduced in 6.0.0. |
|
4281 |
* |
|
4282 |
* @see wp_should_skip_block_supports_serialization() |
|
4283 |
* |
|
4284 |
* @param WP_Block_type $block_type Block type. |
|
4285 |
* @return bool Whether to serialize spacing support styles & classes. |
|
4286 |
*/ |
|
4287 |
function wp_skip_dimensions_serialization( $block_type ) { |
|
4288 |
_deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' ); |
|
4289 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4290 |
$dimensions_support = isset( $block_type->supports['__experimentalDimensions'] ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4291 |
? $block_type->supports['__experimentalDimensions'] |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4292 |
: false; |
19 | 4293 |
|
4294 |
return is_array( $dimensions_support ) && |
|
4295 |
array_key_exists( '__experimentalSkipSerialization', $dimensions_support ) && |
|
4296 |
$dimensions_support['__experimentalSkipSerialization']; |
|
4297 |
} |
|
4298 |
||
4299 |
/** |
|
4300 |
* Checks whether serialization of the current block's spacing properties should occur. |
|
4301 |
* |
|
4302 |
* @since 5.9.0 |
|
4303 |
* @access private |
|
4304 |
* @deprecated 6.0.0 Use wp_should_skip_block_supports_serialization() introduced in 6.0.0. |
|
4305 |
* |
|
4306 |
* @see wp_should_skip_block_supports_serialization() |
|
4307 |
* |
|
4308 |
* @param WP_Block_Type $block_type Block type. |
|
4309 |
* @return bool Whether to serialize spacing support styles & classes. |
|
4310 |
*/ |
|
4311 |
function wp_skip_spacing_serialization( $block_type ) { |
|
4312 |
_deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' ); |
|
4313 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4314 |
$spacing_support = isset( $block_type->supports['spacing'] ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4315 |
? $block_type->supports['spacing'] |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4316 |
: false; |
19 | 4317 |
|
4318 |
return is_array( $spacing_support ) && |
|
4319 |
array_key_exists( '__experimentalSkipSerialization', $spacing_support ) && |
|
4320 |
$spacing_support['__experimentalSkipSerialization']; |
|
4321 |
} |
|
4322 |
||
4323 |
/** |
|
4324 |
* Inject the block editor assets that need to be loaded into the editor's iframe as an inline script. |
|
4325 |
* |
|
4326 |
* @since 5.8.0 |
|
4327 |
* @deprecated 6.0.0 |
|
4328 |
*/ |
|
4329 |
function wp_add_iframed_editor_assets_html() { |
|
4330 |
_deprecated_function( __FUNCTION__, '6.0.0' ); |
|
4331 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4332 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4333 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4334 |
* Retrieves thumbnail for an attachment. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4335 |
* Note that this works only for the (very) old image metadata style where 'thumb' was set, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4336 |
* and the 'sizes' array did not exist. This function returns false for the newer image metadata style |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4337 |
* despite that 'thumbnail' is present in the 'sizes' array. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4338 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4339 |
* @since 2.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4340 |
* @deprecated 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4341 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4342 |
* @param int $post_id Optional. Attachment ID. Default is the ID of the global `$post`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4343 |
* @return string|false Thumbnail file path on success, false on failure. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4344 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4345 |
function wp_get_attachment_thumb_file( $post_id = 0 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4346 |
_deprecated_function( __FUNCTION__, '6.1.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4347 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4348 |
$post_id = (int) $post_id; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4349 |
$post = get_post( $post_id ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4350 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4351 |
if ( ! $post ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4352 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4353 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4354 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4355 |
// Use $post->ID rather than $post_id as get_post() may have used the global $post object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4356 |
$imagedata = wp_get_attachment_metadata( $post->ID ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4357 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4358 |
if ( ! is_array( $imagedata ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4359 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4360 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4361 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4362 |
$file = get_attached_file( $post->ID ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4363 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4364 |
if ( ! empty( $imagedata['thumb'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4365 |
$thumbfile = str_replace( wp_basename( $file ), $imagedata['thumb'], $file ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4366 |
if ( file_exists( $thumbfile ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4367 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4368 |
* Filters the attachment thumbnail file path. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4369 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4370 |
* @since 2.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4371 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4372 |
* @param string $thumbfile File path to the attachment thumbnail. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4373 |
* @param int $post_id Attachment ID. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4374 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4375 |
return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4376 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4377 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4378 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4379 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4380 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4381 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4382 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4383 |
* Gets the path to a translation file for loading a textdomain just in time. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4384 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4385 |
* Caches the retrieved results internally. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4386 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4387 |
* @since 4.7.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4388 |
* @deprecated 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4389 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4390 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4391 |
* @see _load_textdomain_just_in_time() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4392 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4393 |
* @param string $domain Text domain. Unique identifier for retrieving translated strings. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4394 |
* @param bool $reset Whether to reset the internal cache. Used by the switch to locale functionality. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4395 |
* @return string|false The path to the translation file or false if no translation file was found. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4396 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4397 |
function _get_path_to_translation( $domain, $reset = false ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4398 |
_deprecated_function( __FUNCTION__, '6.1.0', 'WP_Textdomain_Registry' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4399 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4400 |
static $available_translations = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4401 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4402 |
if ( true === $reset ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4403 |
$available_translations = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4404 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4405 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4406 |
if ( ! isset( $available_translations[ $domain ] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4407 |
$available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4408 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4409 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4410 |
return $available_translations[ $domain ]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4411 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4412 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4413 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4414 |
* Gets the path to a translation file in the languages directory for the current locale. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4415 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4416 |
* Holds a cached list of available .mo files to improve performance. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4417 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4418 |
* @since 4.7.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4419 |
* @deprecated 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4420 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4421 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4422 |
* @see _get_path_to_translation() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4423 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4424 |
* @param string $domain Text domain. Unique identifier for retrieving translated strings. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4425 |
* @return string|false The path to the translation file or false if no translation file was found. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4426 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4427 |
function _get_path_to_translation_from_lang_dir( $domain ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4428 |
_deprecated_function( __FUNCTION__, '6.1.0', 'WP_Textdomain_Registry' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4429 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4430 |
static $cached_mofiles = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4431 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4432 |
if ( null === $cached_mofiles ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4433 |
$cached_mofiles = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4434 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4435 |
$locations = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4436 |
WP_LANG_DIR . '/plugins', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4437 |
WP_LANG_DIR . '/themes', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4438 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4439 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4440 |
foreach ( $locations as $location ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4441 |
$mofiles = glob( $location . '/*.mo' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4442 |
if ( $mofiles ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4443 |
$cached_mofiles = array_merge( $cached_mofiles, $mofiles ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4444 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4445 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4446 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4447 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4448 |
$locale = determine_locale(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4449 |
$mofile = "{$domain}-{$locale}.mo"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4450 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4451 |
$path = WP_LANG_DIR . '/plugins/' . $mofile; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4452 |
if ( in_array( $path, $cached_mofiles, true ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4453 |
return $path; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4454 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4455 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4456 |
$path = WP_LANG_DIR . '/themes/' . $mofile; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4457 |
if ( in_array( $path, $cached_mofiles, true ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4458 |
return $path; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4459 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4460 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4461 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4462 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4463 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4464 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4465 |
* Allows multiple block styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4466 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4467 |
* @since 5.9.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4468 |
* @deprecated 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4469 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4470 |
* @param array $metadata Metadata for registering a block type. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4471 |
* @return array Metadata for registering a block type. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4472 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4473 |
function _wp_multiple_block_styles( $metadata ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4474 |
_deprecated_function( __FUNCTION__, '6.1.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4475 |
return $metadata; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4476 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4477 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4478 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4479 |
* Generates an inline style for a typography feature e.g. text decoration, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4480 |
* text transform, and font style. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4481 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4482 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4483 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4484 |
* @deprecated 6.1.0 Use wp_style_engine_get_styles() introduced in 6.1.0. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4485 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4486 |
* @see wp_style_engine_get_styles() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4487 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4488 |
* @param array $attributes Block's attributes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4489 |
* @param string $feature Key for the feature within the typography styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4490 |
* @param string $css_property Slug for the CSS property the inline style sets. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4491 |
* @return string CSS inline style. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4492 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4493 |
function wp_typography_get_css_variable_inline_style( $attributes, $feature, $css_property ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4494 |
_deprecated_function( __FUNCTION__, '6.1.0', 'wp_style_engine_get_styles()' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4495 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4496 |
// Retrieve current attribute value or skip if not found. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4497 |
$style_value = _wp_array_get( $attributes, array( 'style', 'typography', $feature ), false ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4498 |
if ( ! $style_value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4499 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4500 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4501 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4502 |
// If we don't have a preset CSS variable, we'll assume it's a regular CSS value. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4503 |
if ( ! str_contains( $style_value, "var:preset|{$css_property}|" ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4504 |
return sprintf( '%s:%s;', $css_property, $style_value ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4505 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4506 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4507 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4508 |
* We have a preset CSS variable as the style. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4509 |
* Get the style value from the string and return CSS style. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4510 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4511 |
$index_to_splice = strrpos( $style_value, '|' ) + 1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4512 |
$slug = substr( $style_value, $index_to_splice ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4513 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4514 |
// Return the actual CSS inline style e.g. `text-decoration:var(--wp--preset--text-decoration--underline);`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4515 |
return sprintf( '%s:var(--wp--preset--%s--%s);', $css_property, $css_property, $slug ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4516 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4517 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4518 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4519 |
* Determines whether global terms are enabled. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4520 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4521 |
* @since 3.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4522 |
* @since 6.1.0 This function now always returns false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4523 |
* @deprecated 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4524 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4525 |
* @return bool Always returns false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4526 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4527 |
function global_terms_enabled() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4528 |
_deprecated_function( __FUNCTION__, '6.1.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4529 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4530 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4531 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4532 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4533 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4534 |
* Filter the SQL clauses of an attachment query to include filenames. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4535 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4536 |
* @since 4.7.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4537 |
* @deprecated 6.0.3 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4538 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4539 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4540 |
* @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4541 |
* DISTINCT, fields (SELECT), and LIMITS clauses. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4542 |
* @return array The unmodified clauses. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4543 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4544 |
function _filter_query_attachment_filenames( $clauses ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4545 |
_deprecated_function( __FUNCTION__, '6.0.3', 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4546 |
remove_filter( 'posts_clauses', __FUNCTION__ ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4547 |
return $clauses; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4548 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4549 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4550 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4551 |
* Retrieves a page given its title. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4552 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4553 |
* If more than one post uses the same title, the post with the smallest ID will be returned. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4554 |
* Be careful: in case of more than one post having the same title, it will check the oldest |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4555 |
* publication date, not the smallest ID. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4556 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4557 |
* Because this function uses the MySQL '=' comparison, $page_title will usually be matched |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4558 |
* as case-insensitive with default collation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4559 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4560 |
* @since 2.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4561 |
* @since 3.0.0 The `$post_type` parameter was added. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4562 |
* @deprecated 6.2.0 Use WP_Query. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4563 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4564 |
* @global wpdb $wpdb WordPress database abstraction object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4565 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4566 |
* @param string $page_title Page title. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4567 |
* @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4568 |
* correspond to a WP_Post object, an associative array, or a numeric array, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4569 |
* respectively. Default OBJECT. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4570 |
* @param string|array $post_type Optional. Post type or array of post types. Default 'page'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4571 |
* @return WP_Post|array|null WP_Post (or array) on success, or null on failure. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4572 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4573 |
function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4574 |
_deprecated_function( __FUNCTION__, '6.2.0', 'WP_Query' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4575 |
global $wpdb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4576 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4577 |
if ( is_array( $post_type ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4578 |
$post_type = esc_sql( $post_type ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4579 |
$post_type_in_string = "'" . implode( "','", $post_type ) . "'"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4580 |
$sql = $wpdb->prepare( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4581 |
"SELECT ID |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4582 |
FROM $wpdb->posts |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4583 |
WHERE post_title = %s |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4584 |
AND post_type IN ($post_type_in_string)", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4585 |
$page_title |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4586 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4587 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4588 |
$sql = $wpdb->prepare( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4589 |
"SELECT ID |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4590 |
FROM $wpdb->posts |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4591 |
WHERE post_title = %s |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4592 |
AND post_type = %s", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4593 |
$page_title, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4594 |
$post_type |
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 |
$page = $wpdb->get_var( $sql ); |
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 |
if ( $page ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4601 |
return get_post( $page, $output ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4602 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4603 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4604 |
return null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4605 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4606 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4607 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4608 |
* Returns the correct template for the site's home page. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4609 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4610 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4611 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4612 |
* @deprecated 6.2.0 Site Editor's server-side redirect for missing postType and postId |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4613 |
* query args is removed. Thus, this function is no longer used. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4614 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4615 |
* @return array|null A template object, or null if none could be found. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4616 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4617 |
function _resolve_home_block_template() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4618 |
_deprecated_function( __FUNCTION__, '6.2.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4619 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4620 |
$show_on_front = get_option( 'show_on_front' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4621 |
$front_page_id = get_option( 'page_on_front' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4622 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4623 |
if ( 'page' === $show_on_front && $front_page_id ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4624 |
return array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4625 |
'postType' => 'page', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4626 |
'postId' => $front_page_id, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4627 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4628 |
} |
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 |
$hierarchy = array( 'front-page', 'home', 'index' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4631 |
$template = resolve_block_template( 'home', $hierarchy, '' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4632 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4633 |
if ( ! $template ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4634 |
return null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4635 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4636 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4637 |
return array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4638 |
'postType' => 'wp_template', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4639 |
'postId' => $template->id, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4640 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4641 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4642 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4643 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4644 |
* Displays the link to the Windows Live Writer manifest file. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4645 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4646 |
* @link https://msdn.microsoft.com/en-us/library/bb463265.aspx |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4647 |
* @since 2.3.1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4648 |
* @deprecated 6.3.0 WLW manifest is no longer in use and no longer included in core, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4649 |
* so the output from this function is removed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4650 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4651 |
function wlwmanifest_link() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4652 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4653 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4654 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4655 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4656 |
* Queues comments for metadata lazy-loading. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4657 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4658 |
* @since 4.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4659 |
* @deprecated 6.3.0 Use wp_lazyload_comment_meta() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4660 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4661 |
* @param WP_Comment[] $comments Array of comment objects. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4662 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4663 |
function wp_queue_comments_for_comment_meta_lazyload( $comments ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4664 |
_deprecated_function( __FUNCTION__, '6.3.0', 'wp_lazyload_comment_meta()' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4665 |
// Don't use `wp_list_pluck()` to avoid by-reference manipulation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4666 |
$comment_ids = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4667 |
if ( is_array( $comments ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4668 |
foreach ( $comments as $comment ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4669 |
if ( $comment instanceof WP_Comment ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4670 |
$comment_ids[] = $comment->comment_ID; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4671 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4672 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4673 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4674 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4675 |
wp_lazyload_comment_meta( $comment_ids ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4676 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4677 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4678 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4679 |
* Gets the default value to use for a `loading` attribute on an element. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4680 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4681 |
* This function should only be called for a tag and context if lazy-loading is generally enabled. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4682 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4683 |
* The function usually returns 'lazy', but uses certain heuristics to guess whether the current element is likely to |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4684 |
* appear above the fold, in which case it returns a boolean `false`, which will lead to the `loading` attribute being |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4685 |
* omitted on the element. The purpose of this refinement is to avoid lazy-loading elements that are within the initial |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4686 |
* viewport, which can have a negative performance impact. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4687 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4688 |
* Under the hood, the function uses {@see wp_increase_content_media_count()} every time it is called for an element |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4689 |
* within the main content. If the element is the very first content element, the `loading` attribute will be omitted. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4690 |
* This default threshold of 3 content elements to omit the `loading` attribute for can be customized using the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4691 |
* {@see 'wp_omit_loading_attr_threshold'} filter. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4692 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4693 |
* @since 5.9.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4694 |
* @deprecated 6.3.0 Use wp_get_loading_optimization_attributes() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4695 |
* @see wp_get_loading_optimization_attributes() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4696 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4697 |
* @global WP_Query $wp_query WordPress Query object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4698 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4699 |
* @param string $context Context for the element for which the `loading` attribute value is requested. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4700 |
* @return string|bool The default `loading` attribute value. Either 'lazy', 'eager', or a boolean `false`, to indicate |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4701 |
* that the `loading` attribute should be skipped. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4702 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4703 |
function wp_get_loading_attr_default( $context ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4704 |
_deprecated_function( __FUNCTION__, '6.3.0', 'wp_get_loading_optimization_attributes()' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4705 |
global $wp_query; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4706 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4707 |
// Skip lazy-loading for the overall block template, as it is handled more granularly. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4708 |
if ( 'template' === $context ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4709 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4710 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4711 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4712 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4713 |
* Do not lazy-load images in the header block template part, as they are likely above the fold. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4714 |
* For classic themes, this is handled in the condition below using the 'get_header' action. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4715 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4716 |
$header_area = WP_TEMPLATE_PART_AREA_HEADER; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4717 |
if ( "template_part_{$header_area}" === $context ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4718 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4719 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4720 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4721 |
// Special handling for programmatically created image tags. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4722 |
if ( 'the_post_thumbnail' === $context || 'wp_get_attachment_image' === $context ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4723 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4724 |
* Skip programmatically created images within post content as they need to be handled together with the other |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4725 |
* images within the post content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4726 |
* Without this clause, they would already be counted below which skews the number and can result in the first |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4727 |
* post content image being lazy-loaded only because there are images elsewhere in the post content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4728 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4729 |
if ( doing_filter( 'the_content' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4730 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4731 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4732 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4733 |
// Conditionally skip lazy-loading on images before the loop. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4734 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4735 |
// Only apply for main query but before the loop. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4736 |
$wp_query->before_loop && $wp_query->is_main_query() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4737 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4738 |
* Any image before the loop, but after the header has started should not be lazy-loaded, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4739 |
* except when the footer has already started which can happen when the current template |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4740 |
* does not include any loop. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4741 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4742 |
&& did_action( 'get_header' ) && ! did_action( 'get_footer' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4743 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4744 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4745 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4746 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4747 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4748 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4749 |
* The first elements in 'the_content' or 'the_post_thumbnail' should not be lazy-loaded, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4750 |
* as they are likely above the fold. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4751 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4752 |
if ( 'the_content' === $context || 'the_post_thumbnail' === $context ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4753 |
// Only elements within the main query loop have special handling. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4754 |
if ( is_admin() || ! in_the_loop() || ! is_main_query() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4755 |
return 'lazy'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4756 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4757 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4758 |
// Increase the counter since this is a main query content element. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4759 |
$content_media_count = wp_increase_content_media_count(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4760 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4761 |
// If the count so far is below the threshold, return `false` so that the `loading` attribute is omitted. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4762 |
if ( $content_media_count <= wp_omit_loading_attr_threshold() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4763 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4764 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4765 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4766 |
// For elements after the threshold, lazy-load them as usual. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4767 |
return 'lazy'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4768 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4769 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4770 |
// Lazy-load by default for any unknown context. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4771 |
return 'lazy'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4772 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4773 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4774 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4775 |
* Adds `loading` attribute to an `img` HTML tag. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4776 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4777 |
* @since 5.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4778 |
* @deprecated 6.3.0 Use wp_img_tag_add_loading_optimization_attrs() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4779 |
* @see wp_img_tag_add_loading_optimization_attrs() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4780 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4781 |
* @param string $image The HTML `img` tag where the attribute should be added. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4782 |
* @param string $context Additional context to pass to the filters. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4783 |
* @return string Converted `img` tag with `loading` attribute added. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4784 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4785 |
function wp_img_tag_add_loading_attr( $image, $context ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4786 |
_deprecated_function( __FUNCTION__, '6.3.0', 'wp_img_tag_add_loading_optimization_attrs()' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4787 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4788 |
* Get loading attribute value to use. This must occur before the conditional check below so that even images that |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4789 |
* are ineligible for being lazy-loaded are considered. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4790 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4791 |
$value = wp_get_loading_attr_default( $context ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4792 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4793 |
// Images should have source and dimension attributes for the `loading` attribute to be added. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4794 |
if ( ! str_contains( $image, ' src="' ) || ! str_contains( $image, ' width="' ) || ! str_contains( $image, ' height="' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4795 |
return $image; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4796 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4797 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4798 |
/** This filter is documented in wp-admin/includes/media.php */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4799 |
$value = apply_filters( 'wp_img_tag_add_loading_attr', $value, $image, $context ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4800 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4801 |
if ( $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4802 |
if ( ! in_array( $value, array( 'lazy', 'eager' ), true ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4803 |
$value = 'lazy'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4804 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4805 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4806 |
return str_replace( '<img', '<img loading="' . esc_attr( $value ) . '"', $image ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4807 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4808 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4809 |
return $image; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4810 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4811 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4812 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4813 |
* Takes input from [0, n] and returns it as [0, 1]. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4814 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4815 |
* Direct port of TinyColor's function, lightly simplified to maintain |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4816 |
* consistency with TinyColor. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4817 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4818 |
* @link https://github.com/bgrins/TinyColor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4819 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4820 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4821 |
* @deprecated 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4822 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4823 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4824 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4825 |
* @param mixed $n Number of unknown type. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4826 |
* @param int $max Upper value of the range to bound to. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4827 |
* @return float Value in the range [0, 1]. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4828 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4829 |
function wp_tinycolor_bound01( $n, $max ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4830 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4831 |
if ( 'string' === gettype( $n ) && str_contains( $n, '.' ) && 1 === (float) $n ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4832 |
$n = '100%'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4833 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4834 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4835 |
$n = min( $max, max( 0, (float) $n ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4836 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4837 |
// Automatically convert percentage into number. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4838 |
if ( 'string' === gettype( $n ) && str_contains( $n, '%' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4839 |
$n = (int) ( $n * $max ) / 100; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4840 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4841 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4842 |
// Handle floating point rounding errors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4843 |
if ( ( abs( $n - $max ) < 0.000001 ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4844 |
return 1.0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4845 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4846 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4847 |
// Convert into [0, 1] range if it isn't already. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4848 |
return ( $n % $max ) / (float) $max; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4849 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4850 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4851 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4852 |
* Direct port of tinycolor's boundAlpha function to maintain consistency with |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4853 |
* how tinycolor works. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4854 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4855 |
* @link https://github.com/bgrins/TinyColor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4856 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4857 |
* @since 5.9.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4858 |
* @deprecated 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4859 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4860 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4861 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4862 |
* @param mixed $n Number of unknown type. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4863 |
* @return float Value in the range [0,1]. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4864 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4865 |
function _wp_tinycolor_bound_alpha( $n ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4866 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4867 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4868 |
if ( is_numeric( $n ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4869 |
$n = (float) $n; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4870 |
if ( $n >= 0 && $n <= 1 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4871 |
return $n; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4872 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4873 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4874 |
return 1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4875 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4876 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4877 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4878 |
* Rounds and converts values of an RGB object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4879 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4880 |
* Direct port of TinyColor's function, lightly simplified to maintain |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4881 |
* consistency with TinyColor. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4882 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4883 |
* @link https://github.com/bgrins/TinyColor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4884 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4885 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4886 |
* @deprecated 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4887 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4888 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4889 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4890 |
* @param array $rgb_color RGB object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4891 |
* @return array Rounded and converted RGB object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4892 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4893 |
function wp_tinycolor_rgb_to_rgb( $rgb_color ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4894 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4895 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4896 |
return array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4897 |
'r' => wp_tinycolor_bound01( $rgb_color['r'], 255 ) * 255, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4898 |
'g' => wp_tinycolor_bound01( $rgb_color['g'], 255 ) * 255, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4899 |
'b' => wp_tinycolor_bound01( $rgb_color['b'], 255 ) * 255, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4900 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4901 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4902 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4903 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4904 |
* Helper function for hsl to rgb conversion. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4905 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4906 |
* Direct port of TinyColor's function, lightly simplified to maintain |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4907 |
* consistency with TinyColor. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4908 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4909 |
* @link https://github.com/bgrins/TinyColor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4910 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4911 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4912 |
* @deprecated 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4913 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4914 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4915 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4916 |
* @param float $p first component. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4917 |
* @param float $q second component. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4918 |
* @param float $t third component. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4919 |
* @return float R, G, or B component. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4920 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4921 |
function wp_tinycolor_hue_to_rgb( $p, $q, $t ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4922 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4923 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4924 |
if ( $t < 0 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4925 |
++$t; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4926 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4927 |
if ( $t > 1 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4928 |
--$t; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4929 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4930 |
if ( $t < 1 / 6 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4931 |
return $p + ( $q - $p ) * 6 * $t; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4932 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4933 |
if ( $t < 1 / 2 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4934 |
return $q; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4935 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4936 |
if ( $t < 2 / 3 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4937 |
return $p + ( $q - $p ) * ( 2 / 3 - $t ) * 6; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4938 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4939 |
return $p; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4940 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4941 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4942 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4943 |
* Converts an HSL object to an RGB object with converted and rounded values. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4944 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4945 |
* Direct port of TinyColor's function, lightly simplified to maintain |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4946 |
* consistency with TinyColor. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4947 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4948 |
* @link https://github.com/bgrins/TinyColor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4949 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4950 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4951 |
* @deprecated 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4952 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4953 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4954 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4955 |
* @param array $hsl_color HSL object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4956 |
* @return array Rounded and converted RGB object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4957 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4958 |
function wp_tinycolor_hsl_to_rgb( $hsl_color ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4959 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4960 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4961 |
$h = wp_tinycolor_bound01( $hsl_color['h'], 360 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4962 |
$s = wp_tinycolor_bound01( $hsl_color['s'], 100 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4963 |
$l = wp_tinycolor_bound01( $hsl_color['l'], 100 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4964 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4965 |
if ( 0 === $s ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4966 |
// Achromatic. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4967 |
$r = $l; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4968 |
$g = $l; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4969 |
$b = $l; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4970 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4971 |
$q = $l < 0.5 ? $l * ( 1 + $s ) : $l + $s - $l * $s; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4972 |
$p = 2 * $l - $q; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4973 |
$r = wp_tinycolor_hue_to_rgb( $p, $q, $h + 1 / 3 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4974 |
$g = wp_tinycolor_hue_to_rgb( $p, $q, $h ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4975 |
$b = wp_tinycolor_hue_to_rgb( $p, $q, $h - 1 / 3 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4976 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4977 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4978 |
return array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4979 |
'r' => $r * 255, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4980 |
'g' => $g * 255, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4981 |
'b' => $b * 255, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4982 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4983 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4984 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4985 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4986 |
* Parses hex, hsl, and rgb CSS strings using the same regex as TinyColor v1.4.2 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4987 |
* used in the JavaScript. Only colors output from react-color are implemented. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4988 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4989 |
* Direct port of TinyColor's function, lightly simplified to maintain |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4990 |
* consistency with TinyColor. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4991 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4992 |
* @link https://github.com/bgrins/TinyColor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4993 |
* @link https://github.com/casesandberg/react-color/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4994 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4995 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4996 |
* @since 5.9.0 Added alpha processing. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4997 |
* @deprecated 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4998 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4999 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5000 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5001 |
* @param string $color_str CSS color string. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5002 |
* @return array RGB object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5003 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5004 |
function wp_tinycolor_string_to_rgb( $color_str ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5005 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5006 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5007 |
$color_str = strtolower( trim( $color_str ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5008 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5009 |
$css_integer = '[-\\+]?\\d+%?'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5010 |
$css_number = '[-\\+]?\\d*\\.\\d+%?'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5011 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5012 |
$css_unit = '(?:' . $css_number . ')|(?:' . $css_integer . ')'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5013 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5014 |
$permissive_match3 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5015 |
$permissive_match4 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5016 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5017 |
$rgb_regexp = '/^rgb' . $permissive_match3 . '$/'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5018 |
if ( preg_match( $rgb_regexp, $color_str, $match ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5019 |
$rgb = wp_tinycolor_rgb_to_rgb( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5020 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5021 |
'r' => $match[1], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5022 |
'g' => $match[2], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5023 |
'b' => $match[3], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5024 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5025 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5026 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5027 |
$rgb['a'] = 1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5028 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5029 |
return $rgb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5030 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5031 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5032 |
$rgba_regexp = '/^rgba' . $permissive_match4 . '$/'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5033 |
if ( preg_match( $rgba_regexp, $color_str, $match ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5034 |
$rgb = wp_tinycolor_rgb_to_rgb( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5035 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5036 |
'r' => $match[1], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5037 |
'g' => $match[2], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5038 |
'b' => $match[3], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5039 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5040 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5041 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5042 |
$rgb['a'] = _wp_tinycolor_bound_alpha( $match[4] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5043 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5044 |
return $rgb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5045 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5046 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5047 |
$hsl_regexp = '/^hsl' . $permissive_match3 . '$/'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5048 |
if ( preg_match( $hsl_regexp, $color_str, $match ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5049 |
$rgb = wp_tinycolor_hsl_to_rgb( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5050 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5051 |
'h' => $match[1], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5052 |
's' => $match[2], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5053 |
'l' => $match[3], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5054 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5055 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5056 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5057 |
$rgb['a'] = 1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5058 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5059 |
return $rgb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5060 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5061 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5062 |
$hsla_regexp = '/^hsla' . $permissive_match4 . '$/'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5063 |
if ( preg_match( $hsla_regexp, $color_str, $match ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5064 |
$rgb = wp_tinycolor_hsl_to_rgb( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5065 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5066 |
'h' => $match[1], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5067 |
's' => $match[2], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5068 |
'l' => $match[3], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5069 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5070 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5071 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5072 |
$rgb['a'] = _wp_tinycolor_bound_alpha( $match[4] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5073 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5074 |
return $rgb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5075 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5076 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5077 |
$hex8_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5078 |
if ( preg_match( $hex8_regexp, $color_str, $match ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5079 |
$rgb = wp_tinycolor_rgb_to_rgb( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5080 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5081 |
'r' => base_convert( $match[1], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5082 |
'g' => base_convert( $match[2], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5083 |
'b' => base_convert( $match[3], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5084 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5085 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5086 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5087 |
$rgb['a'] = _wp_tinycolor_bound_alpha( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5088 |
base_convert( $match[4], 16, 10 ) / 255 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5089 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5090 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5091 |
return $rgb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5092 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5093 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5094 |
$hex6_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5095 |
if ( preg_match( $hex6_regexp, $color_str, $match ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5096 |
$rgb = wp_tinycolor_rgb_to_rgb( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5097 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5098 |
'r' => base_convert( $match[1], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5099 |
'g' => base_convert( $match[2], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5100 |
'b' => base_convert( $match[3], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5101 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5102 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5103 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5104 |
$rgb['a'] = 1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5105 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5106 |
return $rgb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5107 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5108 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5109 |
$hex4_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5110 |
if ( preg_match( $hex4_regexp, $color_str, $match ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5111 |
$rgb = wp_tinycolor_rgb_to_rgb( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5112 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5113 |
'r' => base_convert( $match[1] . $match[1], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5114 |
'g' => base_convert( $match[2] . $match[2], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5115 |
'b' => base_convert( $match[3] . $match[3], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5116 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5117 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5118 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5119 |
$rgb['a'] = _wp_tinycolor_bound_alpha( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5120 |
base_convert( $match[4] . $match[4], 16, 10 ) / 255 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5121 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5122 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5123 |
return $rgb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5124 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5125 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5126 |
$hex3_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5127 |
if ( preg_match( $hex3_regexp, $color_str, $match ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5128 |
$rgb = wp_tinycolor_rgb_to_rgb( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5129 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5130 |
'r' => base_convert( $match[1] . $match[1], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5131 |
'g' => base_convert( $match[2] . $match[2], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5132 |
'b' => base_convert( $match[3] . $match[3], 16, 10 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5133 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5134 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5135 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5136 |
$rgb['a'] = 1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5137 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5138 |
return $rgb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5139 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5140 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5141 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5142 |
* The JS color picker considers the string "transparent" to be a hex value, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5143 |
* so we need to handle it here as a special case. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5144 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5145 |
if ( 'transparent' === $color_str ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5146 |
return array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5147 |
'r' => 0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5148 |
'g' => 0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5149 |
'b' => 0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5150 |
'a' => 0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5151 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5152 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5153 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5154 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5155 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5156 |
* Returns the prefixed id for the duotone filter for use as a CSS id. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5157 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5158 |
* @since 5.9.1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5159 |
* @deprecated 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5160 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5161 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5162 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5163 |
* @param array $preset Duotone preset value as seen in theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5164 |
* @return string Duotone filter CSS id. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5165 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5166 |
function wp_get_duotone_filter_id( $preset ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5167 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5168 |
return WP_Duotone::get_filter_id_from_preset( $preset ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5169 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5170 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5171 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5172 |
* Returns the CSS filter property url to reference the rendered SVG. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5173 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5174 |
* @since 5.9.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5175 |
* @since 6.1.0 Allow unset for preset colors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5176 |
* @deprecated 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5177 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5178 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5179 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5180 |
* @param array $preset Duotone preset value as seen in theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5181 |
* @return string Duotone CSS filter property url value. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5182 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5183 |
function wp_get_duotone_filter_property( $preset ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5184 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5185 |
return WP_Duotone::get_filter_css_property_value_from_preset( $preset ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5186 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5187 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5188 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5189 |
* Returns the duotone filter SVG string for the preset. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5190 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5191 |
* @since 5.9.1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5192 |
* @deprecated 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5193 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5194 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5195 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5196 |
* @param array $preset Duotone preset value as seen in theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5197 |
* @return string Duotone SVG filter. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5198 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5199 |
function wp_get_duotone_filter_svg( $preset ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5200 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5201 |
return WP_Duotone::get_filter_svg_from_preset( $preset ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5202 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5203 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5204 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5205 |
* Registers the style and colors block attributes for block types that support it. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5206 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5207 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5208 |
* @deprecated 6.3.0 Use WP_Duotone::register_duotone_support() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5209 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5210 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5211 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5212 |
* @param WP_Block_Type $block_type Block Type. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5213 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5214 |
function wp_register_duotone_support( $block_type ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5215 |
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::register_duotone_support()' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5216 |
return WP_Duotone::register_duotone_support( $block_type ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5217 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5218 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5219 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5220 |
* Renders out the duotone stylesheet and SVG. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5221 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5222 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5223 |
* @since 6.1.0 Allow unset for preset colors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5224 |
* @deprecated 6.3.0 Use WP_Duotone::render_duotone_support() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5225 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5226 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5227 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5228 |
* @param string $block_content Rendered block content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5229 |
* @param array $block Block object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5230 |
* @return string Filtered block content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5231 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5232 |
function wp_render_duotone_support( $block_content, $block ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5233 |
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::render_duotone_support()' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5234 |
$wp_block = new WP_Block( $block ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5235 |
return WP_Duotone::render_duotone_support( $block_content, $block, $wp_block ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5236 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5237 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5238 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5239 |
* Returns a string containing the SVGs to be referenced as filters (duotone). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5240 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5241 |
* @since 5.9.1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5242 |
* @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5243 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5244 |
* @return string |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5245 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5246 |
function wp_get_global_styles_svg_filters() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5247 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5248 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5249 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5250 |
* Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5251 |
* developer's workflow. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5252 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5253 |
$can_use_cached = ! wp_is_development_mode( 'theme' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5254 |
$cache_group = 'theme_json'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5255 |
$cache_key = 'wp_get_global_styles_svg_filters'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5256 |
if ( $can_use_cached ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5257 |
$cached = wp_cache_get( $cache_key, $cache_group ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5258 |
if ( $cached ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5259 |
return $cached; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5260 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5261 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5262 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5263 |
$supports_theme_json = wp_theme_has_theme_json(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5264 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5265 |
$origins = array( 'default', 'theme', 'custom' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5266 |
if ( ! $supports_theme_json ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5267 |
$origins = array( 'default' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5268 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5269 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5270 |
$tree = WP_Theme_JSON_Resolver::get_merged_data(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5271 |
$svgs = $tree->get_svg_filters( $origins ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5272 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5273 |
if ( $can_use_cached ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5274 |
wp_cache_set( $cache_key, $svgs, $cache_group ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5275 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5276 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5277 |
return $svgs; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5278 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5279 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5280 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5281 |
* Renders the SVG filters supplied by theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5282 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5283 |
* Note that this doesn't render the per-block user-defined |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5284 |
* filters which are handled by wp_render_duotone_support, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5285 |
* but it should be rendered before the filtered content |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5286 |
* in the body to satisfy Safari's rendering quirks. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5287 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5288 |
* @since 5.9.1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5289 |
* @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5290 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5291 |
function wp_global_styles_render_svg_filters() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5292 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5293 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5294 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5295 |
* When calling via the in_admin_header action, we only want to render the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5296 |
* SVGs on block editor pages. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5297 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5298 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5299 |
is_admin() && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5300 |
! get_current_screen()->is_block_editor() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5301 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5302 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5303 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5304 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5305 |
$filters = wp_get_global_styles_svg_filters(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5306 |
if ( ! empty( $filters ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5307 |
echo $filters; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5308 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5309 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5310 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5311 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5312 |
* Build an array with CSS classes and inline styles defining the colors |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5313 |
* which will be applied to the navigation markup in the front-end. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5314 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5315 |
* @since 5.9.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5316 |
* @deprecated 6.3.0 This was removed from the Navigation Submenu block in favour of `wp_apply_colors_support()`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5317 |
* `wp_apply_colors_support()` returns an array with similar class and style values, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5318 |
* but with different keys: `class` and `style`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5319 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5320 |
* @param array $context Navigation block context. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5321 |
* @param array $attributes Block attributes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5322 |
* @param bool $is_sub_menu Whether the block is a sub-menu. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5323 |
* @return array Colors CSS classes and inline styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5324 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5325 |
function block_core_navigation_submenu_build_css_colors( $context, $attributes, $is_sub_menu = false ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5326 |
_deprecated_function( __FUNCTION__, '6.3.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5327 |
$colors = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5328 |
'css_classes' => array(), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5329 |
'inline_styles' => '', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5330 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5331 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5332 |
// Text color. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5333 |
$named_text_color = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5334 |
$custom_text_color = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5335 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5336 |
if ( $is_sub_menu && array_key_exists( 'customOverlayTextColor', $context ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5337 |
$custom_text_color = $context['customOverlayTextColor']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5338 |
} elseif ( $is_sub_menu && array_key_exists( 'overlayTextColor', $context ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5339 |
$named_text_color = $context['overlayTextColor']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5340 |
} elseif ( array_key_exists( 'customTextColor', $context ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5341 |
$custom_text_color = $context['customTextColor']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5342 |
} elseif ( array_key_exists( 'textColor', $context ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5343 |
$named_text_color = $context['textColor']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5344 |
} elseif ( isset( $context['style']['color']['text'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5345 |
$custom_text_color = $context['style']['color']['text']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5346 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5347 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5348 |
// If has text color. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5349 |
if ( ! is_null( $named_text_color ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5350 |
// Add the color class. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5351 |
array_push( $colors['css_classes'], 'has-text-color', sprintf( 'has-%s-color', $named_text_color ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5352 |
} elseif ( ! is_null( $custom_text_color ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5353 |
// Add the custom color inline style. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5354 |
$colors['css_classes'][] = 'has-text-color'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5355 |
$colors['inline_styles'] .= sprintf( 'color: %s;', $custom_text_color ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5356 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5357 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5358 |
// Background color. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5359 |
$named_background_color = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5360 |
$custom_background_color = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5361 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5362 |
if ( $is_sub_menu && array_key_exists( 'customOverlayBackgroundColor', $context ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5363 |
$custom_background_color = $context['customOverlayBackgroundColor']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5364 |
} elseif ( $is_sub_menu && array_key_exists( 'overlayBackgroundColor', $context ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5365 |
$named_background_color = $context['overlayBackgroundColor']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5366 |
} elseif ( array_key_exists( 'customBackgroundColor', $context ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5367 |
$custom_background_color = $context['customBackgroundColor']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5368 |
} elseif ( array_key_exists( 'backgroundColor', $context ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5369 |
$named_background_color = $context['backgroundColor']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5370 |
} elseif ( isset( $context['style']['color']['background'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5371 |
$custom_background_color = $context['style']['color']['background']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5372 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5373 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5374 |
// If has background color. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5375 |
if ( ! is_null( $named_background_color ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5376 |
// Add the background-color class. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5377 |
array_push( $colors['css_classes'], 'has-background', sprintf( 'has-%s-background-color', $named_background_color ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5378 |
} elseif ( ! is_null( $custom_background_color ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5379 |
// Add the custom background-color inline style. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5380 |
$colors['css_classes'][] = 'has-background'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5381 |
$colors['inline_styles'] .= sprintf( 'background-color: %s;', $custom_background_color ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5382 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5383 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5384 |
return $colors; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5385 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5386 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5387 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5388 |
* Runs the theme.json webfonts handler. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5389 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5390 |
* Using `WP_Theme_JSON_Resolver`, it gets the fonts defined |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5391 |
* in the `theme.json` for the current selection and style |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5392 |
* variations, validates the font-face properties, generates |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5393 |
* the '@font-face' style declarations, and then enqueues the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5394 |
* styles for both the editor and front-end. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5395 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5396 |
* Design Notes: |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5397 |
* This is not a public API, but rather an internal handler. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5398 |
* A future public Webfonts API will replace this stopgap code. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5399 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5400 |
* This code design is intentional. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5401 |
* a. It hides the inner-workings. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5402 |
* b. It does not expose API ins or outs for consumption. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5403 |
* c. It only works with a theme's `theme.json`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5404 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5405 |
* Why? |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5406 |
* a. To avoid backwards-compatibility issues when |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5407 |
* the Webfonts API is introduced in Core. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5408 |
* b. To make `fontFace` declarations in `theme.json` work. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5409 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5410 |
* @link https://github.com/WordPress/gutenberg/issues/40472 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5411 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5412 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5413 |
* @deprecated 6.4.0 Use wp_print_font_faces() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5414 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5415 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5416 |
function _wp_theme_json_webfonts_handler() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5417 |
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_print_font_faces' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5418 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5419 |
// Block themes are unavailable during installation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5420 |
if ( wp_installing() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5421 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5422 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5423 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5424 |
if ( ! wp_theme_has_theme_json() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5425 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5426 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5427 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5428 |
// Webfonts to be processed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5429 |
$registered_webfonts = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5430 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5431 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5432 |
* Gets the webfonts from theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5433 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5434 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5435 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5436 |
* @return array Array of defined webfonts. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5437 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5438 |
$fn_get_webfonts_from_theme_json = static function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5439 |
// Get settings from theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5440 |
$settings = WP_Theme_JSON_Resolver::get_merged_data()->get_settings(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5441 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5442 |
// If in the editor, add webfonts defined in variations. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5443 |
if ( is_admin() || wp_is_rest_endpoint() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5444 |
$variations = WP_Theme_JSON_Resolver::get_style_variations(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5445 |
foreach ( $variations as $variation ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5446 |
// Skip if fontFamilies are not defined in the variation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5447 |
if ( empty( $variation['settings']['typography']['fontFamilies'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5448 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5449 |
} |
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 |
// Initialize the array structure. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5452 |
if ( empty( $settings['typography'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5453 |
$settings['typography'] = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5454 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5455 |
if ( empty( $settings['typography']['fontFamilies'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5456 |
$settings['typography']['fontFamilies'] = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5457 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5458 |
if ( empty( $settings['typography']['fontFamilies']['theme'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5459 |
$settings['typography']['fontFamilies']['theme'] = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5460 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5461 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5462 |
// Combine variations with settings. Remove duplicates. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5463 |
$settings['typography']['fontFamilies']['theme'] = array_merge( $settings['typography']['fontFamilies']['theme'], $variation['settings']['typography']['fontFamilies']['theme'] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5464 |
$settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5465 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5466 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5467 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5468 |
// Bail out early if there are no settings for webfonts. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5469 |
if ( empty( $settings['typography']['fontFamilies'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5470 |
return array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5471 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5472 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5473 |
$webfonts = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5474 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5475 |
// Look for fontFamilies. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5476 |
foreach ( $settings['typography']['fontFamilies'] as $font_families ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5477 |
foreach ( $font_families as $font_family ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5478 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5479 |
// Skip if fontFace is not defined. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5480 |
if ( empty( $font_family['fontFace'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5481 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5482 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5483 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5484 |
// Skip if fontFace is not an array of webfonts. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5485 |
if ( ! is_array( $font_family['fontFace'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5486 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5487 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5488 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5489 |
$webfonts = array_merge( $webfonts, $font_family['fontFace'] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5490 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5491 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5492 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5493 |
return $webfonts; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5494 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5495 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5496 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5497 |
* Transforms each 'src' into an URI by replacing 'file:./' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5498 |
* placeholder from theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5499 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5500 |
* The absolute path to the webfont file(s) cannot be defined in |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5501 |
* theme.json. `file:./` is the placeholder which is replaced by |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5502 |
* the theme's URL path to the theme's root. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5503 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5504 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5505 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5506 |
* @param array $src Webfont file(s) `src`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5507 |
* @return array Webfont's `src` in URI. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5508 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5509 |
$fn_transform_src_into_uri = static function( array $src ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5510 |
foreach ( $src as $key => $url ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5511 |
// Tweak the URL to be relative to the theme root. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5512 |
if ( ! str_starts_with( $url, 'file:./' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5513 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5514 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5515 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5516 |
$src[ $key ] = get_theme_file_uri( str_replace( 'file:./', '', $url ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5517 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5518 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5519 |
return $src; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5520 |
}; |
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 |
* Converts the font-face properties (i.e. keys) into kebab-case. |
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 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5526 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5527 |
* @param array $font_face Font face to convert. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5528 |
* @return array Font faces with each property in kebab-case format. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5529 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5530 |
$fn_convert_keys_to_kebab_case = static function( array $font_face ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5531 |
foreach ( $font_face as $property => $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5532 |
$kebab_case = _wp_to_kebab_case( $property ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5533 |
$font_face[ $kebab_case ] = $value; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5534 |
if ( $kebab_case !== $property ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5535 |
unset( $font_face[ $property ] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5536 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5537 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5538 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5539 |
return $font_face; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5540 |
}; |
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 |
* Validates a webfont. |
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 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5546 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5547 |
* @param array $webfont The webfont arguments. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5548 |
* @return array|false The validated webfont arguments, or false if the webfont is invalid. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5549 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5550 |
$fn_validate_webfont = static function( $webfont ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5551 |
$webfont = wp_parse_args( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5552 |
$webfont, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5553 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5554 |
'font-family' => '', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5555 |
'font-style' => 'normal', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5556 |
'font-weight' => '400', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5557 |
'font-display' => 'fallback', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5558 |
'src' => array(), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5559 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5560 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5561 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5562 |
// Check the font-family. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5563 |
if ( empty( $webfont['font-family'] ) || ! is_string( $webfont['font-family'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5564 |
trigger_error( __( 'Webfont font family must be a non-empty string.' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5565 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5566 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5567 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5568 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5569 |
// Check that the `src` property is defined and a valid type. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5570 |
if ( empty( $webfont['src'] ) || ( ! is_string( $webfont['src'] ) && ! is_array( $webfont['src'] ) ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5571 |
trigger_error( __( 'Webfont src must be a non-empty string or an array of strings.' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5572 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5573 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5574 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5575 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5576 |
// Validate the `src` property. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5577 |
foreach ( (array) $webfont['src'] as $src ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5578 |
if ( ! is_string( $src ) || '' === trim( $src ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5579 |
trigger_error( __( 'Each webfont src must be a non-empty string.' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5580 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5581 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5582 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5583 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5584 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5585 |
// Check the font-weight. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5586 |
if ( ! is_string( $webfont['font-weight'] ) && ! is_int( $webfont['font-weight'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5587 |
trigger_error( __( 'Webfont font weight must be a properly formatted string or integer.' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5588 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5589 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5590 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5591 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5592 |
// Check the font-display. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5593 |
if ( ! in_array( $webfont['font-display'], array( 'auto', 'block', 'fallback', 'optional', 'swap' ), true ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5594 |
$webfont['font-display'] = 'fallback'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5595 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5596 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5597 |
$valid_props = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5598 |
'ascend-override', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5599 |
'descend-override', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5600 |
'font-display', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5601 |
'font-family', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5602 |
'font-stretch', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5603 |
'font-style', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5604 |
'font-weight', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5605 |
'font-variant', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5606 |
'font-feature-settings', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5607 |
'font-variation-settings', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5608 |
'line-gap-override', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5609 |
'size-adjust', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5610 |
'src', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5611 |
'unicode-range', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5612 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5613 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5614 |
foreach ( $webfont as $prop => $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5615 |
if ( ! in_array( $prop, $valid_props, true ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5616 |
unset( $webfont[ $prop ] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5617 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5618 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5619 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5620 |
return $webfont; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5621 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5622 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5623 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5624 |
* Registers webfonts declared in theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5625 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5626 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5627 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5628 |
* @uses $registered_webfonts To access and update the registered webfonts registry (passed by reference). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5629 |
* @uses $fn_get_webfonts_from_theme_json To run the function that gets the webfonts from theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5630 |
* @uses $fn_convert_keys_to_kebab_case To run the function that converts keys into kebab-case. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5631 |
* @uses $fn_validate_webfont To run the function that validates each font-face (webfont) from theme.json. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5632 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5633 |
$fn_register_webfonts = static function() use ( &$registered_webfonts, $fn_get_webfonts_from_theme_json, $fn_convert_keys_to_kebab_case, $fn_validate_webfont, $fn_transform_src_into_uri ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5634 |
$registered_webfonts = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5635 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5636 |
foreach ( $fn_get_webfonts_from_theme_json() as $webfont ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5637 |
if ( ! is_array( $webfont ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5638 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5639 |
} |
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 |
$webfont = $fn_convert_keys_to_kebab_case( $webfont ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5642 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5643 |
$webfont = $fn_validate_webfont( $webfont ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5644 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5645 |
$webfont['src'] = $fn_transform_src_into_uri( (array) $webfont['src'] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5646 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5647 |
// Skip if not valid. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5648 |
if ( empty( $webfont ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5649 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5650 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5651 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5652 |
$registered_webfonts[] = $webfont; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5653 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5654 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5655 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5656 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5657 |
* Orders 'src' items to optimize for browser support. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5658 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5659 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5660 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5661 |
* @param array $webfont Webfont to process. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5662 |
* @return array Ordered `src` items. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5663 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5664 |
$fn_order_src = static function( array $webfont ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5665 |
$src = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5666 |
$src_ordered = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5667 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5668 |
foreach ( $webfont['src'] as $url ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5669 |
// Add data URIs first. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5670 |
if ( str_starts_with( trim( $url ), 'data:' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5671 |
$src_ordered[] = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5672 |
'url' => $url, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5673 |
'format' => 'data', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5674 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5675 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5676 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5677 |
$format = pathinfo( $url, PATHINFO_EXTENSION ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5678 |
$src[ $format ] = $url; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5679 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5680 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5681 |
// Add woff2. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5682 |
if ( ! empty( $src['woff2'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5683 |
$src_ordered[] = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5684 |
'url' => sanitize_url( $src['woff2'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5685 |
'format' => 'woff2', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5686 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5687 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5688 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5689 |
// Add woff. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5690 |
if ( ! empty( $src['woff'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5691 |
$src_ordered[] = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5692 |
'url' => sanitize_url( $src['woff'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5693 |
'format' => 'woff', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5694 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5695 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5696 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5697 |
// Add ttf. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5698 |
if ( ! empty( $src['ttf'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5699 |
$src_ordered[] = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5700 |
'url' => sanitize_url( $src['ttf'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5701 |
'format' => 'truetype', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5702 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5703 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5704 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5705 |
// Add eot. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5706 |
if ( ! empty( $src['eot'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5707 |
$src_ordered[] = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5708 |
'url' => sanitize_url( $src['eot'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5709 |
'format' => 'embedded-opentype', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5710 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5711 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5712 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5713 |
// Add otf. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5714 |
if ( ! empty( $src['otf'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5715 |
$src_ordered[] = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5716 |
'url' => sanitize_url( $src['otf'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5717 |
'format' => 'opentype', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5718 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5719 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5720 |
$webfont['src'] = $src_ordered; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5721 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5722 |
return $webfont; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5723 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5724 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5725 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5726 |
* Compiles the 'src' into valid CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5727 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5728 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5729 |
* @since 6.2.0 Removed local() CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5730 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5731 |
* @param string $font_family Font family. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5732 |
* @param array $value Value to process. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5733 |
* @return string The CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5734 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5735 |
$fn_compile_src = static function( $font_family, array $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5736 |
$src = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5737 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5738 |
foreach ( $value as $item ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5739 |
$src .= ( 'data' === $item['format'] ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5740 |
? ", url({$item['url']})" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5741 |
: ", url('{$item['url']}') format('{$item['format']}')"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5742 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5743 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5744 |
$src = ltrim( $src, ', ' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5745 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5746 |
return $src; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5747 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5748 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5749 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5750 |
* Compiles the font variation settings. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5751 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5752 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5753 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5754 |
* @param array $font_variation_settings Array of font variation settings. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5755 |
* @return string The CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5756 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5757 |
$fn_compile_variations = static function( array $font_variation_settings ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5758 |
$variations = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5759 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5760 |
foreach ( $font_variation_settings as $key => $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5761 |
$variations .= "$key $value"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5762 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5763 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5764 |
return $variations; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5765 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5766 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5767 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5768 |
* Builds the font-family's CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5769 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5770 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5771 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5772 |
* @uses $fn_compile_src To run the function that compiles the src. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5773 |
* @uses $fn_compile_variations To run the function that compiles the variations. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5774 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5775 |
* @param array $webfont Webfont to process. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5776 |
* @return string This font-family's CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5777 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5778 |
$fn_build_font_face_css = static function( array $webfont ) use ( $fn_compile_src, $fn_compile_variations ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5779 |
$css = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5780 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5781 |
// Wrap font-family in quotes if it contains spaces. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5782 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5783 |
str_contains( $webfont['font-family'], ' ' ) && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5784 |
! str_contains( $webfont['font-family'], '"' ) && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5785 |
! str_contains( $webfont['font-family'], "'" ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5786 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5787 |
$webfont['font-family'] = '"' . $webfont['font-family'] . '"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5788 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5789 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5790 |
foreach ( $webfont as $key => $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5791 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5792 |
* Skip "provider", since it's for internal API use, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5793 |
* and not a valid CSS property. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5794 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5795 |
if ( 'provider' === $key ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5796 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5797 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5798 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5799 |
// Compile the "src" parameter. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5800 |
if ( 'src' === $key ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5801 |
$value = $fn_compile_src( $webfont['font-family'], $value ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5802 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5803 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5804 |
// If font-variation-settings is an array, convert it to a string. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5805 |
if ( 'font-variation-settings' === $key && is_array( $value ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5806 |
$value = $fn_compile_variations( $value ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5807 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5808 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5809 |
if ( ! empty( $value ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5810 |
$css .= "$key:$value;"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5811 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5812 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5813 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5814 |
return $css; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5815 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5816 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5817 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5818 |
* Gets the '@font-face' CSS styles for locally-hosted font files. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5819 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5820 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5821 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5822 |
* @uses $registered_webfonts To access and update the registered webfonts registry (passed by reference). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5823 |
* @uses $fn_order_src To run the function that orders the src. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5824 |
* @uses $fn_build_font_face_css To run the function that builds the font-face CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5825 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5826 |
* @return string The `@font-face` CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5827 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5828 |
$fn_get_css = static function() use ( &$registered_webfonts, $fn_order_src, $fn_build_font_face_css ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5829 |
$css = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5830 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5831 |
foreach ( $registered_webfonts as $webfont ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5832 |
// Order the webfont's `src` items to optimize for browser support. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5833 |
$webfont = $fn_order_src( $webfont ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5834 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5835 |
// Build the @font-face CSS for this webfont. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5836 |
$css .= '@font-face{' . $fn_build_font_face_css( $webfont ) . '}'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5837 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5838 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5839 |
return $css; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5840 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5841 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5842 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5843 |
* Generates and enqueues webfonts styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5844 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5845 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5846 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5847 |
* @uses $fn_get_css To run the function that gets the CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5848 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5849 |
$fn_generate_and_enqueue_styles = static function() use ( $fn_get_css ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5850 |
// Generate the styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5851 |
$styles = $fn_get_css(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5852 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5853 |
// Bail out if there are no styles to enqueue. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5854 |
if ( '' === $styles ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5855 |
return; |
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 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5858 |
// Enqueue the stylesheet. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5859 |
wp_register_style( 'wp-webfonts', '' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5860 |
wp_enqueue_style( 'wp-webfonts' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5861 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5862 |
// Add the styles to the stylesheet. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5863 |
wp_add_inline_style( 'wp-webfonts', $styles ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5864 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5865 |
|
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 |
* Generates and enqueues editor styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5868 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5869 |
* @since 6.0.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5870 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5871 |
* @uses $fn_get_css To run the function that gets the CSS. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5872 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5873 |
$fn_generate_and_enqueue_editor_styles = static function() use ( $fn_get_css ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5874 |
// Generate the styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5875 |
$styles = $fn_get_css(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5876 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5877 |
// Bail out if there are no styles to enqueue. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5878 |
if ( '' === $styles ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5879 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5880 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5881 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5882 |
wp_add_inline_style( 'wp-block-library', $styles ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5883 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5884 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5885 |
add_action( 'wp_loaded', $fn_register_webfonts ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5886 |
add_action( 'wp_enqueue_scripts', $fn_generate_and_enqueue_styles ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5887 |
add_action( 'admin_init', $fn_generate_and_enqueue_editor_styles ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5888 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5889 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5890 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5891 |
* Prints the CSS in the embed iframe header. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5892 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5893 |
* @since 4.4.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5894 |
* @deprecated 6.4.0 Use wp_enqueue_embed_styles() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5895 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5896 |
function print_embed_styles() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5897 |
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_embed_styles' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5898 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5899 |
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5900 |
$suffix = SCRIPT_DEBUG ? '' : '.min'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5901 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5902 |
<style<?php echo $type_attr; ?>> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5903 |
<?php echo file_get_contents( ABSPATH . WPINC . "/css/wp-embed-template$suffix.css" ); ?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5904 |
</style> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5905 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5906 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5907 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5908 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5909 |
* Prints the important emoji-related styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5910 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5911 |
* @since 4.2.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5912 |
* @deprecated 6.4.0 Use wp_enqueue_emoji_styles() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5913 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5914 |
function print_emoji_styles() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5915 |
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_emoji_styles' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5916 |
static $printed = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5917 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5918 |
if ( $printed ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5919 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5920 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5921 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5922 |
$printed = true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5923 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5924 |
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5925 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5926 |
<style<?php echo $type_attr; ?>> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5927 |
img.wp-smiley, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5928 |
img.emoji { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5929 |
display: inline !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5930 |
border: none !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5931 |
box-shadow: none !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5932 |
height: 1em !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5933 |
width: 1em !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5934 |
margin: 0 0.07em !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5935 |
vertical-align: -0.1em !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5936 |
background: none !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5937 |
padding: 0 !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5938 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5939 |
</style> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5940 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5941 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5942 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5943 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5944 |
* Prints style and scripts for the admin bar. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5945 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5946 |
* @since 3.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5947 |
* @deprecated 6.4.0 Use wp_enqueue_admin_bar_header_styles() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5948 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5949 |
function wp_admin_bar_header() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5950 |
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_admin_bar_header_styles' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5951 |
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5952 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5953 |
<style<?php echo $type_attr; ?> media="print">#wpadminbar { display:none; }</style> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5954 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5955 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5956 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5957 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5958 |
* Prints default admin bar callback. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5959 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5960 |
* @since 3.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5961 |
* @deprecated 6.4.0 Use wp_enqueue_admin_bar_bump_styles() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5962 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5963 |
function _admin_bar_bump_cb() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5964 |
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_admin_bar_bump_styles' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5965 |
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5966 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5967 |
<style<?php echo $type_attr; ?> media="screen"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5968 |
html { margin-top: 32px !important; } |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5969 |
@media screen and ( max-width: 782px ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5970 |
html { margin-top: 46px !important; } |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5971 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5972 |
</style> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5973 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5974 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5975 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5976 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5977 |
* Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5978 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5979 |
* This internal function is called by a regular Cron hook to ensure HTTPS support is detected and maintained. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5980 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5981 |
* @since 5.7.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5982 |
* @deprecated 6.4.0 The `wp_update_https_detection_errors()` function is no longer used and has been replaced by |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5983 |
* `wp_get_https_detection_errors()`. Previously the function was called by a regular Cron hook to |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5984 |
* update the `https_detection_errors` option, but this is no longer necessary as the errors are |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5985 |
* retrieved directly in Site Health and no longer used outside of Site Health. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5986 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5987 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5988 |
function wp_update_https_detection_errors() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5989 |
_deprecated_function( __FUNCTION__, '6.4.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5990 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5991 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5992 |
* Short-circuits the process of detecting errors related to HTTPS support. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5993 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5994 |
* Returning a `WP_Error` from the filter will effectively short-circuit the default logic of trying a remote |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5995 |
* request to the site over HTTPS, storing the errors array from the returned `WP_Error` instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5996 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5997 |
* @since 5.7.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5998 |
* @deprecated 6.4.0 The `wp_update_https_detection_errors` filter is no longer used and has been replaced by `pre_wp_get_https_detection_errors`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5999 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6000 |
* @param null|WP_Error $pre Error object to short-circuit detection, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6001 |
* or null to continue with the default behavior. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6002 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6003 |
$support_errors = apply_filters( 'pre_wp_update_https_detection_errors', null ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6004 |
if ( is_wp_error( $support_errors ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6005 |
update_option( 'https_detection_errors', $support_errors->errors ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6006 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6007 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6008 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6009 |
$support_errors = wp_get_https_detection_errors(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6010 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6011 |
update_option( 'https_detection_errors', $support_errors ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6012 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6013 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6014 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6015 |
* Adds `decoding` attribute to an `img` HTML tag. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6016 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6017 |
* The `decoding` attribute allows developers to indicate whether the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6018 |
* browser can decode the image off the main thread (`async`), on the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6019 |
* main thread (`sync`) or as determined by the browser (`auto`). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6020 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6021 |
* By default WordPress adds `decoding="async"` to images but developers |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6022 |
* can use the {@see 'wp_img_tag_add_decoding_attr'} filter to modify this |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6023 |
* to remove the attribute or set it to another accepted value. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6024 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6025 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6026 |
* @deprecated 6.4.0 Use wp_img_tag_add_loading_optimization_attrs() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6027 |
* @see wp_img_tag_add_loading_optimization_attrs() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6028 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6029 |
* @param string $image The HTML `img` tag where the attribute should be added. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6030 |
* @param string $context Additional context to pass to the filters. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6031 |
* @return string Converted `img` tag with `decoding` attribute added. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6032 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6033 |
function wp_img_tag_add_decoding_attr( $image, $context ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6034 |
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_img_tag_add_loading_optimization_attrs()' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6035 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6036 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6037 |
* Only apply the decoding attribute to images that have a src attribute that |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6038 |
* starts with a double quote, ensuring escaped JSON is also excluded. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6039 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6040 |
if ( ! str_contains( $image, ' src="' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6041 |
return $image; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6042 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6043 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6044 |
/** This action is documented in wp-includes/media.php */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6045 |
$value = apply_filters( 'wp_img_tag_add_decoding_attr', 'async', $image, $context ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6046 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6047 |
if ( in_array( $value, array( 'async', 'sync', 'auto' ), true ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6048 |
$image = str_replace( '<img ', '<img decoding="' . esc_attr( $value ) . '" ', $image ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6049 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6050 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6051 |
return $image; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6052 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6053 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6054 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6055 |
* Parses wp_template content and injects the active theme's |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6056 |
* stylesheet as a theme attribute into each wp_template_part |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6057 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6058 |
* @since 5.9.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6059 |
* @deprecated 6.4.0 Use traverse_and_serialize_blocks( parse_blocks( $template_content ), '_inject_theme_attribute_in_template_part_block' ) instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6060 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6061 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6062 |
* @param string $template_content serialized wp_template content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6063 |
* @return string Updated 'wp_template' content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6064 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6065 |
function _inject_theme_attribute_in_block_template_content( $template_content ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6066 |
_deprecated_function( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6067 |
__FUNCTION__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6068 |
'6.4.0', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6069 |
'traverse_and_serialize_blocks( parse_blocks( $template_content ), "_inject_theme_attribute_in_template_part_block" )' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6070 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6071 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6072 |
$has_updated_content = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6073 |
$new_content = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6074 |
$template_blocks = parse_blocks( $template_content ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6075 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6076 |
$blocks = _flatten_blocks( $template_blocks ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6077 |
foreach ( $blocks as &$block ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6078 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6079 |
'core/template-part' === $block['blockName'] && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6080 |
! isset( $block['attrs']['theme'] ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6081 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6082 |
$block['attrs']['theme'] = get_stylesheet(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6083 |
$has_updated_content = true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6084 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6085 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6086 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6087 |
if ( $has_updated_content ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6088 |
foreach ( $template_blocks as &$block ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6089 |
$new_content .= serialize_block( $block ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6090 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6091 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6092 |
return $new_content; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6093 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6094 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6095 |
return $template_content; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6096 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6097 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6098 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6099 |
* Parses a block template and removes the theme attribute from each template part. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6100 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6101 |
* @since 5.9.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6102 |
* @deprecated 6.4.0 Use traverse_and_serialize_blocks( parse_blocks( $template_content ), '_remove_theme_attribute_from_template_part_block' ) instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6103 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6104 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6105 |
* @param string $template_content Serialized block template content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6106 |
* @return string Updated block template content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6107 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6108 |
function _remove_theme_attribute_in_block_template_content( $template_content ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6109 |
_deprecated_function( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6110 |
__FUNCTION__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6111 |
'6.4.0', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6112 |
'traverse_and_serialize_blocks( parse_blocks( $template_content ), "_remove_theme_attribute_from_template_part_block" )' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6113 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6114 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6115 |
$has_updated_content = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6116 |
$new_content = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6117 |
$template_blocks = parse_blocks( $template_content ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6118 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6119 |
$blocks = _flatten_blocks( $template_blocks ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6120 |
foreach ( $blocks as $key => $block ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6121 |
if ( 'core/template-part' === $block['blockName'] && isset( $block['attrs']['theme'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6122 |
unset( $blocks[ $key ]['attrs']['theme'] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6123 |
$has_updated_content = true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6124 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6125 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6126 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6127 |
if ( ! $has_updated_content ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6128 |
return $template_content; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6129 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6130 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6131 |
foreach ( $template_blocks as $block ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6132 |
$new_content .= serialize_block( $block ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6133 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6134 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6135 |
return $new_content; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6136 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6137 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6138 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6139 |
* Prints the skip-link script & styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6140 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6141 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6142 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6143 |
* @deprecated 6.4.0 Use wp_enqueue_block_template_skip_link() instead. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6144 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6145 |
* @global string $_wp_current_template_content |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6146 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6147 |
function the_block_template_skip_link() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6148 |
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_block_template_skip_link()' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6149 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6150 |
global $_wp_current_template_content; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6151 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6152 |
// Early exit if not a block theme. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6153 |
if ( ! current_theme_supports( 'block-templates' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6154 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6155 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6156 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6157 |
// Early exit if not a block template. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6158 |
if ( ! $_wp_current_template_content ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6159 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6160 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6161 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6162 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6163 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6164 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6165 |
* Print the skip-link styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6166 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6167 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6168 |
<style id="skip-link-styles"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6169 |
.skip-link.screen-reader-text { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6170 |
border: 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6171 |
clip: rect(1px,1px,1px,1px); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6172 |
clip-path: inset(50%); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6173 |
height: 1px; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6174 |
margin: -1px; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6175 |
overflow: hidden; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6176 |
padding: 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6177 |
position: absolute !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6178 |
width: 1px; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6179 |
word-wrap: normal !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6180 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6181 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6182 |
.skip-link.screen-reader-text:focus { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6183 |
background-color: #eee; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6184 |
clip: auto !important; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6185 |
clip-path: none; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6186 |
color: #444; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6187 |
display: block; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6188 |
font-size: 1em; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6189 |
height: auto; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6190 |
left: 5px; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6191 |
line-height: normal; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6192 |
padding: 15px 23px 14px; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6193 |
text-decoration: none; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6194 |
top: 5px; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6195 |
width: auto; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6196 |
z-index: 100000; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6197 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6198 |
</style> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6199 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6200 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6201 |
* Print the skip-link script. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6202 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6203 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6204 |
<script> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6205 |
( function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6206 |
var skipLinkTarget = document.querySelector( 'main' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6207 |
sibling, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6208 |
skipLinkTargetID, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6209 |
skipLink; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6210 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6211 |
// Early exit if a skip-link target can't be located. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6212 |
if ( ! skipLinkTarget ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6213 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6214 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6215 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6216 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6217 |
* Get the site wrapper. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6218 |
* The skip-link will be injected in the beginning of it. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6219 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6220 |
sibling = document.querySelector( '.wp-site-blocks' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6221 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6222 |
// Early exit if the root element was not found. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6223 |
if ( ! sibling ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6224 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6225 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6226 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6227 |
// Get the skip-link target's ID, and generate one if it doesn't exist. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6228 |
skipLinkTargetID = skipLinkTarget.id; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6229 |
if ( ! skipLinkTargetID ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6230 |
skipLinkTargetID = 'wp--skip-link--target'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6231 |
skipLinkTarget.id = skipLinkTargetID; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6232 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6233 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6234 |
// Create the skip link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6235 |
skipLink = document.createElement( 'a' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6236 |
skipLink.classList.add( 'skip-link', 'screen-reader-text' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6237 |
skipLink.href = '#' + skipLinkTargetID; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6238 |
skipLink.innerHTML = '<?php /* translators: Hidden accessibility text. */ esc_html_e( 'Skip to content' ); ?>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6239 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6240 |
// Inject the skip link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6241 |
sibling.parentElement.insertBefore( skipLink, sibling ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6242 |
}() ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6243 |
</script> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6244 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6245 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6246 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6247 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6248 |
* Ensure that the view script has the `wp-interactivity` dependency. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6249 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6250 |
* @since 6.4.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6251 |
* @deprecated 6.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6252 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6253 |
function block_core_query_ensure_interactivity_dependency() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6254 |
_deprecated_function( __FUNCTION__, '6.5.0', 'wp_register_script_module' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6255 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6256 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6257 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6258 |
* Ensure that the view script has the `wp-interactivity` dependency. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6259 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6260 |
* @since 6.4.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6261 |
* @deprecated 6.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6262 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6263 |
function block_core_file_ensure_interactivity_dependency() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6264 |
_deprecated_function( __FUNCTION__, '6.5.0', 'wp_register_script_module' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6265 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6266 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6267 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6268 |
* Ensures that the view script has the `wp-interactivity` dependency. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6269 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6270 |
* @since 6.4.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6271 |
* @deprecated 6.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6272 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6273 |
function block_core_image_ensure_interactivity_dependency() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6274 |
_deprecated_function( __FUNCTION__, '6.5.0', 'wp_register_script_module' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6275 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6276 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6277 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6278 |
* Updates the block content with elements class names. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6279 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6280 |
* @deprecated 6.6.0 Generation of element class name is handled via `render_block_data` filter. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6281 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6282 |
* @since 5.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6283 |
* @since 6.4.0 Added support for button and heading element styling. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6284 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6285 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6286 |
* @param string $block_content Rendered block content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6287 |
* @param array $block Block object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6288 |
* @return string Filtered block content. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6289 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6290 |
function wp_render_elements_support( $block_content, $block ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6291 |
_deprecated_function( __FUNCTION__, '6.6.0', 'wp_render_elements_class_name' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6292 |
return $block_content; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6293 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6294 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6295 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6296 |
* Processes the directives on the rendered HTML of the interactive blocks. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6297 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6298 |
* This processes only one root interactive block at a time because the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6299 |
* rendered HTML of that block contains the rendered HTML of all its inner |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6300 |
* blocks, including any interactive block. It does so by ignoring all the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6301 |
* interactive inner blocks until the root interactive block is processed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6302 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6303 |
* @since 6.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6304 |
* @deprecated 6.6.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6305 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6306 |
* @param array $parsed_block The parsed block. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6307 |
* @return array The same parsed block. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6308 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6309 |
function wp_interactivity_process_directives_of_interactive_blocks( array $parsed_block ): array { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6310 |
_deprecated_function( __FUNCTION__, '6.6.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6311 |
return $parsed_block; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6312 |
} |