Skip to content

Commit

Permalink
Merge pull request #308 from newfold-labs/add/hostgator-support
Browse files Browse the repository at this point in the history
HostGator Support
  • Loading branch information
arunshenoy99 authored Sep 18, 2023
2 parents de93652 + 79d24ff commit c64b815
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 36 deletions.
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 77 additions & 2 deletions includes/Data/Brands.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,97 @@ public static function get_brands() {
),
),
),
'hostgator-br' => array(
'brand' => 'hostgator-br',
'name' => 'HostGator',
'url' => 'https://www.hostgator.com.br',
'knowledgeBaseUrl' => 'https://suporte.hostgator.com.br/hc/pt-br',
'helpUrl' => 'https://cliente.hostgator.com.br/suporte',
'blogUrl' => 'https://www.hostgator.com.br/blog/',
'facebookUrl' => 'https://www.facebook.com/HostgatorBrasil/',
'twitterName' => '@hostgatorbrasil',
'twitterUrl' => 'https://twitter.com/hostgatorbrasil',
'youtubeUrl' => 'https://www.youtube.com/c/HostGatorBrasil',
'linkedinUrl' => 'https://www.linkedin.com/company/hostgator-latam/',
'accountUrl' => 'https://financeiro.hostgator.com.br/',
'domainsUrl' => 'https://cliente.hostgator.com.br/dominios',
'emailUrl' => 'https://cliente.hostgator.com.br/emails-list',
'pluginDashboardPage' => \admin_url( 'admin.php?page=hostgator' ),
'phoneNumbers' => array(
'support' => '',
),
'hireExpertsInfo' => array(
'defaultLink' => 'https://suporte.hostgator.com.br/hc/pt-br',
'fragment' => '',
'queryParameters' => array(
'utm_source' => 'wp-onboarding',
'utm_medium' => 'brand-plugin',
'utm_campaign' => 'wp-setup',
),
),
'expertsInfo' => array(
'defaultLink' => 'https://suporte.hostgator.com.br/hc/pt-br',
'queryParams' => array(
'utm_source' => 'wp-onboarding',
'utm_medium' => 'brand-plugin',
),
),
'fullServiceCreativeTeamInfo' => array(
'defaultLink' => 'https://suporte.hostgator.com.br/hc/pt-br',
'fragment' => '',
'queryParams' => array(
'utm_source' => 'wp-onboarding',
'utm_medium' => 'brand-plugin',
),
),
'techSupportInfo' => array(
'defaultLink' => 'https://suporte.hostgator.com.br/hc/pt-br',
'queryParams' => array(
'utm_source' => 'wp-onboarding',
'utm_medium' => 'brand-plugin',
),
),
'config' => array(
'enabled_flows' => array(
'ecommerce' => true,
'wp-setup' => true,
),
'wonder_blocks' => true,
'views' => array(
'sidebar' => array(
'illustration' => array(
'shown' => false,
),
),
),
),
),
);
}

/**
* Sets the hosting brand for which Onboarding is active.
*
* @param object $container The brand plugin container.
* @return void
* @return string
*/
public static function set_current_brand( $container ) {
if ( ! defined( 'NFD_ONBOARDING_PLUGIN_BRAND' ) ) {
$brand = $container->plugin()->brand;
if ( empty( $brand ) ) {
$brand = 'wordpress';
}
define( 'NFD_ONBOARDING_PLUGIN_BRAND', sanitize_title_with_dashes( str_replace( '_', '-', $brand ) ) );

if ( false !== strpos( $brand, 'hostgator' ) ) {
$region = strtolower( $container->plugin()->region );
$brand = "hostgator-{$region}";
}

$brand = sanitize_title_with_dashes( str_replace( '_', '-', $brand ) );

define( 'NFD_ONBOARDING_PLUGIN_BRAND', $brand );

return $brand;
}
}
}
26 changes: 23 additions & 3 deletions includes/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public static function init() {
public static function module_switcher() {
$module_name = 'onboarding';
// Set brand context for the module.
Brands::set_current_brand( container() );
$current_brand = Brands::set_current_brand( container() );

$enable_onboarding = self::verify_onboarding_criteria();
$enable_onboarding = self::verify_onboarding_criteria( $current_brand );

// Check if he is a Non-Ecommerce Customer and Disable Redirect and Module
if ( ! $enable_onboarding ) {
Expand All @@ -58,9 +58,10 @@ public static function module_switcher() {
/**
* Verify all the necessary criteria to enable Onboarding for the site.
*
* @param string $brand_name The kebab cased name of the brand.
* @return boolean
*/
public static function verify_onboarding_criteria() {
public static function verify_onboarding_criteria( $brand_name ) {
// Check if nfd_module_onboarding_activate query param was passed previously.
$activate_transient_name = Options::get_option_name( 'activate_param' );
if ( '1' === get_transient( $activate_transient_name ) ) {
Expand All @@ -75,6 +76,11 @@ public static function verify_onboarding_criteria() {
return true;
}

$eligible_brand = self::is_brand_eligible( $brand_name );
if ( ! $eligible_brand ) {
return false;
}

$customer_data = Data::customer_data();
$brand_enabled_flows = Flows::get_flows();
foreach ( $brand_enabled_flows as $flow => $enabled ) {
Expand All @@ -96,6 +102,20 @@ public static function verify_onboarding_criteria() {
return false;
}

/**
* Checks if a particular brand name is eligible for Onboarding.
*
* @param string $brand_name The kebab cased name of the brand.
* @return boolean
*/
public static function is_brand_eligible( $brand_name ) {
if ( false !== strpos( $brand_name, 'hostgator' ) && 'hostgator-br' !== $brand_name ) {
return false;
}

return true;
}

/**
* Determine if the install is a new commerce signup
*
Expand Down
14 changes: 6 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Brands/hostgator/step-error-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c64b815

Please sign in to comment.