WP_Speculation_Rules::has_rule
Checks whether a speculation rule for the given mode and ID already exists.
Method of the class: WP_Speculation_Rules{}
No Hooks.
Returns
true|false
. True if the rule already exists, false otherwise.
Usage
$WP_Speculation_Rules = new WP_Speculation_Rules(); $WP_Speculation_Rules->has_rule( $mode, $id ): bool;
- $mode(string) (required)
- Speculative loading mode. Either 'prefetch' or 'prerender'.
- $id(string) (required)
- Unique string identifier for the speculation rule.
Changelog
Since 6.8.0 | Introduced. |
WP_Speculation_Rules::has_rule() WP Speculation Rules::has rule code WP 6.8.1
public function has_rule( string $mode, string $id ): bool { return isset( $this->rules_by_mode[ $mode ][ $id ] ); }