Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/hostinge.../includes
File: Settings.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 Settings {
[6] Fix | Delete
public const MYSELF = 'myself';
[7] Fix | Delete
public const FREELANCER = 'freelancer';
[8] Fix | Delete
public const DEVELOPER = 'developer';
[9] Fix | Delete
public const OTHER = 'other';
[10] Fix | Delete
public const BUSINESS_BEGINNER_SEGMENT = 'business_beginner';
[11] Fix | Delete
public const LEARNER_SEGMENT = 'learner';
[12] Fix | Delete
public const BUSINESS_OWNER_SEGMENT = 'business_owner';
[13] Fix | Delete
public const WEBSITE_TYPE_BUSINESS = 'business';
[14] Fix | Delete
public const WEBSITE_TYPE_PORTFOLIO = 'portfolio';
[15] Fix | Delete
public const WEBSITE_TYPE_BLOG = 'blog';
[16] Fix | Delete
public const SITE_TITLE_OPTION = 'blogname';
[17] Fix | Delete
[18] Fix | Delete
public function __construct() {
[19] Fix | Delete
if ( ! $this->get_setting( 'user_segment' ) ) {
[20] Fix | Delete
$this->set_user_segment();
[21] Fix | Delete
}
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
public function set_user_segment(): void {
[25] Fix | Delete
$created_by = self::get_setting( 'survey.website.created_by' );
[26] Fix | Delete
$created_for = self::get_setting( 'survey.website.for' );
[27] Fix | Delete
$need_help = self::get_setting( 'survey.website.need_help' );
[28] Fix | Delete
$work_at = self::get_setting( 'survey.work_at' );
[29] Fix | Delete
[30] Fix | Delete
if ( $this->is_business_beginner( $created_by, $created_for, $need_help ) ) {
[31] Fix | Delete
self::update_setting( 'user_segment', self::BUSINESS_BEGINNER_SEGMENT );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
if ( $this->is_learner( $work_at, $need_help ) ) {
[35] Fix | Delete
self::update_setting( 'user_segment', self::LEARNER_SEGMENT );
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
if ( $this->is_bussiness_owner( $created_for, $created_by ) ) {
[39] Fix | Delete
self::update_setting( 'user_segment', self::BUSINESS_OWNER_SEGMENT );
[40] Fix | Delete
}
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
private function is_business_beginner( string $created_by, string $created_for, bool $need_help ): bool {
[44] Fix | Delete
return $created_by === self::MYSELF && $created_for === self::MYSELF && $need_help;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
private function is_learner( string $work_at, bool $need_help ): bool {
[48] Fix | Delete
return $work_at === self::FREELANCER && $need_help;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
private function is_bussiness_owner( string $created_for, string $created_by ): bool {
[52] Fix | Delete
return $created_for === self::MYSELF && ( $created_by === self::DEVELOPER || $created_by === self::OTHER );
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
public static function get_setting( string $setting ): string {
[56] Fix | Delete
[57] Fix | Delete
if ( $setting ) {
[58] Fix | Delete
return get_option( 'hostinger_' . $setting, '' );
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
return '';
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
public static function update_setting( string $setting, $value, $autoload = null ): void {
[65] Fix | Delete
[66] Fix | Delete
if ( $setting ) {
[67] Fix | Delete
update_option( 'hostinger_' . $setting, $value, $autoload );
[68] Fix | Delete
}
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
new Settings();
[73] Fix | Delete
[74] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function