| @@ -13,11 +13,12 @@ | ||
| 13 | 13 | public function __construct() { |
| 14 | 14 | add_filter( 'xmlrpc_enabled', array( $this, 'check_xmlrpc_enabled' ) ); |
| 15 | 15 | add_filter( 'wp_is_application_passwords_available', array( $this, 'check_authentication_password_enabled' ) ); |
| 16 | 16 | add_filter( 'wp_headers', array( $this, 'check_pingback' ) ); |
| 17 | - add_action( 'init', array( $this, 'plugins_loaded' ) ); | |
| 17 | + add_filter( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); | |
| 18 | 18 | add_action( 'update_option_woocommerce_coming_soon', array( $this, 'litespeed_flush_cache' ) ); |
| 19 | 19 | add_action( 'update_option_woocommerce_store_pages_only', array( $this, 'litespeed_flush_cache' ) ); |
| 20 | + add_action( 'upgrader_process_complete', array( $this, 'disable_auth_passwords_on_update' ), 10, 2 ); | |
| 20 | 21 | add_action( 'transition_post_status', array( $this, 'handle_transition_post_status' ), 10, 3 ); |
| 21 | 22 | add_action( 'updated_option', array( $this, 'handle_updated_option' ), 10, 3 ); |
| 22 | 23 | } |
| 23 | 24 | |
| @@ -54,8 +55,27 @@ | ||
| 54 | 55 | } |
| 55 | 56 | } |
| 56 | 57 | } |
| 57 | 58 | |
| 59 | + public function disable_auth_passwords_on_update( \WP_Upgrader $upgrader_object, array $options ): void { | |
| 60 | + if ( $options['action'] !== 'update' || $options['type'] !== 'plugin' || empty( $options['plugins'] ) ) { | |
| 61 | + return; | |
| 62 | + } | |
| 63 | + | |
| 64 | + if ( ! in_array( 'hostinger/hostinger.php', $options['plugins'], true ) ) { | |
| 65 | + return; | |
| 66 | + } | |
| 67 | + | |
| 68 | + $settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, array() ); | |
| 69 | + | |
| 70 | + if ( ! empty( $settings['disable_authentication_password'] ) ) { | |
| 71 | + return; | |
| 72 | + } | |
| 73 | + | |
| 74 | + $options = new DefaultOptions(); | |
| 75 | + $options->configure_authentication_password(); | |
| 76 | + } | |
| 77 | + | |
| 58 | 78 | /** |
| 59 | 79 | * @return void |
| 60 | 80 | */ |
| 61 | 81 | public function plugins_loaded() { |
| @@ -115,13 +135,11 @@ | ||
| 115 | 135 | return $headers; |
| 116 | 136 | } |
| 117 | 137 | |
| 118 | 138 | /** |
| 119 | - * @param bool $enabled | |
| 120 | - * | |
| 121 | 139 | * @return bool |
| 122 | 140 | */ |
| 123 | - public function check_xmlrpc_enabled( bool $enabled ): bool { | |
| 141 | + public function check_xmlrpc_enabled(): bool { | |
| 124 | 142 | $plugin_settings = new PluginSettings(); |
| 125 | 143 | $settings = $plugin_settings->get_plugin_settings(); |
| 126 | 144 | |
| 127 | 145 | if ( $settings->get_disable_xml_rpc() ) { |
| @@ -127,9 +145,9 @@ | ||
| 127 | 145 | if ( $settings->get_disable_xml_rpc() ) { |
| 128 | 146 | return false; |
| 129 | 147 | } |
| 130 | 148 | |
| 131 | - return $enabled; | |
| 149 | + return true; | |
| 132 | 150 | } |
| 133 | 151 | |
| 134 | 152 | /** |
| 135 | 153 | * @return bool |