Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/hostinge.../includes
File: Helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Hostinger;
[2] Fix | Delete
[3] Fix | Delete
defined( 'ABSPATH' ) || exit;
[4] Fix | Delete
[5] Fix | Delete
class Helper {
[6] Fix | Delete
const HOSTINGER_LOCALES = array(
[7] Fix | Delete
'lt_LT' => 'hostinger.lt',
[8] Fix | Delete
'uk_UA' => 'hostinger.com.ua',
[9] Fix | Delete
'id_ID' => 'hostinger.co.id',
[10] Fix | Delete
'en_US' => 'hostinger.com',
[11] Fix | Delete
'es_ES' => 'hostinger.es',
[12] Fix | Delete
'es_AR' => 'hostinger.com.ar',
[13] Fix | Delete
'es_MX' => 'hostinger.mx',
[14] Fix | Delete
'es_CO' => 'hostinger.co',
[15] Fix | Delete
'pt_BR' => 'hostinger.com.br',
[16] Fix | Delete
'ro_RO' => 'hostinger.ro',
[17] Fix | Delete
'fr_FR' => 'hostinger.fr',
[18] Fix | Delete
'it_IT' => 'hostinger.it',
[19] Fix | Delete
'pl_PL' => 'hostinger.pl',
[20] Fix | Delete
'en_PH' => 'hostinger.ph',
[21] Fix | Delete
'ar_AE' => 'hostinger.ae',
[22] Fix | Delete
'ms_MY' => 'hostinger.my',
[23] Fix | Delete
'ko_KR' => 'hostinger.kr',
[24] Fix | Delete
'vi_VN' => 'hostinger.vn',
[25] Fix | Delete
'th_TH' => 'hostinger.in.th',
[26] Fix | Delete
'tr_TR' => 'hostinger.web.tr',
[27] Fix | Delete
'pt_PT' => 'hostinger.pt',
[28] Fix | Delete
'de_DE' => 'hostinger.de',
[29] Fix | Delete
'en_IN' => 'hostinger.in',
[30] Fix | Delete
'ja_JP' => 'hostinger.jp',
[31] Fix | Delete
'nl_NL' => 'hostinger.nl',
[32] Fix | Delete
'en_GB' => 'hostinger.co.uk',
[33] Fix | Delete
'el_GR' => 'hostinger.gr',
[34] Fix | Delete
'cs_CZ' => 'hostinger.cz',
[35] Fix | Delete
'hu_HU' => 'hostinger.hu',
[36] Fix | Delete
'sv_SE' => 'hostinger.se',
[37] Fix | Delete
'da_DK' => 'hostinger.dk',
[38] Fix | Delete
'fi_FI' => 'hostinger.fi',
[39] Fix | Delete
'sk_SK' => 'hostinger.sk',
[40] Fix | Delete
'no_NO' => 'hostinger.no',
[41] Fix | Delete
'hr_HR' => 'hostinger.hr',
[42] Fix | Delete
'zh_HK' => 'hostinger.com.hk',
[43] Fix | Delete
'he_IL' => 'hostinger.co.il',
[44] Fix | Delete
'lv_LV' => 'hostinger.lv',
[45] Fix | Delete
'et_EE' => 'hostinger.ee',
[46] Fix | Delete
'ur_PK' => 'hostinger.pk',
[47] Fix | Delete
);
[48] Fix | Delete
[49] Fix | Delete
public const HOMEPAGE_DISPLAY = 'page';
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
*
[53] Fix | Delete
* Check if plugin is active
[54] Fix | Delete
*
[55] Fix | Delete
* @since 1.0.0
[56] Fix | Delete
* @access public
[57] Fix | Delete
*/
[58] Fix | Delete
public static function is_plugin_active( $plugin_slug ): bool {
[59] Fix | Delete
$active_plugins = (array) get_option( 'active_plugins', array() );
[60] Fix | Delete
foreach ( $active_plugins as $active_plugin ) {
[61] Fix | Delete
if ( strpos( $active_plugin, $plugin_slug . '.php' ) !== false ) {
[62] Fix | Delete
return true;
[63] Fix | Delete
}
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
return false;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
public function is_preview_domain( $headers = null ): bool {
[70] Fix | Delete
// @codeCoverageIgnoreStart
[71] Fix | Delete
if ( $headers === null && function_exists( 'getallheaders' ) ) {
[72] Fix | Delete
$headers = getallheaders();
[73] Fix | Delete
}
[74] Fix | Delete
// @codeCoverageIgnoreEnd
[75] Fix | Delete
if ( isset( $headers['X-Preview-Indicator'] ) && $headers['X-Preview-Indicator'] ) {
[76] Fix | Delete
return true;
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
return false;
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
public static function woocommerce_onboarding_choice(): bool {
[83] Fix | Delete
return (bool) get_option( 'hostinger_woo_onboarding_choice', false );
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
public static function generate_bypass_code( $length ) {
[87] Fix | Delete
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
[88] Fix | Delete
$code = '';
[89] Fix | Delete
$max_index = strlen( $characters ) - 1;
[90] Fix | Delete
[91] Fix | Delete
for ( $i = 0; $i < $length; $i++ ) {
[92] Fix | Delete
$random_index = wp_rand( 0, $max_index );
[93] Fix | Delete
$code .= $characters[ $random_index ];
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
return $code;
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
public function should_plugin_split_notice_shown() {
[100] Fix | Delete
$plugin_split_notice_hidden = get_option( 'hts_plugin_split_notice_hidden', false );
[101] Fix | Delete
[102] Fix | Delete
if ( $plugin_split_notice_hidden !== false ) {
[103] Fix | Delete
return false;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
if ( ! version_compare( HOSTINGER_VERSION, '3.0.0', '>=' ) ) {
[107] Fix | Delete
return false;
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
if ( is_plugin_active( 'hostinger-easy-onboarding/hostinger-easy-onboarding.php' ) ) {
[111] Fix | Delete
return false;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
return true;
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
public function get_hostinger_plugin_url(): string {
[118] Fix | Delete
$website_locale = get_locale() ?? 'en_US';
[119] Fix | Delete
$reseller_locale = get_option( 'hostinger_reseller', null );
[120] Fix | Delete
$base_domain = $reseller_locale ?? ( self::HOSTINGER_LOCALES[ $website_locale ] ?? 'hostinger.com' );
[121] Fix | Delete
[122] Fix | Delete
$plugin_url = rtrim( $base_domain, '/' ) . '/';
[123] Fix | Delete
$plugin_url .= str_replace( ABSPATH, '', HOSTINGER_ABSPATH );
[124] Fix | Delete
[125] Fix | Delete
return $plugin_url;
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
public function get_recommended_php_version(): string {
[129] Fix | Delete
$wp_version = get_bloginfo( 'version' );
[130] Fix | Delete
[131] Fix | Delete
if ( empty( $wp_version ) ) {
[132] Fix | Delete
return '8.2';
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
// Remove any additional version info (like -RC1, -beta1, etc.).
[136] Fix | Delete
$wp_version = preg_replace( '/[-+].*$/', '', $wp_version );
[137] Fix | Delete
[138] Fix | Delete
if ( version_compare( $wp_version, '6.6', '>=' ) ) {
[139] Fix | Delete
return '8.2';
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
if ( version_compare( $wp_version, '6.3', '>=' ) ) {
[143] Fix | Delete
return '8.1';
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
if ( version_compare( $wp_version, '5.3', '>=' ) ) {
[147] Fix | Delete
return '7.4';
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
[151] Fix | Delete
return '7.3';
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
if ( version_compare( $wp_version, '4.9', '=' ) ) {
[155] Fix | Delete
return '7.2';
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
if ( version_compare( $wp_version, '4.7', '>=' ) ) {
[159] Fix | Delete
return '7.1';
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
if ( version_compare( $wp_version, '4.4', '>=' ) ) {
[163] Fix | Delete
return '7.0';
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
return '5.6';
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
public function get_edit_site_url(): string {
[170] Fix | Delete
if ( wp_is_block_theme() ) {
[171] Fix | Delete
return add_query_arg(
[172] Fix | Delete
array(
[173] Fix | Delete
'canvas' => 'edit',
[174] Fix | Delete
),
[175] Fix | Delete
admin_url( 'site-editor.php' )
[176] Fix | Delete
);
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
$show_on_front = get_option( 'show_on_front' );
[180] Fix | Delete
$front_page_id = get_option( 'page_on_front' );
[181] Fix | Delete
[182] Fix | Delete
if ( $show_on_front === self::HOMEPAGE_DISPLAY && $front_page_id ) {
[183] Fix | Delete
return add_query_arg(
[184] Fix | Delete
array(
[185] Fix | Delete
'post' => $front_page_id,
[186] Fix | Delete
'action' => 'edit',
[187] Fix | Delete
),
[188] Fix | Delete
admin_url( 'post.php' )
[189] Fix | Delete
);
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
return '';
[193] Fix | Delete
}
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function