PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.3
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
jetpack / jetpack_vendor / automattic / jetpack-seo / src / class-dashboard-data.php

class-dashboard-data.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.3, at jetpack_vendor/automattic/jetpack-seo/src/class-dashboard-data.php

561 lines 23.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The SEO dashboard's read-only REST routes and the payload builders behind
4 * them — one route per data-backed tab, preloaded onto the page so a normal
5 * load resolves them with no request.
6 *
7 * @package automattic/jetpack-seo-package
8 */
9
10 namespace Automattic\Jetpack\SEO;
11
12 use Automattic\Jetpack\Modules;
13 use Jetpack_SEO_Utils;
14
15 /**
16 * Registers the dashboard's read routes and builds their payloads.
17 */
18 class Dashboard_Data {
19
20 /**
21 * Map of read-only dashboard routes: tab slug => data-builder callable. The
22 * single source of truth for both the registered routes and the paths
23 * preloaded onto the page, so the two can't drift.
24 *
25 * @return array<string, callable>
26 */
27 private static function rest_reads() {
28 return array(
29 'overview' => array( __CLASS__, 'get_overview_data' ),
30 'settings' => array( __CLASS__, 'get_settings_data' ),
31 'ai' => array( __CLASS__, 'get_ai_data' ),
32 'content' => array( __CLASS__, 'get_content_data' ),
33 );
34 }
35
36 /**
37 * REST paths the dashboard reads its initial state from, preloaded into the
38 * page (see {@see Admin_Page::inject_script_data()}) and fetched by the app.
39 *
40 * @return string[]
41 */
42 public static function rest_read_paths() {
43 return array_map(
44 static function ( $slug ) {
45 return '/jetpack/v4/seo/' . $slug;
46 },
47 array_keys( self::rest_reads() )
48 );
49 }
50
51 /**
52 * Register the read-only REST routes the dashboard hydrates from — one per
53 * data-backed tab, each returning the same builder payload previously injected
54 * synchronously onto the page. Read-only and gated to the page's own
55 * `manage_options`; writes still go through their existing endpoints.
56 *
57 * @return void
58 */
59 public static function register_rest_reads() {
60 foreach ( self::rest_reads() as $slug => $builder ) {
61 register_rest_route(
62 'jetpack/v4',
63 '/seo/' . $slug,
64 array(
65 'methods' => \WP_REST_Server::READABLE,
66 'callback' => static function () use ( $builder ) {
67 return rest_ensure_response( call_user_func( $builder ) );
68 },
69 'permission_callback' => array( __CLASS__, 'reads_permission_check' ),
70 )
71 );
72 }
73 }
74
75 /**
76 * Capability gate for the dashboard's read routes — the same `manage_options`
77 * the SEO admin page itself requires.
78 *
79 * @return bool
80 */
81 public static function reads_permission_check() {
82 return current_user_can( 'manage_options' );
83 }
84
85 /**
86 * Expose the core `blog_public` option to the REST settings endpoint.
87 *
88 * Search-engine visibility is a WordPress core option, not a Jetpack one,
89 * so the Settings tab saves it through `/wp/v2/settings` — which only
90 * round-trips settings registered with `show_in_rest`. The core settings
91 * controller enforces the `manage_options` capability on writes.
92 *
93 * @return void
94 */
95 public static function register_rest_settings() {
96 register_setting(
97 'reading',
98 'blog_public',
99 array(
100 'show_in_rest' => true,
101 'type' => 'integer',
102 'default' => 1,
103 )
104 );
105
106 // Refuse an indexing write that would publish a private site. Scoped to core's
107 // settings route rather than attached as `blog_public`'s sanitizer, because a
108 // `register_setting()` sanitizer applies to every writer of the option for the
109 // rest of the request — including the site's own visibility control, which must
110 // stay able to change it.
111 add_filter( 'rest_pre_update_setting', array( __CLASS__, 'block_publishing_a_private_site' ), 10, 3 );
112 }
113
114 /**
115 * Whether the site is private or still in coming-soon, which WordPress.com records
116 * as a negative `blog_public`. Always false on self-hosted, where the option is a
117 * plain 0/1.
118 *
119 * @return bool
120 */
121 private static function is_site_private() {
122 return (int) get_option( 'blog_public', 1 ) < 0;
123 }
124
125 /**
126 * Keep a WordPress.com site's private or coming-soon state out of reach of an SEO
127 * toggle.
128 *
129 * `blog_public` is a plain 0/1 on self-hosted, but WordPress.com also stores `-1`
130 * for a private site and `-2` for one still in coming-soon. This dashboard only
131 * offers "allow search engines to index this site", which writes 1 or 0 — so
132 * without this, the owner of an unfinished site who flipped that toggle on
133 * published it. Publishing a site is not a search-engine setting and isn't a
134 * decision this surface asks for, so a negative stored value is left alone.
135 *
136 * The site's own visibility control is what changes it — and still can, because
137 * this hangs off core's settings route rather than the option's sanitizer.
138 * {@see self::get_settings_data()} reports `site_is_private` so the toggle can say
139 * why it's disabled rather than silently doing nothing.
140 *
141 * @param bool $handled Whether another handler already wrote the setting.
142 * @param string $name Setting name.
143 * @param mixed $value Submitted value.
144 * @return bool True to report the write as handled, which skips it.
145 */
146 public static function block_publishing_a_private_site( $handled, $name, $value ) {
147 if ( $handled || 'blog_public' !== $name ) {
148 return $handled;
149 }
150
151 // Leave a write that keeps the site unpublished alone; only a move to a public
152 // value is refused.
153 return self::is_site_private() && (int) $value >= 0;
154 }
155
156 /**
157 * Build the aggregated Overview state the dashboard renders.
158 *
159 * @return array
160 */
161 public static function get_overview_data() {
162 $modules = new Modules();
163 // @phan-suppress-next-line PhanUndeclaredClassMethod -- Jetpack_SEO_Utils lives in plugins/jetpack and is guarded by class_exists.
164 $seo_enabled = class_exists( 'Jetpack_SEO_Utils' ) && Jetpack_SEO_Utils::is_enabled_jetpack_seo();
165
166 $codes = get_option( 'verification_services_codes', array() );
167 if ( ! is_array( $codes ) ) {
168 $codes = array();
169 }
170
171 return array(
172 'site_visibility' => array(
173 'search_engines_visible' => (int) get_option( 'blog_public', 1 ) === 1,
174 'site_is_private' => self::is_site_private(),
175 // Read the durable SEO option (seeded/synced from the `sitemaps` module
176 // by the Jetpack plugin) so the state survives the module's removal. The
177 // reachable sitemap URL + "View" link live on the Settings tab.
178 'sitemap_active' => self::is_sitemap_enabled( $modules ),
179 'seo_tools_active' => $modules->is_active( 'seo-tools' ),
180 ),
181 // Per-service booleans (a code is set or not) for the Overview's
182 // Site verification card.
183 'site_verification' => array(
184 'google' => ! empty( $codes['google'] ),
185 'bing' => ! empty( $codes['bing'] ),
186 'pinterest' => ! empty( $codes['pinterest'] ),
187 'yandex' => ! empty( $codes['yandex'] ),
188 'facebook' => ! empty( $codes['facebook'] ),
189 ),
190 'content_coverage' => Content_Coverage::get(),
191 'plan' => array(
192 'seo_enabled_for_site' => $seo_enabled,
193 ),
194 );
195 }
196
197 /**
198 * Coerce the stored title formats into one `{ type, value }` token list per page type.
199 *
200 * The site-settings API stores a cleared page type as `''` (see JETPACK-2284), so the
201 * option is looser than the Settings tab's type; anything not a token list becomes `array()`.
202 *
203 * @since 0.9.5
204 *
205 * @param mixed $stored Raw option value.
206 * @return array<string, array<int, array{type: string, value: string}>>
207 */
208 public static function normalize_title_formats( $stored ) {
209 if ( ! is_array( $stored ) ) {
210 return array();
211 }
212
213 $normalized = array();
214 foreach ( $stored as $page_type => $format ) {
215 $tokens = array();
216 if ( is_array( $format ) ) {
217 foreach ( $format as $item ) {
218 if ( is_array( $item ) && isset( $item['type'] ) && isset( $item['value'] ) && is_string( $item['type'] ) && is_string( $item['value'] ) ) {
219 $tokens[] = array(
220 'type' => $item['type'],
221 'value' => $item['value'],
222 );
223 }
224 }
225 }
226 $normalized[ (string) $page_type ] = $tokens;
227 }
228
229 return $normalized;
230 }
231
232 /**
233 * Build the editable Settings state the Settings tab hydrates from.
234 *
235 * Read-only bootstrap only. Most writes go through the existing
236 * `/jetpack/v4/settings` REST endpoint, which already validates and
237 * sanitizes those flat fields. Nested Schema writes use the package's
238 * schema-settings route; bootstrapping them here keeps the Settings UI
239 * hydrated without a second request.
240 *
241 * @return array
242 */
243 public static function get_settings_data() {
244 $modules = new Modules();
245
246 // Read the stored values directly: Jetpack_SEO_Titles::get_custom_title_formats()
247 // intentionally hides them while another SEO plugin controls output, but the
248 // dashboard must still show the saved values without allowing edits.
249 $title_formats = self::normalize_title_formats( get_option( 'advanced_seo_title_formats', array() ) );
250 // @phan-suppress-next-line PhanUndeclaredClassMethod -- Jetpack_SEO_Utils lives in plugins/jetpack and is guarded by class_exists.
251 $title_formats_editable = class_exists( 'Jetpack_SEO_Utils' ) && Jetpack_SEO_Utils::is_enabled_jetpack_seo();
252 // @phan-suppress-next-line PhanUndeclaredClassMethod -- Jetpack_SEO_Utils lives in plugins/jetpack and is guarded by class_exists.
253 $front_page_desc = class_exists( 'Jetpack_SEO_Utils' ) ? Jetpack_SEO_Utils::get_front_page_meta_description() : '';
254
255 // A site that set a front-page description back when it was free for all
256 // WordPress.com Simple sites keeps editing it, even when otherwise plan-gated:
257 // the value stays live and `Jetpack_SEO_Utils` still reads/writes it via the
258 // legacy option. The gated Settings uses this to keep that one field editable.
259 // @phan-suppress-next-line PhanUndeclaredClassMethod -- Jetpack_SEO_Utils lives in plugins/jetpack and is guarded by class_exists.
260 $has_legacy_front_page_meta = class_exists( 'Jetpack_SEO_Utils' ) && (bool) Jetpack_SEO_Utils::has_legacy_front_page_meta();
261
262 $codes = get_option( 'verification_services_codes', array() );
263 if ( ! is_array( $codes ) ) {
264 $codes = array();
265 }
266
267 $sitemap_active = self::is_sitemap_enabled( $modules );
268
269 return array(
270 'search_engines_visible' => (int) get_option( 'blog_public', 1 ) === 1,
271 // A private or coming-soon WordPress.com site isn't hidden from search by an
272 // SEO setting and can't be unhidden by one — see {@see self::block_publishing_a_private_site()}.
273 'site_is_private' => self::is_site_private(),
274 // Read the durable SEO option (seeded/synced from the `sitemaps` module
275 // by the Jetpack plugin) so the state survives the module's removal.
276 'sitemap_active' => $sitemap_active,
277 // The reachable sitemap URL (Jetpack serves a valid sitemap here as soon as
278 // it's on + the site is public), or '' when sitemaps are off, so the Settings
279 // tab shows the "View sitemap" link exactly when there's a sitemap to view.
280 'sitemap_url' => self::get_reachable_sitemap_url( $sitemap_active ),
281 // Read the durable SEO option (seeded/synced from the `canonical-urls` module
282 // by the Jetpack plugin) so the state survives the module's removal.
283 'canonical_active' => self::is_canonical_enabled( $modules ),
284 // Cast to object so an empty format set serializes as `{}`, not `[]`.
285 'title_formats' => (object) $title_formats,
286 // Separator WordPress joins default document-title parts with. A page type
287 // with no stored format keeps the default title: `get_custom_title()` returns
288 // the incoming value untouched, so core composes the title itself and the
289 // Settings tab replays that composition to preview it.
290 'title_separator' => self::get_default_title_separator(),
291 'title_formats_editable' => $title_formats_editable,
292 'front_page_description' => (string) $front_page_desc,
293 'has_legacy_front_page_meta' => $has_legacy_front_page_meta,
294 'verification_tools_active' => $modules->is_active( 'verification-tools' ),
295 'verification' => array(
296 'google' => isset( $codes['google'] ) ? (string) $codes['google'] : '',
297 'bing' => isset( $codes['bing'] ) ? (string) $codes['bing'] : '',
298 'pinterest' => isset( $codes['pinterest'] ) ? (string) $codes['pinterest'] : '',
299 'yandex' => isset( $codes['yandex'] ) ? (string) $codes['yandex'] : '',
300 'facebook' => isset( $codes['facebook'] ) ? (string) $codes['facebook'] : '',
301 ),
302 'schema' => Schema_Settings::get_editable(),
303 );
304 }
305
306 /**
307 * Build the Google site-verification state for the Settings tab.
308 *
309 * The Settings verification card lets a connected user verify with Google via a
310 * WordPress.com keyring OAuth popup (in addition to pasting a meta-tag code). This
311 * bootstraps the keyring connect URL and whether the current user is connected —
312 * the live verified status is fetched client-side from `/jetpack/v4/verify-site/google`
313 * (a wpcom round-trip we don't want to make on every page load).
314 *
315 * Both `Keyring_Helper` (Publicize package) and the connection `Manager` are provided
316 * by the host Jetpack plugin, so they're guarded with `class_exists` like the
317 * `Jetpack_SEO_*` helpers. On a disconnected self-hosted site `is_connected` is false
318 * and the UI falls back to manual code entry only.
319 *
320 * @return array
321 */
322 public static function get_google_verify_data() {
323 $connect_url = '';
324 if ( class_exists( 'Automattic\\Jetpack\\Publicize\\Keyring_Helper' ) ) {
325 // @phan-suppress-next-line PhanUndeclaredClassMethod -- guarded; Publicize package is provided by the host plugin.
326 $connect_url = (string) \Automattic\Jetpack\Publicize\Keyring_Helper::connect_url( 'google_site_verification', 'other' );
327 }
328
329 $is_connected = false;
330 if ( class_exists( 'Automattic\\Jetpack\\Connection\\Manager' ) ) {
331 $is_connected = ( new \Automattic\Jetpack\Connection\Manager() )->is_user_connected();
332 }
333
334 return array(
335 'connect_url' => $connect_url,
336 'is_connected' => (bool) $is_connected,
337 );
338 }
339
340 /**
341 * Build the AI tab's initial state.
342 *
343 * The AI SEO Enhancer auto-generates SEO titles/descriptions/alt-text in the
344 * editor (the generation itself is wpcom/AI-Assistant side); this exposes only
345 * its persisted on/off toggle, whether it's available, and whether the AI SEO
346 * control it sits under is on. Availability mirrors the legacy Traffic page:
347 * the `ai_seo_enhancer_enabled` feature filter must be on (it still depends on
348 * AI being available) AND the site's plan must support the `ai-seo-enhancer`
349 * feature. The toggle writes through the existing `/jetpack/v4/settings`
350 * endpoint (`ai_seo_enhancer_enabled`).
351 *
352 * `aiSeoEnabled` is reported separately rather than folded into availability:
353 * with the control off the card is disabled, not hidden, so the saved choice
354 * stays visible — the same treatment the Traffic page gives it.
355 *
356 * @return array
357 */
358 public static function get_ai_data() {
359 $filter_on = (bool) apply_filters( 'ai_seo_enhancer_enabled', true );
360
361 // Jetpack_AI_Settings lives in plugins/jetpack, which bundles this package; guarded
362 // like the other host-plugin classes here. Without the method the AI SEO control
363 // does not exist, so the enhancer keeps its pre-control behavior.
364 // @phan-suppress-next-line PhanUndeclaredClassMethod -- Jetpack_AI_Settings lives in plugins/jetpack and is guarded by is_callable.
365 $ai_seo_on = ! is_callable( array( 'Jetpack_AI_Settings', 'is_ai_seo_enabled' ) ) || \Jetpack_AI_Settings::is_ai_seo_enabled();
366
367 // Current_Plan comes from the jetpack-plans package (a dependency of this
368 // package since the plan-gating work), so it's always available here; the
369 // class_exists guard is kept as belt-and-suspenders for older bundled snapshots.
370 $plan_supports = class_exists( 'Automattic\\Jetpack\\Current_Plan' )
371 && \Automattic\Jetpack\Current_Plan::supports( 'ai-seo-enhancer' );
372
373 return array(
374 'enhancer' => array(
375 'available' => $filter_on && $plan_supports,
376 'enabled' => (bool) get_option( 'ai_seo_enhancer_enabled', false ),
377 'aiSeoEnabled' => $ai_seo_on,
378 ),
379 'llmsTxt' => array(
380 'enabled' => Llms_Txt::is_enabled(),
381 'url' => home_url( '/llms.txt' ),
382 'canServe' => Llms_Txt::can_serve(),
383 ),
384 'crawlers' => Ai_Crawlers::get_bootstrap_data(),
385 );
386 }
387
388 /**
389 * Build the supported post type options for the Content tab.
390 *
391 * @return array{post_types:array<int,array{slug:string,label:string}>}
392 */
393 public static function get_content_data() {
394 return array(
395 'post_types' => Post_Types::get_supported_content_type_options(),
396 );
397 }
398
399 /**
400 * Site identity used to render the homepage search/social previews on the
401 * Settings tab: title, tagline, URL, and representative images. The front-page
402 * description that completes the preview is read from the Settings form
403 * (it's editable there), not bootstrapped here.
404 *
405 * @return array
406 */
407 public static function get_site_data() {
408 $icon_url = (string) get_site_icon_url();
409
410 $logo_id = (int) get_theme_mod( 'custom_logo' );
411 $logo_url = $logo_id ? (string) wp_get_attachment_image_url( $logo_id, 'full' ) : '';
412 if ( class_exists( 'Jetpack_Redux_State_Helper' ) ) {
413 // @phan-suppress-next-line PhanUndeclaredClassMethod -- Jetpack_Redux_State_Helper lives in plugins/jetpack and is guarded by class_exists.
414 $image_url = (string) \Jetpack_Redux_State_Helper::get_site_image();
415 } else {
416 $image_url = $logo_url ? $logo_url : $icon_url;
417 }
418
419 return array(
420 'title' => (string) get_bloginfo( 'name' ),
421 'tagline' => (string) get_bloginfo( 'description' ),
422 'url' => (string) home_url(),
423 'icon' => $icon_url,
424 'image' => $image_url,
425 );
426 }
427
428 /**
429 * Whether sitemap generation is enabled.
430 *
431 * Reads the durable {@see Initializer::SITEMAP_ENABLED_OPTION} flag. The default is only
432 * used when the option is absent (for example before the Jetpack plugin's migration
433 * has run on a freshly upgraded site), in which case it falls back to the live
434 * `sitemaps` module state so behavior is unchanged in that gap.
435 *
436 * @param Modules $modules Modules instance to read live module state from.
437 * @return bool
438 */
439 private static function is_sitemap_enabled( Modules $modules ) {
440 $enabled = get_option( Initializer::SITEMAP_ENABLED_OPTION, null );
441
442 // Only fall back to the live module state when the durable option is absent.
443 // Passing it as get_option()'s default would evaluate it on every call, since
444 // PHP resolves function arguments eagerly even when the option exists.
445 if ( null === $enabled ) {
446 $enabled = $modules->is_active( 'sitemaps' );
447 }
448
449 return (bool) $enabled;
450 }
451
452 /**
453 * Whether canonical URLs are enabled.
454 *
455 * Reads the durable {@see Initializer::CANONICAL_ENABLED_OPTION} flag. The default is only
456 * used when the option is absent (for example before the Jetpack plugin's migration
457 * has run on a freshly upgraded site), in which case it falls back to the live
458 * `canonical-urls` module state so behavior is unchanged in that gap.
459 *
460 * @param Modules $modules Modules instance to read live module state from.
461 * @return bool
462 */
463 private static function is_canonical_enabled( Modules $modules ) {
464 $enabled = get_option( Initializer::CANONICAL_ENABLED_OPTION, null );
465
466 // Only fall back to the live module state when the durable option is absent.
467 // Passing it as get_option()'s default would evaluate it on every call, since
468 // PHP resolves function arguments eagerly even when the option exists.
469 if ( null === $enabled ) {
470 $enabled = $modules->is_active( 'canonical-urls' );
471 }
472
473 return (bool) $enabled;
474 }
475
476 /**
477 * The separator, as rendered, that WordPress joins default document-title parts
478 * with — for previewing the title a page type with no stored format produces.
479 *
480 * `document_title_separator` alone is not what a visitor sees. `wp_get_document_title()`
481 * composes the parts, then passes the whole title through the `document_title`
482 * filter, which WordPress texturizes by default — turning the default spaced
483 * hyphen into an en dash. Previewing the raw filter value would show `-` on a site
484 * that renders `–`, which is every site running core's defaults.
485 *
486 * This applies only to the default title. A stored format short-circuits
487 * `pre_get_document_title`, which returns before the `document_title` filter, so a
488 * custom format keeps the separator the user typed verbatim — the front end renders
489 * `Site - MARKER - Page` for a custom format while producing `Page – Site` for the
490 * default one.
491 *
492 * @return string The rendered separator.
493 */
494 private static function get_default_title_separator() {
495 $separator = (string) apply_filters( 'document_title_separator', '-' );
496
497 // Only texturize when the title itself would be: a site that unhooks
498 // `wptexturize` renders the raw separator, and the preview should match.
499 if ( has_filter( 'document_title', 'wptexturize' ) ) {
500 $separator = trim(
501 html_entity_decode( wptexturize( ' ' . $separator . ' ' ), ENT_QUOTES, 'UTF-8' )
502 );
503 }
504
505 return $separator;
506 }
507
508 /**
509 * The public URL of the XML sitemap, or an empty string when none is reachable.
510 *
511 * A sitemap is reachable as soon as generation is enabled and the site is public:
512 * Jetpack serves a valid (empty-until-built) sitemap at a stable URL — never a 404 —
513 * so the link is safe to surface immediately, without waiting on (or gating against)
514 * the cron build. A prior gate looked the master sitemap up by a mis-built filename
515 * and so never matched, which is what left the Settings tab stuck on "Generating…".
516 *
517 * `jetpack_sitemap_uri()` / `jp_sitemap_filename()` and the JP_MASTER_SITEMAP_TYPE
518 * constant live in the Jetpack plugin's Sitemaps module (loaded only for an active
519 * module on a public site), so they are guarded; in the package-only context they
520 * are absent and the sitemap is reported as not reachable.
521 *
522 * @param bool $sitemap_active Whether sitemap generation is enabled.
523 * @return string The sitemap URL, or '' when not reachable.
524 */
525 private static function get_reachable_sitemap_url( $sitemap_active ) {
526 // Jetpack only serves sitemaps when generation is on and the site is public.
527 if ( ! $sitemap_active || (int) get_option( 'blog_public', 1 ) !== 1 ) {
528 return '';
529 }
530
531 // The `JP_MASTER_SITEMAP_TYPE` constant and the `jp_sitemap_filename()` /
532 // `jetpack_sitemap_uri()` helpers all live together in plugins/jetpack and load
533 // as a unit, so this single guard covers every symbol used below.
534 if (
535 ! defined( 'JP_MASTER_SITEMAP_TYPE' )
536 || ! function_exists( 'jp_sitemap_filename' )
537 || ! function_exists( 'jetpack_sitemap_uri' )
538 ) {
539 return '';
540 }
541
542 // `jp_sitemap_filename()` returns an error string ("error-not-int-…") unless a
543 // non-null number is passed; the master ignores the number, so pass 0 (matching
544 // Jetpack's own call sites). Fail safe: the master file is always 'sitemap.xml',
545 // so if a bundled Jetpack ever returns something else, report not-reachable
546 // rather than surface a broken URL — the exact failure this method shipped with
547 // before (the missing number silently produced an "error-not-int-…" link).
548 // @phan-suppress-next-line PhanUndeclaredFunction -- guarded above; symbols live in plugins/jetpack.
549 $filename = (string) jp_sitemap_filename( JP_MASTER_SITEMAP_TYPE, 0 );
550 if ( 'sitemap.xml' !== $filename ) {
551 return '';
552 }
553
554 // esc_url_raw (not esc_url): transported via script data and rendered by React,
555 // so it must not be HTML-entity-encoded (e.g. the plain-permalink
556 // `?jetpack-sitemap=` form keeps its raw `&`).
557 // @phan-suppress-next-line PhanUndeclaredFunction -- guarded above; symbols live in plugins/jetpack.
558 return esc_url_raw( (string) jetpack_sitemap_uri( $filename ) );
559 }
560 }
561