| @@ -257,8 +257,29 @@ | ||
| 257 | 257 | 'applied' => $id, |
| 258 | 258 | 'recommendations' => self::all(), |
| 259 | 259 | ); |
| 260 | 260 | } |
| 261 | + /** | |
| 262 | + * Last chance to resolve a recommendation id this engine doesn't own. | |
| 263 | + * | |
| 264 | + * Free and Pro each ship a recommendation engine with its OWN id | |
| 265 | + * namespace — Free uses underscores (`nginx_snippet_missing`), Pro | |
| 266 | + * uses hyphens (`cache-disabled`) — but only Free's ids reached this | |
| 267 | + * method, so EVERY Pro Apply button returned 404 and the failure was | |
| 268 | + * swallowed by the UI. This seam lets Pro claim its own ids rather | |
| 269 | + * than duplicating the endpoint. (#198) | |
| 270 | + * | |
| 271 | + * Return an array (the same shape this method returns on success) or | |
| 272 | + * a WP_Error to claim the id; return null to decline it. | |
| 273 | + * | |
| 274 | + * @param array|\WP_Error|null $handled Result from a previous filter, or null. | |
| 275 | + * @param string $id The recommendation id being applied. | |
| 276 | + */ | |
| 277 | + $handled = apply_filters( 'xspeed_apply_recommendation', null, $id ); | |
| 278 | + if ( is_array( $handled ) || is_wp_error( $handled ) ) { | |
| 279 | + return $handled; | |
| 280 | + } | |
| 281 | + | |
| 261 | 282 | return new \WP_Error( |
| 262 | 283 | 'xspeed_rec_unknown', |
| 263 | 284 | __( 'Unknown or no-longer-applicable recommendation.', 'xspeed' ), |
| 264 | 285 | array( 'status' => 404 ) |