/home/u523506497/domains/mymelon.in/public_html/wp-includes UP
<?php
/**
* Class 'WP_Speculation_Rules'.
*
* @package WordPress
* @subpackage Speculative Loading
* @since 6.8.0
*/
/**
* Class representing a set of speculation rules.
*
* @since 6.8.0
* @access private
*/
final class WP_Speculation_Rules implements JsonSerializable {
/**
* Stored rules, as a map of `$mode => $rules` pairs.
*
* Every `$rules` value is a map of `$id => $rule` pairs.
*
* @since 6.8.0
* @var array<string, array<string, array<string, mixed>>>
*/
private $rules_by_mode = array();
/**
* The allowed speculation rules modes as a map, used for validation.
*
* @since 6.8.0
* @var array<string, bool>
*/
private static $mode_allowlist = array(
'prefetch' => true,
'prerender' => true,
);
/**
* The allowed speculation rules eagerness levels as a map, used for validation.
*
* @since 6.8.0
* @var array<string, bool>
*/
private static $eagerness_allowlist = array(
'immediate' => true,
'eager' => true,
'moderate' => true,
'conservative' => true,
);
/**
* The allowed speculation rules sources as a map, used for validation.
*
* @since 6.8.0
* @var array<string, bool>
*/
private static $source_allowlist = array(
'list' => true,
'document' => true,
);
/**
* Adds a speculation rule to the speculation rules to consider.
*
* @since 6.8.0
*
* @param string $mode Speculative loading mode. Either 'prefetch' or 'prerender'.
* @param string $id Unique string identifier for the speculation rule.
* @param array<string, mixed> $rule Associative array of rule arguments.
* @return bool True on success, false if invalid parameters are provided.
*/
public function add_rule( string $mode, string $id, array $rule ): bool {
if ( ! self::is_valid_mode( $mode ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: invalid mode value */
__( 'The value "%s" is not a valid speculation rules mode.' ),
esc_html( $mode )
),
'6.8.0'
);
return false;
}
if ( ! $this->is_valid_id( $id ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: invalid ID value */
__( 'The value "%s" is not a valid ID for a speculation rule.' ),
esc_html( $id )
),
'6.8.0'
);
return false;
}
if ( $this->has_rule( $mode, $id ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: invalid ID value */
__( 'A speculation rule with ID "%s" already exists.' ),
esc_html( $id )
),
'6.8.0'
);
return false;
}
/*
* Perform some basic speculation rule validation.
* Every rule must have either a 'where' key or a 'urls' key, but not both.
* The presence of a 'where' key implies a 'source' of 'document', while the presence of a 'urls' key implies
* a 'source' of 'list'.
*/
if (
( ! isset( $rule['where'] ) && ! isset( $rule['urls'] ) ) ||
( isset( $rule['where'] ) && isset( $rule['urls'] ) )
) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: 1: allowed key, 2: alternative allowed key */
__( 'A speculation rule must include either a "%1$s" key or a "%2$s" key, but not both.' ),
'where',
'urls'
),
'6.8.0'
);
return false;
}
if ( isset( $rule['source'] ) ) {
if ( ! self::is_valid_source( $rule['source'] ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: invalid source value */
__( 'The value "%s" is not a valid source for a speculation rule.' ),
esc_html( $rule['source'] )
),
'6.8.0'
);
return false;
}
if ( 'list' === $rule['source'] && isset( $rule['where'] ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: 1: source value, 2: forbidden key */
__( 'A speculation rule of source "%1$s" must not include a "%2$s" key.' ),
'list',
'where'
),
'6.8.0'
);
return false;
}
if ( 'document' === $rule['source'] && isset( $rule['urls'] ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: 1: source value, 2: forbidden key */
__( 'A speculation rule of source "%1$s" must not include a "%2$s" key.' ),
'document',
'urls'
),
'6.8.0'
);
return false;
}
}
// If there is an 'eagerness' key specified, make sure it's valid.
if ( isset( $rule['eagerness'] ) ) {
if ( ! self::is_valid_eagerness( $rule['eagerness'] ) ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: invalid eagerness value */
__( 'The value "%s" is not a valid eagerness for a speculation rule.' ),
esc_html( $rule['eagerness'] )
),
'6.8.0'
);
return false;
}
if ( isset( $rule['where'] ) && 'immediate' === $rule['eagerness'] ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: forbidden eagerness value */
__( 'The eagerness value "%s" is forbidden for document-level speculation rules.' ),
'immediate'
),
'6.8.0'
);
return false;
}
}
if ( ! isset( $this->rules_by_mode[ $mode ] ) ) {
$this->rules_by_mode[ $mode ] = array();
}
$this->rules_by_mode[ $mode ][ $id ] = $rule;
return true;
}
/**
* Checks whether a speculation rule for the given mode and ID already exists.
*
* @since 6.8.0
*
* @param string $mode Speculative loading mode. Either 'prefetch' or 'prerender'.
* @param string $id Unique string identifier for the speculation rule.
* @return bool True if the rule already exists, false otherwise.
*/
public function has_rule( string $mode, string $id ): bool {
return isset( $this->rules_by_mode[ $mode ][ $id ] );
}
/**
* Returns the speculation rules data ready to be JSON-encoded.
*
* @since 6.8.0
*
* @return array<string, array<int, array<string, mixed>>> Speculation rules data.
*/
#[ReturnTypeWillChange]
public function jsonSerialize() {
// Strip the IDs for JSON output, since they are not relevant for the Speculation Rules API.
return array_map(
static function ( array $rules ) {
return array_values( $rules );
},
array_filter( $this->rules_by_mode )
);
}
/**
* Checks whether the given ID is valid.
*
* @since 6.8.0
*
* @param string $id Unique string identifier for the speculation rule.
* @return bool True if the ID is valid, false otherwise.
*/
private function is_valid_id( string $id ): bool {
return (bool) preg_match( '/^[a-z][a-z0-9_-]+$/', $id );
}
/**
* Checks whether the given speculation rules mode is valid.
*
* @since 6.8.0
* @since 7.1.0 The $mode param now allows mixed and not just string.
*
* @param mixed $mode Speculation rules mode.
* @return bool True if valid, false otherwise.
*
* @phpstan-assert-if-true 'prefetch'|'prerender' $mode
*/
public static function is_valid_mode( $mode ): bool {
return is_string( $mode ) && isset( self::$mode_allowlist[ $mode ] );
}
/**
* Checks whether the given speculation rules eagerness is valid.
*
* @since 6.8.0
* @since 7.1.0 The $eagerness param now allows mixed and not just string.
*
* @param mixed $eagerness Speculation rules eagerness.
* @return bool True if valid, false otherwise.
*
* @phpstan-assert-if-true 'conservative'|'moderate'|'eager'|'immediate' $eagerness
*/
public static function is_valid_eagerness( $eagerness ): bool {
return is_string( $eagerness ) && isset( self::$eagerness_allowlist[ $eagerness ] );
}
/**
* Checks whether the given speculation rules source is valid.
*
* @since 6.8.0
*
* @param string $source Speculation rules source.
* @return bool True if valid, false otherwise.
*/
public static function is_valid_source( string $source ): bool {
return isset( self::$source_allowlist[ $source ] );
}
}
| ID3 | - | |
| IXR | - | |
| PHPMailer | - | |
| Requests | - | |
| SimplePie | - | |
| Text | - | |
| abilities-api | - | |
| abilities-api.php | 32800 | V |
| abilities.php | 11797 | V |
| admin-bar.php | 40067 | V |
| ai-client | - | |
| ai-client.php | 2549 | V |
| assets | - | |
| atomlib.php | 12181 | V |
| author-template.php | 19844 | V |
| block-bindings | - | |
| block-bindings.php | 7632 | V |
| block-editor.php | 28724 | V |
| block-i18n.json | 316 | V |
| block-patterns | - | |
| block-patterns.php | 15606 | V |
| block-supports | - | |
| block-template-utils.php | 63477 | V |
| block-template.php | 18257 | V |
| blocks | - | |
| blocks.php | 124205 | V |
| bookmark-template.php | 12768 | V |
| bookmark.php | 15427 | V |
| build | - | |
| cache-compat.php | 11021 | V |
| cache.php | 13486 | V |
| canonical.php | 34786 | V |
| capabilities.php | 43584 | V |
| category-template.php | 56990 | V |
| category.php | 12834 | V |
| certificates | - | |
| class-IXR.php | 2609 | V |
| class-avif-info.php | 30008 | V |
| class-feed.php | 539 | V |
| class-http.php | 367 | V |
| class-json.php | 171 | V |
| class-oembed.php | 401 | V |
| class-phpass.php | 6771 | V |
| class-phpmailer.php | 664 | V |
| class-pop3.php | 171 | V |
| class-requests.php | 2237 | V |
| class-simplepie.php | 453 | V |
| class-smtp.php | 457 | V |
| class-snoopy.php | 37715 | V |
| class-spl.php | 171 | V |
| class-walker-category-dropdown.php | 2469 | V |
| class-walker-category.php | 8477 | V |
| class-walker-comment.php | 14221 | V |
| class-walker-nav-menu.php | 12044 | V |
| class-walker-page-dropdown.php | 2710 | V |
| class-walker-page.php | 7612 | V |
| class-wp-admin-bar.php | 18002 | V |
| class-wp-ajax-response.php | 5288 | V |
| class-wp-application-passwords.php | 17099 | V |
| class-wp-block-bindings-registry.php | 8263 | V |
| class-wp-block-bindings-source.php | 2992 | V |
| class-wp-block-editor-context.php | 1350 | V |
| class-wp-block-list.php | 4713 | V |
| class-wp-block-metadata-registry.php | 11846 | V |
| class-wp-block-parser-block.php | 2555 | V |
| class-wp-block-parser-frame.php | 1994 | V |
| class-wp-block-parser.php | 11525 | V |
| class-wp-block-pattern-categories-registry.php | 4383 | V |
| class-wp-block-patterns-registry.php | 10265 | V |
| class-wp-block-processor.php | 69914 | V |
| class-wp-block-styles-registry.php | 6419 | V |
| class-wp-block-supports.php | 7578 | V |
| class-wp-block-template.php | 2111 | V |
| class-wp-block-templates-registry.php | 7080 | V |
| class-wp-block-type-registry.php | 5305 | V |
| class-wp-block-type.php | 17222 | V |
| class-wp-block.php | 28236 | V |
| class-wp-classic-to-block-menu-converter.php | 4026 | V |
| class-wp-comment-query.php | 49040 | V |
| class-wp-comment.php | 17249 | V |
| class-wp-connector-registry.php | 15181 | V |
| class-wp-customize-control.php | 26112 | V |
| class-wp-customize-manager.php | 202908 | V |
| class-wp-customize-nav-menus.php | 58034 | V |
| class-wp-customize-panel.php | 10703 | V |
| class-wp-customize-section.php | 11209 | V |
| class-wp-customize-setting.php | 29956 | V |
| class-wp-customize-widgets.php | 72596 | V |
| class-wp-date-query.php | 35970 | V |
| class-wp-dependencies.php | 17089 | V |
| class-wp-dependency.php | 2653 | V |
| class-wp-duotone.php | 40836 | V |
| class-wp-editor.php | 72228 | V |
| class-wp-embed.php | 15908 | V |
| class-wp-error.php | 7514 | V |
| class-wp-exception.php | 253 | V |
| class-wp-fatal-error-handler.php | 8150 | V |
| class-wp-feed-cache-transient.php | 3304 | V |
| class-wp-feed-cache.php | 969 | V |
| class-wp-filter-sentinel.php | 760 | V |
| class-wp-hook.php | 17584 | V |
| class-wp-http-cookie.php | 7269 | V |
| class-wp-http-curl.php | 13261 | V |
| class-wp-http-encoding.php | 6689 | V |
| class-wp-http-ixr-client.php | 3516 | V |
| class-wp-http-proxy.php | 5980 | V |
| class-wp-http-requests-hooks.php | 2022 | V |
| class-wp-http-requests-response.php | 4243 | V |
| class-wp-http-response.php | 2977 | V |
| class-wp-http-streams.php | 16764 | V |
| class-wp-http.php | 41641 | V |
| class-wp-icon-collections-registry.php | 5805 | V |
| class-wp-icons-registry.php | 9903 | V |
| class-wp-image-editor-gd.php | 20741 | V |
| class-wp-image-editor-imagick.php | 43454 | V |
| class-wp-image-editor.php | 17456 | V |
| class-wp-list-util.php | 7443 | V |
| class-wp-locale-switcher.php | 6776 | V |
| class-wp-locale.php | 16848 | V |
| class-wp-matchesmapregex.php | 1828 | V |
| class-wp-meta-query.php | 30507 | V |
| class-wp-metadata-lazyloader.php | 6833 | V |
| class-wp-navigation-fallback.php | 9193 | V |
| class-wp-network-query.php | 19989 | V |
| class-wp-network.php | 12411 | V |
| class-wp-object-cache.php | 17524 | V |
| class-wp-oembed-controller.php | 6905 | V |
| class-wp-oembed.php | 34372 | V |
| class-wp-paused-extensions-storage.php | 5067 | V |
| class-wp-phpmailer.php | 4348 | V |
| class-wp-plugin-dependencies.php | 25209 | V |
| class-wp-post-type-variable.php | 0 | V |
| class-wp-post-type.php | 30672 | V |
| class-wp-post.php | 8806 | V |
| class-wp-query.php | 164148 | V |
| class-wp-recovery-mode-cookie-service.php | 6877 | V |
| class-wp-recovery-mode-email-service.php | 11162 | V |
| class-wp-recovery-mode-key-service.php | 4914 | V |
| class-wp-recovery-mode-link-service.php | 3523 | V |
| class-wp-recovery-mode.php | 11460 | V |
| class-wp-rewrite.php | 63693 | V |
| class-wp-role.php | 2523 | V |
| class-wp-roles.php | 9326 | V |
| class-wp-script-modules.php | 40743 | V |
| class-wp-scripts.php | 36754 | V |
| class-wp-session-tokens.php | 7319 | V |
| class-wp-simplepie-file.php | 3552 | V |
| class-wp-simplepie-sanitize-kses.php | 1903 | V |
| class-wp-site-query.php | 31482 | V |
| class-wp-site.php | 7836 | V |
| class-wp-speculation-rules.php | 7884 | V |
| class-wp-styles.php | 13316 | V |
| class-wp-tax-query.php | 19577 | V |
| class-wp-taxonomy.php | 18559 | V |
| class-wp-term-query.php | 40751 | V |
| class-wp-term.php | 5263 | V |
| class-wp-text-diff-renderer-inline.php | 979 | V |
| class-wp-text-diff-renderer-table.php | 18925 | V |
| class-wp-textdomain-registry.php | 10481 | V |
| class-wp-theme-json-data.php | 1805 | V |
| class-wp-theme-json-resolver.php | 35692 | V |
| class-wp-theme-json-schema.php | 7367 | V |
| class-wp-theme-json.php | 222059 | V |
| class-wp-theme.php | 65811 | V |
| class-wp-token-map.php | 29032 | V |
| class-wp-url-pattern-prefixer.php | 4802 | V |
| class-wp-user-meta-session-tokens.php | 2954 | V |
| class-wp-user-query.php | 44102 | V |
| class-wp-user-request.php | 2342 | V |
| class-wp-user.php | 23189 | V |
| class-wp-view-config-data.php | 29427 | V |
| class-wp-walker.php | 13292 | V |
| class-wp-widget-factory.php | 4113 | V |
| class-wp-widget.php | 18452 | V |
| class-wp-xmlrpc-server.php | 217288 | V |
| class-wp.php | 26520 | V |
| class-wpdb.php | 121437 | V |
| class.wp-dependencies.php | 373 | V |
| class.wp-scripts.php | 343 | V |
| class.wp-styles.php | 338 | V |
| comment-template.php | 103211 | V |
| comment.php | 150630 | V |
| compat-utf8.php | 19386 | V |
| compat.php | 22479 | V |
| connectors.php | 32922 | V |
| cron.php | 46266 | V |
| css | - | |
| customize | - | |
| date.php | 400 | V |
| default-constants.php | 11365 | V |
| default-filters.php | 39500 | V |
| default-widgets.php | 2288 | V |
| deprecated.php | 193977 | V |
| embed-template.php | 338 | V |
| embed.php | 39215 | V |
| error-protection.php | 4092 | V |
| feed-atom-comments.php | 5504 | V |
| feed-atom.php | 3114 | V |
| feed-rdf.php | 2668 | V |
| feed-rss-core.php | 146 | V |
| feed-rss.php | 1189 | V |
| feed-rss2-comments.php | 4136 | V |
| feed-rss2.php | 3799 | V |
| feed.php | 25189 | V |
| fonts | - | |
| fonts.php | 9789 | V |
| formatting.php | 357678 | V |
| functions.php | 295481 | V |
| functions.wp-scripts.php | 20492 | V |
| functions.wp-styles.php | 8654 | V |
| general-template-get.php | 146 | V |
| general-template.php | 184198 | V |
| global-styles-and-settings.php | 20780 | V |
| html-api | - | |
| http.php | 28961 | V |
| https-detection.php | 5857 | V |
| https-migration.php | 4741 | V |
| icons.php | 6334 | V |
| images | - | |
| interactivity-api | - | |
| js | - | |
| json-schema.php | 7802 | V |
| kses.php | 88497 | V |
| l10n | - | |
| l10n.php | 71415 | V |
| link-template.php | 160143 | V |
| load.php | 56475 | V |
| locale.php | 162 | V |
| media-template.php | 65759 | V |
| media.php | 236804 | V |
| meta.php | 66739 | V |
| ms-blogs.php | 26324 | V |
| ms-default-constants.php | 4921 | V |
| ms-default-filters.php | 6636 | V |
| ms-deprecated.php | 21787 | V |
| ms-files.php | 2857 | V |
| ms-functions.php | 92530 | V |
| ms-load.php | 20055 | V |
| ms-network.php | 3782 | V |
| ms-settings.php | 4197 | V |
| ms-site.php | 41729 | V |
| nav-menu-template.php | 25983 | V |
| nav-menu.php | 44269 | V |
| option.php | 105246 | V |
| php-ai-client | - | |
| php-compat | - | |
| pluggable-deprecated.php | 6324 | V |
| pluggable.php | 127919 | V |
| plugin.php | 37123 | V |
| pomo | - | |
| post-formats.php | 7070 | V |
| post-template.php | 69129 | V |
| post-thumbnail-template.php | 10879 | V |
| post.php | 305215 | V |
| query.php | 37554 | V |
| registration-functions.php | 200 | V |
| registration.php | 200 | V |
| rest-api | - | |
| rest-api.php | 102951 | V |
| revision.php | 31241 | V |
| rewrite.php | 19567 | V |
| robots-template.php | 5185 | V |
| rss-functions.php | 277 | V |
| rss.php | 23203 | V |
| script-loader.php | 163550 | V |
| script-modules.php | 12311 | V |
| session.php | 258 | V |
| shortcodes-set.php | 0 | V |
| shortcodes.php | 24034 | V |
| sitemaps | - | |
| sitemaps.php | 3238 | V |
| sodium_compat | - | |
| speculative-loading.php | 11880 | V |
| spl-autoload-compat.php | 441 | V |
| style-engine | - | |
| style-engine.php | 8045 | V |
| taxonomy.php | 178307 | V |
| template-canvas.php | 544 | V |
| template-loader.php | 4267 | V |
| template.php | 38826 | V |
| theme-compat | - | |
| theme-i18n.json | 1892 | V |
| theme-previews.php | 2887 | V |
| theme-templates.php | 4060 | V |
| theme.json | 9480 | V |
| theme.php | 134913 | V |
| update.php | 38269 | V |
| user.php | 180301 | V |
| utf8.php | 6977 | V |
| vars.php | 6600 | V |
| version.php | 1103 | V |
| view-config.php | 19087 | V |
| view-transitions.php | 602 | V |
| widgets | - | |
| widgets.php | 70866 | V |
| wp-db.php | 445 | V |
| wp-diff.php | 792 | V |