| 1 |
<?php |
| 2 |
|
| 3 |
namespace FlyWP; |
| 4 |
|
| 5 |
class Opcache { |
| 6 |
|
| 7 |
public function clear() { |
| 8 |
return opcache_reset(); |
| 9 |
} |
| 10 |
|
| 11 |
public function has_opcache() { |
| 12 |
return function_exists( 'opcache_get_status' ); |
| 13 |
} |
| 14 |
|
| 15 |
public function get_status() { |
| 16 |
return opcache_get_status(); |
| 17 |
} |
| 18 |
|
| 19 |
public function get_config() { |
| 20 |
return opcache_get_configuration(); |
| 21 |
} |
| 22 |
|
| 23 |
public function enabled() { |
| 24 |
if ( ! $this->has_opcache() ) { |
| 25 |
return false; |
| 26 |
} |
| 27 |
|
| 28 |
$status = $this->get_status(); |
| 29 |
|
| 30 |
return $status['opcache_enabled'] === true; |
| 31 |
} |
| 32 |
|
| 33 |
public function purge_cache_url() { |
| 34 |
return wp_nonce_url( |
| 35 |
add_query_arg( |
| 36 |
[ 'flywp-action' => 'purge-opcache' ], |
| 37 |
flywp()->admin->page_url() |
| 38 |
), |
| 39 |
'fly-opcache-purge' |
| 40 |
); |
| 41 |
} |
| 42 |
} |
| 43 |
|