author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* General template tags that can go anywhere in a template. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Template |
|
7 |
*/ |
|
8 |
||
9 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
10 |
* Loads header template. |
0 | 11 |
* |
12 |
* Includes the header template for a theme or if a name is specified then a |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
13 |
* specialized header will be included. |
0 | 14 |
* |
15 |
* For the parameter, if the file is called "header-special.php" then specify |
|
16 |
* "special". |
|
17 |
* |
|
18 |
* @since 1.5.0 |
|
16 | 19 |
* @since 5.5.0 A return value was added. |
20 |
* @since 5.5.0 The `$args` parameter was added. |
|
0 | 21 |
* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
22 |
* @param string|null $name The name of the specialized header. Default null. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
23 |
* @param array $args Optional. Additional arguments passed to the header template. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
24 |
* Default empty array. |
16 | 25 |
* @return void|false Void on success, false if the template does not exist. |
0 | 26 |
*/ |
16 | 27 |
function get_header( $name = null, $args = array() ) { |
5 | 28 |
/** |
29 |
* Fires before the header template file is loaded. |
|
30 |
* |
|
31 |
* @since 2.1.0 |
|
16 | 32 |
* @since 2.8.0 The `$name` parameter was added. |
33 |
* @since 5.5.0 The `$args` parameter was added. |
|
5 | 34 |
* |
16 | 35 |
* @param string|null $name Name of the specific header file to use. Null for the default header. |
36 |
* @param array $args Additional arguments passed to the header template. |
|
5 | 37 |
*/ |
16 | 38 |
do_action( 'get_header', $name, $args ); |
0 | 39 |
|
40 |
$templates = array(); |
|
9 | 41 |
$name = (string) $name; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
if ( '' !== $name ) { |
0 | 43 |
$templates[] = "header-{$name}.php"; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
} |
0 | 45 |
|
46 |
$templates[] = 'header.php'; |
|
47 |
||
16 | 48 |
if ( ! locate_template( $templates, true, true, $args ) ) { |
49 |
return false; |
|
50 |
} |
|
0 | 51 |
} |
52 |
||
53 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
54 |
* Loads footer template. |
0 | 55 |
* |
56 |
* Includes the footer template for a theme or if a name is specified then a |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
57 |
* specialized footer will be included. |
0 | 58 |
* |
59 |
* For the parameter, if the file is called "footer-special.php" then specify |
|
60 |
* "special". |
|
61 |
* |
|
62 |
* @since 1.5.0 |
|
16 | 63 |
* @since 5.5.0 A return value was added. |
64 |
* @since 5.5.0 The `$args` parameter was added. |
|
0 | 65 |
* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
66 |
* @param string|null $name The name of the specialized footer. Default null. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
67 |
* @param array $args Optional. Additional arguments passed to the footer template. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
68 |
* Default empty array. |
16 | 69 |
* @return void|false Void on success, false if the template does not exist. |
0 | 70 |
*/ |
16 | 71 |
function get_footer( $name = null, $args = array() ) { |
5 | 72 |
/** |
73 |
* Fires before the footer template file is loaded. |
|
74 |
* |
|
75 |
* @since 2.1.0 |
|
16 | 76 |
* @since 2.8.0 The `$name` parameter was added. |
77 |
* @since 5.5.0 The `$args` parameter was added. |
|
5 | 78 |
* |
16 | 79 |
* @param string|null $name Name of the specific footer file to use. Null for the default footer. |
80 |
* @param array $args Additional arguments passed to the footer template. |
|
5 | 81 |
*/ |
16 | 82 |
do_action( 'get_footer', $name, $args ); |
0 | 83 |
|
84 |
$templates = array(); |
|
9 | 85 |
$name = (string) $name; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
if ( '' !== $name ) { |
0 | 87 |
$templates[] = "footer-{$name}.php"; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
|
9 | 90 |
$templates[] = 'footer.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
|
16 | 92 |
if ( ! locate_template( $templates, true, true, $args ) ) { |
93 |
return false; |
|
94 |
} |
|
0 | 95 |
} |
96 |
||
97 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
98 |
* Loads sidebar template. |
0 | 99 |
* |
100 |
* Includes the sidebar template for a theme or if a name is specified then a |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
101 |
* specialized sidebar will be included. |
0 | 102 |
* |
103 |
* For the parameter, if the file is called "sidebar-special.php" then specify |
|
104 |
* "special". |
|
105 |
* |
|
106 |
* @since 1.5.0 |
|
16 | 107 |
* @since 5.5.0 A return value was added. |
108 |
* @since 5.5.0 The `$args` parameter was added. |
|
0 | 109 |
* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
110 |
* @param string|null $name The name of the specialized sidebar. Default null. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
111 |
* @param array $args Optional. Additional arguments passed to the sidebar template. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
112 |
* Default empty array. |
16 | 113 |
* @return void|false Void on success, false if the template does not exist. |
0 | 114 |
*/ |
16 | 115 |
function get_sidebar( $name = null, $args = array() ) { |
5 | 116 |
/** |
117 |
* Fires before the sidebar template file is loaded. |
|
118 |
* |
|
119 |
* @since 2.2.0 |
|
16 | 120 |
* @since 2.8.0 The `$name` parameter was added. |
121 |
* @since 5.5.0 The `$args` parameter was added. |
|
5 | 122 |
* |
16 | 123 |
* @param string|null $name Name of the specific sidebar file to use. Null for the default sidebar. |
124 |
* @param array $args Additional arguments passed to the sidebar template. |
|
5 | 125 |
*/ |
16 | 126 |
do_action( 'get_sidebar', $name, $args ); |
0 | 127 |
|
128 |
$templates = array(); |
|
9 | 129 |
$name = (string) $name; |
130 |
if ( '' !== $name ) { |
|
0 | 131 |
$templates[] = "sidebar-{$name}.php"; |
9 | 132 |
} |
0 | 133 |
|
134 |
$templates[] = 'sidebar.php'; |
|
135 |
||
16 | 136 |
if ( ! locate_template( $templates, true, true, $args ) ) { |
137 |
return false; |
|
138 |
} |
|
0 | 139 |
} |
140 |
||
141 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
* Loads a template part into a template. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
* Provides a simple mechanism for child themes to overload reusable sections of code |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
* in the theme. |
0 | 146 |
* |
147 |
* Includes the named template part for a theme or if a name is specified then a |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
148 |
* specialized part will be included. If the theme contains no {slug}.php file |
0 | 149 |
* then no template will be included. |
150 |
* |
|
151 |
* The template is included using require, not require_once, so you may include the |
|
152 |
* same template part multiple times. |
|
153 |
* |
|
154 |
* For the $name parameter, if the file is called "{slug}-special.php" then specify |
|
155 |
* "special". |
|
156 |
* |
|
157 |
* @since 3.0.0 |
|
16 | 158 |
* @since 5.5.0 A return value was added. |
159 |
* @since 5.5.0 The `$args` parameter was added. |
|
0 | 160 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
161 |
* @param string $slug The slug name for the generic template. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
162 |
* @param string|null $name Optional. The name of the specialized template. Default null. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
163 |
* @param array $args Optional. Additional arguments passed to the template. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
164 |
* Default empty array. |
16 | 165 |
* @return void|false Void on success, false if the template does not exist. |
0 | 166 |
*/ |
16 | 167 |
function get_template_part( $slug, $name = null, $args = array() ) { |
5 | 168 |
/** |
169 |
* Fires before the specified template part file is loaded. |
|
170 |
* |
|
171 |
* The dynamic portion of the hook name, `$slug`, refers to the slug name |
|
172 |
* for the generic template part. |
|
173 |
* |
|
174 |
* @since 3.0.0 |
|
16 | 175 |
* @since 5.5.0 The `$args` parameter was added. |
5 | 176 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
* @param string $slug The slug name for the generic template. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
178 |
* @param string|null $name The name of the specialized template |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
179 |
* or null if there is none. |
16 | 180 |
* @param array $args Additional arguments passed to the template. |
5 | 181 |
*/ |
16 | 182 |
do_action( "get_template_part_{$slug}", $slug, $name, $args ); |
0 | 183 |
|
184 |
$templates = array(); |
|
9 | 185 |
$name = (string) $name; |
186 |
if ( '' !== $name ) { |
|
0 | 187 |
$templates[] = "{$slug}-{$name}.php"; |
9 | 188 |
} |
0 | 189 |
|
190 |
$templates[] = "{$slug}.php"; |
|
191 |
||
9 | 192 |
/** |
19 | 193 |
* Fires before an attempt is made to locate and load a template part. |
9 | 194 |
* |
195 |
* @since 5.2.0 |
|
16 | 196 |
* @since 5.5.0 The `$args` parameter was added. |
9 | 197 |
* |
198 |
* @param string $slug The slug name for the generic template. |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
199 |
* @param string $name The name of the specialized template |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
200 |
* or an empty string if there is none. |
9 | 201 |
* @param string[] $templates Array of template files to search for, in order. |
16 | 202 |
* @param array $args Additional arguments passed to the template. |
9 | 203 |
*/ |
16 | 204 |
do_action( 'get_template_part', $slug, $name, $templates, $args ); |
205 |
||
206 |
if ( ! locate_template( $templates, true, false, $args ) ) { |
|
207 |
return false; |
|
208 |
} |
|
0 | 209 |
} |
210 |
||
211 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
212 |
* Displays search form. |
0 | 213 |
* |
214 |
* Will first attempt to locate the searchform.php file in either the child or |
|
215 |
* the parent, then load it. If it doesn't exist, then the default search form |
|
216 |
* will be displayed. The default search form is HTML, which will be displayed. |
|
217 |
* There is a filter applied to the search form HTML in order to edit or replace |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
* it. The filter is {@see 'get_search_form'}. |
0 | 219 |
* |
220 |
* This function is primarily used by themes which want to hardcode the search |
|
221 |
* form into the sidebar and also by the search widget in WordPress. |
|
222 |
* |
|
223 |
* There is also an action that is called whenever the function is run called, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
* {@see 'pre_get_search_form'}. This can be useful for outputting JavaScript that the |
0 | 225 |
* search relies on or various formatting that applies to the beginning of the |
226 |
* search. To give a few examples of what it can be used for. |
|
227 |
* |
|
228 |
* @since 2.7.0 |
|
16 | 229 |
* @since 5.2.0 The `$args` array parameter was added in place of an `$echo` boolean flag. |
9 | 230 |
* |
231 |
* @param array $args { |
|
232 |
* Optional. Array of display arguments. |
|
233 |
* |
|
234 |
* @type bool $echo Whether to echo or return the form. Default true. |
|
235 |
* @type string $aria_label ARIA label for the search form. Useful to distinguish |
|
236 |
* multiple search forms on the same page and improve |
|
237 |
* accessibility. Default empty. |
|
238 |
* } |
|
16 | 239 |
* @return void|string Void if 'echo' argument is true, search form HTML if 'echo' is false. |
0 | 240 |
*/ |
9 | 241 |
function get_search_form( $args = array() ) { |
5 | 242 |
/** |
243 |
* Fires before the search form is retrieved, at the start of get_search_form(). |
|
244 |
* |
|
245 |
* @since 2.7.0 as 'get_search_form' action. |
|
246 |
* @since 3.6.0 |
|
16 | 247 |
* @since 5.5.0 The `$args` parameter was added. |
5 | 248 |
* |
249 |
* @link https://core.trac.wordpress.org/ticket/19321 |
|
16 | 250 |
* |
251 |
* @param array $args The array of arguments for building the search form. |
|
18 | 252 |
* See get_search_form() for information on accepted arguments. |
5 | 253 |
*/ |
16 | 254 |
do_action( 'pre_get_search_form', $args ); |
0 | 255 |
|
9 | 256 |
$echo = true; |
257 |
||
258 |
if ( ! is_array( $args ) ) { |
|
259 |
/* |
|
260 |
* Back compat: to ensure previous uses of get_search_form() continue to |
|
261 |
* function as expected, we handle a value for the boolean $echo param removed |
|
262 |
* in 5.2.0. Then we deal with the $args array and cast its defaults. |
|
263 |
*/ |
|
264 |
$echo = (bool) $args; |
|
265 |
||
266 |
// Set an empty array and allow default arguments to take over. |
|
267 |
$args = array(); |
|
268 |
} |
|
269 |
||
270 |
// Defaults are to echo and to output no custom label on the form. |
|
271 |
$defaults = array( |
|
272 |
'echo' => $echo, |
|
273 |
'aria_label' => '', |
|
274 |
); |
|
275 |
||
276 |
$args = wp_parse_args( $args, $defaults ); |
|
277 |
||
278 |
/** |
|
279 |
* Filters the array of arguments used when generating the search form. |
|
280 |
* |
|
281 |
* @since 5.2.0 |
|
282 |
* |
|
283 |
* @param array $args The array of arguments for building the search form. |
|
18 | 284 |
* See get_search_form() for information on accepted arguments. |
9 | 285 |
*/ |
286 |
$args = apply_filters( 'search_form_args', $args ); |
|
287 |
||
18 | 288 |
// Ensure that the filtered arguments contain all required default values. |
289 |
$args = array_merge( $defaults, $args ); |
|
290 |
||
0 | 291 |
$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml'; |
5 | 292 |
|
293 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
* Filters the HTML format of the search form. |
5 | 295 |
* |
296 |
* @since 3.6.0 |
|
16 | 297 |
* @since 5.5.0 The `$args` parameter was added. |
5 | 298 |
* |
299 |
* @param string $format The type of markup to use in the search form. |
|
300 |
* Accepts 'html5', 'xhtml'. |
|
16 | 301 |
* @param array $args The array of arguments for building the search form. |
18 | 302 |
* See get_search_form() for information on accepted arguments. |
5 | 303 |
*/ |
16 | 304 |
$format = apply_filters( 'search_form_format', $format, $args ); |
0 | 305 |
|
306 |
$search_form_template = locate_template( 'searchform.php' ); |
|
16 | 307 |
|
308 |
if ( '' !== $search_form_template ) { |
|
0 | 309 |
ob_start(); |
16 | 310 |
require $search_form_template; |
0 | 311 |
$form = ob_get_clean(); |
312 |
} else { |
|
9 | 313 |
// Build a string containing an aria-label to use for the search form. |
18 | 314 |
if ( $args['aria_label'] ) { |
9 | 315 |
$aria_label = 'aria-label="' . esc_attr( $args['aria_label'] ) . '" '; |
316 |
} else { |
|
317 |
/* |
|
318 |
* If there's no custom aria-label, we can set a default here. At the |
|
319 |
* moment it's empty as there's uncertainty about what the default should be. |
|
320 |
*/ |
|
321 |
$aria_label = ''; |
|
322 |
} |
|
16 | 323 |
|
324 |
if ( 'html5' === $format ) { |
|
9 | 325 |
$form = '<form role="search" ' . $aria_label . 'method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '"> |
0 | 326 |
<label> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
327 |
<span class="screen-reader-text">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
328 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
329 |
_x( 'Search for:', 'label' ) . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
330 |
'</span> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" /> |
0 | 332 |
</label> |
9 | 333 |
<input type="submit" class="search-submit" value="' . esc_attr_x( 'Search', 'submit button' ) . '" /> |
0 | 334 |
</form>'; |
335 |
} else { |
|
9 | 336 |
$form = '<form role="search" ' . $aria_label . 'method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '"> |
0 | 337 |
<div> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
338 |
<label class="screen-reader-text" for="s">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
339 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
340 |
_x( 'Search for:', 'label' ) . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
341 |
'</label> |
0 | 342 |
<input type="text" value="' . get_search_query() . '" name="s" id="s" /> |
9 | 343 |
<input type="submit" id="searchsubmit" value="' . esc_attr_x( 'Search', 'submit button' ) . '" /> |
0 | 344 |
</div> |
345 |
</form>'; |
|
346 |
} |
|
347 |
} |
|
348 |
||
5 | 349 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
* Filters the HTML output of the search form. |
5 | 351 |
* |
352 |
* @since 2.7.0 |
|
16 | 353 |
* @since 5.5.0 The `$args` parameter was added. |
5 | 354 |
* |
355 |
* @param string $form The search form HTML output. |
|
16 | 356 |
* @param array $args The array of arguments for building the search form. |
18 | 357 |
* See get_search_form() for information on accepted arguments. |
5 | 358 |
*/ |
16 | 359 |
$result = apply_filters( 'get_search_form', $form, $args ); |
5 | 360 |
|
9 | 361 |
if ( null === $result ) { |
0 | 362 |
$result = $form; |
9 | 363 |
} |
364 |
||
16 | 365 |
if ( $args['echo'] ) { |
0 | 366 |
echo $result; |
9 | 367 |
} else { |
0 | 368 |
return $result; |
9 | 369 |
} |
0 | 370 |
} |
371 |
||
372 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
373 |
* Displays the Log In/Out link. |
0 | 374 |
* |
375 |
* Displays a link, which allows users to navigate to the Log In page to log in |
|
376 |
* or log out depending on whether they are currently logged in. |
|
377 |
* |
|
378 |
* @since 1.5.0 |
|
379 |
* |
|
380 |
* @param string $redirect Optional path to redirect to on login/logout. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
381 |
* @param bool $display Default to echo and not return the link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
382 |
* @return void|string Void if `$display` argument is true, log in/out link if `$display` is false. |
0 | 383 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
384 |
function wp_loginout( $redirect = '', $display = true ) { |
9 | 385 |
if ( ! is_user_logged_in() ) { |
386 |
$link = '<a href="' . esc_url( wp_login_url( $redirect ) ) . '">' . __( 'Log in' ) . '</a>'; |
|
387 |
} else { |
|
388 |
$link = '<a href="' . esc_url( wp_logout_url( $redirect ) ) . '">' . __( 'Log out' ) . '</a>'; |
|
389 |
} |
|
0 | 390 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
391 |
if ( $display ) { |
5 | 392 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
* Filters the HTML output for the Log In/Log Out link. |
5 | 394 |
* |
395 |
* @since 1.5.0 |
|
396 |
* |
|
397 |
* @param string $link The HTML link content. |
|
398 |
*/ |
|
399 |
echo apply_filters( 'loginout', $link ); |
|
400 |
} else { |
|
401 |
/** This filter is documented in wp-includes/general-template.php */ |
|
402 |
return apply_filters( 'loginout', $link ); |
|
403 |
} |
|
0 | 404 |
} |
405 |
||
406 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
* Retrieves the logout URL. |
0 | 408 |
* |
409 |
* Returns the URL that allows the user to log out of the site. |
|
410 |
* |
|
411 |
* @since 2.7.0 |
|
412 |
* |
|
413 |
* @param string $redirect Path to redirect to on logout. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
* @return string The logout URL. Note: HTML-encoded via esc_html() in wp_nonce_url(). |
0 | 415 |
*/ |
9 | 416 |
function wp_logout_url( $redirect = '' ) { |
16 | 417 |
$args = array(); |
9 | 418 |
if ( ! empty( $redirect ) ) { |
0 | 419 |
$args['redirect_to'] = urlencode( $redirect ); |
420 |
} |
|
421 |
||
16 | 422 |
$logout_url = add_query_arg( $args, site_url( 'wp-login.php?action=logout', 'login' ) ); |
0 | 423 |
$logout_url = wp_nonce_url( $logout_url, 'log-out' ); |
424 |
||
5 | 425 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
* Filters the logout URL. |
5 | 427 |
* |
428 |
* @since 2.8.0 |
|
429 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
* @param string $logout_url The HTML-encoded logout URL. |
5 | 431 |
* @param string $redirect Path to redirect to on logout. |
432 |
*/ |
|
433 |
return apply_filters( 'logout_url', $logout_url, $redirect ); |
|
0 | 434 |
} |
435 |
||
436 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
437 |
* Retrieves the login URL. |
0 | 438 |
* |
439 |
* @since 2.7.0 |
|
440 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
* @param string $redirect Path to redirect to on log in. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
* @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
443 |
* Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
* @return string The login URL. Not HTML-encoded. |
0 | 445 |
*/ |
9 | 446 |
function wp_login_url( $redirect = '', $force_reauth = false ) { |
447 |
$login_url = site_url( 'wp-login.php', 'login' ); |
|
448 |
||
449 |
if ( ! empty( $redirect ) ) { |
|
450 |
$login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url ); |
|
451 |
} |
|
452 |
||
453 |
if ( $force_reauth ) { |
|
454 |
$login_url = add_query_arg( 'reauth', '1', $login_url ); |
|
455 |
} |
|
0 | 456 |
|
5 | 457 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
* Filters the login URL. |
5 | 459 |
* |
460 |
* @since 2.8.0 |
|
461 |
* @since 4.2.0 The `$force_reauth` parameter was added. |
|
462 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
* @param string $login_url The login URL. Not HTML-encoded. |
5 | 464 |
* @param string $redirect The path to redirect to on login, if supplied. |
465 |
* @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. |
|
466 |
*/ |
|
467 |
return apply_filters( 'login_url', $login_url, $redirect, $force_reauth ); |
|
0 | 468 |
} |
469 |
||
470 |
/** |
|
471 |
* Returns the URL that allows the user to register on the site. |
|
472 |
* |
|
473 |
* @since 3.6.0 |
|
474 |
* |
|
5 | 475 |
* @return string User registration URL. |
0 | 476 |
*/ |
477 |
function wp_registration_url() { |
|
5 | 478 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
479 |
* Filters the user registration URL. |
5 | 480 |
* |
481 |
* @since 3.6.0 |
|
482 |
* |
|
483 |
* @param string $register The user registration URL. |
|
484 |
*/ |
|
0 | 485 |
return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) ); |
486 |
} |
|
487 |
||
488 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
* Provides a simple login form for use anywhere within WordPress. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
490 |
* |
16 | 491 |
* The login form HTML is echoed by default. Pass a false value for `$echo` to return it instead. |
0 | 492 |
* |
493 |
* @since 3.0.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
494 |
* @since 6.6.0 Added `required_username` and `required_password` arguments. |
5 | 495 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
* @param array $args { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
* Optional. Array of options to control the form output. Default empty array. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
498 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
499 |
* @type bool $echo Whether to display the login form or return the form HTML code. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
500 |
* Default true (echo). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
501 |
* @type string $redirect URL to redirect to. Must be absolute, as in "https://example.com/mypage/". |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
502 |
* Default is to redirect back to the request URI. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
503 |
* @type string $form_id ID attribute value for the form. Default 'loginform'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
504 |
* @type string $label_username Label for the username or email address field. Default 'Username or Email Address'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
505 |
* @type string $label_password Label for the password field. Default 'Password'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
506 |
* @type string $label_remember Label for the remember field. Default 'Remember Me'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
507 |
* @type string $label_log_in Label for the submit button. Default 'Log In'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
508 |
* @type string $id_username ID attribute value for the username field. Default 'user_login'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
509 |
* @type string $id_password ID attribute value for the password field. Default 'user_pass'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
510 |
* @type string $id_remember ID attribute value for the remember field. Default 'rememberme'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
511 |
* @type string $id_submit ID attribute value for the submit button. Default 'wp-submit'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
512 |
* @type bool $remember Whether to display the "rememberme" checkbox in the form. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
513 |
* @type string $value_username Default value for the username field. Default empty. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
514 |
* @type bool $value_remember Whether the "Remember Me" checkbox should be checked by default. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
515 |
* Default false (unchecked). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
516 |
* @type bool $required_username Whether the username field has the 'required' attribute. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
517 |
* Default false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
518 |
* @type bool $required_password Whether the password field has the 'required' attribute. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
519 |
* Default false. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
520 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
* } |
16 | 522 |
* @return void|string Void if 'echo' argument is true, login form HTML if 'echo' is false. |
0 | 523 |
*/ |
524 |
function wp_login_form( $args = array() ) { |
|
525 |
$defaults = array( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
526 |
'echo' => true, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
527 |
// Default 'redirect' value takes the user back to the request URI. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
528 |
'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
529 |
'form_id' => 'loginform', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
530 |
'label_username' => __( 'Username or Email Address' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
531 |
'label_password' => __( 'Password' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
532 |
'label_remember' => __( 'Remember Me' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
533 |
'label_log_in' => __( 'Log In' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
534 |
'id_username' => 'user_login', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
535 |
'id_password' => 'user_pass', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
536 |
'id_remember' => 'rememberme', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
537 |
'id_submit' => 'wp-submit', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
538 |
'remember' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
539 |
'value_username' => '', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
540 |
// Set 'value_remember' to true to default the "Remember me" checkbox to checked. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
541 |
'value_remember' => false, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
542 |
// Set 'required_username' to true to add the required attribute to username field. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
543 |
'required_username' => false, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
544 |
// Set 'required_password' to true to add the required attribute to password field. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
545 |
'required_password' => false, |
0 | 546 |
); |
5 | 547 |
|
548 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
* Filters the default login form output arguments. |
5 | 550 |
* |
551 |
* @since 3.0.0 |
|
552 |
* |
|
553 |
* @see wp_login_form() |
|
554 |
* |
|
555 |
* @param array $defaults An array of default login form arguments. |
|
556 |
*/ |
|
0 | 557 |
$args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) ); |
558 |
||
5 | 559 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
* Filters content to display at the top of the login form. |
5 | 561 |
* |
562 |
* The filter evaluates just following the opening form tag element. |
|
563 |
* |
|
564 |
* @since 3.0.0 |
|
565 |
* |
|
566 |
* @param string $content Content to display. Default empty. |
|
567 |
* @param array $args Array of login form arguments. |
|
568 |
*/ |
|
569 |
$login_form_top = apply_filters( 'login_form_top', '', $args ); |
|
570 |
||
571 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
* Filters content to display in the middle of the login form. |
5 | 573 |
* |
574 |
* The filter evaluates just following the location where the 'login-password' |
|
575 |
* field is displayed. |
|
576 |
* |
|
577 |
* @since 3.0.0 |
|
578 |
* |
|
579 |
* @param string $content Content to display. Default empty. |
|
580 |
* @param array $args Array of login form arguments. |
|
581 |
*/ |
|
582 |
$login_form_middle = apply_filters( 'login_form_middle', '', $args ); |
|
583 |
||
584 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
* Filters content to display at the bottom of the login form. |
5 | 586 |
* |
587 |
* The filter evaluates just preceding the closing form tag element. |
|
588 |
* |
|
589 |
* @since 3.0.0 |
|
590 |
* |
|
591 |
* @param string $content Content to display. Default empty. |
|
592 |
* @param array $args Array of login form arguments. |
|
593 |
*/ |
|
594 |
$login_form_bottom = apply_filters( 'login_form_bottom', '', $args ); |
|
595 |
||
19 | 596 |
$form = |
597 |
sprintf( |
|
598 |
'<form name="%1$s" id="%1$s" action="%2$s" method="post">', |
|
599 |
esc_attr( $args['form_id'] ), |
|
600 |
esc_url( site_url( 'wp-login.php', 'login_post' ) ) |
|
601 |
) . |
|
602 |
$login_form_top . |
|
603 |
sprintf( |
|
604 |
'<p class="login-username"> |
|
605 |
<label for="%1$s">%2$s</label> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
606 |
<input type="text" name="log" id="%1$s" autocomplete="username" class="input" value="%3$s" size="20"%4$s /> |
19 | 607 |
</p>', |
608 |
esc_attr( $args['id_username'] ), |
|
609 |
esc_html( $args['label_username'] ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
610 |
esc_attr( $args['value_username'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
611 |
( $args['required_username'] ? ' required="required"' : '' ) |
19 | 612 |
) . |
613 |
sprintf( |
|
614 |
'<p class="login-password"> |
|
615 |
<label for="%1$s">%2$s</label> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
616 |
<input type="password" name="pwd" id="%1$s" autocomplete="current-password" spellcheck="false" class="input" value="" size="20"%3$s /> |
19 | 617 |
</p>', |
618 |
esc_attr( $args['id_password'] ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
619 |
esc_html( $args['label_password'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
620 |
( $args['required_password'] ? ' required="required"' : '' ) |
19 | 621 |
) . |
622 |
$login_form_middle . |
|
623 |
( $args['remember'] ? |
|
624 |
sprintf( |
|
625 |
'<p class="login-remember"><label><input name="rememberme" type="checkbox" id="%1$s" value="forever"%2$s /> %3$s</label></p>', |
|
626 |
esc_attr( $args['id_remember'] ), |
|
627 |
( $args['value_remember'] ? ' checked="checked"' : '' ), |
|
628 |
esc_html( $args['label_remember'] ) |
|
629 |
) : '' |
|
630 |
) . |
|
631 |
sprintf( |
|
632 |
'<p class="login-submit"> |
|
633 |
<input type="submit" name="wp-submit" id="%1$s" class="button button-primary" value="%2$s" /> |
|
634 |
<input type="hidden" name="redirect_to" value="%3$s" /> |
|
635 |
</p>', |
|
636 |
esc_attr( $args['id_submit'] ), |
|
637 |
esc_attr( $args['label_log_in'] ), |
|
638 |
esc_url( $args['redirect'] ) |
|
639 |
) . |
|
640 |
$login_form_bottom . |
|
641 |
'</form>'; |
|
0 | 642 |
|
9 | 643 |
if ( $args['echo'] ) { |
0 | 644 |
echo $form; |
9 | 645 |
} else { |
0 | 646 |
return $form; |
9 | 647 |
} |
0 | 648 |
} |
649 |
||
650 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
651 |
* Returns the URL that allows the user to reset the lost password. |
0 | 652 |
* |
653 |
* @since 2.8.0 |
|
654 |
* |
|
655 |
* @param string $redirect Path to redirect to on login. |
|
656 |
* @return string Lost password URL. |
|
657 |
*/ |
|
658 |
function wp_lostpassword_url( $redirect = '' ) { |
|
16 | 659 |
$args = array( |
660 |
'action' => 'lostpassword', |
|
661 |
); |
|
662 |
||
9 | 663 |
if ( ! empty( $redirect ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
$args['redirect_to'] = urlencode( $redirect ); |
0 | 665 |
} |
666 |
||
16 | 667 |
if ( is_multisite() ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
668 |
$blog_details = get_site(); |
16 | 669 |
$wp_login_path = $blog_details->path . 'wp-login.php'; |
670 |
} else { |
|
671 |
$wp_login_path = 'wp-login.php'; |
|
672 |
} |
|
673 |
||
674 |
$lostpassword_url = add_query_arg( $args, network_site_url( $wp_login_path, 'login' ) ); |
|
5 | 675 |
|
676 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
* Filters the Lost Password URL. |
5 | 678 |
* |
679 |
* @since 2.8.0 |
|
680 |
* |
|
681 |
* @param string $lostpassword_url The lost password page URL. |
|
682 |
* @param string $redirect The path to redirect to on login. |
|
683 |
*/ |
|
0 | 684 |
return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect ); |
685 |
} |
|
686 |
||
687 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
688 |
* Displays the Registration or Admin link. |
0 | 689 |
* |
690 |
* Display a link which allows the user to navigate to the registration page if |
|
691 |
* not logged in and registration is enabled or to the dashboard if logged in. |
|
692 |
* |
|
693 |
* @since 1.5.0 |
|
694 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
695 |
* @param string $before Text to output before the link. Default `<li>`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
696 |
* @param string $after Text to output after the link. Default `</li>`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
697 |
* @param bool $display Default to echo and not return the link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
698 |
* @return void|string Void if `$display` argument is true, registration or admin link |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
699 |
* if `$display` is false. |
0 | 700 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
701 |
function wp_register( $before = '<li>', $after = '</li>', $display = true ) { |
0 | 702 |
if ( ! is_user_logged_in() ) { |
9 | 703 |
if ( get_option( 'users_can_register' ) ) { |
704 |
$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Register' ) . '</a>' . $after; |
|
705 |
} else { |
|
0 | 706 |
$link = ''; |
9 | 707 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
} elseif ( current_user_can( 'read' ) ) { |
9 | 709 |
$link = $before . '<a href="' . admin_url() . '">' . __( 'Site Admin' ) . '</a>' . $after; |
0 | 710 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
$link = ''; |
0 | 712 |
} |
713 |
||
5 | 714 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
* Filters the HTML link to the Registration or Admin page. |
5 | 716 |
* |
717 |
* Users are sent to the admin page if logged-in, or the registration page |
|
718 |
* if enabled and logged-out. |
|
719 |
* |
|
720 |
* @since 1.5.0 |
|
721 |
* |
|
722 |
* @param string $link The HTML code for the link to the Registration or Admin page. |
|
723 |
*/ |
|
724 |
$link = apply_filters( 'register', $link ); |
|
725 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
726 |
if ( $display ) { |
5 | 727 |
echo $link; |
728 |
} else { |
|
729 |
return $link; |
|
730 |
} |
|
0 | 731 |
} |
732 |
||
733 |
/** |
|
734 |
* Theme container function for the 'wp_meta' action. |
|
735 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
736 |
* The {@see 'wp_meta'} action can have several purposes, depending on how you use it, |
0 | 737 |
* but one purpose might have been to allow for theme switching. |
738 |
* |
|
739 |
* @since 1.5.0 |
|
5 | 740 |
* |
741 |
* @link https://core.trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action. |
|
0 | 742 |
*/ |
743 |
function wp_meta() { |
|
5 | 744 |
/** |
745 |
* Fires before displaying echoed content in the sidebar. |
|
746 |
* |
|
747 |
* @since 1.5.0 |
|
748 |
*/ |
|
749 |
do_action( 'wp_meta' ); |
|
0 | 750 |
} |
751 |
||
752 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
753 |
* Displays information about the current site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
754 |
* |
0 | 755 |
* @since 0.71 |
756 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
757 |
* @see get_bloginfo() For possible `$show` values |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
758 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
* @param string $show Optional. Site information to display. Default empty. |
0 | 760 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
function bloginfo( $show = '' ) { |
0 | 762 |
echo get_bloginfo( $show, 'display' ); |
763 |
} |
|
764 |
||
765 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
* Retrieves information about the current site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
767 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
768 |
* Possible values for `$show` include: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
769 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
770 |
* - 'name' - Site title (set in Settings > General) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
771 |
* - 'description' - Site tagline (set in Settings > General) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
* - 'wpurl' - The WordPress address (URL) (set in Settings > General) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
773 |
* - 'url' - The Site address (URL) (set in Settings > General) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
774 |
* - 'admin_email' - Admin email (set in Settings > General) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
775 |
* - 'charset' - The "Encoding for pages and feeds" (set in Settings > Reading) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
* - 'version' - The current WordPress version |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
777 |
* - 'html_type' - The Content-Type (default: "text/html"). Themes and plugins |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
778 |
* can override the default value using the {@see 'pre_option_html_type'} filter |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
* - 'text_direction' - The text direction determined by the site's language. is_rtl() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
780 |
* should be used instead |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
781 |
* - 'language' - Language code for the current site |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
782 |
* - 'stylesheet_url' - URL to the stylesheet for the active theme. An active child theme |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
783 |
* will take precedence over this value |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
784 |
* - 'stylesheet_directory' - Directory path for the active theme. An active child theme |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
* will take precedence over this value |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
786 |
* - 'template_url' / 'template_directory' - URL of the active theme's directory. An active |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
787 |
* child theme will NOT take precedence over this value |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
* - 'pingback_url' - The pingback XML-RPC file URL (xmlrpc.php) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
789 |
* - 'atom_url' - The Atom feed URL (/feed/atom) |
9 | 790 |
* - 'rdf_url' - The RDF/RSS 1.0 feed URL (/feed/rdf) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
791 |
* - 'rss_url' - The RSS 0.92 feed URL (/feed/rss) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
792 |
* - 'rss2_url' - The RSS 2.0 feed URL (/feed) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
* - 'comments_atom_url' - The comments Atom feed URL (/comments/feed) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
794 |
* - 'comments_rss2_url' - The comments RSS 2.0 feed URL (/comments/feed) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
* Some `$show` values are deprecated and will be removed in future versions. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
* These options will trigger the _deprecated_argument() function. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
798 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
799 |
* Deprecated arguments include: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
801 |
* - 'siteurl' - Use 'url' instead |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
802 |
* - 'home' - Use 'url' instead |
0 | 803 |
* |
804 |
* @since 0.71 |
|
805 |
* |
|
16 | 806 |
* @global string $wp_version The WordPress version string. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
807 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
808 |
* @param string $show Optional. Site info to retrieve. Default empty (site name). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
809 |
* @param string $filter Optional. How to filter what is retrieved. Default 'raw'. |
0 | 810 |
* @return string Mostly string values, might be empty. |
811 |
*/ |
|
812 |
function get_bloginfo( $show = '', $filter = 'raw' ) { |
|
9 | 813 |
switch ( $show ) { |
16 | 814 |
case 'home': // Deprecated. |
815 |
case 'siteurl': // Deprecated. |
|
9 | 816 |
_deprecated_argument( |
817 |
__FUNCTION__, |
|
818 |
'2.2.0', |
|
819 |
sprintf( |
|
16 | 820 |
/* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument. */ |
9 | 821 |
__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ), |
822 |
'<code>' . $show . '</code>', |
|
823 |
'<code>bloginfo()</code>', |
|
824 |
'<code>url</code>' |
|
825 |
) |
|
826 |
); |
|
827 |
// Intentional fall-through to be handled by the 'url' case. |
|
828 |
case 'url': |
|
0 | 829 |
$output = home_url(); |
830 |
break; |
|
9 | 831 |
case 'wpurl': |
0 | 832 |
$output = site_url(); |
833 |
break; |
|
834 |
case 'description': |
|
9 | 835 |
$output = get_option( 'blogdescription' ); |
0 | 836 |
break; |
837 |
case 'rdf_url': |
|
9 | 838 |
$output = get_feed_link( 'rdf' ); |
0 | 839 |
break; |
840 |
case 'rss_url': |
|
9 | 841 |
$output = get_feed_link( 'rss' ); |
0 | 842 |
break; |
843 |
case 'rss2_url': |
|
9 | 844 |
$output = get_feed_link( 'rss2' ); |
0 | 845 |
break; |
846 |
case 'atom_url': |
|
9 | 847 |
$output = get_feed_link( 'atom' ); |
0 | 848 |
break; |
849 |
case 'comments_atom_url': |
|
9 | 850 |
$output = get_feed_link( 'comments_atom' ); |
0 | 851 |
break; |
852 |
case 'comments_rss2_url': |
|
9 | 853 |
$output = get_feed_link( 'comments_rss2' ); |
0 | 854 |
break; |
855 |
case 'pingback_url': |
|
856 |
$output = site_url( 'xmlrpc.php' ); |
|
857 |
break; |
|
858 |
case 'stylesheet_url': |
|
859 |
$output = get_stylesheet_uri(); |
|
860 |
break; |
|
861 |
case 'stylesheet_directory': |
|
862 |
$output = get_stylesheet_directory_uri(); |
|
863 |
break; |
|
864 |
case 'template_directory': |
|
865 |
case 'template_url': |
|
866 |
$output = get_template_directory_uri(); |
|
867 |
break; |
|
868 |
case 'admin_email': |
|
9 | 869 |
$output = get_option( 'admin_email' ); |
0 | 870 |
break; |
871 |
case 'charset': |
|
9 | 872 |
$output = get_option( 'blog_charset' ); |
16 | 873 |
if ( '' === $output ) { |
9 | 874 |
$output = 'UTF-8'; |
875 |
} |
|
0 | 876 |
break; |
9 | 877 |
case 'html_type': |
878 |
$output = get_option( 'html_type' ); |
|
0 | 879 |
break; |
880 |
case 'version': |
|
881 |
global $wp_version; |
|
882 |
$output = $wp_version; |
|
883 |
break; |
|
884 |
case 'language': |
|
16 | 885 |
/* |
886 |
* translators: Translate this to the correct language tag for your locale, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
887 |
* see https://www.w3.org/International/articles/language-tags/ for reference. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
* Do not translate into your own language. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
889 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
890 |
$output = __( 'html_lang_attribute' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
891 |
if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) { |
9 | 892 |
$output = determine_locale(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
893 |
$output = str_replace( '_', '-', $output ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
894 |
} |
0 | 895 |
break; |
896 |
case 'text_direction': |
|
9 | 897 |
_deprecated_argument( |
898 |
__FUNCTION__, |
|
899 |
'2.2.0', |
|
900 |
sprintf( |
|
16 | 901 |
/* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name. */ |
9 | 902 |
__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ), |
903 |
'<code>' . $show . '</code>', |
|
904 |
'<code>bloginfo()</code>', |
|
905 |
'<code>is_rtl()</code>' |
|
906 |
) |
|
907 |
); |
|
0 | 908 |
if ( function_exists( 'is_rtl' ) ) { |
909 |
$output = is_rtl() ? 'rtl' : 'ltr'; |
|
910 |
} else { |
|
911 |
$output = 'ltr'; |
|
912 |
} |
|
913 |
break; |
|
914 |
case 'name': |
|
915 |
default: |
|
9 | 916 |
$output = get_option( 'blogname' ); |
0 | 917 |
break; |
918 |
} |
|
919 |
||
16 | 920 |
if ( 'display' === $filter ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
921 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
922 |
str_contains( $show, 'url' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
923 |
|| str_contains( $show, 'directory' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
924 |
|| str_contains( $show, 'home' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
925 |
) { |
5 | 926 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
927 |
* Filters the URL returned by get_bloginfo(). |
5 | 928 |
* |
929 |
* @since 2.0.5 |
|
930 |
* |
|
16 | 931 |
* @param string $output The URL returned by bloginfo(). |
932 |
* @param string $show Type of information requested. |
|
5 | 933 |
*/ |
934 |
$output = apply_filters( 'bloginfo_url', $output, $show ); |
|
935 |
} else { |
|
936 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
937 |
* Filters the site information returned by get_bloginfo(). |
5 | 938 |
* |
939 |
* @since 0.71 |
|
940 |
* |
|
16 | 941 |
* @param mixed $output The requested non-URL site information. |
942 |
* @param string $show Type of information requested. |
|
5 | 943 |
*/ |
944 |
$output = apply_filters( 'bloginfo', $output, $show ); |
|
945 |
} |
|
0 | 946 |
} |
947 |
||
948 |
return $output; |
|
949 |
} |
|
950 |
||
951 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
952 |
* Returns the Site Icon URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
954 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
955 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
956 |
* @param int $size Optional. Size of the site icon. Default 512 (pixels). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
* @param string $url Optional. Fallback url if no site icon is found. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
958 |
* @param int $blog_id Optional. ID of the blog to get the site icon for. Default current blog. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
959 |
* @return string Site Icon URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
960 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
961 |
function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
962 |
$switched_blog = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
963 |
|
16 | 964 |
if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
965 |
switch_to_blog( $blog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
966 |
$switched_blog = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
967 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
968 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
969 |
$site_icon_id = (int) get_option( 'site_icon' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
970 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
if ( $site_icon_id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
972 |
if ( $size >= 512 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
973 |
$size_data = 'full'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
974 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
$size_data = array( $size, $size ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
976 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
977 |
$url = wp_get_attachment_image_url( $site_icon_id, $size_data ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
978 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
979 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
980 |
if ( $switched_blog ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
981 |
restore_current_blog(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
982 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
983 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
984 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
985 |
* Filters the site icon URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
986 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
987 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
988 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
989 |
* @param string $url Site icon URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
* @param int $size Size of the site icon. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
991 |
* @param int $blog_id ID of the blog to get the site icon for. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
992 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
993 |
return apply_filters( 'get_site_icon_url', $url, $size, $blog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
994 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
995 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
996 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
997 |
* Displays the Site Icon URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
998 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
999 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1000 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
* @param int $size Optional. Size of the site icon. Default 512 (pixels). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
* @param string $url Optional. Fallback url if no site icon is found. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
* @param int $blog_id Optional. ID of the blog to get the site icon for. Default current blog. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1004 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1005 |
function site_icon_url( $size = 512, $url = '', $blog_id = 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1006 |
echo esc_url( get_site_icon_url( $size, $url, $blog_id ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1007 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1009 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1010 |
* Determines whether the site has a Site Icon. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1011 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1012 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1013 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1014 |
* @param int $blog_id Optional. ID of the blog in question. Default current blog. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
* @return bool Whether the site has a site icon or not. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1016 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1017 |
function has_site_icon( $blog_id = 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
return (bool) get_site_icon_url( 512, '', $blog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1019 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1020 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1021 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1022 |
* Determines whether the site has a custom logo. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1023 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1024 |
* @since 4.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1025 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1026 |
* @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1027 |
* @return bool Whether the site has a custom logo or not. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1028 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1029 |
function has_custom_logo( $blog_id = 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1030 |
$switched_blog = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1031 |
|
16 | 1032 |
if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1033 |
switch_to_blog( $blog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1034 |
$switched_blog = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1035 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1036 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1037 |
$custom_logo_id = get_theme_mod( 'custom_logo' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1038 |
$is_image = ( $custom_logo_id ) ? wp_attachment_is_image( $custom_logo_id ) : false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1039 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1040 |
if ( $switched_blog ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1041 |
restore_current_blog(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1042 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1043 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1044 |
return $is_image; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1045 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1046 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1047 |
/** |
16 | 1048 |
* Returns a custom logo, linked to home unless the theme supports removing the link on the home page. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1049 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1050 |
* @since 4.5.0 |
18 | 1051 |
* @since 5.5.0 Added option to remove the link on the home page with `unlink-homepage-logo` theme support |
1052 |
* for the `custom-logo` theme feature. |
|
16 | 1053 |
* @since 5.5.1 Disabled lazy-loading by default. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1054 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1055 |
* @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1056 |
* @return string Custom logo markup. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1057 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1058 |
function get_custom_logo( $blog_id = 0 ) { |
9 | 1059 |
$html = ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1060 |
$switched_blog = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
|
16 | 1062 |
if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1063 |
switch_to_blog( $blog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1064 |
$switched_blog = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1065 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1066 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1067 |
// We have a logo. Logo is go. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1068 |
if ( has_custom_logo() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1069 |
$custom_logo_id = get_theme_mod( 'custom_logo' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1070 |
$custom_logo_attr = array( |
16 | 1071 |
'class' => 'custom-logo', |
1072 |
'loading' => false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1073 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1074 |
|
16 | 1075 |
$unlink_homepage_logo = (bool) get_theme_support( 'custom-logo', 'unlink-homepage-logo' ); |
1076 |
||
1077 |
if ( $unlink_homepage_logo && is_front_page() && ! is_paged() ) { |
|
1078 |
/* |
|
1079 |
* If on the home page, set the logo alt attribute to an empty string, |
|
1080 |
* as the image is decorative and doesn't need its purpose to be described. |
|
1081 |
*/ |
|
1082 |
$custom_logo_attr['alt'] = ''; |
|
1083 |
} else { |
|
1084 |
/* |
|
1085 |
* If the logo alt attribute is empty, get the site title and explicitly pass it |
|
1086 |
* to the attributes used by wp_get_attachment_image(). |
|
1087 |
*/ |
|
1088 |
$image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true ); |
|
1089 |
if ( empty( $image_alt ) ) { |
|
1090 |
$custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' ); |
|
1091 |
} |
|
1092 |
} |
|
1093 |
||
1094 |
/** |
|
1095 |
* Filters the list of custom logo image attributes. |
|
1096 |
* |
|
1097 |
* @since 5.5.0 |
|
1098 |
* |
|
1099 |
* @param array $custom_logo_attr Custom logo image attributes. |
|
1100 |
* @param int $custom_logo_id Custom logo attachment ID. |
|
1101 |
* @param int $blog_id ID of the blog to get the custom logo for. |
|
1102 |
*/ |
|
1103 |
$custom_logo_attr = apply_filters( 'get_custom_logo_image_attributes', $custom_logo_attr, $custom_logo_id, $blog_id ); |
|
1104 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1105 |
/* |
16 | 1106 |
* If the alt attribute is not empty, there's no need to explicitly pass it |
1107 |
* because wp_get_attachment_image() already adds the alt attribute. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
*/ |
16 | 1109 |
$image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr ); |
1110 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1111 |
// Check that we have a proper HTML img element. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1112 |
if ( $image ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1113 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1114 |
if ( $unlink_homepage_logo && is_front_page() && ! is_paged() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1115 |
// If on the home page, don't link the logo to home. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1116 |
$html = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1117 |
'<span class="custom-logo-link">%1$s</span>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1118 |
$image |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1119 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1120 |
} else { |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1121 |
$aria_current = ! is_paged() && ( is_front_page() || is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ? ' aria-current="page"' : ''; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1122 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1123 |
$html = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1124 |
'<a href="%1$s" class="custom-logo-link" rel="home"%2$s>%3$s</a>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1125 |
esc_url( home_url( '/' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1126 |
$aria_current, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1127 |
$image |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1128 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1129 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
} |
9 | 1131 |
} elseif ( is_customize_preview() ) { |
1132 |
// If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview). |
|
1133 |
$html = sprintf( |
|
18 | 1134 |
'<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo" alt="" /></a>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1135 |
esc_url( home_url( '/' ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1136 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1137 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1138 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1139 |
if ( $switched_blog ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1140 |
restore_current_blog(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1141 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1142 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1143 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1144 |
* Filters the custom logo output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1145 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1146 |
* @since 4.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1147 |
* @since 4.6.0 Added the `$blog_id` parameter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1148 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1149 |
* @param string $html Custom logo HTML output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1150 |
* @param int $blog_id ID of the blog to get the custom logo for. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1151 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1152 |
return apply_filters( 'get_custom_logo', $html, $blog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1153 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1154 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1155 |
/** |
16 | 1156 |
* Displays a custom logo, linked to home unless the theme supports removing the link on the home page. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1157 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1158 |
* @since 4.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
* @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1162 |
function the_custom_logo( $blog_id = 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1163 |
echo get_custom_logo( $blog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1164 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1165 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1166 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1167 |
* Returns document title for the current page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1168 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1169 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1170 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1171 |
* @global int $page Page number of a single post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1172 |
* @global int $paged Page number of a list of posts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1173 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1174 |
* @return string Tag with the document title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1175 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1176 |
function wp_get_document_title() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1177 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1178 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1179 |
* Filters the document title before it is generated. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1180 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1181 |
* Passing a non-empty value will short-circuit wp_get_document_title(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1182 |
* returning that value instead. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1183 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1184 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1185 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1186 |
* @param string $title The document title. Default empty string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1187 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1188 |
$title = apply_filters( 'pre_get_document_title', '' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1189 |
if ( ! empty( $title ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1190 |
return $title; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1191 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1192 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1193 |
global $page, $paged; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1194 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1195 |
$title = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1196 |
'title' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1197 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1198 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1199 |
// If it's a 404 page, use a "Page not found" title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1200 |
if ( is_404() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1201 |
$title['title'] = __( 'Page not found' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1202 |
|
9 | 1203 |
// If it's a search, use a dynamic search results title. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1204 |
} elseif ( is_search() ) { |
16 | 1205 |
/* translators: %s: Search query. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1206 |
$title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1207 |
|
9 | 1208 |
// If on the front page, use the site title. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1209 |
} elseif ( is_front_page() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1210 |
$title['title'] = get_bloginfo( 'name', 'display' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1211 |
|
9 | 1212 |
// If on a post type archive, use the post type archive title. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1213 |
} elseif ( is_post_type_archive() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1214 |
$title['title'] = post_type_archive_title( '', false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1215 |
|
9 | 1216 |
// If on a taxonomy archive, use the term title. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1217 |
} elseif ( is_tax() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1218 |
$title['title'] = single_term_title( '', false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
|
9 | 1220 |
/* |
16 | 1221 |
* If we're on the blog page that is not the homepage |
1222 |
* or a single post of any post type, use the post title. |
|
9 | 1223 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
} elseif ( is_home() || is_singular() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
$title['title'] = single_post_title( '', false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1226 |
|
9 | 1227 |
// If on a category or tag archive, use the term title. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
} elseif ( is_category() || is_tag() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1229 |
$title['title'] = single_term_title( '', false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1230 |
|
9 | 1231 |
// If on an author archive, use the author's display name. |
16 | 1232 |
} elseif ( is_author() && get_queried_object() ) { |
1233 |
$author = get_queried_object(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1234 |
$title['title'] = $author->display_name; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1235 |
|
9 | 1236 |
// If it's a date archive, use the date as the title. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
} elseif ( is_year() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1238 |
$title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1239 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1240 |
} elseif ( is_month() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1241 |
$title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1243 |
} elseif ( is_day() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
$title['title'] = get_the_date(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1246 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1247 |
// Add a page number if necessary. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1248 |
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { |
16 | 1249 |
/* translators: %s: Page number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
$title['page'] = sprintf( __( 'Page %s' ), max( $paged, $page ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1251 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1252 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
// Append the description or site title to give context. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
if ( is_front_page() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
$title['tagline'] = get_bloginfo( 'description', 'display' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
$title['site'] = get_bloginfo( 'name', 'display' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1259 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1260 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1261 |
* Filters the separator for the document title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1263 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1265 |
* @param string $sep Document title separator. Default '-'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1266 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1267 |
$sep = apply_filters( 'document_title_separator', '-' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1269 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
* Filters the parts of the document title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1271 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1272 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1273 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1274 |
* @param array $title { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1275 |
* The document title parts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
* @type string $title Title of the viewed page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1278 |
* @type string $page Optional. Page number if paginated. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1279 |
* @type string $tagline Optional. Site description when on home page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
* @type string $site Optional. Site title when not on home page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1281 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1282 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1283 |
$title = apply_filters( 'document_title_parts', $title ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1284 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1285 |
$title = implode( " $sep ", array_filter( $title ) ); |
18 | 1286 |
|
1287 |
/** |
|
1288 |
* Filters the document title. |
|
1289 |
* |
|
1290 |
* @since 5.8.0 |
|
1291 |
* |
|
1292 |
* @param string $title Document title. |
|
1293 |
*/ |
|
1294 |
$title = apply_filters( 'document_title', $title ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1295 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1296 |
return $title; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1297 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1298 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1299 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
* Displays title tag with content. |
5 | 1301 |
* |
1302 |
* @since 4.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
* @since 4.4.0 Improved title output replaced `wp_title()`. |
5 | 1304 |
* @access private |
1305 |
*/ |
|
1306 |
function _wp_render_title_tag() { |
|
1307 |
if ( ! current_theme_supports( 'title-tag' ) ) { |
|
1308 |
return; |
|
1309 |
} |
|
1310 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1311 |
echo '<title>' . wp_get_document_title() . '</title>' . "\n"; |
5 | 1312 |
} |
1313 |
||
1314 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1315 |
* Displays or retrieves page title for all areas of blog. |
0 | 1316 |
* |
1317 |
* By default, the page title will display the separator before the page title, |
|
1318 |
* so that the blog title will be before the page title. This is not good for |
|
1319 |
* title display, since the blog title shows up on most tabs and not what is |
|
1320 |
* important, which is the page that the user is looking at. |
|
1321 |
* |
|
1322 |
* There are also SEO benefits to having the blog title after or to the 'right' |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1323 |
* of the page title. However, it is mostly common sense to have the blog title |
0 | 1324 |
* to the right with most browsers supporting tabs. You can achieve this by |
1325 |
* using the seplocation parameter and setting the value to 'right'. This change |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1326 |
* was introduced around 2.5.0, in case backward compatibility of themes is |
0 | 1327 |
* important. |
1328 |
* |
|
1329 |
* @since 1.0.0 |
|
1330 |
* |
|
16 | 1331 |
* @global WP_Locale $wp_locale WordPress date and time locale object. |
1332 |
* |
|
1333 |
* @param string $sep Optional. How to separate the various items within the page title. |
|
1334 |
* Default '»'. |
|
1335 |
* @param bool $display Optional. Whether to display or retrieve title. Default true. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1336 |
* @param string $seplocation Optional. Location of the separator (either 'left' or 'right'). |
19 | 1337 |
* @return string|void String when `$display` is false, nothing otherwise. |
0 | 1338 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1339 |
function wp_title( $sep = '»', $display = true, $seplocation = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1340 |
global $wp_locale; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1341 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1342 |
$m = get_query_var( 'm' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1343 |
$year = get_query_var( 'year' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1344 |
$monthnum = get_query_var( 'monthnum' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1345 |
$day = get_query_var( 'day' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1346 |
$search = get_query_var( 's' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1347 |
$title = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1348 |
|
16 | 1349 |
$t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary. |
1350 |
||
1351 |
// If there is a post. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) { |
0 | 1353 |
$title = single_post_title( '', false ); |
1354 |
} |
|
1355 |
||
16 | 1356 |
// If there's a post type archive. |
0 | 1357 |
if ( is_post_type_archive() ) { |
1358 |
$post_type = get_query_var( 'post_type' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1359 |
if ( is_array( $post_type ) ) { |
0 | 1360 |
$post_type = reset( $post_type ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1361 |
} |
0 | 1362 |
$post_type_object = get_post_type_object( $post_type ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1363 |
if ( ! $post_type_object->has_archive ) { |
0 | 1364 |
$title = post_type_archive_title( '', false ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1365 |
} |
0 | 1366 |
} |
1367 |
||
16 | 1368 |
// If there's a category or tag. |
0 | 1369 |
if ( is_category() || is_tag() ) { |
1370 |
$title = single_term_title( '', false ); |
|
1371 |
} |
|
1372 |
||
16 | 1373 |
// If there's a taxonomy. |
0 | 1374 |
if ( is_tax() ) { |
1375 |
$term = get_queried_object(); |
|
1376 |
if ( $term ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1377 |
$tax = get_taxonomy( $term->taxonomy ); |
0 | 1378 |
$title = single_term_title( $tax->labels->name . $t_sep, false ); |
1379 |
} |
|
1380 |
} |
|
1381 |
||
16 | 1382 |
// If there's an author. |
5 | 1383 |
if ( is_author() && ! is_post_type_archive() ) { |
0 | 1384 |
$author = get_queried_object(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1385 |
if ( $author ) { |
0 | 1386 |
$title = $author->display_name; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1387 |
} |
0 | 1388 |
} |
1389 |
||
1390 |
// Post type archives with has_archive should override terms. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
if ( is_post_type_archive() && $post_type_object->has_archive ) { |
0 | 1392 |
$title = post_type_archive_title( '', false ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1393 |
} |
0 | 1394 |
|
16 | 1395 |
// If there's a month. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
if ( is_archive() && ! empty( $m ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1397 |
$my_year = substr( $m, 0, 4 ); |
19 | 1398 |
$my_month = substr( $m, 4, 2 ); |
18 | 1399 |
$my_day = (int) substr( $m, 6, 2 ); |
19 | 1400 |
$title = $my_year . |
1401 |
( $my_month ? $t_sep . $wp_locale->get_month( $my_month ) : '' ) . |
|
1402 |
( $my_day ? $t_sep . $my_day : '' ); |
|
0 | 1403 |
} |
1404 |
||
16 | 1405 |
// If there's a year. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1406 |
if ( is_archive() && ! empty( $year ) ) { |
0 | 1407 |
$title = $year; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1408 |
if ( ! empty( $monthnum ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1409 |
$title .= $t_sep . $wp_locale->get_month( $monthnum ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1410 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1411 |
if ( ! empty( $day ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1412 |
$title .= $t_sep . zeroise( $day, 2 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1413 |
} |
0 | 1414 |
} |
1415 |
||
16 | 1416 |
// If it's a search. |
0 | 1417 |
if ( is_search() ) { |
16 | 1418 |
/* translators: 1: Separator, 2: Search query. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1419 |
$title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) ); |
0 | 1420 |
} |
1421 |
||
16 | 1422 |
// If it's a 404 page. |
0 | 1423 |
if ( is_404() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1424 |
$title = __( 'Page not found' ); |
0 | 1425 |
} |
1426 |
||
1427 |
$prefix = ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1428 |
if ( ! empty( $title ) ) { |
0 | 1429 |
$prefix = " $sep "; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1430 |
} |
0 | 1431 |
|
5 | 1432 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1433 |
* Filters the parts of the page title. |
5 | 1434 |
* |
1435 |
* @since 4.0.0 |
|
1436 |
* |
|
16 | 1437 |
* @param string[] $title_array Array of parts of the page title. |
5 | 1438 |
*/ |
1439 |
$title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) ); |
|
1440 |
||
16 | 1441 |
// Determines position of the separator and direction of the breadcrumb. |
1442 |
if ( 'right' === $seplocation ) { // Separator on right, so reverse the order. |
|
0 | 1443 |
$title_array = array_reverse( $title_array ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
$title = implode( " $sep ", $title_array ) . $prefix; |
0 | 1445 |
} else { |
1446 |
$title = $prefix . implode( " $sep ", $title_array ); |
|
1447 |
} |
|
1448 |
||
5 | 1449 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
* Filters the text of the page title. |
5 | 1451 |
* |
1452 |
* @since 2.0.0 |
|
1453 |
* |
|
16 | 1454 |
* @param string $title Page title. |
1455 |
* @param string $sep Title separator. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1456 |
* @param string $seplocation Location of the separator (either 'left' or 'right'). |
5 | 1457 |
*/ |
1458 |
$title = apply_filters( 'wp_title', $title, $sep, $seplocation ); |
|
0 | 1459 |
|
16 | 1460 |
// Send it out. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1461 |
if ( $display ) { |
0 | 1462 |
echo $title; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
} else { |
0 | 1464 |
return $title; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
} |
0 | 1466 |
} |
1467 |
||
1468 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1469 |
* Displays or retrieves page title for post. |
0 | 1470 |
* |
1471 |
* This is optimized for single.php template file for displaying the post title. |
|
1472 |
* |
|
1473 |
* It does not support placing the separator after the title, but by leaving the |
|
1474 |
* prefix parameter empty, you can set the title separator manually. The prefix |
|
1475 |
* does not automatically place a space between the prefix, so if there should |
|
1476 |
* be a space, the parameter value will need to have it at the end. |
|
1477 |
* |
|
1478 |
* @since 0.71 |
|
1479 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1480 |
* @param string $prefix Optional. What to display before the title. |
16 | 1481 |
* @param bool $display Optional. Whether to display or retrieve title. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1482 |
* @return string|void Title when retrieving. |
0 | 1483 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1484 |
function single_post_title( $prefix = '', $display = true ) { |
0 | 1485 |
$_post = get_queried_object(); |
1486 |
||
9 | 1487 |
if ( ! isset( $_post->post_title ) ) { |
0 | 1488 |
return; |
9 | 1489 |
} |
0 | 1490 |
|
5 | 1491 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1492 |
* Filters the page title for a single post. |
5 | 1493 |
* |
1494 |
* @since 0.71 |
|
1495 |
* |
|
16 | 1496 |
* @param string $_post_title The single post page title. |
1497 |
* @param WP_Post $_post The current post. |
|
5 | 1498 |
*/ |
1499 |
$title = apply_filters( 'single_post_title', $_post->post_title, $_post ); |
|
9 | 1500 |
if ( $display ) { |
0 | 1501 |
echo $prefix . $title; |
9 | 1502 |
} else { |
0 | 1503 |
return $prefix . $title; |
9 | 1504 |
} |
0 | 1505 |
} |
1506 |
||
1507 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1508 |
* Displays or retrieves title for a post type archive. |
0 | 1509 |
* |
1510 |
* This is optimized for archive.php and archive-{$post_type}.php template files |
|
1511 |
* for displaying the title of the post type. |
|
1512 |
* |
|
1513 |
* @since 3.1.0 |
|
1514 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1515 |
* @param string $prefix Optional. What to display before the title. |
16 | 1516 |
* @param bool $display Optional. Whether to display or retrieve title. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1517 |
* @return string|void Title when retrieving, null when displaying or failure. |
0 | 1518 |
*/ |
1519 |
function post_type_archive_title( $prefix = '', $display = true ) { |
|
9 | 1520 |
if ( ! is_post_type_archive() ) { |
0 | 1521 |
return; |
9 | 1522 |
} |
0 | 1523 |
|
1524 |
$post_type = get_query_var( 'post_type' ); |
|
9 | 1525 |
if ( is_array( $post_type ) ) { |
0 | 1526 |
$post_type = reset( $post_type ); |
9 | 1527 |
} |
0 | 1528 |
|
1529 |
$post_type_obj = get_post_type_object( $post_type ); |
|
5 | 1530 |
|
1531 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1532 |
* Filters the post type archive title. |
5 | 1533 |
* |
1534 |
* @since 3.1.0 |
|
1535 |
* |
|
1536 |
* @param string $post_type_name Post type 'name' label. |
|
1537 |
* @param string $post_type Post type. |
|
1538 |
*/ |
|
1539 |
$title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type ); |
|
0 | 1540 |
|
9 | 1541 |
if ( $display ) { |
0 | 1542 |
echo $prefix . $title; |
9 | 1543 |
} else { |
0 | 1544 |
return $prefix . $title; |
9 | 1545 |
} |
0 | 1546 |
} |
1547 |
||
1548 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1549 |
* Displays or retrieves page title for category archive. |
0 | 1550 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1551 |
* Useful for category template files for displaying the category page title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1552 |
* The prefix does not automatically place a space between the prefix, so if |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1553 |
* there should be a space, the parameter value will need to have it at the end. |
0 | 1554 |
* |
1555 |
* @since 0.71 |
|
1556 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1557 |
* @param string $prefix Optional. What to display before the title. |
16 | 1558 |
* @param bool $display Optional. Whether to display or retrieve title. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1559 |
* @return string|void Title when retrieving. |
0 | 1560 |
*/ |
1561 |
function single_cat_title( $prefix = '', $display = true ) { |
|
1562 |
return single_term_title( $prefix, $display ); |
|
1563 |
} |
|
1564 |
||
1565 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1566 |
* Displays or retrieves page title for tag post archive. |
0 | 1567 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1568 |
* Useful for tag template files for displaying the tag page title. The prefix |
0 | 1569 |
* does not automatically place a space between the prefix, so if there should |
1570 |
* be a space, the parameter value will need to have it at the end. |
|
1571 |
* |
|
1572 |
* @since 2.3.0 |
|
1573 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1574 |
* @param string $prefix Optional. What to display before the title. |
16 | 1575 |
* @param bool $display Optional. Whether to display or retrieve title. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1576 |
* @return string|void Title when retrieving. |
0 | 1577 |
*/ |
1578 |
function single_tag_title( $prefix = '', $display = true ) { |
|
1579 |
return single_term_title( $prefix, $display ); |
|
1580 |
} |
|
1581 |
||
1582 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1583 |
* Displays or retrieves page title for taxonomy term archive. |
0 | 1584 |
* |
1585 |
* Useful for taxonomy term template files for displaying the taxonomy term page title. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1586 |
* The prefix does not automatically place a space between the prefix, so if there should |
0 | 1587 |
* be a space, the parameter value will need to have it at the end. |
1588 |
* |
|
1589 |
* @since 3.1.0 |
|
1590 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1591 |
* @param string $prefix Optional. What to display before the title. |
16 | 1592 |
* @param bool $display Optional. Whether to display or retrieve title. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1593 |
* @return string|void Title when retrieving. |
0 | 1594 |
*/ |
1595 |
function single_term_title( $prefix = '', $display = true ) { |
|
1596 |
$term = get_queried_object(); |
|
1597 |
||
9 | 1598 |
if ( ! $term ) { |
0 | 1599 |
return; |
9 | 1600 |
} |
0 | 1601 |
|
5 | 1602 |
if ( is_category() ) { |
1603 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1604 |
* Filters the category archive page title. |
5 | 1605 |
* |
1606 |
* @since 2.0.10 |
|
1607 |
* |
|
1608 |
* @param string $term_name Category name for archive being displayed. |
|
1609 |
*/ |
|
0 | 1610 |
$term_name = apply_filters( 'single_cat_title', $term->name ); |
5 | 1611 |
} elseif ( is_tag() ) { |
1612 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1613 |
* Filters the tag archive page title. |
5 | 1614 |
* |
1615 |
* @since 2.3.0 |
|
1616 |
* |
|
1617 |
* @param string $term_name Tag name for archive being displayed. |
|
1618 |
*/ |
|
0 | 1619 |
$term_name = apply_filters( 'single_tag_title', $term->name ); |
5 | 1620 |
} elseif ( is_tax() ) { |
1621 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1622 |
* Filters the custom taxonomy archive page title. |
5 | 1623 |
* |
1624 |
* @since 3.1.0 |
|
1625 |
* |
|
1626 |
* @param string $term_name Term name for archive being displayed. |
|
1627 |
*/ |
|
0 | 1628 |
$term_name = apply_filters( 'single_term_title', $term->name ); |
5 | 1629 |
} else { |
0 | 1630 |
return; |
5 | 1631 |
} |
0 | 1632 |
|
9 | 1633 |
if ( empty( $term_name ) ) { |
0 | 1634 |
return; |
9 | 1635 |
} |
1636 |
||
1637 |
if ( $display ) { |
|
0 | 1638 |
echo $prefix . $term_name; |
9 | 1639 |
} else { |
0 | 1640 |
return $prefix . $term_name; |
9 | 1641 |
} |
0 | 1642 |
} |
1643 |
||
1644 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1645 |
* Displays or retrieves page title for post archive based on date. |
0 | 1646 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1647 |
* Useful for when the template only needs to display the month and year, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1648 |
* if either are available. The prefix does not automatically place a space |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1649 |
* between the prefix, so if there should be a space, the parameter value |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1650 |
* will need to have it at the end. |
0 | 1651 |
* |
1652 |
* @since 0.71 |
|
1653 |
* |
|
16 | 1654 |
* @global WP_Locale $wp_locale WordPress date and time locale object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1655 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1656 |
* @param string $prefix Optional. What to display before the title. |
16 | 1657 |
* @param bool $display Optional. Whether to display or retrieve title. Default true. |
19 | 1658 |
* @return string|false|void False if there's no valid title for the month. Title when retrieving. |
0 | 1659 |
*/ |
9 | 1660 |
function single_month_title( $prefix = '', $display = true ) { |
0 | 1661 |
global $wp_locale; |
1662 |
||
9 | 1663 |
$m = get_query_var( 'm' ); |
1664 |
$year = get_query_var( 'year' ); |
|
1665 |
$monthnum = get_query_var( 'monthnum' ); |
|
1666 |
||
1667 |
if ( ! empty( $monthnum ) && ! empty( $year ) ) { |
|
1668 |
$my_year = $year; |
|
1669 |
$my_month = $wp_locale->get_month( $monthnum ); |
|
1670 |
} elseif ( ! empty( $m ) ) { |
|
1671 |
$my_year = substr( $m, 0, 4 ); |
|
1672 |
$my_month = $wp_locale->get_month( substr( $m, 4, 2 ) ); |
|
0 | 1673 |
} |
1674 |
||
9 | 1675 |
if ( empty( $my_month ) ) { |
0 | 1676 |
return false; |
9 | 1677 |
} |
0 | 1678 |
|
1679 |
$result = $prefix . $my_month . $prefix . $my_year; |
|
1680 |
||
9 | 1681 |
if ( ! $display ) { |
0 | 1682 |
return $result; |
9 | 1683 |
} |
0 | 1684 |
echo $result; |
1685 |
} |
|
1686 |
||
1687 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1688 |
* Displays the archive title based on the queried object. |
5 | 1689 |
* |
1690 |
* @since 4.1.0 |
|
1691 |
* |
|
1692 |
* @see get_the_archive_title() |
|
1693 |
* |
|
1694 |
* @param string $before Optional. Content to prepend to the title. Default empty. |
|
1695 |
* @param string $after Optional. Content to append to the title. Default empty. |
|
1696 |
*/ |
|
1697 |
function the_archive_title( $before = '', $after = '' ) { |
|
1698 |
$title = get_the_archive_title(); |
|
1699 |
||
1700 |
if ( ! empty( $title ) ) { |
|
1701 |
echo $before . $title . $after; |
|
1702 |
} |
|
1703 |
} |
|
1704 |
||
1705 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1706 |
* Retrieves the archive title based on the queried object. |
5 | 1707 |
* |
1708 |
* @since 4.1.0 |
|
16 | 1709 |
* @since 5.5.0 The title part is wrapped in a `<span>` element. |
5 | 1710 |
* |
1711 |
* @return string Archive title. |
|
1712 |
*/ |
|
1713 |
function get_the_archive_title() { |
|
16 | 1714 |
$title = __( 'Archives' ); |
1715 |
$prefix = ''; |
|
1716 |
||
5 | 1717 |
if ( is_category() ) { |
16 | 1718 |
$title = single_cat_title( '', false ); |
1719 |
$prefix = _x( 'Category:', 'category archive title prefix' ); |
|
5 | 1720 |
} elseif ( is_tag() ) { |
16 | 1721 |
$title = single_tag_title( '', false ); |
1722 |
$prefix = _x( 'Tag:', 'tag archive title prefix' ); |
|
5 | 1723 |
} elseif ( is_author() ) { |
16 | 1724 |
$title = get_the_author(); |
1725 |
$prefix = _x( 'Author:', 'author archive title prefix' ); |
|
5 | 1726 |
} elseif ( is_year() ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1727 |
/* translators: See https://www.php.net/manual/datetime.format.php */ |
16 | 1728 |
$title = get_the_date( _x( 'Y', 'yearly archives date format' ) ); |
1729 |
$prefix = _x( 'Year:', 'date archive title prefix' ); |
|
5 | 1730 |
} elseif ( is_month() ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1731 |
/* translators: See https://www.php.net/manual/datetime.format.php */ |
16 | 1732 |
$title = get_the_date( _x( 'F Y', 'monthly archives date format' ) ); |
1733 |
$prefix = _x( 'Month:', 'date archive title prefix' ); |
|
5 | 1734 |
} elseif ( is_day() ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1735 |
/* translators: See https://www.php.net/manual/datetime.format.php */ |
16 | 1736 |
$title = get_the_date( _x( 'F j, Y', 'daily archives date format' ) ); |
1737 |
$prefix = _x( 'Day:', 'date archive title prefix' ); |
|
5 | 1738 |
} elseif ( is_tax( 'post_format' ) ) { |
1739 |
if ( is_tax( 'post_format', 'post-format-aside' ) ) { |
|
1740 |
$title = _x( 'Asides', 'post format archive title' ); |
|
1741 |
} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { |
|
1742 |
$title = _x( 'Galleries', 'post format archive title' ); |
|
1743 |
} elseif ( is_tax( 'post_format', 'post-format-image' ) ) { |
|
1744 |
$title = _x( 'Images', 'post format archive title' ); |
|
1745 |
} elseif ( is_tax( 'post_format', 'post-format-video' ) ) { |
|
1746 |
$title = _x( 'Videos', 'post format archive title' ); |
|
1747 |
} elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { |
|
1748 |
$title = _x( 'Quotes', 'post format archive title' ); |
|
1749 |
} elseif ( is_tax( 'post_format', 'post-format-link' ) ) { |
|
1750 |
$title = _x( 'Links', 'post format archive title' ); |
|
1751 |
} elseif ( is_tax( 'post_format', 'post-format-status' ) ) { |
|
1752 |
$title = _x( 'Statuses', 'post format archive title' ); |
|
1753 |
} elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { |
|
1754 |
$title = _x( 'Audio', 'post format archive title' ); |
|
1755 |
} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { |
|
1756 |
$title = _x( 'Chats', 'post format archive title' ); |
|
1757 |
} |
|
1758 |
} elseif ( is_post_type_archive() ) { |
|
16 | 1759 |
$title = post_type_archive_title( '', false ); |
1760 |
$prefix = _x( 'Archives:', 'post type archive title prefix' ); |
|
5 | 1761 |
} elseif ( is_tax() ) { |
16 | 1762 |
$queried_object = get_queried_object(); |
1763 |
if ( $queried_object ) { |
|
1764 |
$tax = get_taxonomy( $queried_object->taxonomy ); |
|
1765 |
$title = single_term_title( '', false ); |
|
1766 |
$prefix = sprintf( |
|
1767 |
/* translators: %s: Taxonomy singular name. */ |
|
1768 |
_x( '%s:', 'taxonomy term archive title prefix' ), |
|
1769 |
$tax->labels->singular_name |
|
1770 |
); |
|
1771 |
} |
|
1772 |
} |
|
1773 |
||
1774 |
$original_title = $title; |
|
1775 |
||
1776 |
/** |
|
1777 |
* Filters the archive title prefix. |
|
1778 |
* |
|
1779 |
* @since 5.5.0 |
|
1780 |
* |
|
1781 |
* @param string $prefix Archive title prefix. |
|
1782 |
*/ |
|
1783 |
$prefix = apply_filters( 'get_the_archive_title_prefix', $prefix ); |
|
1784 |
if ( $prefix ) { |
|
1785 |
$title = sprintf( |
|
1786 |
/* translators: 1: Title prefix. 2: Title. */ |
|
1787 |
_x( '%1$s %2$s', 'archive title' ), |
|
1788 |
$prefix, |
|
1789 |
'<span>' . $title . '</span>' |
|
1790 |
); |
|
5 | 1791 |
} |
1792 |
||
1793 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1794 |
* Filters the archive title. |
5 | 1795 |
* |
1796 |
* @since 4.1.0 |
|
16 | 1797 |
* @since 5.5.0 Added the `$prefix` and `$original_title` parameters. |
5 | 1798 |
* |
16 | 1799 |
* @param string $title Archive title to be displayed. |
1800 |
* @param string $original_title Archive title without prefix. |
|
1801 |
* @param string $prefix Archive title prefix. |
|
5 | 1802 |
*/ |
16 | 1803 |
return apply_filters( 'get_the_archive_title', $title, $original_title, $prefix ); |
5 | 1804 |
} |
1805 |
||
1806 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1807 |
* Displays category, tag, term, or author description. |
5 | 1808 |
* |
1809 |
* @since 4.1.0 |
|
1810 |
* |
|
1811 |
* @see get_the_archive_description() |
|
1812 |
* |
|
1813 |
* @param string $before Optional. Content to prepend to the description. Default empty. |
|
1814 |
* @param string $after Optional. Content to append to the description. Default empty. |
|
1815 |
*/ |
|
1816 |
function the_archive_description( $before = '', $after = '' ) { |
|
1817 |
$description = get_the_archive_description(); |
|
1818 |
if ( $description ) { |
|
1819 |
echo $before . $description . $after; |
|
1820 |
} |
|
1821 |
} |
|
1822 |
||
1823 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1824 |
* Retrieves the description for an author, post type, or term archive. |
5 | 1825 |
* |
1826 |
* @since 4.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1827 |
* @since 4.7.0 Added support for author archives. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1828 |
* @since 4.9.0 Added support for post type archives. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1829 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1830 |
* @see term_description() |
5 | 1831 |
* |
1832 |
* @return string Archive description. |
|
1833 |
*/ |
|
1834 |
function get_the_archive_description() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1835 |
if ( is_author() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1836 |
$description = get_the_author_meta( 'description' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1837 |
} elseif ( is_post_type_archive() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1838 |
$description = get_the_post_type_description(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1839 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1840 |
$description = term_description(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1841 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1842 |
|
5 | 1843 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1844 |
* Filters the archive description. |
5 | 1845 |
* |
1846 |
* @since 4.1.0 |
|
1847 |
* |
|
1848 |
* @param string $description Archive description to be displayed. |
|
1849 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1850 |
return apply_filters( 'get_the_archive_description', $description ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1851 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1852 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1853 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1854 |
* Retrieves the description for a post type archive. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1855 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1856 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1857 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1858 |
* @return string The post type description. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1859 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1860 |
function get_the_post_type_description() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1861 |
$post_type = get_query_var( 'post_type' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1862 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1863 |
if ( is_array( $post_type ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1864 |
$post_type = reset( $post_type ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1865 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1866 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1867 |
$post_type_obj = get_post_type_object( $post_type ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1868 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1869 |
// Check if a description is set. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1870 |
if ( isset( $post_type_obj->description ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1871 |
$description = $post_type_obj->description; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1872 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1873 |
$description = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1874 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1875 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1876 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1877 |
* Filters the description for a post type archive. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1878 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1879 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1880 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1881 |
* @param string $description The post type description. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1882 |
* @param WP_Post_Type $post_type_obj The post type object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1883 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1884 |
return apply_filters( 'get_the_post_type_description', $description, $post_type_obj ); |
5 | 1885 |
} |
1886 |
||
1887 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1888 |
* Retrieves archive link content based on predefined or custom code. |
0 | 1889 |
* |
1890 |
* The format can be one of four styles. The 'link' for head element, 'option' |
|
1891 |
* for use in the select element, 'html' for use in list (either ol or ul HTML |
|
1892 |
* elements). Custom content is also supported using the before and after |
|
1893 |
* parameters. |
|
1894 |
* |
|
5 | 1895 |
* The 'link' format uses the `<link>` HTML element with the **archives** |
0 | 1896 |
* relationship. The before and after parameters are not used. The text |
1897 |
* parameter is used to describe the link. |
|
1898 |
* |
|
1899 |
* The 'option' format uses the option HTML element for use in select element. |
|
1900 |
* The value is the url parameter and the before and after parameters are used |
|
1901 |
* between the text description. |
|
1902 |
* |
|
1903 |
* The 'html' format, which is the default, uses the li HTML element for use in |
|
1904 |
* the list HTML elements. The before parameter is before the link and the after |
|
1905 |
* parameter is after the closing link. |
|
1906 |
* |
|
1907 |
* The custom format uses the before parameter before the link ('a' HTML |
|
1908 |
* element) and the after parameter after the closing link tag. If the above |
|
1909 |
* three values for the format are not used, then custom format is assumed. |
|
1910 |
* |
|
1911 |
* @since 1.0.0 |
|
9 | 1912 |
* @since 5.2.0 Added the `$selected` parameter. |
1913 |
* |
|
1914 |
* @param string $url URL to archive. |
|
1915 |
* @param string $text Archive text description. |
|
16 | 1916 |
* @param string $format Optional. Can be 'link', 'option', 'html', or custom. Default 'html'. |
9 | 1917 |
* @param string $before Optional. Content to prepend to the description. Default empty. |
1918 |
* @param string $after Optional. Content to append to the description. Default empty. |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1919 |
* @param bool $selected Optional. Set to true if the current page is the selected archive page. Default false. |
0 | 1920 |
* @return string HTML link content for archive. |
1921 |
*/ |
|
9 | 1922 |
function get_archives_link( $url, $text, $format = 'html', $before = '', $after = '', $selected = false ) { |
16 | 1923 |
$text = wptexturize( $text ); |
1924 |
$url = esc_url( $url ); |
|
1925 |
$aria_current = $selected ? ' aria-current="page"' : ''; |
|
1926 |
||
1927 |
if ( 'link' === $format ) { |
|
0 | 1928 |
$link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n"; |
16 | 1929 |
} elseif ( 'option' === $format ) { |
9 | 1930 |
$selected_attr = $selected ? " selected='selected'" : ''; |
1931 |
$link_html = "\t<option value='$url'$selected_attr>$before $text $after</option>\n"; |
|
16 | 1932 |
} elseif ( 'html' === $format ) { |
1933 |
$link_html = "\t<li>$before<a href='$url'$aria_current>$text</a>$after</li>\n"; |
|
1934 |
} else { // Custom. |
|
1935 |
$link_html = "\t$before<a href='$url'$aria_current>$text</a>$after\n"; |
|
9 | 1936 |
} |
0 | 1937 |
|
5 | 1938 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1939 |
* Filters the archive link content. |
5 | 1940 |
* |
1941 |
* @since 2.6.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1942 |
* @since 4.5.0 Added the `$url`, `$text`, `$format`, `$before`, and `$after` parameters. |
9 | 1943 |
* @since 5.2.0 Added the `$selected` parameter. |
5 | 1944 |
* |
1945 |
* @param string $link_html The archive HTML link content. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1946 |
* @param string $url URL to archive. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1947 |
* @param string $text Archive text description. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1948 |
* @param string $format Link format. Can be 'link', 'option', 'html', or custom. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1949 |
* @param string $before Content to prepend to the description. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1950 |
* @param string $after Content to append to the description. |
9 | 1951 |
* @param bool $selected True if the current page is the selected archive. |
5 | 1952 |
*/ |
9 | 1953 |
return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after, $selected ); |
0 | 1954 |
} |
1955 |
||
1956 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1957 |
* Displays archive links based on type and format. |
0 | 1958 |
* |
1959 |
* @since 1.2.0 |
|
9 | 1960 |
* @since 4.4.0 The `$post_type` argument was added. |
1961 |
* @since 5.2.0 The `$year`, `$monthnum`, `$day`, and `$w` arguments were added. |
|
0 | 1962 |
* |
5 | 1963 |
* @see get_archives_link() |
1964 |
* |
|
16 | 1965 |
* @global wpdb $wpdb WordPress database abstraction object. |
1966 |
* @global WP_Locale $wp_locale WordPress date and time locale object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1967 |
* |
5 | 1968 |
* @param string|array $args { |
1969 |
* Default archive links arguments. Optional. |
|
1970 |
* |
|
1971 |
* @type string $type Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly', |
|
1972 |
* 'yearly', 'postbypost', or 'alpha'. Both 'postbypost' and 'alpha' |
|
1973 |
* display the same archive link list as well as post titles instead |
|
1974 |
* of displaying dates. The difference between the two is that 'alpha' |
|
1975 |
* will order by post title and 'postbypost' will order by post date. |
|
1976 |
* Default 'monthly'. |
|
1977 |
* @type string|int $limit Number of links to limit the query to. Default empty (no limit). |
|
1978 |
* @type string $format Format each link should take using the $before and $after args. |
|
1979 |
* Accepts 'link' (`<link>` tag), 'option' (`<option>` tag), 'html' |
|
1980 |
* (`<li>` tag), or a custom format, which generates a link anchor |
|
1981 |
* with $before preceding and $after succeeding. Default 'html'. |
|
1982 |
* @type string $before Markup to prepend to the beginning of each link. Default empty. |
|
1983 |
* @type string $after Markup to append to the end of each link. Default empty. |
|
1984 |
* @type bool $show_post_count Whether to display the post count alongside the link. Default false. |
|
1985 |
* @type bool|int $echo Whether to echo or return the links list. Default 1|true to echo. |
|
1986 |
* @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'. |
|
1987 |
* Default 'DESC'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1988 |
* @type string $post_type Post type. Default 'post'. |
9 | 1989 |
* @type string $year Year. Default current year. |
1990 |
* @type string $monthnum Month number. Default current month number. |
|
1991 |
* @type string $day Day. Default current day. |
|
1992 |
* @type string $w Week. Default current week. |
|
5 | 1993 |
* } |
16 | 1994 |
* @return void|string Void if 'echo' argument is true, archive links if 'echo' is false. |
0 | 1995 |
*/ |
5 | 1996 |
function wp_get_archives( $args = '' ) { |
0 | 1997 |
global $wpdb, $wp_locale; |
1998 |
||
1999 |
$defaults = array( |
|
9 | 2000 |
'type' => 'monthly', |
2001 |
'limit' => '', |
|
2002 |
'format' => 'html', |
|
2003 |
'before' => '', |
|
2004 |
'after' => '', |
|
2005 |
'show_post_count' => false, |
|
2006 |
'echo' => 1, |
|
2007 |
'order' => 'DESC', |
|
2008 |
'post_type' => 'post', |
|
2009 |
'year' => get_query_var( 'year' ), |
|
2010 |
'monthnum' => get_query_var( 'monthnum' ), |
|
2011 |
'day' => get_query_var( 'day' ), |
|
2012 |
'w' => get_query_var( 'w' ), |
|
0 | 2013 |
); |
2014 |
||
16 | 2015 |
$parsed_args = wp_parse_args( $args, $defaults ); |
2016 |
||
2017 |
$post_type_object = get_post_type_object( $parsed_args['post_type'] ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2018 |
if ( ! is_post_type_viewable( $post_type_object ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2019 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2020 |
} |
16 | 2021 |
|
2022 |
$parsed_args['post_type'] = $post_type_object->name; |
|
2023 |
||
2024 |
if ( '' === $parsed_args['type'] ) { |
|
2025 |
$parsed_args['type'] = 'monthly'; |
|
0 | 2026 |
} |
2027 |
||
16 | 2028 |
if ( ! empty( $parsed_args['limit'] ) ) { |
2029 |
$parsed_args['limit'] = absint( $parsed_args['limit'] ); |
|
2030 |
$parsed_args['limit'] = ' LIMIT ' . $parsed_args['limit']; |
|
5 | 2031 |
} |
2032 |
||
16 | 2033 |
$order = strtoupper( $parsed_args['order'] ); |
2034 |
if ( 'ASC' !== $order ) { |
|
0 | 2035 |
$order = 'DESC'; |
5 | 2036 |
} |
0 | 2037 |
|
16 | 2038 |
// This is what will separate dates on weekly archive links. |
0 | 2039 |
$archive_week_separator = '–'; |
2040 |
||
16 | 2041 |
$sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $parsed_args['post_type'] ); |
0 | 2042 |
|
5 | 2043 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2044 |
* Filters the SQL WHERE clause for retrieving archives. |
5 | 2045 |
* |
2046 |
* @since 2.2.0 |
|
2047 |
* |
|
16 | 2048 |
* @param string $sql_where Portion of SQL query containing the WHERE clause. |
2049 |
* @param array $parsed_args An array of default arguments. |
|
5 | 2050 |
*/ |
16 | 2051 |
$where = apply_filters( 'getarchives_where', $sql_where, $parsed_args ); |
5 | 2052 |
|
2053 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2054 |
* Filters the SQL JOIN clause for retrieving archives. |
5 | 2055 |
* |
2056 |
* @since 2.2.0 |
|
2057 |
* |
|
16 | 2058 |
* @param string $sql_join Portion of SQL query containing JOIN clause. |
2059 |
* @param array $parsed_args An array of default arguments. |
|
5 | 2060 |
*/ |
16 | 2061 |
$join = apply_filters( 'getarchives_join', '', $parsed_args ); |
0 | 2062 |
|
2063 |
$output = ''; |
|
2064 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2065 |
$last_changed = wp_cache_get_last_changed( 'posts' ); |
0 | 2066 |
|
16 | 2067 |
$limit = $parsed_args['limit']; |
2068 |
||
2069 |
if ( 'monthly' === $parsed_args['type'] ) { |
|
2070 |
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit"; |
|
2071 |
$key = md5( $query ); |
|
2072 |
$key = "wp_get_archives:$key:$last_changed"; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2073 |
$results = wp_cache_get( $key, 'post-queries' ); |
16 | 2074 |
if ( ! $results ) { |
0 | 2075 |
$results = $wpdb->get_results( $query ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2076 |
wp_cache_set( $key, $results, 'post-queries' ); |
0 | 2077 |
} |
2078 |
if ( $results ) { |
|
16 | 2079 |
$after = $parsed_args['after']; |
0 | 2080 |
foreach ( (array) $results as $result ) { |
2081 |
$url = get_month_link( $result->year, $result->month ); |
|
16 | 2082 |
if ( 'post' !== $parsed_args['post_type'] ) { |
2083 |
$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2084 |
} |
16 | 2085 |
/* translators: 1: Month name, 2: 4-digit year. */ |
5 | 2086 |
$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year ); |
16 | 2087 |
if ( $parsed_args['show_post_count'] ) { |
2088 |
$parsed_args['after'] = ' (' . $result->posts . ')' . $after; |
|
5 | 2089 |
} |
16 | 2090 |
$selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month; |
2091 |
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected ); |
|
0 | 2092 |
} |
2093 |
} |
|
16 | 2094 |
} elseif ( 'yearly' === $parsed_args['type'] ) { |
2095 |
$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; |
|
2096 |
$key = md5( $query ); |
|
2097 |
$key = "wp_get_archives:$key:$last_changed"; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2098 |
$results = wp_cache_get( $key, 'post-queries' ); |
16 | 2099 |
if ( ! $results ) { |
0 | 2100 |
$results = $wpdb->get_results( $query ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2101 |
wp_cache_set( $key, $results, 'post-queries' ); |
0 | 2102 |
} |
2103 |
if ( $results ) { |
|
16 | 2104 |
$after = $parsed_args['after']; |
9 | 2105 |
foreach ( (array) $results as $result ) { |
5 | 2106 |
$url = get_year_link( $result->year ); |
16 | 2107 |
if ( 'post' !== $parsed_args['post_type'] ) { |
2108 |
$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2109 |
} |
5 | 2110 |
$text = sprintf( '%d', $result->year ); |
16 | 2111 |
if ( $parsed_args['show_post_count'] ) { |
2112 |
$parsed_args['after'] = ' (' . $result->posts . ')' . $after; |
|
5 | 2113 |
} |
16 | 2114 |
$selected = is_archive() && (string) $parsed_args['year'] === $result->year; |
2115 |
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected ); |
|
0 | 2116 |
} |
2117 |
} |
|
16 | 2118 |
} elseif ( 'daily' === $parsed_args['type'] ) { |
2119 |
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; |
|
2120 |
$key = md5( $query ); |
|
2121 |
$key = "wp_get_archives:$key:$last_changed"; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2122 |
$results = wp_cache_get( $key, 'post-queries' ); |
16 | 2123 |
if ( ! $results ) { |
0 | 2124 |
$results = $wpdb->get_results( $query ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2125 |
wp_cache_set( $key, $results, 'post-queries' ); |
0 | 2126 |
} |
2127 |
if ( $results ) { |
|
16 | 2128 |
$after = $parsed_args['after']; |
0 | 2129 |
foreach ( (array) $results as $result ) { |
9 | 2130 |
$url = get_day_link( $result->year, $result->month, $result->dayofmonth ); |
16 | 2131 |
if ( 'post' !== $parsed_args['post_type'] ) { |
2132 |
$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2133 |
} |
5 | 2134 |
$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2135 |
$text = mysql2date( get_option( 'date_format' ), $date ); |
16 | 2136 |
if ( $parsed_args['show_post_count'] ) { |
2137 |
$parsed_args['after'] = ' (' . $result->posts . ')' . $after; |
|
5 | 2138 |
} |
16 | 2139 |
$selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month && (string) $parsed_args['day'] === $result->dayofmonth; |
2140 |
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected ); |
|
0 | 2141 |
} |
2142 |
} |
|
16 | 2143 |
} elseif ( 'weekly' === $parsed_args['type'] ) { |
2144 |
$week = _wp_mysql_week( '`post_date`' ); |
|
2145 |
$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; |
|
2146 |
$key = md5( $query ); |
|
2147 |
$key = "wp_get_archives:$key:$last_changed"; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2148 |
$results = wp_cache_get( $key, 'post-queries' ); |
16 | 2149 |
if ( ! $results ) { |
0 | 2150 |
$results = $wpdb->get_results( $query ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2151 |
wp_cache_set( $key, $results, 'post-queries' ); |
0 | 2152 |
} |
2153 |
$arc_w_last = ''; |
|
2154 |
if ( $results ) { |
|
16 | 2155 |
$after = $parsed_args['after']; |
5 | 2156 |
foreach ( (array) $results as $result ) { |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2157 |
if ( $result->week !== $arc_w_last ) { |
5 | 2158 |
$arc_year = $result->yr; |
2159 |
$arc_w_last = $result->week; |
|
2160 |
$arc_week = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2161 |
$arc_week_start = date_i18n( get_option( 'date_format' ), $arc_week['start'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2162 |
$arc_week_end = date_i18n( get_option( 'date_format' ), $arc_week['end'] ); |
9 | 2163 |
$url = add_query_arg( |
2164 |
array( |
|
2165 |
'm' => $arc_year, |
|
2166 |
'w' => $result->week, |
|
2167 |
), |
|
2168 |
home_url( '/' ) |
|
2169 |
); |
|
16 | 2170 |
if ( 'post' !== $parsed_args['post_type'] ) { |
2171 |
$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2172 |
} |
9 | 2173 |
$text = $arc_week_start . $archive_week_separator . $arc_week_end; |
16 | 2174 |
if ( $parsed_args['show_post_count'] ) { |
2175 |
$parsed_args['after'] = ' (' . $result->posts . ')' . $after; |
|
0 | 2176 |
} |
16 | 2177 |
$selected = is_archive() && (string) $parsed_args['year'] === $result->yr && (string) $parsed_args['w'] === $result->week; |
2178 |
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected ); |
|
0 | 2179 |
} |
5 | 2180 |
} |
0 | 2181 |
} |
16 | 2182 |
} elseif ( ( 'postbypost' === $parsed_args['type'] ) || ( 'alpha' === $parsed_args['type'] ) ) { |
2183 |
$orderby = ( 'alpha' === $parsed_args['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC '; |
|
9 | 2184 |
$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; |
2185 |
$key = md5( $query ); |
|
2186 |
$key = "wp_get_archives:$key:$last_changed"; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2187 |
$results = wp_cache_get( $key, 'post-queries' ); |
16 | 2188 |
if ( ! $results ) { |
0 | 2189 |
$results = $wpdb->get_results( $query ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2190 |
wp_cache_set( $key, $results, 'post-queries' ); |
0 | 2191 |
} |
2192 |
if ( $results ) { |
|
2193 |
foreach ( (array) $results as $result ) { |
|
16 | 2194 |
if ( '0000-00-00 00:00:00' !== $result->post_date ) { |
5 | 2195 |
$url = get_permalink( $result ); |
0 | 2196 |
if ( $result->post_title ) { |
2197 |
/** This filter is documented in wp-includes/post-template.php */ |
|
2198 |
$text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) ); |
|
2199 |
} else { |
|
2200 |
$text = $result->ID; |
|
2201 |
} |
|
16 | 2202 |
$selected = get_the_ID() === $result->ID; |
2203 |
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected ); |
|
0 | 2204 |
} |
2205 |
} |
|
2206 |
} |
|
2207 |
} |
|
16 | 2208 |
|
2209 |
if ( $parsed_args['echo'] ) { |
|
0 | 2210 |
echo $output; |
5 | 2211 |
} else { |
0 | 2212 |
return $output; |
5 | 2213 |
} |
0 | 2214 |
} |
2215 |
||
2216 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2217 |
* Gets number of days since the start of the week. |
0 | 2218 |
* |
2219 |
* @since 1.5.0 |
|
2220 |
* |
|
2221 |
* @param int $num Number of day. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2222 |
* @return float Days since the start of the week. |
0 | 2223 |
*/ |
9 | 2224 |
function calendar_week_mod( $num ) { |
0 | 2225 |
$base = 7; |
9 | 2226 |
return ( $num - $base * floor( $num / $base ) ); |
0 | 2227 |
} |
2228 |
||
2229 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2230 |
* Displays calendar with days that have posts as links. |
0 | 2231 |
* |
2232 |
* The calendar is cached, which will be retrieved, if it exists. If there are |
|
2233 |
* no posts for the month, then it will not be displayed. |
|
2234 |
* |
|
2235 |
* @since 1.0.0 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2236 |
* @since 6.8.0 Added the `$args` parameter, with backward compatibility |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2237 |
* for the replaced `$initial` and `$display` parameters. |
0 | 2238 |
* |
16 | 2239 |
* @global wpdb $wpdb WordPress database abstraction object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2240 |
* @global int $m |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2241 |
* @global int $monthnum |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2242 |
* @global int $year |
16 | 2243 |
* @global WP_Locale $wp_locale WordPress date and time locale object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2244 |
* @global array $posts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2245 |
* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2246 |
* @param array $args { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2247 |
* Optional. Arguments for the `get_calendar` function. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2248 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2249 |
* @type bool $initial Whether to use initial calendar names. Default true. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2250 |
* @type bool $display Whether to display the calendar output. Default true. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2251 |
* @type string $post_type Optional. Post type. Default 'post'. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2252 |
* } |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2253 |
* @return void|string Void if `$display` argument is true, calendar HTML if `$display` is false. |
0 | 2254 |
*/ |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2255 |
function get_calendar( $args = array() ) { |
0 | 2256 |
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; |
2257 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2258 |
$defaults = array( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2259 |
'initial' => true, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2260 |
'display' => true, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2261 |
'post_type' => 'post', |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2262 |
); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2263 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2264 |
$original_args = func_get_args(); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2265 |
$args = array(); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2266 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2267 |
if ( ! empty( $original_args ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2268 |
if ( ! is_array( $original_args[0] ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2269 |
if ( isset( $original_args[0] ) && is_bool( $original_args[0] ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2270 |
$defaults['initial'] = $original_args[0]; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2271 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2272 |
if ( isset( $original_args[1] ) && is_bool( $original_args[1] ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2273 |
$defaults['display'] = $original_args[1]; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2274 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2275 |
} else { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2276 |
$args = $original_args[0]; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2277 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2278 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2279 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2280 |
/** |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2281 |
* Filter the `get_calendar` function arguments before they are used. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2282 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2283 |
* @since 6.8.0 |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2284 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2285 |
* @param array $args { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2286 |
* Optional. Arguments for the `get_calendar` function. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2287 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2288 |
* @type bool $initial Whether to use initial calendar names. Default true. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2289 |
* @type bool $display Whether to display the calendar output. Default true. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2290 |
* @type string $post_type Optional. Post type. Default 'post'. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2291 |
* } |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2292 |
* @return array The arguments for the `get_calendar` function. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2293 |
*/ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2294 |
$args = apply_filters( 'get_calendar_args', wp_parse_args( $args, $defaults ) ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2295 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2296 |
if ( ! post_type_exists( $args['post_type'] ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2297 |
$args['post_type'] = 'post'; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2298 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2299 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2300 |
$w = 0; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2301 |
if ( isset( $_GET['w'] ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2302 |
$w = (int) $_GET['w']; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2303 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2304 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2305 |
/* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2306 |
* Normalize the cache key. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2307 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2308 |
* The following ensures the same cache key is used for the same parameter |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2309 |
* and parameter equivalents. This prevents `post_type > post, initial > true` |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2310 |
* from generating a different key from the same values in the reverse order. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2311 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2312 |
* `display` is excluded from the cache key as the cache contains the same |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2313 |
* HTML regardless of this function's need to echo or return the output. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2314 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2315 |
* The global values contain data generated by the URL query string variables. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2316 |
*/ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2317 |
$cache_args = $args; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2318 |
unset( $cache_args['display'] ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2319 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2320 |
$cache_args['globals'] = array( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2321 |
'm' => $m, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2322 |
'monthnum' => $monthnum, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2323 |
'year' => $year, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2324 |
'week' => $w, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2325 |
); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2326 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2327 |
wp_recursive_ksort( $cache_args ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2328 |
$key = md5( serialize( $cache_args ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2329 |
$cache = wp_cache_get( 'get_calendar', 'calendar' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2330 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2331 |
if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2332 |
/** This filter is documented in wp-includes/general-template.php */ |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2333 |
$output = apply_filters( 'get_calendar', $cache[ $key ], $args ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2334 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2335 |
if ( $args['display'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2336 |
echo $output; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2337 |
return; |
0 | 2338 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2339 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2340 |
return $output; |
0 | 2341 |
} |
2342 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2343 |
if ( ! is_array( $cache ) ) { |
0 | 2344 |
$cache = array(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2345 |
} |
0 | 2346 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2347 |
$post_type = $args['post_type']; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2348 |
|
0 | 2349 |
// Quick check. If we have no posts at all, abort! |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2350 |
if ( ! $posts ) { |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2351 |
$gotsome = $wpdb->get_var( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2352 |
$wpdb->prepare( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2353 |
"SELECT 1 as test |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2354 |
FROM $wpdb->posts |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2355 |
WHERE post_type = %s |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2356 |
AND post_status = 'publish' |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2357 |
LIMIT 1", |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2358 |
$post_type |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2359 |
) |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2360 |
); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2361 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2362 |
if ( ! $gotsome ) { |
0 | 2363 |
$cache[ $key ] = ''; |
2364 |
wp_cache_set( 'get_calendar', $cache, 'calendar' ); |
|
2365 |
return; |
|
2366 |
} |
|
2367 |
} |
|
2368 |
||
16 | 2369 |
// week_begins = 0 stands for Sunday. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2370 |
$week_begins = (int) get_option( 'start_of_week' ); |
0 | 2371 |
|
16 | 2372 |
// Let's figure out when we are. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2373 |
if ( ! empty( $monthnum ) && ! empty( $year ) ) { |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2374 |
$thismonth = (int) $monthnum; |
9 | 2375 |
$thisyear = (int) $year; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2376 |
} elseif ( ! empty( $w ) ) { |
16 | 2377 |
// We need to get the month from MySQL. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2378 |
$thisyear = (int) substr( $m, 0, 4 ); |
16 | 2379 |
// It seems MySQL's weeks disagree with PHP's. |
9 | 2380 |
$d = ( ( $w - 1 ) * 7 ) + 6; |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2381 |
$thismonth = (int) $wpdb->get_var( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2382 |
$wpdb->prepare( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2383 |
"SELECT DATE_FORMAT((DATE_ADD('%d0101', INTERVAL %d DAY) ), '%%m')", |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2384 |
$thisyear, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2385 |
$d |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2386 |
) |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2387 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2388 |
} elseif ( ! empty( $m ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2389 |
$thisyear = (int) substr( $m, 0, 4 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2390 |
if ( strlen( $m ) < 6 ) { |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2391 |
$thismonth = 1; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2392 |
} else { |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2393 |
$thismonth = (int) substr( $m, 4, 2 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2394 |
} |
0 | 2395 |
} else { |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2396 |
$thisyear = (int) current_time( 'Y' ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2397 |
$thismonth = (int) current_time( 'm' ); |
0 | 2398 |
} |
2399 |
||
9 | 2400 |
$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear ); |
16 | 2401 |
$last_day = gmdate( 't', $unixmonth ); |
2402 |
||
2403 |
// Get the next and previous month and year with at least one post. |
|
9 | 2404 |
$previous = $wpdb->get_row( |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2405 |
$wpdb->prepare( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2406 |
"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2407 |
FROM $wpdb->posts |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2408 |
WHERE post_date < '%d-%d-01' |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2409 |
AND post_type = %s AND post_status = 'publish' |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2410 |
ORDER BY post_date DESC |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2411 |
LIMIT 1", |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2412 |
$thisyear, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2413 |
zeroise( $thismonth, 2 ), |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2414 |
$post_type |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2415 |
) |
9 | 2416 |
); |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2417 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2418 |
$next = $wpdb->get_row( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2419 |
$wpdb->prepare( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2420 |
"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2421 |
FROM $wpdb->posts |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2422 |
WHERE post_date > '%d-%d-%d 23:59:59' |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2423 |
AND post_type = %s AND post_status = 'publish' |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2424 |
ORDER BY post_date ASC |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2425 |
LIMIT 1", |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2426 |
$thisyear, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2427 |
zeroise( $thismonth, 2 ), |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2428 |
$last_day, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2429 |
$post_type |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2430 |
) |
9 | 2431 |
); |
0 | 2432 |
|
16 | 2433 |
/* translators: Calendar caption: 1: Month name, 2: 4-digit year. */ |
9 | 2434 |
$calendar_caption = _x( '%1$s %2$s', 'calendar caption' ); |
16 | 2435 |
$calendar_output = '<table id="wp-calendar" class="wp-calendar-table"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2436 |
<caption>' . sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2437 |
$calendar_caption, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2438 |
$wp_locale->get_month( $thismonth ), |
16 | 2439 |
gmdate( 'Y', $unixmonth ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2440 |
) . '</caption> |
0 | 2441 |
<thead> |
2442 |
<tr>'; |
|
2443 |
||
2444 |
$myweek = array(); |
|
2445 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2446 |
for ( $wdcount = 0; $wdcount <= 6; $wdcount++ ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2447 |
$myweek[] = $wp_locale->get_weekday( ( $wdcount + $week_begins ) % 7 ); |
0 | 2448 |
} |
2449 |
||
2450 |
foreach ( $myweek as $wd ) { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2451 |
$day_name = $args['initial'] ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd ); |
9 | 2452 |
$wd = esc_attr( $wd ); |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2453 |
$calendar_output .= "\n\t\t<th scope=\"col\" aria-label=\"$wd\">$day_name</th>"; |
0 | 2454 |
} |
2455 |
||
2456 |
$calendar_output .= ' |
|
2457 |
</tr> |
|
2458 |
</thead> |
|
2459 |
<tbody> |
|
2460 |
<tr>'; |
|
2461 |
||
5 | 2462 |
$daywithpost = array(); |
2463 |
||
16 | 2464 |
// Get days with posts. |
9 | 2465 |
$dayswithposts = $wpdb->get_results( |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2466 |
$wpdb->prepare( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2467 |
"SELECT DISTINCT DAYOFMONTH(post_date) |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2468 |
FROM $wpdb->posts WHERE post_date >= '%d-%d-01 00:00:00' |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2469 |
AND post_type = %s AND post_status = 'publish' |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2470 |
AND post_date <= '%d-%d-%d 23:59:59'", |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2471 |
$thisyear, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2472 |
zeroise( $thismonth, 2 ), |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2473 |
$post_type, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2474 |
$thisyear, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2475 |
zeroise( $thismonth, 2 ), |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2476 |
$last_day |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2477 |
), |
9 | 2478 |
ARRAY_N |
2479 |
); |
|
16 | 2480 |
|
0 | 2481 |
if ( $dayswithposts ) { |
2482 |
foreach ( (array) $dayswithposts as $daywith ) { |
|
16 | 2483 |
$daywithpost[] = (int) $daywith[0]; |
0 | 2484 |
} |
2485 |
} |
|
2486 |
||
16 | 2487 |
// See how much we should pad in the beginning. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2488 |
$pad = calendar_week_mod( (int) gmdate( 'w', $unixmonth ) - $week_begins ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2489 |
if ( $pad > 0 ) { |
9 | 2490 |
$calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr( $pad ) . '" class="pad"> </td>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2491 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2492 |
|
9 | 2493 |
$newrow = false; |
16 | 2494 |
$daysinmonth = (int) gmdate( 't', $unixmonth ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2495 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2496 |
for ( $day = 1; $day <= $daysinmonth; ++$day ) { |
9 | 2497 |
if ( isset( $newrow ) && $newrow ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2498 |
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2499 |
} |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2500 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2501 |
$newrow = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2502 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2503 |
if ( (int) current_time( 'j' ) === $day |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2504 |
&& (int) current_time( 'm' ) === $thismonth |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2505 |
&& (int) current_time( 'Y' ) === $thisyear |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2506 |
) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2507 |
$calendar_output .= '<td id="today">'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2508 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2509 |
$calendar_output .= '<td>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2510 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2511 |
|
16 | 2512 |
if ( in_array( $day, $daywithpost, true ) ) { |
2513 |
// Any posts today? |
|
2514 |
$date_format = gmdate( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) ); |
|
2515 |
/* translators: Post calendar label. %s: Date. */ |
|
9 | 2516 |
$label = sprintf( __( 'Posts published on %s' ), $date_format ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2517 |
$calendar_output .= sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2518 |
'<a href="%s" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2519 |
get_day_link( $thisyear, $thismonth, $day ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2520 |
esc_attr( $label ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2521 |
$day |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2522 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2523 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2524 |
$calendar_output .= $day; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2525 |
} |
16 | 2526 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2527 |
$calendar_output .= '</td>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2528 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2529 |
if ( 6 === (int) calendar_week_mod( (int) gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2530 |
$newrow = true; |
0 | 2531 |
} |
2532 |
} |
|
2533 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2534 |
$pad = 7 - calendar_week_mod( (int) gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2535 |
if ( 0 < $pad && $pad < 7 ) { |
9 | 2536 |
$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '"> </td>'; |
0 | 2537 |
} |
16 | 2538 |
|
2539 |
$calendar_output .= "\n\t</tr>\n\t</tbody>"; |
|
2540 |
||
2541 |
$calendar_output .= "\n\t</table>"; |
|
2542 |
||
2543 |
$calendar_output .= '<nav aria-label="' . __( 'Previous and next months' ) . '" class="wp-calendar-nav">'; |
|
2544 |
||
2545 |
if ( $previous ) { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2546 |
$calendar_output .= "\n\t\t" . sprintf( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2547 |
'<span class="wp-calendar-nav-prev"><a href="%1$s">« %2$s</a></span>', |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2548 |
get_month_link( $previous->year, $previous->month ), |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2549 |
$wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2550 |
); |
16 | 2551 |
} else { |
2552 |
$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-prev"> </span>'; |
|
2553 |
} |
|
2554 |
||
2555 |
$calendar_output .= "\n\t\t" . '<span class="pad"> </span>'; |
|
2556 |
||
2557 |
if ( $next ) { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2558 |
$calendar_output .= "\n\t\t" . sprintf( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2559 |
'<span class="wp-calendar-nav-next"><a href="%1$s">%2$s »</a></span>', |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2560 |
get_month_link( $next->year, $next->month ), |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2561 |
$wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2562 |
); |
16 | 2563 |
} else { |
2564 |
$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-next"> </span>'; |
|
2565 |
} |
|
2566 |
||
2567 |
$calendar_output .= ' |
|
2568 |
</nav>'; |
|
0 | 2569 |
|
2570 |
$cache[ $key ] = $calendar_output; |
|
2571 |
wp_cache_set( 'get_calendar', $cache, 'calendar' ); |
|
2572 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2573 |
/** |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2574 |
* Filters the HTML calendar output. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2575 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2576 |
* @since 3.0.0 |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2577 |
* @since 6.8.0 Added the `$args` parameter. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2578 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2579 |
* @param string $calendar_output HTML output of the calendar. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2580 |
* @param array $args { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2581 |
* Optional. Array of display arguments. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2582 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2583 |
* @type bool $initial Whether to use initial calendar names. Default true. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2584 |
* @type bool $display Whether to display the calendar output. Default true. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2585 |
* @type string $post_type Optional. Post type. Default 'post'. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2586 |
* } |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2587 |
*/ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2588 |
$calendar_output = apply_filters( 'get_calendar', $calendar_output, $args ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2589 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2590 |
if ( $args['display'] ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2591 |
echo $calendar_output; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2592 |
return; |
5 | 2593 |
} |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2594 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2595 |
return $calendar_output; |
0 | 2596 |
} |
2597 |
||
2598 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2599 |
* Purges the cached results of get_calendar. |
0 | 2600 |
* |
18 | 2601 |
* @see get_calendar() |
0 | 2602 |
* @since 2.1.0 |
2603 |
*/ |
|
2604 |
function delete_get_calendar_cache() { |
|
2605 |
wp_cache_delete( 'get_calendar', 'calendar' ); |
|
2606 |
} |
|
2607 |
||
2608 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2609 |
* Displays all of the allowed tags in HTML format with attributes. |
0 | 2610 |
* |
2611 |
* This is useful for displaying in the comment area, which elements and |
|
2612 |
* attributes are supported. As well as any plugins which want to display it. |
|
2613 |
* |
|
2614 |
* @since 1.0.1 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2615 |
* @since 4.4.0 No longer used in core. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2616 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2617 |
* @global array $allowedtags |
0 | 2618 |
* |
2619 |
* @return string HTML allowed tags entity encoded. |
|
2620 |
*/ |
|
2621 |
function allowed_tags() { |
|
2622 |
global $allowedtags; |
|
2623 |
$allowed = ''; |
|
2624 |
foreach ( (array) $allowedtags as $tag => $attributes ) { |
|
9 | 2625 |
$allowed .= '<' . $tag; |
2626 |
if ( 0 < count( $attributes ) ) { |
|
0 | 2627 |
foreach ( $attributes as $attribute => $limits ) { |
9 | 2628 |
$allowed .= ' ' . $attribute . '=""'; |
0 | 2629 |
} |
2630 |
} |
|
2631 |
$allowed .= '> '; |
|
2632 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2633 |
return htmlentities( $allowed ); |
0 | 2634 |
} |
2635 |
||
9 | 2636 |
/***** Date/Time tags */ |
0 | 2637 |
|
2638 |
/** |
|
2639 |
* Outputs the date in iso8601 format for xml files. |
|
2640 |
* |
|
2641 |
* @since 1.0.0 |
|
2642 |
*/ |
|
2643 |
function the_date_xml() { |
|
2644 |
echo mysql2date( 'Y-m-d', get_post()->post_date, false ); |
|
2645 |
} |
|
2646 |
||
2647 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2648 |
* Displays or retrieves the date of the post (once per date). |
0 | 2649 |
* |
2650 |
* Will only output the date if the current post's date is different from the |
|
2651 |
* previous one output. |
|
2652 |
* |
|
2653 |
* i.e. Only one date listing will show per day worth of posts shown in the loop, even if the |
|
2654 |
* function is called several times for each post. |
|
2655 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2656 |
* HTML output can be filtered with {@see 'the_date'}. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2657 |
* Date string output can be filtered with {@see 'get_the_date'}. |
0 | 2658 |
* |
2659 |
* @since 0.71 |
|
5 | 2660 |
* |
16 | 2661 |
* @global string $currentday The day of the current post in the loop. |
2662 |
* @global string $previousday The day of the previous post in the loop. |
|
2663 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2664 |
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2665 |
* @param string $before Optional. Output before the date. Default empty. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2666 |
* @param string $after Optional. Output after the date. Default empty. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2667 |
* @param bool $display Optional. Whether to echo the date or return it. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2668 |
* @return string|void String if retrieving. |
0 | 2669 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2670 |
function the_date( $format = '', $before = '', $after = '', $display = true ) { |
0 | 2671 |
global $currentday, $previousday; |
5 | 2672 |
|
16 | 2673 |
$the_date = ''; |
2674 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2675 |
if ( is_new_day() ) { |
16 | 2676 |
$the_date = $before . get_the_date( $format ) . $after; |
0 | 2677 |
$previousday = $currentday; |
16 | 2678 |
} |
2679 |
||
2680 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2681 |
* Filters the date of the post, for display. |
16 | 2682 |
* |
2683 |
* @since 0.71 |
|
2684 |
* |
|
2685 |
* @param string $the_date The formatted date string. |
|
18 | 2686 |
* @param string $format PHP date format. |
16 | 2687 |
* @param string $before HTML output before the date. |
2688 |
* @param string $after HTML output after the date. |
|
2689 |
*/ |
|
2690 |
$the_date = apply_filters( 'the_date', $the_date, $format, $before, $after ); |
|
2691 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2692 |
if ( $display ) { |
16 | 2693 |
echo $the_date; |
2694 |
} else { |
|
2695 |
return $the_date; |
|
0 | 2696 |
} |
2697 |
} |
|
2698 |
||
2699 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2700 |
* Retrieves the date of the post. |
0 | 2701 |
* |
2702 |
* Unlike the_date() this function will always return the date. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2703 |
* Modify output with the {@see 'get_the_date'} filter. |
0 | 2704 |
* |
2705 |
* @since 3.0.0 |
|
2706 |
* |
|
18 | 2707 |
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option. |
16 | 2708 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. |
19 | 2709 |
* @return string|int|false Date the current post was written. False on failure. |
0 | 2710 |
*/ |
16 | 2711 |
function get_the_date( $format = '', $post = null ) { |
5 | 2712 |
$post = get_post( $post ); |
2713 |
||
2714 |
if ( ! $post ) { |
|
2715 |
return false; |
|
2716 |
} |
|
0 | 2717 |
|
16 | 2718 |
$_format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
2719 |
||
2720 |
$the_date = get_post_time( $_format, false, $post, true ); |
|
0 | 2721 |
|
5 | 2722 |
/** |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2723 |
* Filters the date of the post. |
5 | 2724 |
* |
2725 |
* @since 3.0.0 |
|
2726 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2727 |
* @param string|int $the_date Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2728 |
* @param string $format PHP date format. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2729 |
* @param WP_Post $post The post object. |
5 | 2730 |
*/ |
16 | 2731 |
return apply_filters( 'get_the_date', $the_date, $format, $post ); |
0 | 2732 |
} |
2733 |
||
2734 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2735 |
* Displays the date on which the post was last modified. |
0 | 2736 |
* |
2737 |
* @since 2.1.0 |
|
2738 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2739 |
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2740 |
* @param string $before Optional. Output before the date. Default empty. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2741 |
* @param string $after Optional. Output after the date. Default empty. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2742 |
* @param bool $display Optional. Whether to echo the date or return it. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2743 |
* @return string|void String if retrieving. |
0 | 2744 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2745 |
function the_modified_date( $format = '', $before = '', $after = '', $display = true ) { |
16 | 2746 |
$the_modified_date = $before . get_the_modified_date( $format ) . $after; |
5 | 2747 |
|
2748 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2749 |
* Filters the date a post was last modified, for display. |
5 | 2750 |
* |
2751 |
* @since 2.1.0 |
|
2752 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2753 |
* @param string $the_modified_date The last modified date. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2754 |
* @param string $format PHP date format. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2755 |
* @param string $before HTML output before the date. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2756 |
* @param string $after HTML output after the date. |
5 | 2757 |
*/ |
16 | 2758 |
$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $format, $before, $after ); |
0 | 2759 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2760 |
if ( $display ) { |
0 | 2761 |
echo $the_modified_date; |
9 | 2762 |
} else { |
0 | 2763 |
return $the_modified_date; |
9 | 2764 |
} |
0 | 2765 |
} |
2766 |
||
2767 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2768 |
* Retrieves the date on which the post was last modified. |
0 | 2769 |
* |
2770 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2771 |
* @since 4.6.0 Added the `$post` parameter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2772 |
* |
18 | 2773 |
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option. |
16 | 2774 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. |
18 | 2775 |
* @return string|int|false Date the current post was modified. False on failure. |
0 | 2776 |
*/ |
16 | 2777 |
function get_the_modified_date( $format = '', $post = null ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2778 |
$post = get_post( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2779 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2780 |
if ( ! $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2781 |
// For backward compatibility, failures go through the filter below. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2782 |
$the_time = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2783 |
} else { |
16 | 2784 |
$_format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
2785 |
||
2786 |
$the_time = get_post_modified_time( $_format, false, $post, true ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2787 |
} |
5 | 2788 |
|
2789 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2790 |
* Filters the date a post was last modified. |
5 | 2791 |
* |
2792 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2793 |
* @since 4.6.0 Added the `$post` parameter. |
5 | 2794 |
* |
18 | 2795 |
* @param string|int|false $the_time The formatted date or false if no post is found. |
2796 |
* @param string $format PHP date format. |
|
2797 |
* @param WP_Post|null $post WP_Post object or null if no post is found. |
|
5 | 2798 |
*/ |
16 | 2799 |
return apply_filters( 'get_the_modified_date', $the_time, $format, $post ); |
0 | 2800 |
} |
2801 |
||
2802 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2803 |
* Displays the time of the post. |
0 | 2804 |
* |
2805 |
* @since 0.71 |
|
2806 |
* |
|
18 | 2807 |
* @param string $format Optional. Format to use for retrieving the time the post |
2808 |
* was written. Accepts 'G', 'U', or PHP date format. |
|
2809 |
* Defaults to the 'time_format' option. |
|
0 | 2810 |
*/ |
16 | 2811 |
function the_time( $format = '' ) { |
5 | 2812 |
/** |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2813 |
* Filters the time of the post, for display. |
5 | 2814 |
* |
2815 |
* @since 0.71 |
|
2816 |
* |
|
2817 |
* @param string $get_the_time The formatted time. |
|
18 | 2818 |
* @param string $format Format to use for retrieving the time the post |
2819 |
* was written. Accepts 'G', 'U', or PHP date format. |
|
5 | 2820 |
*/ |
16 | 2821 |
echo apply_filters( 'the_time', get_the_time( $format ), $format ); |
0 | 2822 |
} |
2823 |
||
2824 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2825 |
* Retrieves the time of the post. |
0 | 2826 |
* |
2827 |
* @since 1.5.0 |
|
2828 |
* |
|
16 | 2829 |
* @param string $format Optional. Format to use for retrieving the time the post |
18 | 2830 |
* was written. Accepts 'G', 'U', or PHP date format. |
2831 |
* Defaults to the 'time_format' option. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2832 |
* @param int|WP_Post $post Post ID or post object. Default is global `$post` object. |
16 | 2833 |
* @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. |
2834 |
* False on failure. |
|
0 | 2835 |
*/ |
16 | 2836 |
function get_the_time( $format = '', $post = null ) { |
9 | 2837 |
$post = get_post( $post ); |
0 | 2838 |
|
5 | 2839 |
if ( ! $post ) { |
2840 |
return false; |
|
2841 |
} |
|
2842 |
||
16 | 2843 |
$_format = ! empty( $format ) ? $format : get_option( 'time_format' ); |
2844 |
||
2845 |
$the_time = get_post_time( $_format, false, $post, true ); |
|
5 | 2846 |
|
2847 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2848 |
* Filters the time of the post. |
5 | 2849 |
* |
2850 |
* @since 1.5.0 |
|
2851 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2852 |
* @param string|int $the_time Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2853 |
* @param string $format Format to use for retrieving the time the post |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2854 |
* was written. Accepts 'G', 'U', or PHP date format. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2855 |
* @param WP_Post $post Post object. |
5 | 2856 |
*/ |
16 | 2857 |
return apply_filters( 'get_the_time', $the_time, $format, $post ); |
0 | 2858 |
} |
2859 |
||
2860 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2861 |
* Retrieves the localized time of the post. |
0 | 2862 |
* |
2863 |
* @since 2.0.0 |
|
2864 |
* |
|
16 | 2865 |
* @param string $format Optional. Format to use for retrieving the time the post |
18 | 2866 |
* was written. Accepts 'G', 'U', or PHP date format. Default 'U'. |
5 | 2867 |
* @param bool $gmt Optional. Whether to retrieve the GMT time. Default false. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2868 |
* @param int|WP_Post $post Post ID or post object. Default is global `$post` object. |
5 | 2869 |
* @param bool $translate Whether to translate the time string. Default false. |
16 | 2870 |
* @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. |
2871 |
* False on failure. |
|
0 | 2872 |
*/ |
16 | 2873 |
function get_post_time( $format = 'U', $gmt = false, $post = null, $translate = false ) { |
9 | 2874 |
$post = get_post( $post ); |
0 | 2875 |
|
5 | 2876 |
if ( ! $post ) { |
2877 |
return false; |
|
2878 |
} |
|
2879 |
||
16 | 2880 |
$source = ( $gmt ) ? 'gmt' : 'local'; |
2881 |
$datetime = get_post_datetime( $post, 'date', $source ); |
|
2882 |
||
2883 |
if ( false === $datetime ) { |
|
2884 |
return false; |
|
2885 |
} |
|
2886 |
||
2887 |
if ( 'U' === $format || 'G' === $format ) { |
|
2888 |
$time = $datetime->getTimestamp(); |
|
2889 |
||
2890 |
// Returns a sum of timestamp with timezone offset. Ideally should never be used. |
|
2891 |
if ( ! $gmt ) { |
|
2892 |
$time += $datetime->getOffset(); |
|
2893 |
} |
|
2894 |
} elseif ( $translate ) { |
|
2895 |
$time = wp_date( $format, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null ); |
|
9 | 2896 |
} else { |
16 | 2897 |
if ( $gmt ) { |
2898 |
$datetime = $datetime->setTimezone( new DateTimeZone( 'UTC' ) ); |
|
2899 |
} |
|
2900 |
||
2901 |
$time = $datetime->format( $format ); |
|
9 | 2902 |
} |
2903 |
||
5 | 2904 |
/** |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2905 |
* Filters the localized time of the post. |
5 | 2906 |
* |
2907 |
* @since 2.6.0 |
|
2908 |
* |
|
19 | 2909 |
* @param string|int $time Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
2910 |
* @param string $format Format to use for retrieving the date of the post. |
19 | 2911 |
* Accepts 'G', 'U', or PHP date format. |
2912 |
* @param bool $gmt Whether to retrieve the GMT time. |
|
5 | 2913 |
*/ |
16 | 2914 |
return apply_filters( 'get_post_time', $time, $format, $gmt ); |
2915 |
} |
|
2916 |
||
2917 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2918 |
* Retrieves post published or modified time as a `DateTimeImmutable` object instance. |
16 | 2919 |
* |
2920 |
* The object will be set to the timezone from WordPress settings. |
|
2921 |
* |
|
2922 |
* For legacy reasons, this function allows to choose to instantiate from local or UTC time in database. |
|
2923 |
* Normally this should make no difference to the result. However, the values might get out of sync in database, |
|
2924 |
* typically because of timezone setting changes. The parameter ensures the ability to reproduce backwards |
|
2925 |
* compatible behaviors in such cases. |
|
2926 |
* |
|
2927 |
* @since 5.3.0 |
|
2928 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2929 |
* @param int|WP_Post $post Optional. Post ID or post object. Default is global `$post` object. |
16 | 2930 |
* @param string $field Optional. Published or modified time to use from database. Accepts 'date' or 'modified'. |
2931 |
* Default 'date'. |
|
2932 |
* @param string $source Optional. Local or UTC time to use from database. Accepts 'local' or 'gmt'. |
|
2933 |
* Default 'local'. |
|
2934 |
* @return DateTimeImmutable|false Time object on success, false on failure. |
|
2935 |
*/ |
|
2936 |
function get_post_datetime( $post = null, $field = 'date', $source = 'local' ) { |
|
2937 |
$post = get_post( $post ); |
|
2938 |
||
2939 |
if ( ! $post ) { |
|
2940 |
return false; |
|
2941 |
} |
|
2942 |
||
2943 |
$wp_timezone = wp_timezone(); |
|
2944 |
||
2945 |
if ( 'gmt' === $source ) { |
|
2946 |
$time = ( 'modified' === $field ) ? $post->post_modified_gmt : $post->post_date_gmt; |
|
2947 |
$timezone = new DateTimeZone( 'UTC' ); |
|
2948 |
} else { |
|
2949 |
$time = ( 'modified' === $field ) ? $post->post_modified : $post->post_date; |
|
2950 |
$timezone = $wp_timezone; |
|
2951 |
} |
|
2952 |
||
2953 |
if ( empty( $time ) || '0000-00-00 00:00:00' === $time ) { |
|
2954 |
return false; |
|
2955 |
} |
|
2956 |
||
2957 |
$datetime = date_create_immutable_from_format( 'Y-m-d H:i:s', $time, $timezone ); |
|
2958 |
||
2959 |
if ( false === $datetime ) { |
|
2960 |
return false; |
|
2961 |
} |
|
2962 |
||
2963 |
return $datetime->setTimezone( $wp_timezone ); |
|
2964 |
} |
|
2965 |
||
2966 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2967 |
* Retrieves post published or modified time as a Unix timestamp. |
16 | 2968 |
* |
2969 |
* Note that this function returns a true Unix timestamp, not summed with timezone offset |
|
2970 |
* like older WP functions. |
|
2971 |
* |
|
2972 |
* @since 5.3.0 |
|
2973 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2974 |
* @param int|WP_Post $post Optional. Post ID or post object. Default is global `$post` object. |
16 | 2975 |
* @param string $field Optional. Published or modified time to use from database. Accepts 'date' or 'modified'. |
2976 |
* Default 'date'. |
|
2977 |
* @return int|false Unix timestamp on success, false on failure. |
|
2978 |
*/ |
|
2979 |
function get_post_timestamp( $post = null, $field = 'date' ) { |
|
2980 |
$datetime = get_post_datetime( $post, $field ); |
|
2981 |
||
2982 |
if ( false === $datetime ) { |
|
2983 |
return false; |
|
2984 |
} |
|
2985 |
||
2986 |
return $datetime->getTimestamp(); |
|
0 | 2987 |
} |
2988 |
||
2989 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2990 |
* Displays the time at which the post was last modified. |
0 | 2991 |
* |
2992 |
* @since 2.0.0 |
|
2993 |
* |
|
18 | 2994 |
* @param string $format Optional. Format to use for retrieving the time the post |
2995 |
* was modified. Accepts 'G', 'U', or PHP date format. |
|
2996 |
* Defaults to the 'time_format' option. |
|
0 | 2997 |
*/ |
16 | 2998 |
function the_modified_time( $format = '' ) { |
5 | 2999 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3000 |
* Filters the localized time a post was last modified, for display. |
5 | 3001 |
* |
3002 |
* @since 2.0.0 |
|
3003 |
* |
|
18 | 3004 |
* @param string|false $get_the_modified_time The formatted time or false if no post is found. |
3005 |
* @param string $format Format to use for retrieving the time the post |
|
3006 |
* was modified. Accepts 'G', 'U', or PHP date format. |
|
5 | 3007 |
*/ |
16 | 3008 |
echo apply_filters( 'the_modified_time', get_the_modified_time( $format ), $format ); |
0 | 3009 |
} |
3010 |
||
3011 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3012 |
* Retrieves the time at which the post was last modified. |
0 | 3013 |
* |
3014 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3015 |
* @since 4.6.0 Added the `$post` parameter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3016 |
* |
16 | 3017 |
* @param string $format Optional. Format to use for retrieving the time the post |
18 | 3018 |
* was modified. Accepts 'G', 'U', or PHP date format. |
3019 |
* Defaults to the 'time_format' option. |
|
16 | 3020 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. |
18 | 3021 |
* @return string|int|false Formatted date string or Unix timestamp. False on failure. |
0 | 3022 |
*/ |
16 | 3023 |
function get_the_modified_time( $format = '', $post = null ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3024 |
$post = get_post( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3025 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3026 |
if ( ! $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3027 |
// For backward compatibility, failures go through the filter below. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3028 |
$the_time = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3029 |
} else { |
16 | 3030 |
$_format = ! empty( $format ) ? $format : get_option( 'time_format' ); |
3031 |
||
3032 |
$the_time = get_post_modified_time( $_format, false, $post, true ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3033 |
} |
5 | 3034 |
|
3035 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3036 |
* Filters the localized time a post was last modified. |
5 | 3037 |
* |
3038 |
* @since 2.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3039 |
* @since 4.6.0 Added the `$post` parameter. |
5 | 3040 |
* |
18 | 3041 |
* @param string|int|false $the_time The formatted time or false if no post is found. |
3042 |
* @param string $format Format to use for retrieving the time the post |
|
3043 |
* was modified. Accepts 'G', 'U', or PHP date format. |
|
3044 |
* @param WP_Post|null $post WP_Post object or null if no post is found. |
|
5 | 3045 |
*/ |
16 | 3046 |
return apply_filters( 'get_the_modified_time', $the_time, $format, $post ); |
0 | 3047 |
} |
3048 |
||
3049 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3050 |
* Retrieves the time at which the post was last modified. |
0 | 3051 |
* |
3052 |
* @since 2.0.0 |
|
3053 |
* |
|
16 | 3054 |
* @param string $format Optional. Format to use for retrieving the time the post |
18 | 3055 |
* was modified. Accepts 'G', 'U', or PHP date format. Default 'U'. |
5 | 3056 |
* @param bool $gmt Optional. Whether to retrieve the GMT time. Default false. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3057 |
* @param int|WP_Post $post Post ID or post object. Default is global `$post` object. |
5 | 3058 |
* @param bool $translate Whether to translate the time string. Default false. |
16 | 3059 |
* @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. |
3060 |
* False on failure. |
|
0 | 3061 |
*/ |
16 | 3062 |
function get_post_modified_time( $format = 'U', $gmt = false, $post = null, $translate = false ) { |
9 | 3063 |
$post = get_post( $post ); |
0 | 3064 |
|
5 | 3065 |
if ( ! $post ) { |
3066 |
return false; |
|
3067 |
} |
|
3068 |
||
16 | 3069 |
$source = ( $gmt ) ? 'gmt' : 'local'; |
3070 |
$datetime = get_post_datetime( $post, 'modified', $source ); |
|
3071 |
||
3072 |
if ( false === $datetime ) { |
|
3073 |
return false; |
|
3074 |
} |
|
3075 |
||
3076 |
if ( 'U' === $format || 'G' === $format ) { |
|
3077 |
$time = $datetime->getTimestamp(); |
|
3078 |
||
3079 |
// Returns a sum of timestamp with timezone offset. Ideally should never be used. |
|
3080 |
if ( ! $gmt ) { |
|
3081 |
$time += $datetime->getOffset(); |
|
3082 |
} |
|
3083 |
} elseif ( $translate ) { |
|
3084 |
$time = wp_date( $format, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null ); |
|
9 | 3085 |
} else { |
16 | 3086 |
if ( $gmt ) { |
3087 |
$datetime = $datetime->setTimezone( new DateTimeZone( 'UTC' ) ); |
|
3088 |
} |
|
3089 |
||
3090 |
$time = $datetime->format( $format ); |
|
9 | 3091 |
} |
0 | 3092 |
|
5 | 3093 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3094 |
* Filters the localized time a post was last modified. |
5 | 3095 |
* |
3096 |
* @since 2.8.0 |
|
3097 |
* |
|
18 | 3098 |
* @param string|int $time Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. |
3099 |
* @param string $format Format to use for retrieving the time the post was modified. |
|
3100 |
* Accepts 'G', 'U', or PHP date format. Default 'U'. |
|
3101 |
* @param bool $gmt Whether to retrieve the GMT time. Default false. |
|
5 | 3102 |
*/ |
16 | 3103 |
return apply_filters( 'get_post_modified_time', $time, $format, $gmt ); |
0 | 3104 |
} |
3105 |
||
3106 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3107 |
* Displays the localized weekday for the post. |
0 | 3108 |
* |
3109 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3110 |
* |
16 | 3111 |
* @global WP_Locale $wp_locale WordPress date and time locale object. |
0 | 3112 |
*/ |
3113 |
function the_weekday() { |
|
3114 |
global $wp_locale; |
|
16 | 3115 |
|
3116 |
$post = get_post(); |
|
3117 |
||
3118 |
if ( ! $post ) { |
|
3119 |
return; |
|
3120 |
} |
|
3121 |
||
3122 |
$the_weekday = $wp_locale->get_weekday( get_post_time( 'w', false, $post ) ); |
|
5 | 3123 |
|
3124 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3125 |
* Filters the localized weekday of the post, for display. |
5 | 3126 |
* |
3127 |
* @since 0.71 |
|
3128 |
* |
|
3129 |
* @param string $the_weekday |
|
3130 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3131 |
echo apply_filters( 'the_weekday', $the_weekday ); |
0 | 3132 |
} |
3133 |
||
3134 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3135 |
* Displays the localized weekday for the post. |
0 | 3136 |
* |
3137 |
* Will only output the weekday if the current post's weekday is different from |
|
3138 |
* the previous one output. |
|
3139 |
* |
|
3140 |
* @since 0.71 |
|
3141 |
* |
|
16 | 3142 |
* @global WP_Locale $wp_locale WordPress date and time locale object. |
3143 |
* @global string $currentday The day of the current post in the loop. |
|
3144 |
* @global string $previousweekday The day of the previous post in the loop. |
|
3145 |
* |
|
18 | 3146 |
* @param string $before Optional. Output before the date. Default empty. |
3147 |
* @param string $after Optional. Output after the date. Default empty. |
|
0 | 3148 |
*/ |
9 | 3149 |
function the_weekday_date( $before = '', $after = '' ) { |
0 | 3150 |
global $wp_locale, $currentday, $previousweekday; |
16 | 3151 |
|
3152 |
$post = get_post(); |
|
3153 |
||
3154 |
if ( ! $post ) { |
|
3155 |
return; |
|
3156 |
} |
|
3157 |
||
0 | 3158 |
$the_weekday_date = ''; |
16 | 3159 |
|
3160 |
if ( $currentday !== $previousweekday ) { |
|
0 | 3161 |
$the_weekday_date .= $before; |
16 | 3162 |
$the_weekday_date .= $wp_locale->get_weekday( get_post_time( 'w', false, $post ) ); |
0 | 3163 |
$the_weekday_date .= $after; |
9 | 3164 |
$previousweekday = $currentday; |
0 | 3165 |
} |
5 | 3166 |
|
3167 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3168 |
* Filters the localized weekday of the post, for display. |
5 | 3169 |
* |
3170 |
* @since 0.71 |
|
3171 |
* |
|
16 | 3172 |
* @param string $the_weekday_date The weekday on which the post was written. |
5 | 3173 |
* @param string $before The HTML to output before the date. |
3174 |
* @param string $after The HTML to output after the date. |
|
3175 |
*/ |
|
16 | 3176 |
echo apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after ); |
0 | 3177 |
} |
3178 |
||
3179 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3180 |
* Fires the wp_head action. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3181 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3182 |
* See {@see 'wp_head'}. |
0 | 3183 |
* |
3184 |
* @since 1.2.0 |
|
3185 |
*/ |
|
3186 |
function wp_head() { |
|
5 | 3187 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3188 |
* Prints scripts or data in the head tag on the front end. |
5 | 3189 |
* |
3190 |
* @since 1.5.0 |
|
3191 |
*/ |
|
3192 |
do_action( 'wp_head' ); |
|
0 | 3193 |
} |
3194 |
||
3195 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3196 |
* Fires the wp_footer action. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3197 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3198 |
* See {@see 'wp_footer'}. |
0 | 3199 |
* |
3200 |
* @since 1.5.1 |
|
3201 |
*/ |
|
3202 |
function wp_footer() { |
|
5 | 3203 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3204 |
* Prints scripts or data before the closing body tag on the front end. |
5 | 3205 |
* |
3206 |
* @since 1.5.1 |
|
3207 |
*/ |
|
3208 |
do_action( 'wp_footer' ); |
|
0 | 3209 |
} |
3210 |
||
3211 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3212 |
* Fires the wp_body_open action. |
9 | 3213 |
* |
16 | 3214 |
* See {@see 'wp_body_open'}. |
9 | 3215 |
* |
3216 |
* @since 5.2.0 |
|
3217 |
*/ |
|
3218 |
function wp_body_open() { |
|
3219 |
/** |
|
16 | 3220 |
* Triggered after the opening body tag. |
9 | 3221 |
* |
3222 |
* @since 5.2.0 |
|
3223 |
*/ |
|
3224 |
do_action( 'wp_body_open' ); |
|
3225 |
} |
|
3226 |
||
3227 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3228 |
* Displays the links to the general feeds. |
0 | 3229 |
* |
3230 |
* @since 2.8.0 |
|
3231 |
* |
|
3232 |
* @param array $args Optional arguments. |
|
3233 |
*/ |
|
3234 |
function feed_links( $args = array() ) { |
|
9 | 3235 |
if ( ! current_theme_supports( 'automatic-feed-links' ) ) { |
0 | 3236 |
return; |
9 | 3237 |
} |
0 | 3238 |
|
3239 |
$defaults = array( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3240 |
/* translators: Separator between site name and feed type in feed links. */ |
9 | 3241 |
'separator' => _x( '»', 'feed link' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3242 |
/* translators: 1: Site title, 2: Separator (raquo). */ |
9 | 3243 |
'feedtitle' => __( '%1$s %2$s Feed' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3244 |
/* translators: 1: Site title, 2: Separator (raquo). */ |
9 | 3245 |
'comstitle' => __( '%1$s %2$s Comments Feed' ), |
0 | 3246 |
); |
3247 |
||
3248 |
$args = wp_parse_args( $args, $defaults ); |
|
3249 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3250 |
/** |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3251 |
* Filters the feed links arguments. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3252 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3253 |
* @since 6.7.0 |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3254 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3255 |
* @param array $args An array of feed links arguments. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3256 |
*/ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3257 |
$args = apply_filters( 'feed_links_args', $args ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3258 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3259 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3260 |
* Filters whether to display the posts feed link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3261 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3262 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3263 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3264 |
* @param bool $show Whether to display the posts feed link. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3265 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3266 |
if ( apply_filters( 'feed_links_show_posts_feed', true ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3267 |
printf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3268 |
'<link rel="alternate" type="%s" title="%s" href="%s" />' . "\n", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3269 |
feed_content_type(), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3270 |
esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3271 |
esc_url( get_feed_link() ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3272 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3273 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3274 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3275 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3276 |
* Filters whether to display the comments feed link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3277 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3278 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3279 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3280 |
* @param bool $show Whether to display the comments feed link. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3281 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3282 |
if ( apply_filters( 'feed_links_show_comments_feed', true ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3283 |
printf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3284 |
'<link rel="alternate" type="%s" title="%s" href="%s" />' . "\n", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3285 |
feed_content_type(), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3286 |
esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3287 |
esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3288 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3289 |
} |
0 | 3290 |
} |
3291 |
||
3292 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3293 |
* Displays the links to the extra feeds such as category feeds. |
0 | 3294 |
* |
3295 |
* @since 2.8.0 |
|
3296 |
* |
|
3297 |
* @param array $args Optional arguments. |
|
3298 |
*/ |
|
3299 |
function feed_links_extra( $args = array() ) { |
|
3300 |
$defaults = array( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3301 |
/* translators: Separator between site name and feed type in feed links. */ |
9 | 3302 |
'separator' => _x( '»', 'feed link' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3303 |
/* translators: 1: Site name, 2: Separator (raquo), 3: Post title. */ |
9 | 3304 |
'singletitle' => __( '%1$s %2$s %3$s Comments Feed' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3305 |
/* translators: 1: Site name, 2: Separator (raquo), 3: Category name. */ |
9 | 3306 |
'cattitle' => __( '%1$s %2$s %3$s Category Feed' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3307 |
/* translators: 1: Site name, 2: Separator (raquo), 3: Tag name. */ |
9 | 3308 |
'tagtitle' => __( '%1$s %2$s %3$s Tag Feed' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3309 |
/* translators: 1: Site name, 2: Separator (raquo), 3: Term name, 4: Taxonomy singular name. */ |
9 | 3310 |
'taxtitle' => __( '%1$s %2$s %3$s %4$s Feed' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3311 |
/* translators: 1: Site name, 2: Separator (raquo), 3: Author name. */ |
9 | 3312 |
'authortitle' => __( '%1$s %2$s Posts by %3$s Feed' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3313 |
/* translators: 1: Site name, 2: Separator (raquo), 3: Search query. */ |
9 | 3314 |
'searchtitle' => __( '%1$s %2$s Search Results for “%3$s” Feed' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3315 |
/* translators: 1: Site name, 2: Separator (raquo), 3: Post type name. */ |
9 | 3316 |
'posttypetitle' => __( '%1$s %2$s %3$s Feed' ), |
0 | 3317 |
); |
3318 |
||
3319 |
$args = wp_parse_args( $args, $defaults ); |
|
3320 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3321 |
/** |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3322 |
* Filters the extra feed links arguments. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3323 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3324 |
* @since 6.7.0 |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3325 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3326 |
* @param array $args An array of extra feed links arguments. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3327 |
*/ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3328 |
$args = apply_filters( 'feed_links_extra_args', $args ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3329 |
|
0 | 3330 |
if ( is_singular() ) { |
9 | 3331 |
$id = 0; |
0 | 3332 |
$post = get_post( $id ); |
3333 |
||
19 | 3334 |
/** This filter is documented in wp-includes/general-template.php */ |
3335 |
$show_comments_feed = apply_filters( 'feed_links_show_comments_feed', true ); |
|
3336 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3337 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3338 |
* Filters whether to display the post comments feed link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3339 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3340 |
* This filter allows to enable or disable the feed link for a singular post |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3341 |
* in a way that is independent of {@see 'feed_links_show_comments_feed'} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3342 |
* (which controls the global comments feed). The result of that filter |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3343 |
* is accepted as a parameter. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3344 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3345 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3346 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3347 |
* @param bool $show_comments_feed Whether to display the post comments feed link. Defaults to |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3348 |
* the {@see 'feed_links_show_comments_feed'} filter result. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3349 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3350 |
$show_post_comments_feed = apply_filters( 'feed_links_extra_show_post_comments_feed', $show_comments_feed ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3351 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3352 |
if ( $show_post_comments_feed && ( comments_open() || pings_open() || $post->comment_count > 0 ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3353 |
$title = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3354 |
$args['singletitle'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3355 |
get_bloginfo( 'name' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3356 |
$args['separator'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3357 |
the_title_attribute( array( 'echo' => false ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3358 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3359 |
|
19 | 3360 |
$feed_link = get_post_comments_feed_link( $post->ID ); |
3361 |
||
3362 |
if ( $feed_link ) { |
|
3363 |
$href = $feed_link; |
|
3364 |
} |
|
0 | 3365 |
} |
3366 |
} elseif ( is_post_type_archive() ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3367 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3368 |
* Filters whether to display the post type archive feed link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3369 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3370 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3371 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3372 |
* @param bool $show Whether to display the post type archive feed link. Default true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3373 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3374 |
$show_post_type_archive_feed = apply_filters( 'feed_links_extra_show_post_type_archive_feed', true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3375 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3376 |
if ( $show_post_type_archive_feed ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3377 |
$post_type = get_query_var( 'post_type' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3378 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3379 |
if ( is_array( $post_type ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3380 |
$post_type = reset( $post_type ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3381 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3382 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3383 |
$post_type_obj = get_post_type_object( $post_type ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3384 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3385 |
$title = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3386 |
$args['posttypetitle'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3387 |
get_bloginfo( 'name' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3388 |
$args['separator'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3389 |
$post_type_obj->labels->name |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3390 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3391 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3392 |
$href = get_post_type_archive_feed_link( $post_type_obj->name ); |
9 | 3393 |
} |
0 | 3394 |
} elseif ( is_category() ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3395 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3396 |
* Filters whether to display the category feed link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3397 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3398 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3399 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3400 |
* @param bool $show Whether to display the category feed link. Default true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3401 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3402 |
$show_category_feed = apply_filters( 'feed_links_extra_show_category_feed', true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3403 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3404 |
if ( $show_category_feed ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3405 |
$term = get_queried_object(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3406 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3407 |
if ( $term ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3408 |
$title = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3409 |
$args['cattitle'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3410 |
get_bloginfo( 'name' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3411 |
$args['separator'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3412 |
$term->name |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3413 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3414 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3415 |
$href = get_category_feed_link( $term->term_id ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3416 |
} |
0 | 3417 |
} |
3418 |
} elseif ( is_tag() ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3419 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3420 |
* Filters whether to display the tag feed link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3421 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3422 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3423 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3424 |
* @param bool $show Whether to display the tag feed link. Default true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3425 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3426 |
$show_tag_feed = apply_filters( 'feed_links_extra_show_tag_feed', true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3427 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3428 |
if ( $show_tag_feed ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3429 |
$term = get_queried_object(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3430 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3431 |
if ( $term ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3432 |
$title = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3433 |
$args['tagtitle'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3434 |
get_bloginfo( 'name' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3435 |
$args['separator'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3436 |
$term->name |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3437 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3438 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3439 |
$href = get_tag_feed_link( $term->term_id ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3440 |
} |
0 | 3441 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3442 |
} elseif ( is_tax() ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3443 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3444 |
* Filters whether to display the custom taxonomy feed link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3445 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3446 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3447 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3448 |
* @param bool $show Whether to display the custom taxonomy feed link. Default true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3449 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3450 |
$show_tax_feed = apply_filters( 'feed_links_extra_show_tax_feed', true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3451 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3452 |
if ( $show_tax_feed ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3453 |
$term = get_queried_object(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3454 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3455 |
if ( $term ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3456 |
$tax = get_taxonomy( $term->taxonomy ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3457 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3458 |
$title = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3459 |
$args['taxtitle'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3460 |
get_bloginfo( 'name' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3461 |
$args['separator'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3462 |
$term->name, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3463 |
$tax->labels->singular_name |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3464 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3465 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3466 |
$href = get_term_feed_link( $term->term_id, $term->taxonomy ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3467 |
} |
16 | 3468 |
} |
0 | 3469 |
} elseif ( is_author() ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3470 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3471 |
* Filters whether to display the author feed link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3472 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3473 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3474 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3475 |
* @param bool $show Whether to display the author feed link. Default true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3476 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3477 |
$show_author_feed = apply_filters( 'feed_links_extra_show_author_feed', true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3478 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3479 |
if ( $show_author_feed ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3480 |
$author_id = (int) get_query_var( 'author' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3481 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3482 |
$title = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3483 |
$args['authortitle'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3484 |
get_bloginfo( 'name' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3485 |
$args['separator'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3486 |
get_the_author_meta( 'display_name', $author_id ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3487 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3488 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3489 |
$href = get_author_feed_link( $author_id ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3490 |
} |
0 | 3491 |
} elseif ( is_search() ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3492 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3493 |
* Filters whether to display the search results feed link. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3494 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3495 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3496 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3497 |
* @param bool $show Whether to display the search results feed link. Default true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3498 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3499 |
$show_search_feed = apply_filters( 'feed_links_extra_show_search_feed', true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3500 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3501 |
if ( $show_search_feed ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3502 |
$title = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3503 |
$args['searchtitle'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3504 |
get_bloginfo( 'name' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3505 |
$args['separator'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3506 |
get_search_query( false ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3507 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3508 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3509 |
$href = get_search_feed_link(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3510 |
} |
0 | 3511 |
} |
3512 |
||
9 | 3513 |
if ( isset( $title ) && isset( $href ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3514 |
printf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3515 |
'<link rel="alternate" type="%s" title="%s" href="%s" />' . "\n", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3516 |
feed_content_type(), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3517 |
esc_attr( $title ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3518 |
esc_url( $href ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3519 |
); |
9 | 3520 |
} |
0 | 3521 |
} |
3522 |
||
3523 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3524 |
* Displays the link to the Really Simple Discovery service endpoint. |
0 | 3525 |
* |
3526 |
* @link http://archipelago.phrasewise.com/rsd |
|
3527 |
* @since 2.0.0 |
|
3528 |
*/ |
|
3529 |
function rsd_link() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3530 |
printf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3531 |
'<link rel="EditURI" type="application/rsd+xml" title="RSD" href="%s" />' . "\n", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3532 |
esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3533 |
); |
0 | 3534 |
} |
3535 |
||
3536 |
/** |
|
19 | 3537 |
* Displays a referrer `strict-origin-when-cross-origin` meta tag. |
3538 |
* |
|
3539 |
* Outputs a referrer `strict-origin-when-cross-origin` meta tag that tells the browser not to send |
|
3540 |
* the full URL as a referrer to other sites when cross-origin assets are loaded. |
|
3541 |
* |
|
3542 |
* Typical usage is as a {@see 'wp_head'} callback: |
|
3543 |
* |
|
3544 |
* add_action( 'wp_head', 'wp_strict_cross_origin_referrer' ); |
|
18 | 3545 |
* |
3546 |
* @since 5.7.0 |
|
9 | 3547 |
*/ |
18 | 3548 |
function wp_strict_cross_origin_referrer() { |
9 | 3549 |
?> |
3550 |
<meta name='referrer' content='strict-origin-when-cross-origin' /> |
|
3551 |
<?php |
|
3552 |
} |
|
3553 |
||
3554 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3555 |
* Displays site icon meta tags. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3556 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3557 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3558 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3559 |
* @link https://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#rel-icon HTML5 specification link icon. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3560 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3561 |
function wp_site_icon() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3562 |
if ( ! has_site_icon() && ! is_customize_preview() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3563 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3564 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3565 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3566 |
$meta_tags = array(); |
9 | 3567 |
$icon_32 = get_site_icon_url( 32 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3568 |
if ( empty( $icon_32 ) && is_customize_preview() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3569 |
$icon_32 = '/favicon.ico'; // Serve default favicon URL in customizer so element can be updated for preview. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3570 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3571 |
if ( $icon_32 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3572 |
$meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( $icon_32 ) ); |
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 |
$icon_192 = get_site_icon_url( 192 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3575 |
if ( $icon_192 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3576 |
$meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="192x192" />', esc_url( $icon_192 ) ); |
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 |
$icon_180 = get_site_icon_url( 180 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3579 |
if ( $icon_180 ) { |
16 | 3580 |
$meta_tags[] = sprintf( '<link rel="apple-touch-icon" href="%s" />', esc_url( $icon_180 ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3581 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3582 |
$icon_270 = get_site_icon_url( 270 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3583 |
if ( $icon_270 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3584 |
$meta_tags[] = sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( $icon_270 ) ); |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3587 |
/** |
9 | 3588 |
* Filters the site icon meta tags, so plugins can add their own. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3589 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3590 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3591 |
* |
9 | 3592 |
* @param string[] $meta_tags Array of Site Icon meta tags. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3593 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3594 |
$meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3595 |
$meta_tags = array_filter( $meta_tags ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3596 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3597 |
foreach ( $meta_tags as $meta_tag ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3598 |
echo "$meta_tag\n"; |
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 |
} |
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 |
* Prints resource hints to browsers for pre-fetching, pre-rendering |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3604 |
* and pre-connecting to websites. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3605 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3606 |
* Gives hints to browsers to prefetch specific pages or render them |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3607 |
* in the background, to perform DNS lookups or to begin the connection |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3608 |
* handshake (DNS, TCP, TLS) in the background. |
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 |
* These performance improving indicators work by using `<link rel"…">`. |
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 |
* @since 4.6.0 |
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 |
function wp_resource_hints() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3615 |
$hints = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3616 |
'dns-prefetch' => wp_dependencies_unique_hosts(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3617 |
'preconnect' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3618 |
'prefetch' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3619 |
'prerender' => array(), |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3622 |
foreach ( $hints as $relation_type => $urls ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3623 |
$unique_urls = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3624 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3625 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3626 |
* Filters domains and URLs for resource hints of the given relation type. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3627 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3628 |
* @since 4.6.0 |
18 | 3629 |
* @since 4.7.0 The `$urls` parameter accepts arrays of specific HTML attributes |
3630 |
* as its child elements. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3631 |
* |
18 | 3632 |
* @param array $urls { |
3633 |
* Array of resources and their attributes, or URLs to print for resource hints. |
|
3634 |
* |
|
3635 |
* @type array|string ...$0 { |
|
3636 |
* Array of resource attributes, or a URL string. |
|
3637 |
* |
|
3638 |
* @type string $href URL to include in resource hints. Required. |
|
3639 |
* @type string $as How the browser should treat the resource |
|
3640 |
* (`script`, `style`, `image`, `document`, etc). |
|
3641 |
* @type string $crossorigin Indicates the CORS policy of the specified resource. |
|
3642 |
* @type float $pr Expected probability that the resource hint will be used. |
|
3643 |
* @type string $type Type of the resource (`text/html`, `text/css`, etc). |
|
3644 |
* } |
|
3645 |
* } |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3646 |
* @param string $relation_type The relation type the URLs are printed for. One of |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3647 |
* 'dns-prefetch', 'preconnect', 'prefetch', or 'prerender'. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3648 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3649 |
$urls = apply_filters( 'wp_resource_hints', $urls, $relation_type ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3650 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3651 |
foreach ( $urls as $key => $url ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3652 |
$atts = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3653 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3654 |
if ( is_array( $url ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3655 |
if ( isset( $url['href'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3656 |
$atts = $url; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3657 |
$url = $url['href']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3658 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3659 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3660 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3661 |
} |
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 |
$url = esc_url( $url, array( 'http', 'https' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3664 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3665 |
if ( ! $url ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3666 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3667 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3668 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3669 |
if ( isset( $unique_urls[ $url ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3670 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3671 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3672 |
|
16 | 3673 |
if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ), true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3674 |
$parsed = wp_parse_url( $url ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3675 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3676 |
if ( empty( $parsed['host'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3677 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3678 |
} |
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 ( 'preconnect' === $relation_type && ! empty( $parsed['scheme'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3681 |
$url = $parsed['scheme'] . '://' . $parsed['host']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3682 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3683 |
// Use protocol-relative URLs for dns-prefetch or if scheme is missing. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3684 |
$url = '//' . $parsed['host']; |
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 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3687 |
|
9 | 3688 |
$atts['rel'] = $relation_type; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3689 |
$atts['href'] = $url; |
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 |
$unique_urls[ $url ] = $atts; |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3694 |
foreach ( $unique_urls as $atts ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3695 |
$html = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3696 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3697 |
foreach ( $atts as $attr => $value ) { |
16 | 3698 |
if ( ! is_scalar( $value ) |
3699 |
|| ( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr ) ) |
|
3700 |
) { |
|
9 | 3701 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3702 |
continue; |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3705 |
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3706 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3707 |
if ( ! is_string( $attr ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3708 |
$html .= " $value"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3709 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3710 |
$html .= " $attr='$value'"; |
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 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3713 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3714 |
$html = trim( $html ); |
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 |
echo "<link $html />\n"; |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3721 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3722 |
* Prints resource preloads directives to browsers. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3723 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3724 |
* Gives directive to browsers to preload specific resources that website will |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3725 |
* need very soon, this ensures that they are available earlier and are less |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3726 |
* likely to block the page's render. Preload directives should not be used for |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3727 |
* non-render-blocking elements, as then they would compete with the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3728 |
* render-blocking ones, slowing down the render. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3729 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3730 |
* These performance improving indicators work by using `<link rel="preload">`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3731 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3732 |
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3733 |
* @link https://web.dev/preload-responsive-images/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3734 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3735 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3736 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3737 |
function wp_preload_resources() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3738 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3739 |
* Filters domains and URLs for resource preloads. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3740 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3741 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3742 |
* @since 6.6.0 Added the `$fetchpriority` attribute. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3743 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3744 |
* @param array $preload_resources { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3745 |
* Array of resources and their attributes, or URLs to print for resource preloads. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3746 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3747 |
* @type array ...$0 { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3748 |
* Array of resource attributes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3749 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3750 |
* @type string $href URL to include in resource preloads. Required. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3751 |
* @type string $as How the browser should treat the resource |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3752 |
* (`script`, `style`, `image`, `document`, etc). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3753 |
* @type string $crossorigin Indicates the CORS policy of the specified resource. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3754 |
* @type string $type Type of the resource (`text/html`, `text/css`, etc). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3755 |
* @type string $media Accepts media types or media queries. Allows responsive preloading. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3756 |
* @type string $imagesizes Responsive source size to the source Set. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3757 |
* @type string $imagesrcset Responsive image sources to the source set. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3758 |
* @type string $fetchpriority Fetchpriority value for the resource. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3759 |
* } |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3760 |
* } |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3761 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3762 |
$preload_resources = apply_filters( 'wp_preload_resources', array() ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3763 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3764 |
if ( ! is_array( $preload_resources ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3765 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3766 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3767 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3768 |
$unique_resources = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3769 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3770 |
// Parse the complete resource list and extract unique resources. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3771 |
foreach ( $preload_resources as $resource ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3772 |
if ( ! is_array( $resource ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3773 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3774 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3775 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3776 |
$attributes = $resource; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3777 |
if ( isset( $resource['href'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3778 |
$href = $resource['href']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3779 |
if ( isset( $unique_resources[ $href ] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3780 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3781 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3782 |
$unique_resources[ $href ] = $attributes; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3783 |
// Media can use imagesrcset and not href. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3784 |
} elseif ( ( 'image' === $resource['as'] ) && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3785 |
( isset( $resource['imagesrcset'] ) || isset( $resource['imagesizes'] ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3786 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3787 |
if ( isset( $unique_resources[ $resource['imagesrcset'] ] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3788 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3789 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3790 |
$unique_resources[ $resource['imagesrcset'] ] = $attributes; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3791 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3792 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3793 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3794 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3795 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3796 |
// Build and output the HTML for each unique resource. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3797 |
foreach ( $unique_resources as $unique_resource ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3798 |
$html = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3799 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3800 |
foreach ( $unique_resource as $resource_key => $resource_value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3801 |
if ( ! is_scalar( $resource_value ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3802 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3803 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3804 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3805 |
// Ignore non-supported attributes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3806 |
$non_supported_attributes = array( 'as', 'crossorigin', 'href', 'imagesrcset', 'imagesizes', 'type', 'media', 'fetchpriority' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3807 |
if ( ! in_array( $resource_key, $non_supported_attributes, true ) && ! is_numeric( $resource_key ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3808 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3809 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3810 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3811 |
// imagesrcset only usable when preloading image, ignore otherwise. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3812 |
if ( ( 'imagesrcset' === $resource_key ) && ( ! isset( $unique_resource['as'] ) || ( 'image' !== $unique_resource['as'] ) ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3813 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3814 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3815 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3816 |
// imagesizes only usable when preloading image and imagesrcset present, ignore otherwise. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3817 |
if ( ( 'imagesizes' === $resource_key ) && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3818 |
( ! isset( $unique_resource['as'] ) || ( 'image' !== $unique_resource['as'] ) || ! isset( $unique_resource['imagesrcset'] ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3819 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3820 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3821 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3822 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3823 |
$resource_value = ( 'href' === $resource_key ) ? esc_url( $resource_value, array( 'http', 'https' ) ) : esc_attr( $resource_value ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3824 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3825 |
if ( ! is_string( $resource_key ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3826 |
$html .= " $resource_value"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3827 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3828 |
$html .= " $resource_key='$resource_value'"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3829 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3830 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3831 |
$html = trim( $html ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3832 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3833 |
printf( "<link rel='preload' %s />\n", $html ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3834 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3835 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3836 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3837 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3838 |
* Retrieves a list of unique hosts of all enqueued scripts and styles. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3839 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3840 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3841 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3842 |
* @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3843 |
* @global WP_Styles $wp_styles The WP_Styles object for printing styles. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3844 |
* |
16 | 3845 |
* @return string[] A list of unique hosts of enqueued scripts and styles. |
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 |
function wp_dependencies_unique_hosts() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3848 |
global $wp_scripts, $wp_styles; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3849 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3850 |
$unique_hosts = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3851 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3852 |
foreach ( array( $wp_scripts, $wp_styles ) as $dependencies ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3853 |
if ( $dependencies instanceof WP_Dependencies && ! empty( $dependencies->queue ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3854 |
foreach ( $dependencies->queue as $handle ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3855 |
if ( ! isset( $dependencies->registered[ $handle ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3856 |
continue; |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3859 |
/* @var _WP_Dependency $dependency */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3860 |
$dependency = $dependencies->registered[ $handle ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3861 |
$parsed = wp_parse_url( $dependency->src ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3862 |
|
16 | 3863 |
if ( ! empty( $parsed['host'] ) |
3864 |
&& ! in_array( $parsed['host'], $unique_hosts, true ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] |
|
3865 |
) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3866 |
$unique_hosts[] = $parsed['host']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3867 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3868 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3869 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3870 |
} |
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 |
return $unique_hosts; |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3875 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3876 |
* Determines whether the user can access the visual editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3877 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3878 |
* Checks if the user can access the visual editor and that it's supported by the user's browser. |
0 | 3879 |
* |
3880 |
* @since 2.0.0 |
|
3881 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3882 |
* @global bool $wp_rich_edit Whether the user can access the visual editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3883 |
* @global bool $is_gecko Whether the browser is Gecko-based. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3884 |
* @global bool $is_opera Whether the browser is Opera. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3885 |
* @global bool $is_safari Whether the browser is Safari. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3886 |
* @global bool $is_chrome Whether the browser is Chrome. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3887 |
* @global bool $is_IE Whether the browser is Internet Explorer. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3888 |
* @global bool $is_edge Whether the browser is Microsoft Edge. |
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 bool True if the user can access the visual editor, false otherwise. |
0 | 3891 |
*/ |
3892 |
function user_can_richedit() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3893 |
global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge; |
0 | 3894 |
|
9 | 3895 |
if ( ! isset( $wp_rich_edit ) ) { |
0 | 3896 |
$wp_rich_edit = false; |
3897 |
||
16 | 3898 |
if ( 'true' === get_user_option( 'rich_editing' ) || ! is_user_logged_in() ) { // Default to 'true' for logged out users. |
0 | 3899 |
if ( $is_safari ) { |
18 | 3900 |
$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && (int) $match[1] >= 534 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3901 |
} elseif ( $is_IE ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3902 |
$wp_rich_edit = str_contains( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ); |
9 | 3903 |
} elseif ( $is_gecko || $is_chrome || $is_edge || ( $is_opera && ! wp_is_mobile() ) ) { |
0 | 3904 |
$wp_rich_edit = true; |
3905 |
} |
|
3906 |
} |
|
3907 |
} |
|
3908 |
||
5 | 3909 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3910 |
* Filters whether the user can access the visual editor. |
5 | 3911 |
* |
3912 |
* @since 2.1.0 |
|
3913 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3914 |
* @param bool $wp_rich_edit Whether the user can access the visual editor. |
5 | 3915 |
*/ |
3916 |
return apply_filters( 'user_can_richedit', $wp_rich_edit ); |
|
0 | 3917 |
} |
3918 |
||
3919 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3920 |
* Finds out which editor should be displayed by default. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3921 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3922 |
* Works out which of the editors to display as the current editor for a |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
3923 |
* user. The 'html' setting is for the "Code" editor tab. |
0 | 3924 |
* |
3925 |
* @since 2.5.0 |
|
3926 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3927 |
* @return string Either 'tinymce', 'html', or 'test' |
0 | 3928 |
*/ |
3929 |
function wp_default_editor() { |
|
16 | 3930 |
$r = user_can_richedit() ? 'tinymce' : 'html'; // Defaults. |
3931 |
if ( wp_get_current_user() ) { // Look for cookie. |
|
9 | 3932 |
$ed = get_user_setting( 'editor', 'tinymce' ); |
16 | 3933 |
$r = ( in_array( $ed, array( 'tinymce', 'html', 'test' ), true ) ) ? $ed : $r; |
0 | 3934 |
} |
5 | 3935 |
|
3936 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3937 |
* Filters which editor should be displayed by default. |
5 | 3938 |
* |
3939 |
* @since 2.5.0 |
|
3940 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3941 |
* @param string $r Which editor should be displayed by default. Either 'tinymce', 'html', or 'test'. |
5 | 3942 |
*/ |
3943 |
return apply_filters( 'wp_default_editor', $r ); |
|
0 | 3944 |
} |
3945 |
||
3946 |
/** |
|
3947 |
* Renders an editor. |
|
3948 |
* |
|
3949 |
* Using this function is the proper way to output all needed components for both TinyMCE and Quicktags. |
|
5 | 3950 |
* _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144. |
0 | 3951 |
* |
3952 |
* NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3953 |
* running wp_editor() inside of a meta box is not a good idea unless only Quicktags is used. |
0 | 3954 |
* On the post edit screen several actions can be used to include additional editors |
3955 |
* containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'. |
|
5 | 3956 |
* See https://core.trac.wordpress.org/ticket/19173 for more information. |
0 | 3957 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3958 |
* @see _WP_Editors::editor() |
16 | 3959 |
* @see _WP_Editors::parse_settings() |
0 | 3960 |
* @since 3.3.0 |
3961 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3962 |
* @param string $content Initial content for the editor. |
16 | 3963 |
* @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. |
3964 |
* Should not contain square brackets. |
|
3965 |
* @param array $settings See _WP_Editors::parse_settings() for description. |
|
0 | 3966 |
*/ |
3967 |
function wp_editor( $content, $editor_id, $settings = array() ) { |
|
9 | 3968 |
if ( ! class_exists( '_WP_Editors', false ) ) { |
16 | 3969 |
require ABSPATH . WPINC . '/class-wp-editor.php'; |
9 | 3970 |
} |
3971 |
_WP_Editors::editor( $content, $editor_id, $settings ); |
|
0 | 3972 |
} |
3973 |
||
3974 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3975 |
* Outputs the editor scripts, stylesheets, and default settings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3976 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3977 |
* The editor can be initialized when needed after page load. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3978 |
* See wp.editor.initialize() in wp-admin/js/editor.js for initialization options. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3979 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3980 |
* @uses _WP_Editors |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3981 |
* @since 4.8.0 |
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 |
function wp_enqueue_editor() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3984 |
if ( ! class_exists( '_WP_Editors', false ) ) { |
16 | 3985 |
require ABSPATH . WPINC . '/class-wp-editor.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3986 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3987 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3988 |
_WP_Editors::enqueue_default_editor(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3989 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3990 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3991 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3992 |
* Enqueues assets needed by the code editor for the given settings. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3993 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3994 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3995 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3996 |
* @see wp_enqueue_editor() |
9 | 3997 |
* @see wp_get_code_editor_settings(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3998 |
* @see _WP_Editors::parse_settings() |
9 | 3999 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4000 |
* @param array $args { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4001 |
* Args. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4002 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4003 |
* @type string $type The MIME type of the file to be edited. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4004 |
* @type string $file Filename to be edited. Extension is used to sniff the type. Can be supplied as alternative to `$type` param. |
19 | 4005 |
* @type WP_Theme $theme Theme being edited when on the theme file editor. |
4006 |
* @type string $plugin Plugin being edited when on the plugin file editor. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4007 |
* @type array $codemirror Additional CodeMirror setting overrides. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4008 |
* @type array $csslint CSSLint rule overrides. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4009 |
* @type array $jshint JSHint rule overrides. |
18 | 4010 |
* @type array $htmlhint HTMLHint rule overrides. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4011 |
* } |
9 | 4012 |
* @return array|false Settings for the enqueued code editor, or false if the editor was not enqueued. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4013 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4014 |
function wp_enqueue_code_editor( $args ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4015 |
if ( is_user_logged_in() && 'false' === wp_get_current_user()->syntax_highlighting ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4016 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4017 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4018 |
|
9 | 4019 |
$settings = wp_get_code_editor_settings( $args ); |
4020 |
||
4021 |
if ( empty( $settings ) || empty( $settings['codemirror'] ) ) { |
|
4022 |
return false; |
|
4023 |
} |
|
4024 |
||
4025 |
wp_enqueue_script( 'code-editor' ); |
|
4026 |
wp_enqueue_style( 'code-editor' ); |
|
4027 |
||
4028 |
if ( isset( $settings['codemirror']['mode'] ) ) { |
|
4029 |
$mode = $settings['codemirror']['mode']; |
|
4030 |
if ( is_string( $mode ) ) { |
|
4031 |
$mode = array( |
|
4032 |
'name' => $mode, |
|
4033 |
); |
|
4034 |
} |
|
4035 |
||
4036 |
if ( ! empty( $settings['codemirror']['lint'] ) ) { |
|
4037 |
switch ( $mode['name'] ) { |
|
4038 |
case 'css': |
|
4039 |
case 'text/css': |
|
4040 |
case 'text/x-scss': |
|
4041 |
case 'text/x-less': |
|
4042 |
wp_enqueue_script( 'csslint' ); |
|
4043 |
break; |
|
4044 |
case 'htmlmixed': |
|
4045 |
case 'text/html': |
|
4046 |
case 'php': |
|
4047 |
case 'application/x-httpd-php': |
|
4048 |
case 'text/x-php': |
|
4049 |
wp_enqueue_script( 'htmlhint' ); |
|
4050 |
wp_enqueue_script( 'csslint' ); |
|
4051 |
wp_enqueue_script( 'jshint' ); |
|
4052 |
if ( ! current_user_can( 'unfiltered_html' ) ) { |
|
4053 |
wp_enqueue_script( 'htmlhint-kses' ); |
|
4054 |
} |
|
4055 |
break; |
|
4056 |
case 'javascript': |
|
4057 |
case 'application/ecmascript': |
|
4058 |
case 'application/json': |
|
4059 |
case 'application/javascript': |
|
4060 |
case 'application/ld+json': |
|
4061 |
case 'text/typescript': |
|
4062 |
case 'application/typescript': |
|
4063 |
wp_enqueue_script( 'jshint' ); |
|
4064 |
wp_enqueue_script( 'jsonlint' ); |
|
4065 |
break; |
|
4066 |
} |
|
4067 |
} |
|
4068 |
} |
|
4069 |
||
4070 |
wp_add_inline_script( 'code-editor', sprintf( 'jQuery.extend( wp.codeEditor.defaultSettings, %s );', wp_json_encode( $settings ) ) ); |
|
4071 |
||
4072 |
/** |
|
4073 |
* Fires when scripts and styles are enqueued for the code editor. |
|
4074 |
* |
|
4075 |
* @since 4.9.0 |
|
4076 |
* |
|
4077 |
* @param array $settings Settings for the enqueued code editor. |
|
4078 |
*/ |
|
4079 |
do_action( 'wp_enqueue_code_editor', $settings ); |
|
4080 |
||
4081 |
return $settings; |
|
4082 |
} |
|
4083 |
||
4084 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4085 |
* Generates and returns code editor settings. |
9 | 4086 |
* |
4087 |
* @since 5.0.0 |
|
4088 |
* |
|
4089 |
* @see wp_enqueue_code_editor() |
|
4090 |
* |
|
4091 |
* @param array $args { |
|
4092 |
* Args. |
|
4093 |
* |
|
4094 |
* @type string $type The MIME type of the file to be edited. |
|
4095 |
* @type string $file Filename to be edited. Extension is used to sniff the type. Can be supplied as alternative to `$type` param. |
|
19 | 4096 |
* @type WP_Theme $theme Theme being edited when on the theme file editor. |
4097 |
* @type string $plugin Plugin being edited when on the plugin file editor. |
|
9 | 4098 |
* @type array $codemirror Additional CodeMirror setting overrides. |
4099 |
* @type array $csslint CSSLint rule overrides. |
|
4100 |
* @type array $jshint JSHint rule overrides. |
|
18 | 4101 |
* @type array $htmlhint HTMLHint rule overrides. |
9 | 4102 |
* } |
4103 |
* @return array|false Settings for the code editor. |
|
4104 |
*/ |
|
4105 |
function wp_get_code_editor_settings( $args ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4106 |
$settings = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4107 |
'codemirror' => array( |
9 | 4108 |
'indentUnit' => 4, |
4109 |
'indentWithTabs' => true, |
|
4110 |
'inputStyle' => 'contenteditable', |
|
4111 |
'lineNumbers' => true, |
|
4112 |
'lineWrapping' => true, |
|
4113 |
'styleActiveLine' => true, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4114 |
'continueComments' => true, |
9 | 4115 |
'extraKeys' => array( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4116 |
'Ctrl-Space' => 'autocomplete', |
9 | 4117 |
'Ctrl-/' => 'toggleComment', |
4118 |
'Cmd-/' => 'toggleComment', |
|
4119 |
'Alt-F' => 'findPersistent', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4120 |
'Ctrl-F' => 'findPersistent', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4121 |
'Cmd-F' => 'findPersistent', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4122 |
), |
9 | 4123 |
'direction' => 'ltr', // Code is shown in LTR even in RTL languages. |
4124 |
'gutters' => array(), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4125 |
), |
9 | 4126 |
'csslint' => array( |
4127 |
'errors' => true, // Parsing errors. |
|
4128 |
'box-model' => true, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4129 |
'display-property-grouping' => true, |
9 | 4130 |
'duplicate-properties' => true, |
4131 |
'known-properties' => true, |
|
4132 |
'outline-none' => true, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4133 |
), |
9 | 4134 |
'jshint' => array( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4135 |
// The following are copied from <https://github.com/WordPress/wordpress-develop/blob/4.8.1/.jshintrc>. |
9 | 4136 |
'boss' => true, |
4137 |
'curly' => true, |
|
4138 |
'eqeqeq' => true, |
|
4139 |
'eqnull' => true, |
|
4140 |
'es3' => true, |
|
4141 |
'expr' => true, |
|
4142 |
'immed' => true, |
|
4143 |
'noarg' => true, |
|
4144 |
'nonbsp' => true, |
|
4145 |
'onevar' => true, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4146 |
'quotmark' => 'single', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4147 |
'trailing' => true, |
9 | 4148 |
'undef' => true, |
4149 |
'unused' => true, |
|
4150 |
||
4151 |
'browser' => true, |
|
4152 |
||
4153 |
'globals' => array( |
|
4154 |
'_' => false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4155 |
'Backbone' => false, |
9 | 4156 |
'jQuery' => false, |
4157 |
'JSON' => false, |
|
4158 |
'wp' => false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4159 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4160 |
), |
9 | 4161 |
'htmlhint' => array( |
4162 |
'tagname-lowercase' => true, |
|
4163 |
'attr-lowercase' => true, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4164 |
'attr-value-double-quotes' => false, |
9 | 4165 |
'doctype-first' => false, |
4166 |
'tag-pair' => true, |
|
4167 |
'spec-char-escape' => true, |
|
4168 |
'id-unique' => true, |
|
4169 |
'src-not-empty' => true, |
|
4170 |
'attr-no-duplication' => true, |
|
4171 |
'alt-require' => true, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4172 |
'space-tab-mixed-disabled' => 'tab', |
9 | 4173 |
'attr-unsafe-chars' => true, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4174 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4175 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4176 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4177 |
$type = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4178 |
if ( isset( $args['type'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4179 |
$type = $args['type']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4180 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4181 |
// Remap MIME types to ones that CodeMirror modes will recognize. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4182 |
if ( 'application/x-patch' === $type || 'text/x-patch' === $type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4183 |
$type = 'text/x-diff'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4184 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4185 |
} elseif ( isset( $args['file'] ) && str_contains( basename( $args['file'] ), '.' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4186 |
$extension = strtolower( pathinfo( $args['file'], PATHINFO_EXTENSION ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4187 |
foreach ( wp_get_mime_types() as $exts => $mime ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4188 |
if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4189 |
$type = $mime; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4190 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4191 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4192 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4193 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4194 |
// Supply any types that are not matched by wp_get_mime_types(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4195 |
if ( empty( $type ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4196 |
switch ( $extension ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4197 |
case 'conf': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4198 |
$type = 'text/nginx'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4199 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4200 |
case 'css': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4201 |
$type = 'text/css'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4202 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4203 |
case 'diff': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4204 |
case 'patch': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4205 |
$type = 'text/x-diff'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4206 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4207 |
case 'html': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4208 |
case 'htm': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4209 |
$type = 'text/html'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4210 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4211 |
case 'http': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4212 |
$type = 'message/http'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4213 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4214 |
case 'js': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4215 |
$type = 'text/javascript'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4216 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4217 |
case 'json': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4218 |
$type = 'application/json'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4219 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4220 |
case 'jsx': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4221 |
$type = 'text/jsx'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4222 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4223 |
case 'less': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4224 |
$type = 'text/x-less'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4225 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4226 |
case 'md': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4227 |
$type = 'text/x-gfm'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4228 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4229 |
case 'php': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4230 |
case 'phtml': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4231 |
case 'php3': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4232 |
case 'php4': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4233 |
case 'php5': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4234 |
case 'php7': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4235 |
case 'phps': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4236 |
$type = 'application/x-httpd-php'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4237 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4238 |
case 'scss': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4239 |
$type = 'text/x-scss'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4240 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4241 |
case 'sass': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4242 |
$type = 'text/x-sass'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4243 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4244 |
case 'sh': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4245 |
case 'bash': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4246 |
$type = 'text/x-sh'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4247 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4248 |
case 'sql': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4249 |
$type = 'text/x-sql'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4250 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4251 |
case 'svg': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4252 |
$type = 'application/svg+xml'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4253 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4254 |
case 'xml': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4255 |
$type = 'text/xml'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4256 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4257 |
case 'yml': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4258 |
case 'yaml': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4259 |
$type = 'text/x-yaml'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4260 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4261 |
case 'txt': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4262 |
default: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4263 |
$type = 'text/plain'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4264 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4265 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4266 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4267 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4268 |
|
16 | 4269 |
if ( in_array( $type, array( 'text/css', 'text/x-scss', 'text/x-less', 'text/x-sass' ), true ) ) { |
9 | 4270 |
$settings['codemirror'] = array_merge( |
4271 |
$settings['codemirror'], |
|
4272 |
array( |
|
4273 |
'mode' => $type, |
|
4274 |
'lint' => false, |
|
4275 |
'autoCloseBrackets' => true, |
|
4276 |
'matchBrackets' => true, |
|
4277 |
) |
|
4278 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4279 |
} elseif ( 'text/x-diff' === $type ) { |
9 | 4280 |
$settings['codemirror'] = array_merge( |
4281 |
$settings['codemirror'], |
|
4282 |
array( |
|
4283 |
'mode' => 'diff', |
|
4284 |
) |
|
4285 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4286 |
} elseif ( 'text/html' === $type ) { |
9 | 4287 |
$settings['codemirror'] = array_merge( |
4288 |
$settings['codemirror'], |
|
4289 |
array( |
|
4290 |
'mode' => 'htmlmixed', |
|
4291 |
'lint' => true, |
|
4292 |
'autoCloseBrackets' => true, |
|
4293 |
'autoCloseTags' => true, |
|
4294 |
'matchTags' => array( |
|
4295 |
'bothTags' => true, |
|
4296 |
), |
|
4297 |
) |
|
4298 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4299 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4300 |
if ( ! current_user_can( 'unfiltered_html' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4301 |
$settings['htmlhint']['kses'] = wp_kses_allowed_html( 'post' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4302 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4303 |
} elseif ( 'text/x-gfm' === $type ) { |
9 | 4304 |
$settings['codemirror'] = array_merge( |
4305 |
$settings['codemirror'], |
|
4306 |
array( |
|
4307 |
'mode' => 'gfm', |
|
4308 |
'highlightFormatting' => true, |
|
4309 |
) |
|
4310 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4311 |
} elseif ( 'application/javascript' === $type || 'text/javascript' === $type ) { |
9 | 4312 |
$settings['codemirror'] = array_merge( |
4313 |
$settings['codemirror'], |
|
4314 |
array( |
|
4315 |
'mode' => 'javascript', |
|
4316 |
'lint' => true, |
|
4317 |
'autoCloseBrackets' => true, |
|
4318 |
'matchBrackets' => true, |
|
4319 |
) |
|
4320 |
); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4321 |
} elseif ( str_contains( $type, 'json' ) ) { |
9 | 4322 |
$settings['codemirror'] = array_merge( |
4323 |
$settings['codemirror'], |
|
4324 |
array( |
|
4325 |
'mode' => array( |
|
4326 |
'name' => 'javascript', |
|
4327 |
), |
|
4328 |
'lint' => true, |
|
4329 |
'autoCloseBrackets' => true, |
|
4330 |
'matchBrackets' => true, |
|
4331 |
) |
|
4332 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4333 |
if ( 'application/ld+json' === $type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4334 |
$settings['codemirror']['mode']['jsonld'] = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4335 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4336 |
$settings['codemirror']['mode']['json'] = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4337 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4338 |
} elseif ( str_contains( $type, 'jsx' ) ) { |
9 | 4339 |
$settings['codemirror'] = array_merge( |
4340 |
$settings['codemirror'], |
|
4341 |
array( |
|
4342 |
'mode' => 'jsx', |
|
4343 |
'autoCloseBrackets' => true, |
|
4344 |
'matchBrackets' => true, |
|
4345 |
) |
|
4346 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4347 |
} elseif ( 'text/x-markdown' === $type ) { |
9 | 4348 |
$settings['codemirror'] = array_merge( |
4349 |
$settings['codemirror'], |
|
4350 |
array( |
|
4351 |
'mode' => 'markdown', |
|
4352 |
'highlightFormatting' => true, |
|
4353 |
) |
|
4354 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4355 |
} elseif ( 'text/nginx' === $type ) { |
9 | 4356 |
$settings['codemirror'] = array_merge( |
4357 |
$settings['codemirror'], |
|
4358 |
array( |
|
4359 |
'mode' => 'nginx', |
|
4360 |
) |
|
4361 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4362 |
} elseif ( 'application/x-httpd-php' === $type ) { |
9 | 4363 |
$settings['codemirror'] = array_merge( |
4364 |
$settings['codemirror'], |
|
4365 |
array( |
|
4366 |
'mode' => 'php', |
|
4367 |
'autoCloseBrackets' => true, |
|
4368 |
'autoCloseTags' => true, |
|
4369 |
'matchBrackets' => true, |
|
4370 |
'matchTags' => array( |
|
4371 |
'bothTags' => true, |
|
4372 |
), |
|
4373 |
) |
|
4374 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4375 |
} elseif ( 'text/x-sql' === $type || 'text/x-mysql' === $type ) { |
9 | 4376 |
$settings['codemirror'] = array_merge( |
4377 |
$settings['codemirror'], |
|
4378 |
array( |
|
4379 |
'mode' => 'sql', |
|
4380 |
'autoCloseBrackets' => true, |
|
4381 |
'matchBrackets' => true, |
|
4382 |
) |
|
4383 |
); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4384 |
} elseif ( str_contains( $type, 'xml' ) ) { |
9 | 4385 |
$settings['codemirror'] = array_merge( |
4386 |
$settings['codemirror'], |
|
4387 |
array( |
|
4388 |
'mode' => 'xml', |
|
4389 |
'autoCloseBrackets' => true, |
|
4390 |
'autoCloseTags' => true, |
|
4391 |
'matchTags' => array( |
|
4392 |
'bothTags' => true, |
|
4393 |
), |
|
4394 |
) |
|
4395 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4396 |
} elseif ( 'text/x-yaml' === $type ) { |
9 | 4397 |
$settings['codemirror'] = array_merge( |
4398 |
$settings['codemirror'], |
|
4399 |
array( |
|
4400 |
'mode' => 'yaml', |
|
4401 |
) |
|
4402 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4403 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4404 |
$settings['codemirror']['mode'] = $type; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4405 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4406 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4407 |
if ( ! empty( $settings['codemirror']['lint'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4408 |
$settings['codemirror']['gutters'][] = 'CodeMirror-lint-markers'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4409 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4410 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4411 |
// Let settings supplied via args override any defaults. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4412 |
foreach ( wp_array_slice_assoc( $args, array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ) ) as $key => $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4413 |
$settings[ $key ] = array_merge( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4414 |
$settings[ $key ], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4415 |
$value |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4416 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4417 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4418 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4419 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4420 |
* Filters settings that are passed into the code editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4421 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4422 |
* Returning a falsey value will disable the syntax-highlighting code editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4423 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4424 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4425 |
* |
16 | 4426 |
* @param array $settings The array of settings passed to the code editor. |
4427 |
* A falsey value disables the editor. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4428 |
* @param array $args { |
9 | 4429 |
* Args passed when calling `get_code_editor_settings()`. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4430 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4431 |
* @type string $type The MIME type of the file to be edited. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4432 |
* @type string $file Filename being edited. |
19 | 4433 |
* @type WP_Theme $theme Theme being edited when on the theme file editor. |
4434 |
* @type string $plugin Plugin being edited when on the plugin file editor. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4435 |
* @type array $codemirror Additional CodeMirror setting overrides. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4436 |
* @type array $csslint CSSLint rule overrides. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4437 |
* @type array $jshint JSHint rule overrides. |
18 | 4438 |
* @type array $htmlhint HTMLHint rule overrides. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4439 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4440 |
*/ |
9 | 4441 |
return apply_filters( 'wp_code_editor_settings', $settings, $args ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4442 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4443 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4444 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4445 |
* Retrieves the contents of the search WordPress query variable. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4446 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4447 |
* The search query string is passed through esc_attr() to ensure that it is safe |
16 | 4448 |
* for placing in an HTML attribute. |
0 | 4449 |
* |
4450 |
* @since 2.3.0 |
|
4451 |
* |
|
4452 |
* @param bool $escaped Whether the result is escaped. Default true. |
|
9 | 4453 |
* Only use when you are later escaping it. Do not use unescaped. |
0 | 4454 |
* @return string |
4455 |
*/ |
|
4456 |
function get_search_query( $escaped = true ) { |
|
5 | 4457 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4458 |
* Filters the contents of the search query variable. |
5 | 4459 |
* |
4460 |
* @since 2.3.0 |
|
4461 |
* |
|
4462 |
* @param mixed $search Contents of the search query variable. |
|
4463 |
*/ |
|
0 | 4464 |
$query = apply_filters( 'get_search_query', get_query_var( 's' ) ); |
5 | 4465 |
|
9 | 4466 |
if ( $escaped ) { |
0 | 4467 |
$query = esc_attr( $query ); |
9 | 4468 |
} |
0 | 4469 |
return $query; |
4470 |
} |
|
4471 |
||
4472 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4473 |
* Displays the contents of the search query variable. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4474 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4475 |
* The search query string is passed through esc_attr() to ensure that it is safe |
16 | 4476 |
* for placing in an HTML attribute. |
0 | 4477 |
* |
4478 |
* @since 2.1.0 |
|
4479 |
*/ |
|
4480 |
function the_search_query() { |
|
5 | 4481 |
/** |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
4482 |
* Filters the contents of the search query variable, for display. |
5 | 4483 |
* |
4484 |
* @since 2.3.0 |
|
4485 |
* |
|
4486 |
* @param mixed $search Contents of the search query variable. |
|
4487 |
*/ |
|
0 | 4488 |
echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) ); |
4489 |
} |
|
4490 |
||
4491 |
/** |
|
16 | 4492 |
* Gets the language attributes for the 'html' tag. |
4493 |
* |
|
4494 |
* Builds up a set of HTML attributes containing the text direction and language |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4495 |
* information for the page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4496 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4497 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4498 |
* |
16 | 4499 |
* @param string $doctype Optional. The type of HTML document. Accepts 'xhtml' or 'html'. Default 'html'. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4500 |
* @return string A space-separated list of language attributes. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4501 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4502 |
function get_language_attributes( $doctype = 'html' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4503 |
$attributes = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4504 |
|
9 | 4505 |
if ( function_exists( 'is_rtl' ) && is_rtl() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4506 |
$attributes[] = 'dir="rtl"'; |
9 | 4507 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4508 |
|
16 | 4509 |
$lang = get_bloginfo( 'language' ); |
4510 |
if ( $lang ) { |
|
4511 |
if ( 'text/html' === get_option( 'html_type' ) || 'html' === $doctype ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4512 |
$attributes[] = 'lang="' . esc_attr( $lang ) . '"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4513 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4514 |
|
16 | 4515 |
if ( 'text/html' !== get_option( 'html_type' ) || 'xhtml' === $doctype ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4516 |
$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4517 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4518 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4519 |
|
9 | 4520 |
$output = implode( ' ', $attributes ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4521 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4522 |
/** |
16 | 4523 |
* Filters the language attributes for display in the 'html' tag. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4524 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4525 |
* @since 2.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4526 |
* @since 4.3.0 Added the `$doctype` parameter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4527 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4528 |
* @param string $output A space-separated list of language attributes. |
16 | 4529 |
* @param string $doctype The type of HTML document (xhtml|html). |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4530 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4531 |
return apply_filters( 'language_attributes', $output, $doctype ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4532 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4533 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4534 |
/** |
16 | 4535 |
* Displays the language attributes for the 'html' tag. |
4536 |
* |
|
4537 |
* Builds up a set of HTML attributes containing the text direction and language |
|
0 | 4538 |
* information for the page. |
4539 |
* |
|
4540 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4541 |
* @since 4.3.0 Converted into a wrapper for get_language_attributes(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4542 |
* |
16 | 4543 |
* @param string $doctype Optional. The type of HTML document. Accepts 'xhtml' or 'html'. Default 'html'. |
0 | 4544 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4545 |
function language_attributes( $doctype = 'html' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4546 |
echo get_language_attributes( $doctype ); |
0 | 4547 |
} |
4548 |
||
4549 |
/** |
|
18 | 4550 |
* Retrieves paginated links for archive post pages. |
0 | 4551 |
* |
4552 |
* Technically, the function can be used to create paginated link list for any |
|
4553 |
* area. The 'base' argument is used to reference the url, which will be used to |
|
4554 |
* create the paginated links. The 'format' argument is then used for replacing |
|
4555 |
* the page number. It is however, most likely and by default, to be used on the |
|
4556 |
* archive post pages. |
|
4557 |
* |
|
4558 |
* The 'type' argument controls format of the returned value. The default is |
|
4559 |
* 'plain', which is just a string with the links separated by a newline |
|
4560 |
* character. The other possible values are either 'array' or 'list'. The |
|
4561 |
* 'array' value will return an array of the paginated link list to offer full |
|
4562 |
* control of display. The 'list' value will place all of the paginated links in |
|
4563 |
* an unordered HTML list. |
|
4564 |
* |
|
4565 |
* The 'total' argument is the total amount of pages and is an integer. The |
|
4566 |
* 'current' argument is the current page number and is also an integer. |
|
4567 |
* |
|
4568 |
* An example of the 'base' argument is "http://example.com/all_posts.php%_%" |
|
4569 |
* and the '%_%' is required. The '%_%' will be replaced by the contents of in |
|
4570 |
* the 'format' argument. An example for the 'format' argument is "?page=%#%" |
|
4571 |
* and the '%#%' is also required. The '%#%' will be replaced with the page |
|
4572 |
* number. |
|
4573 |
* |
|
4574 |
* You can include the previous and next links in the list by setting the |
|
4575 |
* 'prev_next' argument to true, which it is by default. You can set the |
|
4576 |
* previous text, by using the 'prev_text' argument. You can set the next text |
|
4577 |
* by setting the 'next_text' argument. |
|
4578 |
* |
|
4579 |
* If the 'show_all' argument is set to true, then it will show all of the pages |
|
4580 |
* instead of a short list of the pages near the current page. By default, the |
|
4581 |
* 'show_all' is set to false and controlled by the 'end_size' and 'mid_size' |
|
4582 |
* arguments. The 'end_size' argument is how many numbers on either the start |
|
4583 |
* and the end list edges, by default is 1. The 'mid_size' argument is how many |
|
4584 |
* numbers to either side of current page, but not including current page. |
|
4585 |
* |
|
4586 |
* It is possible to add query vars to the link by using the 'add_args' argument |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4587 |
* and see add_query_arg() for more information. |
0 | 4588 |
* |
5 | 4589 |
* The 'before_page_number' and 'after_page_number' arguments allow users to |
4590 |
* augment the links themselves. Typically this might be to add context to the |
|
4591 |
* numbered links so that screen reader users understand what the links are for. |
|
4592 |
* The text strings are added before and after the page number - within the |
|
4593 |
* anchor tag. |
|
4594 |
* |
|
0 | 4595 |
* @since 2.1.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4596 |
* @since 4.9.0 Added the `aria_current` argument. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4597 |
* |
16 | 4598 |
* @global WP_Query $wp_query WordPress Query object. |
4599 |
* @global WP_Rewrite $wp_rewrite WordPress rewrite component. |
|
0 | 4600 |
* |
5 | 4601 |
* @param string|array $args { |
4602 |
* Optional. Array or string of arguments for generating paginated links for archives. |
|
4603 |
* |
|
4604 |
* @type string $base Base of the paginated url. Default empty. |
|
4605 |
* @type string $format Format for the pagination structure. Default empty. |
|
4606 |
* @type int $total The total amount of pages. Default is the value WP_Query's |
|
4607 |
* `max_num_pages` or 1. |
|
4608 |
* @type int $current The current page number. Default is 'paged' query var or 1. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4609 |
* @type string $aria_current The value for the aria-current attribute. Possible values are 'page', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4610 |
* 'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'. |
5 | 4611 |
* @type bool $show_all Whether to show all pages. Default false. |
4612 |
* @type int $end_size How many numbers on either the start and the end list edges. |
|
4613 |
* Default 1. |
|
4614 |
* @type int $mid_size How many numbers to either side of the current pages. Default 2. |
|
4615 |
* @type bool $prev_next Whether to include the previous and next links in the list. Default true. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4616 |
* @type string $prev_text The previous page text. Default '« Previous'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4617 |
* @type string $next_text The next page text. Default 'Next »'. |
5 | 4618 |
* @type string $type Controls format of the returned value. Possible values are 'plain', |
4619 |
* 'array' and 'list'. Default is 'plain'. |
|
4620 |
* @type array $add_args An array of query args to add. Default false. |
|
4621 |
* @type string $add_fragment A string to append to each link. Default empty. |
|
4622 |
* @type string $before_page_number A string to appear before the page number. Default empty. |
|
4623 |
* @type string $after_page_number A string to append after the page number. Default empty. |
|
4624 |
* } |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4625 |
* @return string|string[]|void String of page links or array of page links, depending on 'type' argument. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4626 |
* Void if total number of pages is less than 2. |
0 | 4627 |
*/ |
4628 |
function paginate_links( $args = '' ) { |
|
5 | 4629 |
global $wp_query, $wp_rewrite; |
4630 |
||
4631 |
// Setting up default values based on the current URL. |
|
4632 |
$pagenum_link = html_entity_decode( get_pagenum_link() ); |
|
4633 |
$url_parts = explode( '?', $pagenum_link ); |
|
4634 |
||
4635 |
// Get max pages and current page out of the current query, if available. |
|
4636 |
$total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1; |
|
18 | 4637 |
$current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1; |
5 | 4638 |
|
4639 |
// Append the format placeholder to the base URL. |
|
4640 |
$pagenum_link = trailingslashit( $url_parts[0] ) . '%_%'; |
|
4641 |
||
4642 |
// URL base depends on permalink settings. |
|
4643 |
$format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; |
|
4644 |
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; |
|
4645 |
||
0 | 4646 |
$defaults = array( |
16 | 4647 |
'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below). |
4648 |
'format' => $format, // ?page=%#% : %#% is replaced by the page number. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4649 |
'total' => $total, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4650 |
'current' => $current, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4651 |
'aria_current' => 'page', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4652 |
'show_all' => false, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4653 |
'prev_next' => true, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4654 |
'prev_text' => __( '« Previous' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4655 |
'next_text' => __( 'Next »' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4656 |
'end_size' => 1, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4657 |
'mid_size' => 2, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4658 |
'type' => 'plain', |
16 | 4659 |
'add_args' => array(), // Array of query args to add. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4660 |
'add_fragment' => '', |
5 | 4661 |
'before_page_number' => '', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4662 |
'after_page_number' => '', |
0 | 4663 |
); |
4664 |
||
4665 |
$args = wp_parse_args( $args, $defaults ); |
|
5 | 4666 |
|
4667 |
if ( ! is_array( $args['add_args'] ) ) { |
|
4668 |
$args['add_args'] = array(); |
|
4669 |
} |
|
4670 |
||
4671 |
// Merge additional query vars found in the original URL into 'add_args' array. |
|
4672 |
if ( isset( $url_parts[1] ) ) { |
|
4673 |
// Find the format argument. |
|
9 | 4674 |
$format = explode( '?', str_replace( '%_%', $args['format'], $args['base'] ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4675 |
$format_query = isset( $format[1] ) ? $format[1] : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4676 |
wp_parse_str( $format_query, $format_args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4677 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4678 |
// Find the query args of the requested URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4679 |
wp_parse_str( $url_parts[1], $url_query_args ); |
5 | 4680 |
|
4681 |
// Remove the format argument from the array of query arguments, to avoid overwriting custom format. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4682 |
foreach ( $format_args as $format_arg => $format_arg_value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4683 |
unset( $url_query_args[ $format_arg ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4684 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4685 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4686 |
$args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) ); |
5 | 4687 |
} |
0 | 4688 |
|
16 | 4689 |
// Who knows what else people pass in $args. |
5 | 4690 |
$total = (int) $args['total']; |
4691 |
if ( $total < 2 ) { |
|
0 | 4692 |
return; |
5 | 4693 |
} |
4694 |
$current = (int) $args['current']; |
|
16 | 4695 |
$end_size = (int) $args['end_size']; // Out of bounds? Make it the default. |
5 | 4696 |
if ( $end_size < 1 ) { |
4697 |
$end_size = 1; |
|
4698 |
} |
|
4699 |
$mid_size = (int) $args['mid_size']; |
|
4700 |
if ( $mid_size < 0 ) { |
|
4701 |
$mid_size = 2; |
|
4702 |
} |
|
16 | 4703 |
|
9 | 4704 |
$add_args = $args['add_args']; |
4705 |
$r = ''; |
|
0 | 4706 |
$page_links = array(); |
9 | 4707 |
$dots = false; |
0 | 4708 |
|
5 | 4709 |
if ( $args['prev_next'] && $current && 1 < $current ) : |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
4710 |
$link = str_replace( '%_%', 2 === $current ? '' : $args['format'], $args['base'] ); |
5 | 4711 |
$link = str_replace( '%#%', $current - 1, $link ); |
9 | 4712 |
if ( $add_args ) { |
0 | 4713 |
$link = add_query_arg( $add_args, $link ); |
9 | 4714 |
} |
5 | 4715 |
$link .= $args['add_fragment']; |
4716 |
||
16 | 4717 |
$page_links[] = sprintf( |
4718 |
'<a class="prev page-numbers" href="%s">%s</a>', |
|
4719 |
/** |
|
4720 |
* Filters the paginated links for the given archive pages. |
|
4721 |
* |
|
4722 |
* @since 3.0.0 |
|
4723 |
* |
|
4724 |
* @param string $link The paginated link URL. |
|
4725 |
*/ |
|
4726 |
esc_url( apply_filters( 'paginate_links', $link ) ), |
|
4727 |
$args['prev_text'] |
|
4728 |
); |
|
0 | 4729 |
endif; |
16 | 4730 |
|
0 | 4731 |
for ( $n = 1; $n <= $total; $n++ ) : |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
4732 |
if ( $n === $current ) : |
16 | 4733 |
$page_links[] = sprintf( |
4734 |
'<span aria-current="%s" class="page-numbers current">%s</span>', |
|
4735 |
esc_attr( $args['aria_current'] ), |
|
4736 |
$args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] |
|
4737 |
); |
|
4738 |
||
4739 |
$dots = true; |
|
0 | 4740 |
else : |
5 | 4741 |
if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) : |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
4742 |
$link = str_replace( '%_%', 1 === $n ? '' : $args['format'], $args['base'] ); |
5 | 4743 |
$link = str_replace( '%#%', $n, $link ); |
9 | 4744 |
if ( $add_args ) { |
0 | 4745 |
$link = add_query_arg( $add_args, $link ); |
9 | 4746 |
} |
5 | 4747 |
$link .= $args['add_fragment']; |
4748 |
||
16 | 4749 |
$page_links[] = sprintf( |
4750 |
'<a class="page-numbers" href="%s">%s</a>', |
|
4751 |
/** This filter is documented in wp-includes/general-template.php */ |
|
4752 |
esc_url( apply_filters( 'paginate_links', $link ) ), |
|
4753 |
$args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] |
|
4754 |
); |
|
4755 |
||
4756 |
$dots = true; |
|
5 | 4757 |
elseif ( $dots && ! $args['show_all'] ) : |
0 | 4758 |
$page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>'; |
16 | 4759 |
|
4760 |
$dots = false; |
|
0 | 4761 |
endif; |
4762 |
endif; |
|
4763 |
endfor; |
|
16 | 4764 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4765 |
if ( $args['prev_next'] && $current && $current < $total ) : |
5 | 4766 |
$link = str_replace( '%_%', $args['format'], $args['base'] ); |
4767 |
$link = str_replace( '%#%', $current + 1, $link ); |
|
9 | 4768 |
if ( $add_args ) { |
0 | 4769 |
$link = add_query_arg( $add_args, $link ); |
9 | 4770 |
} |
5 | 4771 |
$link .= $args['add_fragment']; |
4772 |
||
16 | 4773 |
$page_links[] = sprintf( |
4774 |
'<a class="next page-numbers" href="%s">%s</a>', |
|
4775 |
/** This filter is documented in wp-includes/general-template.php */ |
|
4776 |
esc_url( apply_filters( 'paginate_links', $link ) ), |
|
4777 |
$args['next_text'] |
|
4778 |
); |
|
0 | 4779 |
endif; |
16 | 4780 |
|
5 | 4781 |
switch ( $args['type'] ) { |
9 | 4782 |
case 'array': |
0 | 4783 |
return $page_links; |
5 | 4784 |
|
9 | 4785 |
case 'list': |
0 | 4786 |
$r .= "<ul class='page-numbers'>\n\t<li>"; |
18 | 4787 |
$r .= implode( "</li>\n\t<li>", $page_links ); |
0 | 4788 |
$r .= "</li>\n</ul>\n"; |
4789 |
break; |
|
5 | 4790 |
|
9 | 4791 |
default: |
18 | 4792 |
$r = implode( "\n", $page_links ); |
0 | 4793 |
break; |
5 | 4794 |
} |
16 | 4795 |
|
18 | 4796 |
/** |
4797 |
* Filters the HTML output of paginated links for archives. |
|
4798 |
* |
|
4799 |
* @since 5.7.0 |
|
4800 |
* |
|
4801 |
* @param string $r HTML output. |
|
4802 |
* @param array $args An array of arguments. See paginate_links() |
|
4803 |
* for information on accepted arguments. |
|
4804 |
*/ |
|
4805 |
$r = apply_filters( 'paginate_links_output', $r, $args ); |
|
4806 |
||
0 | 4807 |
return $r; |
4808 |
} |
|
4809 |
||
4810 |
/** |
|
9 | 4811 |
* Registers an admin color scheme css file. |
4812 |
* |
|
4813 |
* Allows a plugin to register a new admin color scheme. For example: |
|
5 | 4814 |
* |
4815 |
* wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array( |
|
4816 |
* '#07273E', '#14568A', '#D54E21', '#2683AE' |
|
4817 |
* ) ); |
|
0 | 4818 |
* |
4819 |
* @since 2.5.0 |
|
4820 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4821 |
* @global array $_wp_admin_css_colors |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4822 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4823 |
* @param string $key The unique key for this theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4824 |
* @param string $name The name of the theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4825 |
* @param string $url The URL of the CSS file containing the color scheme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4826 |
* @param array $colors Optional. An array of CSS color definition strings which are used |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4827 |
* to give the user a feel for the theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4828 |
* @param array $icons { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4829 |
* Optional. CSS color definitions used to color any SVG icons. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4830 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4831 |
* @type string $base SVG icon base color. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4832 |
* @type string $focus SVG icon color on focus. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4833 |
* @type string $current SVG icon color of current admin menu link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4834 |
* } |
0 | 4835 |
*/ |
5 | 4836 |
function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) { |
0 | 4837 |
global $_wp_admin_css_colors; |
4838 |
||
9 | 4839 |
if ( ! isset( $_wp_admin_css_colors ) ) { |
0 | 4840 |
$_wp_admin_css_colors = array(); |
9 | 4841 |
} |
4842 |
||
4843 |
$_wp_admin_css_colors[ $key ] = (object) array( |
|
4844 |
'name' => $name, |
|
4845 |
'url' => $url, |
|
4846 |
'colors' => $colors, |
|
5 | 4847 |
'icon_colors' => $icons, |
4848 |
); |
|
0 | 4849 |
} |
4850 |
||
4851 |
/** |
|
9 | 4852 |
* Registers the default admin color schemes. |
4853 |
* |
|
4854 |
* Registers the initial set of eight color schemes in the Profile section |
|
4855 |
* of the dashboard which allows for styling the admin menu and toolbar. |
|
4856 |
* |
|
4857 |
* @see wp_admin_css_color() |
|
0 | 4858 |
* |
4859 |
* @since 3.0.0 |
|
4860 |
*/ |
|
4861 |
function register_admin_color_schemes() { |
|
9 | 4862 |
$suffix = is_rtl() ? '-rtl' : ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4863 |
$suffix .= SCRIPT_DEBUG ? '' : '.min'; |
5 | 4864 |
|
9 | 4865 |
wp_admin_css_color( |
4866 |
'fresh', |
|
4867 |
_x( 'Default', 'admin color scheme' ), |
|
5 | 4868 |
false, |
18 | 4869 |
array( '#1d2327', '#2c3338', '#2271b1', '#72aee6' ), |
9 | 4870 |
array( |
18 | 4871 |
'base' => '#a7aaad', |
4872 |
'focus' => '#72aee6', |
|
9 | 4873 |
'current' => '#fff', |
4874 |
) |
|
5 | 4875 |
); |
4876 |
||
9 | 4877 |
wp_admin_css_color( |
4878 |
'light', |
|
4879 |
_x( 'Light', 'admin color scheme' ), |
|
5 | 4880 |
admin_url( "css/colors/light/colors$suffix.css" ), |
4881 |
array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ), |
|
9 | 4882 |
array( |
4883 |
'base' => '#999', |
|
4884 |
'focus' => '#ccc', |
|
4885 |
'current' => '#ccc', |
|
4886 |
) |
|
5 | 4887 |
); |
4888 |
||
9 | 4889 |
wp_admin_css_color( |
16 | 4890 |
'modern', |
4891 |
_x( 'Modern', 'admin color scheme' ), |
|
4892 |
admin_url( "css/colors/modern/colors$suffix.css" ), |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
4893 |
array( '#1e1e1e', '#3858e9', '#7b90ff' ), |
16 | 4894 |
array( |
4895 |
'base' => '#f3f1f1', |
|
4896 |
'focus' => '#fff', |
|
4897 |
'current' => '#fff', |
|
4898 |
) |
|
4899 |
); |
|
4900 |
||
4901 |
wp_admin_css_color( |
|
9 | 4902 |
'blue', |
4903 |
_x( 'Blue', 'admin color scheme' ), |
|
5 | 4904 |
admin_url( "css/colors/blue/colors$suffix.css" ), |
4905 |
array( '#096484', '#4796b3', '#52accc', '#74B6CE' ), |
|
9 | 4906 |
array( |
4907 |
'base' => '#e5f8ff', |
|
4908 |
'focus' => '#fff', |
|
4909 |
'current' => '#fff', |
|
4910 |
) |
|
5 | 4911 |
); |
4912 |
||
9 | 4913 |
wp_admin_css_color( |
4914 |
'midnight', |
|
4915 |
_x( 'Midnight', 'admin color scheme' ), |
|
5 | 4916 |
admin_url( "css/colors/midnight/colors$suffix.css" ), |
4917 |
array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ), |
|
9 | 4918 |
array( |
4919 |
'base' => '#f1f2f3', |
|
4920 |
'focus' => '#fff', |
|
4921 |
'current' => '#fff', |
|
4922 |
) |
|
5 | 4923 |
); |
4924 |
||
9 | 4925 |
wp_admin_css_color( |
4926 |
'sunrise', |
|
4927 |
_x( 'Sunrise', 'admin color scheme' ), |
|
5 | 4928 |
admin_url( "css/colors/sunrise/colors$suffix.css" ), |
4929 |
array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ), |
|
9 | 4930 |
array( |
4931 |
'base' => '#f3f1f1', |
|
4932 |
'focus' => '#fff', |
|
4933 |
'current' => '#fff', |
|
4934 |
) |
|
5 | 4935 |
); |
4936 |
||
9 | 4937 |
wp_admin_css_color( |
4938 |
'ectoplasm', |
|
4939 |
_x( 'Ectoplasm', 'admin color scheme' ), |
|
5 | 4940 |
admin_url( "css/colors/ectoplasm/colors$suffix.css" ), |
4941 |
array( '#413256', '#523f6d', '#a3b745', '#d46f15' ), |
|
9 | 4942 |
array( |
4943 |
'base' => '#ece6f6', |
|
4944 |
'focus' => '#fff', |
|
4945 |
'current' => '#fff', |
|
4946 |
) |
|
5 | 4947 |
); |
4948 |
||
9 | 4949 |
wp_admin_css_color( |
4950 |
'ocean', |
|
4951 |
_x( 'Ocean', 'admin color scheme' ), |
|
5 | 4952 |
admin_url( "css/colors/ocean/colors$suffix.css" ), |
4953 |
array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ), |
|
9 | 4954 |
array( |
4955 |
'base' => '#f2fcff', |
|
4956 |
'focus' => '#fff', |
|
4957 |
'current' => '#fff', |
|
4958 |
) |
|
5 | 4959 |
); |
4960 |
||
9 | 4961 |
wp_admin_css_color( |
4962 |
'coffee', |
|
4963 |
_x( 'Coffee', 'admin color scheme' ), |
|
5 | 4964 |
admin_url( "css/colors/coffee/colors$suffix.css" ), |
4965 |
array( '#46403c', '#59524c', '#c7a589', '#9ea476' ), |
|
9 | 4966 |
array( |
4967 |
'base' => '#f3f2f1', |
|
4968 |
'focus' => '#fff', |
|
4969 |
'current' => '#fff', |
|
4970 |
) |
|
5 | 4971 |
); |
0 | 4972 |
} |
4973 |
||
4974 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4975 |
* Displays the URL of a WordPress admin CSS file. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4976 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4977 |
* @see WP_Styles::_css_href() and its {@see 'style_loader_src'} filter. |
0 | 4978 |
* |
4979 |
* @since 2.3.0 |
|
4980 |
* |
|
4981 |
* @param string $file file relative to wp-admin/ without its ".css" extension. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4982 |
* @return string |
0 | 4983 |
*/ |
4984 |
function wp_admin_css_uri( $file = 'wp-admin' ) { |
|
9 | 4985 |
if ( defined( 'WP_INSTALLING' ) ) { |
0 | 4986 |
$_file = "./$file.css"; |
4987 |
} else { |
|
9 | 4988 |
$_file = admin_url( "$file.css" ); |
0 | 4989 |
} |
9 | 4990 |
$_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file ); |
0 | 4991 |
|
5 | 4992 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4993 |
* Filters the URI of a WordPress admin CSS file. |
5 | 4994 |
* |
4995 |
* @since 2.3.0 |
|
4996 |
* |
|
4997 |
* @param string $_file Relative path to the file with query arguments attached. |
|
4998 |
* @param string $file Relative path to the file, minus its ".css" extension. |
|
4999 |
*/ |
|
0 | 5000 |
return apply_filters( 'wp_admin_css_uri', $_file, $file ); |
5001 |
} |
|
5002 |
||
5003 |
/** |
|
5004 |
* Enqueues or directly prints a stylesheet link to the specified CSS file. |
|
5005 |
* |
|
5006 |
* "Intelligently" decides to enqueue or to print the CSS file. If the |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5007 |
* {@see 'wp_print_styles'} action has *not* yet been called, the CSS file will be |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5008 |
* enqueued. If the {@see 'wp_print_styles'} action has been called, the CSS link will |
0 | 5009 |
* be printed. Printing may be forced by passing true as the $force_echo |
5010 |
* (second) parameter. |
|
5011 |
* |
|
5012 |
* For backward compatibility with WordPress 2.3 calling method: If the $file |
|
5013 |
* (first) parameter does not correspond to a registered CSS file, we assume |
|
5014 |
* $file is a file relative to wp-admin/ without its ".css" extension. A |
|
5015 |
* stylesheet link to that generated URL is printed. |
|
5016 |
* |
|
5017 |
* @since 2.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5018 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5019 |
* @param string $file Optional. Style handle name or file name (without ".css" extension) relative |
9 | 5020 |
* to wp-admin/. Defaults to 'wp-admin'. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5021 |
* @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. |
0 | 5022 |
*/ |
5023 |
function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { |
|
16 | 5024 |
// For backward compatibility. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5025 |
$handle = str_starts_with( $file, 'css/' ) ? substr( $file, 4 ) : $file; |
0 | 5026 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5027 |
if ( wp_styles()->query( $handle ) ) { |
16 | 5028 |
if ( $force_echo || did_action( 'wp_print_styles' ) ) { |
5029 |
// We already printed the style queue. Print this one immediately. |
|
0 | 5030 |
wp_print_styles( $handle ); |
16 | 5031 |
} else { |
5032 |
// Add to style queue. |
|
0 | 5033 |
wp_enqueue_style( $handle ); |
9 | 5034 |
} |
0 | 5035 |
return; |
5036 |
} |
|
5037 |
||
16 | 5038 |
$stylesheet_link = sprintf( |
5039 |
"<link rel='stylesheet' href='%s' type='text/css' />\n", |
|
5040 |
esc_url( wp_admin_css_uri( $file ) ) |
|
5041 |
); |
|
5042 |
||
5 | 5043 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5044 |
* Filters the stylesheet link to the specified CSS file. |
5 | 5045 |
* |
5046 |
* If the site is set to display right-to-left, the RTL stylesheet link |
|
5047 |
* will be used instead. |
|
5048 |
* |
|
5049 |
* @since 2.3.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5050 |
* @param string $stylesheet_link HTML link element for the stylesheet. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5051 |
* @param string $file Style handle name or filename (without ".css" extension) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5052 |
* relative to wp-admin/. Defaults to 'wp-admin'. |
5 | 5053 |
*/ |
16 | 5054 |
echo apply_filters( 'wp_admin_css', $stylesheet_link, $file ); |
5 | 5055 |
|
5056 |
if ( function_exists( 'is_rtl' ) && is_rtl() ) { |
|
16 | 5057 |
$rtl_stylesheet_link = sprintf( |
5058 |
"<link rel='stylesheet' href='%s' type='text/css' />\n", |
|
5059 |
esc_url( wp_admin_css_uri( "$file-rtl" ) ) |
|
5060 |
); |
|
5061 |
||
5 | 5062 |
/** This filter is documented in wp-includes/general-template.php */ |
16 | 5063 |
echo apply_filters( 'wp_admin_css', $rtl_stylesheet_link, "$file-rtl" ); |
5 | 5064 |
} |
0 | 5065 |
} |
5066 |
||
5067 |
/** |
|
5068 |
* Enqueues the default ThickBox js and css. |
|
5069 |
* |
|
5070 |
* If any of the settings need to be changed, this can be done with another js |
|
5071 |
* file similar to media-upload.js. That file should |
|
5072 |
* require array('thickbox') to ensure it is loaded after. |
|
5073 |
* |
|
5074 |
* @since 2.5.0 |
|
5075 |
*/ |
|
5076 |
function add_thickbox() { |
|
5077 |
wp_enqueue_script( 'thickbox' ); |
|
5078 |
wp_enqueue_style( 'thickbox' ); |
|
5079 |
||
9 | 5080 |
if ( is_network_admin() ) { |
0 | 5081 |
add_action( 'admin_head', '_thickbox_path_admin_subfolder' ); |
9 | 5082 |
} |
0 | 5083 |
} |
5084 |
||
5085 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5086 |
* Displays the XHTML generator that is generated on the wp_head hook. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5087 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5088 |
* See {@see 'wp_head'}. |
0 | 5089 |
* |
5090 |
* @since 2.5.0 |
|
5091 |
*/ |
|
5092 |
function wp_generator() { |
|
5 | 5093 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5094 |
* Filters the output of the XHTML generator tag. |
5 | 5095 |
* |
5096 |
* @since 2.5.0 |
|
5097 |
* |
|
5098 |
* @param string $generator_type The XHTML generator. |
|
5099 |
*/ |
|
0 | 5100 |
the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) ); |
5101 |
} |
|
5102 |
||
5103 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5104 |
* Displays the generator XML or Comment for RSS, ATOM, etc. |
0 | 5105 |
* |
5106 |
* Returns the correct generator type for the requested output format. Allows |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5107 |
* for a plugin to filter generators overall the {@see 'the_generator'} filter. |
0 | 5108 |
* |
5109 |
* @since 2.5.0 |
|
5110 |
* |
|
5111 |
* @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export). |
|
5112 |
*/ |
|
5113 |
function the_generator( $type ) { |
|
5 | 5114 |
/** |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
5115 |
* Filters the output of the XHTML generator tag, for display. |
5 | 5116 |
* |
5117 |
* @since 2.5.0 |
|
5118 |
* |
|
5119 |
* @param string $generator_type The generator output. |
|
5120 |
* @param string $type The type of generator to output. Accepts 'html', |
|
5121 |
* 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'. |
|
5122 |
*/ |
|
9 | 5123 |
echo apply_filters( 'the_generator', get_the_generator( $type ), $type ) . "\n"; |
0 | 5124 |
} |
5125 |
||
5126 |
/** |
|
5127 |
* Creates the generator XML or Comment for RSS, ATOM, etc. |
|
5128 |
* |
|
5129 |
* Returns the correct generator type for the requested output format. Allows |
|
5130 |
* for a plugin to filter generators on an individual basis using the |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5131 |
* {@see 'get_the_generator_$type'} filter. |
0 | 5132 |
* |
5133 |
* @since 2.5.0 |
|
5134 |
* |
|
5135 |
* @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export). |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5136 |
* @return string|void The HTML content for the generator. |
0 | 5137 |
*/ |
5138 |
function get_the_generator( $type = '' ) { |
|
5139 |
if ( empty( $type ) ) { |
|
5140 |
||
5141 |
$current_filter = current_filter(); |
|
9 | 5142 |
if ( empty( $current_filter ) ) { |
0 | 5143 |
return; |
9 | 5144 |
} |
0 | 5145 |
|
5146 |
switch ( $current_filter ) { |
|
9 | 5147 |
case 'rss2_head': |
5148 |
case 'commentsrss2_head': |
|
0 | 5149 |
$type = 'rss2'; |
5150 |
break; |
|
9 | 5151 |
case 'rss_head': |
5152 |
case 'opml_head': |
|
0 | 5153 |
$type = 'comment'; |
5154 |
break; |
|
9 | 5155 |
case 'rdf_header': |
0 | 5156 |
$type = 'rdf'; |
5157 |
break; |
|
9 | 5158 |
case 'atom_head': |
5159 |
case 'comments_atom_head': |
|
5160 |
case 'app_head': |
|
0 | 5161 |
$type = 'atom'; |
5162 |
break; |
|
5163 |
} |
|
5164 |
} |
|
5165 |
||
5166 |
switch ( $type ) { |
|
5167 |
case 'html': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5168 |
$gen = '<meta name="generator" content="WordPress ' . esc_attr( get_bloginfo( 'version' ) ) . '">'; |
0 | 5169 |
break; |
5170 |
case 'xhtml': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5171 |
$gen = '<meta name="generator" content="WordPress ' . esc_attr( get_bloginfo( 'version' ) ) . '" />'; |
0 | 5172 |
break; |
5173 |
case 'atom': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5174 |
$gen = '<generator uri="https://wordpress.org/" version="' . esc_attr( get_bloginfo_rss( 'version' ) ) . '">WordPress</generator>'; |
0 | 5175 |
break; |
5176 |
case 'rss2': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5177 |
$gen = '<generator>' . sanitize_url( 'https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) ) . '</generator>'; |
0 | 5178 |
break; |
5179 |
case 'rdf': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5180 |
$gen = '<admin:generatorAgent rdf:resource="' . sanitize_url( 'https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) ) . '" />'; |
0 | 5181 |
break; |
5182 |
case 'comment': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5183 |
$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo( 'version' ) ) . '" -->'; |
0 | 5184 |
break; |
5185 |
case 'export': |
|
16 | 5186 |
$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo_rss( 'version' ) ) . '" created="' . gmdate( 'Y-m-d H:i' ) . '" -->'; |
0 | 5187 |
break; |
5188 |
} |
|
5 | 5189 |
|
5190 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5191 |
* Filters the HTML for the retrieved generator type. |
5 | 5192 |
* |
5193 |
* The dynamic portion of the hook name, `$type`, refers to the generator type. |
|
5194 |
* |
|
18 | 5195 |
* Possible hook names include: |
5196 |
* |
|
5197 |
* - `get_the_generator_atom` |
|
5198 |
* - `get_the_generator_comment` |
|
5199 |
* - `get_the_generator_export` |
|
5200 |
* - `get_the_generator_html` |
|
5201 |
* - `get_the_generator_rdf` |
|
5202 |
* - `get_the_generator_rss2` |
|
5203 |
* - `get_the_generator_xhtml` |
|
5204 |
* |
|
5 | 5205 |
* @since 2.5.0 |
5206 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5207 |
* @param string $gen The HTML markup output to wp_head(). |
5 | 5208 |
* @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom', |
5209 |
* 'rss2', 'rdf', 'comment', 'export'. |
|
5210 |
*/ |
|
0 | 5211 |
return apply_filters( "get_the_generator_{$type}", $gen, $type ); |
5212 |
} |
|
5213 |
||
5214 |
/** |
|
16 | 5215 |
* Outputs the HTML checked attribute. |
0 | 5216 |
* |
19 | 5217 |
* Compares the first two arguments and if identical marks as checked. |
0 | 5218 |
* |
5219 |
* @since 1.0.0 |
|
5220 |
* |
|
19 | 5221 |
* @param mixed $checked One of the values to compare. |
5222 |
* @param mixed $current Optional. The other value to compare if not just true. |
|
5223 |
* Default true. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5224 |
* @param bool $display Optional. Whether to echo or just return the string. |
19 | 5225 |
* Default true. |
5226 |
* @return string HTML attribute or empty string. |
|
0 | 5227 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5228 |
function checked( $checked, $current = true, $display = true ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5229 |
return __checked_selected_helper( $checked, $current, $display, 'checked' ); |
0 | 5230 |
} |
5231 |
||
5232 |
/** |
|
16 | 5233 |
* Outputs the HTML selected attribute. |
0 | 5234 |
* |
19 | 5235 |
* Compares the first two arguments and if identical marks as selected. |
0 | 5236 |
* |
5237 |
* @since 1.0.0 |
|
5238 |
* |
|
19 | 5239 |
* @param mixed $selected One of the values to compare. |
5240 |
* @param mixed $current Optional. The other value to compare if not just true. |
|
5241 |
* Default true. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5242 |
* @param bool $display Optional. Whether to echo or just return the string. |
19 | 5243 |
* Default true. |
5244 |
* @return string HTML attribute or empty string. |
|
0 | 5245 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5246 |
function selected( $selected, $current = true, $display = true ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5247 |
return __checked_selected_helper( $selected, $current, $display, 'selected' ); |
0 | 5248 |
} |
5249 |
||
5250 |
/** |
|
16 | 5251 |
* Outputs the HTML disabled attribute. |
0 | 5252 |
* |
19 | 5253 |
* Compares the first two arguments and if identical marks as disabled. |
0 | 5254 |
* |
5255 |
* @since 3.0.0 |
|
5256 |
* |
|
19 | 5257 |
* @param mixed $disabled One of the values to compare. |
5258 |
* @param mixed $current Optional. The other value to compare if not just true. |
|
5259 |
* Default true. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5260 |
* @param bool $display Optional. Whether to echo or just return the string. |
19 | 5261 |
* Default true. |
5262 |
* @return string HTML attribute or empty string. |
|
0 | 5263 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5264 |
function disabled( $disabled, $current = true, $display = true ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5265 |
return __checked_selected_helper( $disabled, $current, $display, 'disabled' ); |
0 | 5266 |
} |
5267 |
||
5268 |
/** |
|
16 | 5269 |
* Outputs the HTML readonly attribute. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5270 |
* |
19 | 5271 |
* Compares the first two arguments and if identical marks as readonly. |
5272 |
* |
|
5273 |
* @since 5.9.0 |
|
5274 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5275 |
* @param mixed $readonly_value One of the values to compare. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5276 |
* @param mixed $current Optional. The other value to compare if not just true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5277 |
* Default true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5278 |
* @param bool $display Optional. Whether to echo or just return the string. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5279 |
* Default true. |
19 | 5280 |
* @return string HTML attribute or empty string. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5281 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5282 |
function wp_readonly( $readonly_value, $current = true, $display = true ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5283 |
return __checked_selected_helper( $readonly_value, $current, $display, 'readonly' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5284 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5285 |
|
19 | 5286 |
/* |
5287 |
* Include a compat `readonly()` function on PHP < 8.1. Since PHP 8.1, |
|
5288 |
* `readonly` is a reserved keyword and cannot be used as a function name. |
|
5289 |
* In order to avoid PHP parser errors, this function was extracted |
|
5290 |
* to a separate file and is only included conditionally on PHP < 8.1. |
|
5291 |
*/ |
|
5292 |
if ( PHP_VERSION_ID < 80100 ) { |
|
5293 |
require_once __DIR__ . '/php-compat/readonly.php'; |
|
5294 |
} |
|
5295 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5296 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5297 |
* Private helper function for checked, selected, disabled and readonly. |
0 | 5298 |
* |
19 | 5299 |
* Compares the first two arguments and if identical marks as `$type`. |
0 | 5300 |
* |
5301 |
* @since 2.8.0 |
|
5302 |
* @access private |
|
5303 |
* |
|
19 | 5304 |
* @param mixed $helper One of the values to compare. |
5305 |
* @param mixed $current The other value to compare if not just true. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5306 |
* @param bool $display Whether to echo or just return the string. |
19 | 5307 |
* @param string $type The type of checked|selected|disabled|readonly we are doing. |
5308 |
* @return string HTML attribute or empty string. |
|
0 | 5309 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5310 |
function __checked_selected_helper( $helper, $current, $display, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore |
9 | 5311 |
if ( (string) $helper === (string) $current ) { |
0 | 5312 |
$result = " $type='$type'"; |
9 | 5313 |
} else { |
0 | 5314 |
$result = ''; |
9 | 5315 |
} |
5316 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5317 |
if ( $display ) { |
0 | 5318 |
echo $result; |
9 | 5319 |
} |
0 | 5320 |
|
5321 |
return $result; |
|
5322 |
} |
|
5323 |
||
5324 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5325 |
* Assigns a visual indicator for required form fields. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5326 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5327 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5328 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5329 |
* @return string Indicator glyph wrapped in a `span` tag. |
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 |
function wp_required_field_indicator() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5332 |
/* translators: Character to identify required form fields. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5333 |
$glyph = __( '*' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5334 |
$indicator = '<span class="required">' . esc_html( $glyph ) . '</span>'; |
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 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5337 |
* Filters the markup for a visual indicator of required form fields. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5338 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5339 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5340 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5341 |
* @param string $indicator Markup for the indicator element. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5342 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5343 |
return apply_filters( 'wp_required_field_indicator', $indicator ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5344 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5345 |
|
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 |
* Creates a message to explain required form fields. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5348 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5349 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5350 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5351 |
* @return string Message text and glyph wrapped in a `span` tag. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5352 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5353 |
function wp_required_field_message() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5354 |
$message = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5355 |
'<span class="required-field-message">%s</span>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5356 |
/* translators: %s: Asterisk symbol (*). */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5357 |
sprintf( __( 'Required fields are marked %s' ), wp_required_field_indicator() ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5358 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5359 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5360 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5361 |
* Filters the message to explain required form fields. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5362 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5363 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5364 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5365 |
* @param string $message Message text and glyph wrapped in a `span` tag. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5366 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5367 |
return apply_filters( 'wp_required_field_message', $message ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5368 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5369 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5370 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5371 |
* Default settings for heartbeat. |
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 |
* Outputs the nonce used in the heartbeat XHR. |
0 | 5374 |
* |
5375 |
* @since 3.6.0 |
|
5376 |
* |
|
5377 |
* @param array $settings |
|
16 | 5378 |
* @return array Heartbeat settings. |
0 | 5379 |
*/ |
5380 |
function wp_heartbeat_settings( $settings ) { |
|
9 | 5381 |
if ( ! is_admin() ) { |
0 | 5382 |
$settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' ); |
9 | 5383 |
} |
5384 |
||
5385 |
if ( is_user_logged_in() ) { |
|
0 | 5386 |
$settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' ); |
9 | 5387 |
} |
0 | 5388 |
|
5389 |
return $settings; |
|
5390 |
} |