You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/optimization-detective/readme.txt
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -246,6 +246,20 @@ The ETag is a unique identifier that changes whenever the underlying data used t
246
246
247
247
When the ETag for URL Metrics in a complete viewport group no longer matches the current environment's ETag, new URL Metrics will then begin to be collected until there are no more stored URL Metrics with the old ETag. These new URL Metrics will include data relevant to the newly activated plugins and their tag visitors.
Filters whether a URL Metric is valid for storage.
252
+
253
+
Three paramters are passed to this filter:
254
+
255
+
1. `$validity` (`bool|WP_Error`): Validity. Invalid if false or a WP_Error with errors.
256
+
2. `$url_metric` (`OD_Strict_URL_Metric`): URL Metric, already validated against the JSON Schema.
257
+
3. `$url_metric_data` (`array<string, mixed>`): Original URL Metric data before any mutations.
258
+
259
+
This allows for custom validation constraints to be applied beyond what can be expressed in JSON Schema. This filter only applies when storing a URL Metric via the REST API. It does not run when a stored URL Metric is loaded from the `od_url_metrics` post type. This means that validation logic enforced via this filter can be more expensive, such as doing filesystem checks or HTTP requests.
260
+
261
+
In addition to having the filter return `false` or a non-empty `WP_Error` to block storing the URL Metric, a plugin may also mutate the `OD_URL_Metric` instance passed by reference to the filter callback. This is useful for plugins in particular to unset extended properties which couldn't be validated using JSON Schema alone.
0 commit comments