Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions plugins/image-prioritizer/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* @param string $optimization_detective_version Current version of the optimization detective plugin.
*/
function image_prioritizer_init( string $optimization_detective_version ): void {
$required_od_version = '0.9.0';
if ( ! version_compare( (string) strtok( $optimization_detective_version, '-' ), $required_od_version, '>=' ) ) {
$required_od_version = '1.0.0-beta3';
if ( ! version_compare( $optimization_detective_version, $required_od_version, '>=' ) ) {
add_action(
'admin_notices',
static function (): void {
Expand Down Expand Up @@ -297,16 +297,15 @@ static function ( $host ) {
function image_prioritizer_filter_rest_request_before_callbacks( $response, array $handler, WP_REST_Request $request ) {
unset( $handler ); // Unused.

// Check for class existence and use constant or class method calls accordingly.
$route_endpoint = class_exists( 'OD_REST_URL_Metrics_Store_Endpoint' )
? OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE
: OD_REST_API_NAMESPACE . OD_URL_METRICS_ROUTE; // @phpstan-ignore constant.deprecated, constant.deprecated (To be replaced with class method calls in subsequent release.)

if (
$request->get_method() !== 'POST'
||
// 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'.
( rtrim( strtolower( ltrim( $request->get_route(), '/' ) ) ) !== $route_endpoint )
(
OD_REST_URL_Metrics_Store_Endpoint::ROUTE_NAMESPACE . OD_REST_URL_Metrics_Store_Endpoint::ROUTE_BASE
!==
rtrim( strtolower( ltrim( $request->get_route(), '/' ) ) )
)
) {
return $response;
}
Expand Down
14 changes: 0 additions & 14 deletions plugins/optimization-detective/class-od-tag-visitor-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,6 @@ public function __get( string $name ) {
return $this->url_metrics_id;
case 'url_metric_group_collection':
return $this->url_metric_group_collection;
case 'url_metrics_group_collection':
// TODO: Remove this when no plugins are possibly referring to the url_metrics_group_collection property anymore.
_doing_it_wrong(
esc_html( __CLASS__ . '::$' . $name ),
esc_html(
sprintf(
/* translators: %s is class member variable name */
__( 'Use %s instead.', 'optimization-detective' ),
__CLASS__ . '::$url_metric_group_collection'
)
),
'optimization-detective 0.7.0'
);
return $this->url_metric_group_collection;
default:
throw new Error(
esc_html(
Expand Down
2 changes: 0 additions & 2 deletions plugins/optimization-detective/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ static function ( string $version ): void {
require_once __DIR__ . '/class-od-strict-url-metric.php';
require_once __DIR__ . '/class-od-url-metric-group.php';
require_once __DIR__ . '/class-od-url-metric-group-collection.php';
class_alias( OD_URL_Metric_Group::class, 'OD_URL_Metrics_Group' ); // Temporary class alias for back-compat after rename.
class_alias( OD_URL_Metric_Group_Collection::class, 'OD_URL_Metrics_Group_Collection' ); // Temporary class alias for back-compat after rename.

// Storage logic.
require_once __DIR__ . '/storage/class-od-url-metrics-post-type.php';
Expand Down
3 changes: 0 additions & 3 deletions plugins/optimization-detective/tests/test-optimization.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,6 @@ function ( OD_Tag_Visitor_Registry $tag_visitor_registry ): void {
'img',
function ( OD_Tag_Visitor_Context $context ): bool {
$this->assertInstanceOf( OD_URL_Metric_Group_Collection::class, $context->url_metric_group_collection );
$this->setExpectedIncorrectUsage( 'OD_Tag_Visitor_Context::$url_metrics_group_collection' );
$this->assertInstanceOf( OD_URL_Metric_Group_Collection::class, $context->url_metrics_group_collection );
$this->assertSame( $context->url_metric_group_collection, $context->url_metrics_group_collection );
$this->assertInstanceOf( OD_HTML_Tag_Processor::class, $context->processor );
$this->assertInstanceOf( OD_Link_Collection::class, $context->link_collection );
$this->assertTrue( null === $context->url_metrics_id || $context->url_metrics_id > 0 );
Expand Down
Loading