Skip to content

Commit c5e8406

Browse files
committed
fix rocketnet compat
1 parent 6580b45 commit c5e8406

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

inc/compatibilities/kinsta.php renamed to inc/compatibilities/rocketnet.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

33
/**
4-
* Class Optml_kinsta.
4+
* Class Optml_rocketnet.
55
*
6-
* @reason Clear cache on kinsta.
6+
* @reason Clear cache on rocketnet.
77
*/
8-
class Optml_kinsta extends Optml_compatibility {
8+
class Optml_rocketnet extends Optml_compatibility {
99

1010

1111
/**
@@ -24,7 +24,7 @@ public function should_load() {
2424
* @return void
2525
*/
2626
public function register() {
27-
add_action( 'optml_clear_cache', [ $this, 'add_clear_cache_action' ], 10, 1 );
27+
add_action( 'optml_clear_cache', [ $this, 'add_clear_cache_action' ], 99, 1 );
2828
}
2929

3030

@@ -37,7 +37,7 @@ public function should_load_early() {
3737
return true;
3838
}
3939
/**
40-
* Clear cache on kinsta.
40+
* Clear cache on rocketnet.
4141
*
4242
* @param string|bool $location The location to clear the cache for. If true, clear the cache globally. If a string, clear the cache for a particular url.
4343
* @return void
@@ -48,6 +48,11 @@ public function add_clear_cache_action( $location ) {
4848
}
4949

5050
if ( is_string( $location ) && class_exists( '\CDN_Clear_Cache_Api' ) && method_exists( '\CDN_Clear_Cache_Api', 'cache_api_call' ) ) { // @phpstan-ignore-line
51+
$url_parts = parse_url( $location );
52+
$location = ( isset( $url_parts['path'] ) ) ? rtrim( $url_parts['path'], '/' ) : '/';
53+
if ( ! empty( $url_parts['query'] ) ) {
54+
$location .= '?' . $url_parts['query'];
55+
}
5156
\CDN_Clear_Cache_Api::cache_api_call( [ $location ], 'purge' );
5257
}
5358
}

inc/manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ final class Optml_Manager {
108108
'litespeed_cache',
109109
'autoptimize_cache',
110110
'endurance_cache',
111-
'kinsta',
111+
'rocketnet',
112112
'speedycache',
113113
];
114114
/**

0 commit comments

Comments
 (0)