Skip to content

Commit b6838f8

Browse files
committed
Use the class constant in image priortizer in rest request callback
1 parent 968a1eb commit b6838f8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

plugins/image-prioritizer/helper.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,15 @@ static function ( $host ) {
297297
function image_prioritizer_filter_rest_request_before_callbacks( $response, array $handler, WP_REST_Request $request ) {
298298
unset( $handler ); // Unused.
299299

300-
// Check for class existence and use constant or class method calls accordingly.
301-
$route_endpoint = class_exists( 'OD_REST_URL_Metrics_Store_Endpoint' )
302-
? OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE
303-
: OD_REST_API_NAMESPACE . OD_URL_METRICS_ROUTE; // @phpstan-ignore constant.deprecated, constant.deprecated (To be replaced with class method calls in subsequent release.)
304-
305300
if (
306301
$request->get_method() !== 'POST'
307302
||
308303
// The strtolower() and outer trim are due to \WP_REST_Server::match_request_to_handler() using case-insensitive pattern match and using '$' instead of '\z'.
309-
( rtrim( strtolower( ltrim( $request->get_route(), '/' ) ) ) !== $route_endpoint )
304+
(
305+
OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE
306+
!==
307+
rtrim( strtolower( ltrim( $request->get_route(), '/' ) ) )
308+
)
310309
) {
311310
return $response;
312311
}

0 commit comments

Comments
 (0)