PluginProbe
Hostinger Tools / 3.0.21
Hostinger Tools v3.0.21
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/Helper.php +85 -93 3.0.723.0.21 View file →
@@ -4,9 +4,9 @@
4 4
5 5 defined( 'ABSPATH' ) || exit;
6 6
7 7 class Helper {
8 - const HOSTINGER_LOCALES = array(
8 + const HOSTINGER_LOCALES = [
9 9 'lt_LT' => 'hostinger.lt',
10 10 'uk_UA' => 'hostinger.com.ua',
11 11 'id_ID' => 'hostinger.co.id',
12 12 'en_US' => 'hostinger.com',
@@ -45,136 +45,128 @@
45 45 'he_IL' => 'hostinger.co.il',
46 46 'lv_LV' => 'hostinger.lv',
47 47 'et_EE' => 'hostinger.ee',
48 48 'ur_PK' => 'hostinger.pk',
49 - );
49 + ];
50 50
51 - public const HOMEPAGE_DISPLAY = 'page';
51 + /**
52 + *
53 + * Check if plugin is active
54 + *
55 + * @since 1.0.0
56 + * @access public
57 + */
58 + public static function is_plugin_active( $plugin_slug ): bool {
59 + $active_plugins = (array) get_option( 'active_plugins', array() );
60 + foreach ( $active_plugins as $active_plugin ) {
61 + if ( strpos( $active_plugin, $plugin_slug . '.php' ) !== false ) {
62 + return true;
63 + }
64 + }
52 65
53 - /**
54 - *
55 - * Check if plugin is active
56 - *
57 - * @since 1.0.0
58 - * @access public
59 - */
60 - public static function is_plugin_active( $plugin_slug ): bool {
61 - $active_plugins = (array) get_option( 'active_plugins', array() );
62 - foreach ( $active_plugins as $active_plugin ) {
63 - if ( strpos( $active_plugin, $plugin_slug . '.php' ) !== false ) {
64 - return true;
65 - }
66 - }
66 + return false;
67 + }
67 68
68 - return false;
69 - }
69 + public function is_preview_domain( $headers = null ): bool {
70 + // @codeCoverageIgnoreStart
71 + if ( $headers === null && function_exists( 'getallheaders' ) ) {
72 + $headers = getallheaders();
73 + }
74 + // @codeCoverageIgnoreEnd
75 + if ( isset( $headers['X-Preview-Indicator'] ) && $headers['X-Preview-Indicator'] ) {
76 + return true;
77 + }
70 78
71 - public function is_preview_domain( $headers = null ): bool {
72 - // @codeCoverageIgnoreStart
73 - if ( $headers === null && function_exists( 'getallheaders' ) ) {
74 - $headers = getallheaders();
75 - }
76 - // @codeCoverageIgnoreEnd
77 - if ( isset( $headers['X-Preview-Indicator'] ) && $headers['X-Preview-Indicator'] ) {
78 - return true;
79 - }
79 + return false;
80 + }
80 81
81 - return false;
82 - }
82 + public static function woocommerce_onboarding_choice(): bool {
83 + return (bool) get_option( 'hostinger_woo_onboarding_choice', false );
84 + }
83 85
84 - public static function woocommerce_onboarding_choice(): bool {
85 - return (bool) get_option( 'hostinger_woo_onboarding_choice', false );
86 - }
86 + public static function generate_bypass_code( $length ) {
87 + $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
88 + $code = '';
89 + $max_index = strlen( $characters ) - 1;
87 90
88 - public static function generate_bypass_code( $length ) {
89 - $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
90 - $code = '';
91 - $max_index = strlen( $characters ) - 1;
91 + for ( $i = 0; $i < $length; $i++ ) {
92 + $random_index = wp_rand( 0, $max_index );
93 + $code .= $characters[ $random_index ];
94 + }
92 95
93 - for ( $i = 0; $i < $length; $i++ ) {
94 - $random_index = wp_rand( 0, $max_index );
95 - $code .= $characters[ $random_index ];
96 + return $code;
97 + }
98 +
99 + public function should_plugin_split_notice_shown() {
100 + $plugin_split_notice_hidden = get_option( 'hts_plugin_split_notice_hidden', false );
101 +
102 + if ( $plugin_split_notice_hidden !== false ) {
103 + return false;
96 104 }
97 105
98 - return $code;
99 - }
106 + if ( ! version_compare( HOSTINGER_VERSION, '3.0.0', '>=' ) ) {
107 + return false;
108 + }
100 109
110 + if ( is_plugin_active( 'hostinger-easy-onboarding/hostinger-easy-onboarding.php' ) ) {
111 + return false;
112 + }
101 113
114 + return true;
115 + }
102 116
103 - public function get_hostinger_plugin_url(): string {
104 - $website_locale = get_locale() ?? 'en_US';
105 - $reseller_locale = get_option( 'hostinger_reseller', null );
106 - $base_domain = $reseller_locale ?? ( self::HOSTINGER_LOCALES[ $website_locale ] ?? 'hostinger.com' );
117 + public function get_hostinger_plugin_url() : string {
118 + $websiteLocale = get_locale() ?? 'en_US';
119 + $resellerLocale = get_option( 'hostinger_reseller', '' );
120 + $baseDomain = $resellerLocale ? : ( self::HOSTINGER_LOCALES[$websiteLocale] ?? 'hostinger.com' );
107 121
108 - $plugin_url = rtrim( $base_domain, '/' ) . '/';
109 - $plugin_url .= str_replace( ABSPATH, '', HOSTINGER_ABSPATH );
122 + $pluginUrl = rtrim( $baseDomain, '/' ) . '/';
123 + $pluginUrl .= str_replace( ABSPATH, '', HOSTINGER_ABSPATH );
110 124
111 - return $plugin_url;
125 + return $pluginUrl;
112 126 }
113 127
114 128 public function get_recommended_php_version(): string {
115 - $wp_version = get_bloginfo( 'version' );
129 + $wp_version = get_bloginfo('version');
116 130
117 - if ( empty( $wp_version ) ) {
131 + if (empty($wp_version)) {
118 132 return '8.2';
119 133 }
120 134
121 - // Remove any additional version info (like -RC1, -beta1, etc.).
122 - $wp_version = preg_replace( '/[-+].*$/', '', $wp_version );
135 + // Remove any additional version info (like -RC1, -beta1, etc.)
136 + $wp_version = preg_replace('/[-+].*$/', '', $wp_version);
123 137
124 - if ( version_compare( $wp_version, '6.6', '>=' ) ) {
125 - return '8.2';
138 + // Version specific recommendations
139 + if (version_compare($wp_version, '6.6', '>=')) {
140 + return '8.2'; // Latest recommended version for WP 6.6+
126 141 }
127 142
128 - if ( version_compare( $wp_version, '6.3', '>=' ) ) {
129 - return '8.1';
143 + if (version_compare($wp_version, '6.3', '>=')) {
144 + return '8.1'; // Recommended for WP 6.3-6.5
130 145 }
131 146
132 - if ( version_compare( $wp_version, '5.3', '>=' ) ) {
133 - return '7.4';
147 + if (version_compare($wp_version, '5.3', '>=')) {
148 + return '7.4'; // Recommended for WP 5.3-6.2
134 149 }
135 150
136 - if ( version_compare( $wp_version, '5.0', '>=' ) ) {
137 - return '7.3';
151 + if (version_compare($wp_version, '5.0', '>=')) {
152 + return '7.3'; // Recommended for WP 5.0-5.2
138 153 }
139 154
140 - if ( version_compare( $wp_version, '4.9', '=' ) ) {
141 - return '7.2';
155 + if (version_compare($wp_version, '4.9', '=')) {
156 + return '7.2'; // Recommended for WP 4.9
142 157 }
143 158
144 - if ( version_compare( $wp_version, '4.7', '>=' ) ) {
145 - return '7.1';
159 + if (version_compare($wp_version, '4.7', '>=')) {
160 + return '7.1'; // Recommended for WP 4.7-4.8
146 161 }
147 162
148 - if ( version_compare( $wp_version, '4.4', '>=' ) ) {
149 - return '7.0';
163 + if (version_compare($wp_version, '4.4', '>=')) {
164 + return '7.0'; // Recommended for WP 4.4-4.6
150 165 }
151 166
167 + // For versions below 4.9
152 168 return '5.6';
153 169 }
170 +}
154 171
155 - public function get_edit_site_url(): string {
156 - if ( wp_is_block_theme() ) {
157 - return add_query_arg(
158 - array(
159 - 'canvas' => 'edit',
160 - ),
161 - admin_url( 'site-editor.php' )
162 - );
163 - }
164 -
165 - $show_on_front = get_option( 'show_on_front' );
166 - $front_page_id = get_option( 'page_on_front' );
167 -
168 - if ( $show_on_front === self::HOMEPAGE_DISPLAY && $front_page_id ) {
169 - return add_query_arg(
170 - array(
171 - 'post' => $front_page_id,
172 - 'action' => 'edit',
173 - ),
174 - admin_url( 'post.php' )
175 - );
176 - }
177 -
178 - return '';
179 - }
180 -}
172 +$hostinger_helper = new Helper();