| @@ -1,13 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * Avoid possibility to get file accessed directly | |
| 4 | - */ | |
| 5 | - | |
| 6 | 2 | namespace Hostinger\Admin; |
| 7 | 3 | |
| 8 | 4 | use Hostinger\Admin\Options\PluginOptions; |
| 9 | 5 | |
| 6 | +/** | |
| 7 | + * Avoid possibility to get file accessed directly | |
| 8 | + */ | |
| 10 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | 10 | die; |
| 12 | 11 | } |
| 13 | 12 | |
| @@ -16,9 +15,9 @@ | ||
| 16 | 15 | */ |
| 17 | 16 | class PluginSettings { |
| 18 | 17 | |
| 19 | 18 | /** |
| 20 | - * @var PluginOptions|null | |
| 19 | + * @var PluginOptions | |
| 21 | 20 | */ |
| 22 | 21 | private ?PluginOptions $plugin_options = null; |
| 23 | 22 | |
| 24 | 23 | /** |
| @@ -23,10 +22,10 @@ | ||
| 23 | 22 | |
| 24 | 23 | /** |
| 25 | 24 | * @param PluginOptions|null $plugin_options |
| 26 | 25 | */ |
| 27 | - public function __construct( ?PluginOptions $plugin_options = null ) { | |
| 28 | - if ( ! is_null( $plugin_options ) ) { | |
| 26 | + public function __construct( PluginOptions $plugin_options = null ) { | |
| 27 | + if ( ! empty( $plugin_options ) ) { | |
| 29 | 28 | $this->plugin_options = $plugin_options; |
| 30 | 29 | } |
| 31 | 30 | } |
| 32 | 31 | |
| @@ -34,12 +33,14 @@ | ||
| 34 | 33 | * Return plugin settings |
| 35 | 34 | * |
| 36 | 35 | * @return PluginOptions |
| 37 | 36 | */ |
| 38 | - public function get_plugin_settings(): PluginOptions { | |
| 37 | + public function get_plugin_settings( ): PluginOptions { | |
| 39 | 38 | |
| 40 | 39 | if ( ! empty( $this->plugin_options ) ) { |
| 40 | + | |
| 41 | 41 | $settings = $this->plugin_options; |
| 42 | + | |
| 42 | 43 | } else { |
| 43 | 44 | $settings = get_option( |
| 44 | 45 | HOSTINGER_PLUGIN_SETTINGS_OPTION, |
| 45 | 46 | array() |
| @@ -60,7 +61,11 @@ | ||
| 60 | 61 | $existing_settings = $this->get_plugin_settings(); |
| 61 | 62 | |
| 62 | 63 | $update = update_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, $plugin_options->to_array(), false ); |
| 63 | 64 | |
| 65 | + if ( has_action( 'litespeed_purge_all' ) ) { | |
| 66 | + do_action( 'litespeed_purge_all' ); | |
| 67 | + } | |
| 68 | + | |
| 64 | 69 | return ! empty( $update ) ? $plugin_options : $existing_settings; |
| 65 | 70 | } |
| 66 | -} | |
| 71 | +} | |