PluginProbe
Hostinger Tools / 3.0.41
Hostinger Tools v3.0.41
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 +15 -67 3.0.753.0.41 View file →
@@ -1,12 +1,9 @@
1 1 <?php
2 2
3 3 namespace Hostinger;
4 4
5 -use Hostinger\Admin\Menu;
6 5 use Hostinger\Admin\PluginSettings;
7 -use Hostinger\Admin\Jobs\NotifyMcpJob;
8 -use Hostinger\Mcp\EventHandlerFactory;
9 6 use Hostinger\WpHelper\Utils;
10 7
11 8 defined( 'ABSPATH' ) || exit;
12 9
@@ -13,49 +10,33 @@
13 10 class Hooks {
14 11 public function __construct() {
15 12 add_filter( 'xmlrpc_enabled', array( $this, 'check_xmlrpc_enabled' ) );
16 13 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 14 add_filter( 'wp_headers', array( $this, 'check_pingback' ) );
19 - add_action( 'init', array( $this, 'plugins_loaded' ) );
15 + add_filter( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
16 +
20 17 add_action( 'update_option_woocommerce_coming_soon', array( $this, 'litespeed_flush_cache' ) );
21 18 add_action( 'update_option_woocommerce_store_pages_only', array( $this, 'litespeed_flush_cache' ) );
22 - add_action( 'transition_post_status', array( $this, 'handle_transition_post_status' ), 10, 3 );
23 - add_action( 'updated_option', array( $this, 'handle_updated_option' ), 10, 3 );
19 + add_action( 'upgrader_process_complete', array( $this, 'disable_auth_passwords_on_update' ), 10, 2 );
24 20 }
25 21
26 - public function handle_transition_post_status( string $new_status, string $old_status, \WP_Post $post ): void {
27 - if ( $new_status === 'publish' || $old_status === 'publish' ) {
28 - do_action(
29 - NotifyMcpJob::JOB_NAME,
30 - array(
31 - 'event' => EventHandlerFactory::MCP_EVENT_PAGE_UPDATED,
32 - 'post_id' => $post->ID,
33 - )
34 - );
22 + public function disable_auth_passwords_on_update( \WP_Upgrader $upgrader_object, array $options ): void {
23 + if ( $options['action'] !== 'update' || $options['type'] !== 'plugin' || empty( $options['plugins'] ) ) {
24 + return;
35 25 }
36 - }
37 26
38 - public function handle_updated_option( string $option, mixed $old_value, mixed $value ): void {
39 - if ( $option === 'cron' || $this->is_transient( $option ) ) {
27 + if ( ! in_array( 'hostinger/hostinger.php', $options['plugins'], true ) ) {
40 28 return;
41 29 }
42 30
43 - if ( $old_value !== $value ) {
44 - do_action( NotifyMcpJob::JOB_NAME, array( 'event' => EventHandlerFactory::MCP_EVENT_UPDATED ) );
31 + $settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, array() );
32 +
33 + if ( ! empty( $settings['disable_authentication_password'] ) ) {
34 + return;
45 35 }
46 36
47 - if ( $option === HOSTINGER_PLUGIN_SETTINGS_OPTION && isset( $value['optin_mcp'] ) && isset( $old_value['optin_mcp'] ) ) {
48 - if ( $old_value['optin_mcp'] !== $value['optin_mcp'] ) {
49 - do_action(
50 - NotifyMcpJob::JOB_NAME,
51 - array(
52 - 'event' => EventHandlerFactory::MCP_EVENT_OPTIN_TOGGLED,
53 - 'value' => $value['optin_mcp'],
54 - )
55 - );
56 - }
57 - }
37 + $options = new DefaultOptions();
38 + $options->configure_authentication_password();
58 39 }
59 40
60 41 /**
61 42 * @return void
@@ -117,13 +98,11 @@
117 98 return $headers;
118 99 }
119 100
120 101 /**
121 - * @param bool $enabled
122 - *
123 102 * @return bool
124 103 */
125 - public function check_xmlrpc_enabled( bool $enabled ): bool {
104 + public function check_xmlrpc_enabled(): bool {
126 105 $plugin_settings = new PluginSettings();
127 106 $settings = $plugin_settings->get_plugin_settings();
128 107
129 108 if ( $settings->get_disable_xml_rpc() ) {
@@ -129,9 +108,9 @@
129 108 if ( $settings->get_disable_xml_rpc() ) {
130 109 return false;
131 110 }
132 111
133 - return $enabled;
112 + return true;
134 113 }
135 114
136 115 /**
137 116 * @return bool
@@ -146,41 +125,10 @@
146 125
147 126 return true;
148 127 }
149 128
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 - }
176 -
177 129 public function litespeed_flush_cache(): void {
178 130 if ( has_action( 'litespeed_purge_all' ) ) {
179 131 do_action( 'litespeed_purge_all' );
180 132 }
181 - }
182 -
183 - private function is_transient( $option ): bool {
184 - return str_contains( $option, '_transient' );
185 133 }
186 134 }