PluginProbe
Hostinger Tools / 3.0.49
Hostinger Tools v3.0.49
3.0.77 3.0.76 3.0.75 3.0.74 3.0.73 3.0.72 3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.4 All 108 releases
← All changes | includes/Hooks.php +23 -34 3.0.773.0.49 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2
3 3 namespace Hostinger;
4 4
5 -use Hostinger\Admin\Menu;
6 5 use Hostinger\Admin\PluginSettings;
7 6 use Hostinger\Admin\Jobs\NotifyMcpJob;
8 7 use Hostinger\Mcp\EventHandlerFactory;
9 8 use Hostinger\WpHelper\Utils;
@@ -13,13 +12,13 @@
13 12 class Hooks {
14 13 public function __construct() {
15 14 add_filter( 'xmlrpc_enabled', array( $this, 'check_xmlrpc_enabled' ) );
16 15 add_filter( 'wp_is_application_passwords_available', array( $this, 'check_authentication_password_enabled' ) );
17 - add_filter( 'wp_die_handler', array( $this, 'maybe_customize_application_password_die_handler' ) );
18 16 add_filter( 'wp_headers', array( $this, 'check_pingback' ) );
19 - add_action( 'init', array( $this, 'plugins_loaded' ) );
17 + add_filter( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
20 18 add_action( 'update_option_woocommerce_coming_soon', array( $this, 'litespeed_flush_cache' ) );
21 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 );
22 21 add_action( 'transition_post_status', array( $this, 'handle_transition_post_status' ), 10, 3 );
23 22 add_action( 'updated_option', array( $this, 'handle_updated_option' ), 10, 3 );
24 23 }
25 24
@@ -56,8 +55,27 @@
56 55 }
57 56 }
58 57 }
59 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 +
60 78 /**
61 79 * @return void
62 80 */
63 81 public function plugins_loaded() {
@@ -117,13 +135,11 @@
117 135 return $headers;
118 136 }
119 137
120 138 /**
121 - * @param bool $enabled
122 - *
123 139 * @return bool
124 140 */
125 - public function check_xmlrpc_enabled( bool $enabled ): bool {
141 + public function check_xmlrpc_enabled(): bool {
126 142 $plugin_settings = new PluginSettings();
127 143 $settings = $plugin_settings->get_plugin_settings();
128 144
129 145 if ( $settings->get_disable_xml_rpc() ) {
@@ -129,9 +145,9 @@
129 145 if ( $settings->get_disable_xml_rpc() ) {
130 146 return false;
131 147 }
132 148
133 - return $enabled;
149 + return true;
134 150 }
135 151
136 152 /**
137 153 * @return bool
@@ -144,35 +160,8 @@
144 160 return false;
145 161 }
146 162
147 163 return true;
148 - }
149 -
150 - public function maybe_customize_application_password_die_handler( $handler ) {
151 - $plugin_settings = new PluginSettings();
152 - $settings = $plugin_settings->get_plugin_settings();
153 -
154 - if ( ! $settings->get_disable_authentication_password() ) {
155 - return $handler;
156 - }
157 -
158 - return function ( $message, $title = '', $args = array() ) use ( $handler ) {
159 - if ( is_string( $message ) && $message === __( 'Application passwords are not available.' ) ) {
160 - $message = $this->get_application_password_disabled_message();
161 - }
162 -
163 - call_user_func( $handler, $message, $title, $args );
164 - };
165 - }
166 -
167 - private function get_application_password_disabled_message(): string {
168 - $settings_url = admin_url( 'admin.php?page=' . Menu::MENU_SLUG );
169 -
170 - return sprintf(
171 - /* translators: %s: URL to the Hostinger Tools settings page. */
172 - __( 'Application passwords have been disabled by Hostinger for security reasons. You can turn them back on from <a href="%s">Hostinger Tools → Security settings</a>.', 'hostinger' ),
173 - esc_url( $settings_url )
174 - );
175 164 }
176 165
177 166 public function litespeed_flush_cache(): void {
178 167 if ( has_action( 'litespeed_purge_all' ) ) {