Skip to content

Commit c7cfa39

Browse files
authored
Merge pull request #332 from newfold-labs/update/brand-aware-footer
Add brand awareness to links and phone texts
2 parents 31e973b + 6941e6a commit c7cfa39

13 files changed

Lines changed: 739 additions & 238 deletions

File tree

.github/workflows/brand-plugin-test-playwright.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,45 @@ jobs:
2727
id: extract_branch
2828

2929
bluehost:
30-
name: Bluehost Build and Test Cypress
30+
name: Bluehost Build and Test
3131
needs: setup
3232
uses: newfold-labs/workflows/.github/workflows/module-plugin-test-playwright.yml@main
3333
with:
3434
module-repo: ${{ github.repository }}
3535
module-branch: ${{ needs.setup.outputs.branch }}
3636
plugin-repo: 'newfold-labs/wp-plugin-bluehost'
3737
secrets: inherit
38+
39+
bluehost-dev:
40+
name: Bluehost Dev Build and Test
41+
needs: setup
42+
uses: newfold-labs/workflows/.github/workflows/module-plugin-test-playwright.yml@main
43+
with:
44+
module-repo: ${{ github.repository }}
45+
module-branch: ${{ needs.setup.outputs.branch }}
46+
plugin-repo: 'newfold-labs/wp-plugin-bluehost'
47+
plugin-branch: 'develop'
48+
artifact-name: 'wp-plugin-bluehost-develop'
49+
secrets: inherit
50+
51+
hostgator:
52+
name: HostGator Build and Test
53+
needs: setup
54+
uses: newfold-labs/workflows/.github/workflows/module-plugin-test-playwright.yml@main
55+
with:
56+
module-repo: ${{ github.repository }}
57+
module-branch: ${{ needs.setup.outputs.branch }}
58+
plugin-repo: 'newfold-labs/wp-plugin-hostgator'
59+
secrets: inherit
60+
61+
hostgator-dev:
62+
name: HostGator Dev Build and Test
63+
needs: setup
64+
uses: newfold-labs/workflows/.github/workflows/module-plugin-test-playwright.yml@main
65+
with:
66+
module-repo: ${{ github.repository }}
67+
module-branch: ${{ needs.setup.outputs.branch }}
68+
plugin-repo: 'newfold-labs/wp-plugin-hostgator'
69+
plugin-branch: 'develop'
70+
artifact-name: 'wp-plugin-hostgator-develop'
71+
secrets: inherit

build/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '427d6dcf19972240b232');
1+
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '46250b54ef78e9498d33');

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/Data/Brands.php

Lines changed: 226 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,69 +7,260 @@
77
*/
88
final class Brands {
99

10-
1110
/**
12-
* Brand specific data - Bluehost, HostGator
11+
* Brand-specific data for JS components and resource links.
12+
* Keys match NFD_HELPCENTER_PLUGIN_BRAND (bluehost, hostgator-us, hostgator-ar, etc.).
13+
* HostGator regions mirror region.js: main, help_phone_number, help_chat, help_kb.
1314
*
1415
* @return array
1516
*/
16-
public static function get_brands() {
17+
public static function get_brand_data() {
18+
$help_chat_latam = 'https://soporte.hostgator.mx/hc/es-419/articles/28439167280915-C%C3%B3mo-entrar-en-contacto-con-Soporte';
19+
$help_kb_latam = 'https://soporte.hostgator.mx/hc/es-419';
20+
1721
return array(
1822
'bluehost' => array(
19-
'brand' => 'bluehost',
20-
'name' => 'Bluehost',
21-
'url' => apply_filters( 'nfd_build_url', 'https://bluehost.com' ),
22-
'helpURL' => apply_filters( 'nfd_build_url', 'https://www.bluehost.com/help' ),
23+
'brand' => 'bluehost',
24+
'name' => __( 'Bluehost', 'wp-module-help-center' ),
25+
'url' => apply_filters( 'nfd_build_url', 'https://bluehost.com' ),
26+
'helpURL' => apply_filters( 'nfd_build_url', 'https://www.bluehost.com/help' ),
27+
'contactUrl' => apply_filters( 'nfd_build_url', 'https://www.bluehost.com/contact' ),
28+
'phone' => '8884014678',
29+
'phoneDisplay' => '888-401-4678',
30+
'accountName' => __( 'Bluehost', 'wp-module-help-center' ),
31+
'hasPhone' => true,
32+
'showProDesignBanner' => true,
33+
'kbClickDomains' => array( 'bhmultisite.com' ),
34+
'proDesignUrl' => apply_filters( 'nfd_build_url', 'https://www.bluehost.com/pro-design-live' ),
35+
'proDesignHeading' => __( 'Your dream site is just a click away.', 'wp-module-help-center' ),
36+
'proDesignSubheading' => __( "Let's build a site you love, together.", 'wp-module-help-center' ),
37+
'proDesignBody' => __( 'With Pro Design Live, our expert team bring your vision to life. We help you to create the site you\'ve always dreamed of — tailored to your goals, ready to perform.', 'wp-module-help-center' ),
38+
'proDesignCta' => __( 'Start Now', 'wp-module-help-center' ),
2339
),
2440
'hostgator-us' => array(
25-
'brand' => 'hostgator',
26-
'name' => 'HostGator',
27-
'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.com' ),
28-
'helpUrl' => apply_filters( 'nfd_build_url', 'https://www.hostgator.com/help' ),
29-
),
30-
'hostgator-br' => array(
31-
'brand' => 'hostgator-br',
32-
'name' => 'HostGator',
33-
'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.com.br' ),
34-
'helpUrl' => apply_filters( 'nfd_build_url', 'https://suporte.hostgator.com.br/hc/pt-br' ),
41+
'brand' => 'hostgator',
42+
'name' => __( 'HostGator', 'wp-module-help-center' ),
43+
'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.com' ),
44+
'helpURL' => apply_filters( 'nfd_build_url', 'https://www.hostgator.com/help' ),
45+
'contactUrl' => apply_filters( 'nfd_build_url', 'https://helpchat.hostgator.com' ),
46+
'phone' => '8669642867',
47+
'phoneDisplay' => '866-964-2867',
48+
'accountName' => __( 'HostGator', 'wp-module-help-center' ),
49+
'hasPhone' => true,
50+
'showProDesignBanner' => false,
51+
'kbClickDomains' => array(),
3552
),
53+
54+
/*
55+
* HostGator regions below are NOT YET IN USE — only US sites have the help center capability.
56+
* Uncomment when ready to enable help center for these regions.
57+
*/
58+
// phpcs:disable Squiz.PHP.CommentedOutCode.Found -- Future regions, keep for easy re-enable.
59+
// 'hostgator-ar' => array(
60+
// 'brand' => 'hostgator-ar',
61+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
62+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.ar' ),
63+
// 'helpURL' => apply_filters( 'nfd_build_url', $help_kb_latam ),
64+
// 'contactUrl' => apply_filters( 'nfd_build_url', $help_chat_latam ),
65+
// 'phone' => '',
66+
// 'phoneDisplay' => '',
67+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
68+
// 'hasPhone' => false,
69+
// 'showProDesignBanner' => false,
70+
// 'kbClickDomains' => array(),
71+
// ),
72+
// 'hostgator-bo' => array(
73+
// 'brand' => 'hostgator-bo',
74+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
75+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.bo' ),
76+
// 'helpURL' => apply_filters( 'nfd_build_url', $help_kb_latam ),
77+
// 'contactUrl' => apply_filters( 'nfd_build_url', $help_chat_latam ),
78+
// 'phone' => '',
79+
// 'phoneDisplay' => '',
80+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
81+
// 'hasPhone' => false,
82+
// 'showProDesignBanner' => false,
83+
// 'kbClickDomains' => array(),
84+
// ),
85+
// 'hostgator-br' => array(
86+
// 'brand' => 'hostgator-br',
87+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
88+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.com.br' ),
89+
// 'helpURL' => apply_filters( 'nfd_build_url', 'https://suporte.hostgator.com.br/hc/pt-br' ),
90+
// 'contactUrl' => apply_filters( 'nfd_build_url', 'https://suporte.hostgator.com.br/hc/pt-br' ),
91+
// 'phone' => '',
92+
// 'phoneDisplay' => '',
93+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
94+
// 'hasPhone' => false,
95+
// 'showProDesignBanner' => false,
96+
// 'kbClickDomains' => array(),
97+
// ),
98+
// 'hostgator-cl' => array(
99+
// 'brand' => 'hostgator-cl',
100+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
101+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.cl' ),
102+
// 'helpURL' => apply_filters( 'nfd_build_url', $help_kb_latam ),
103+
// 'contactUrl' => apply_filters( 'nfd_build_url', $help_chat_latam ),
104+
// 'phone' => '',
105+
// 'phoneDisplay' => '',
106+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
107+
// 'hasPhone' => false,
108+
// 'showProDesignBanner' => false,
109+
// 'kbClickDomains' => array(),
110+
// ),
111+
// 'hostgator-co' => array(
112+
// 'brand' => 'hostgator-co',
113+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
114+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.co' ),
115+
// 'helpURL' => apply_filters( 'nfd_build_url', $help_kb_latam ),
116+
// 'contactUrl' => apply_filters( 'nfd_build_url', $help_chat_latam ),
117+
// 'phone' => '',
118+
// 'phoneDisplay' => '',
119+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
120+
// 'hasPhone' => false,
121+
// 'showProDesignBanner' => false,
122+
// 'kbClickDomains' => array(),
123+
// ),
124+
// 'hostgator-do' => array(
125+
// 'brand' => 'hostgator-do',
126+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
127+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.do' ),
128+
// 'helpURL' => apply_filters( 'nfd_build_url', $help_kb_latam ),
129+
// 'contactUrl' => apply_filters( 'nfd_build_url', $help_chat_latam ),
130+
// 'phone' => '',
131+
// 'phoneDisplay' => '',
132+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
133+
// 'hasPhone' => false,
134+
// 'showProDesignBanner' => false,
135+
// 'kbClickDomains' => array(),
136+
// ),
137+
// 'hostgator-ec' => array(
138+
// 'brand' => 'hostgator-ec',
139+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
140+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.net.ec' ),
141+
// 'helpURL' => apply_filters( 'nfd_build_url', $help_kb_latam ),
142+
// 'contactUrl' => apply_filters( 'nfd_build_url', $help_chat_latam ),
143+
// 'phone' => '',
144+
// 'phoneDisplay' => '',
145+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
146+
// 'hasPhone' => false,
147+
// 'showProDesignBanner' => false,
148+
// 'kbClickDomains' => array(),
149+
// ),
150+
// 'hostgator-mx' => array(
151+
// 'brand' => 'hostgator-mx',
152+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
153+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.mx' ),
154+
// 'helpURL' => apply_filters( 'nfd_build_url', $help_kb_latam ),
155+
// 'contactUrl' => apply_filters( 'nfd_build_url', $help_chat_latam ),
156+
// 'phone' => '',
157+
// 'phoneDisplay' => '',
158+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
159+
// 'hasPhone' => false,
160+
// 'showProDesignBanner' => false,
161+
// 'kbClickDomains' => array(),
162+
// ),
163+
// 'hostgator-pe' => array(
164+
// 'brand' => 'hostgator-pe',
165+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
166+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.pe' ),
167+
// 'helpURL' => apply_filters( 'nfd_build_url', $help_kb_latam ),
168+
// 'contactUrl' => apply_filters( 'nfd_build_url', $help_chat_latam ),
169+
// 'phone' => '',
170+
// 'phoneDisplay' => '',
171+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
172+
// 'hasPhone' => false,
173+
// 'showProDesignBanner' => false,
174+
// 'kbClickDomains' => array(),
175+
// ),
176+
// 'hostgator-uy' => array(
177+
// 'brand' => 'hostgator-uy',
178+
// 'name' => __( 'HostGator', 'wp-module-help-center' ),
179+
// 'url' => apply_filters( 'nfd_build_url', 'https://www.hostgator.uy' ),
180+
// 'helpURL' => apply_filters( 'nfd_build_url', $help_kb_latam ),
181+
// 'contactUrl' => apply_filters( 'nfd_build_url', $help_chat_latam ),
182+
// 'phone' => '',
183+
// 'phoneDisplay' => '',
184+
// 'accountName' => __( 'HostGator', 'wp-module-help-center' ),
185+
// 'hasPhone' => false,
186+
// 'showProDesignBanner' => false,
187+
// 'kbClickDomains' => array(),
188+
// ),
189+
// phpcs:enable Squiz.PHP.CommentedOutCode.Found
36190
);
37191
}
38192

39193
/**
40-
* Sets the hosting brand.
194+
* Get the brand data for the given brand key.
195+
*
196+
* @param string $brand_key NFD_HELPCENTER_PLUGIN_BRAND (e.g. bluehost, hostgator-us).
197+
* @return array
198+
*/
199+
public static function get_data_for_brand( $brand_key ) {
200+
$data = self::get_brand_data();
201+
202+
// 1. Exact match: return the requested brand's data if it exists.
203+
if ( isset( $data[ $brand_key ] ) ) {
204+
return $data[ $brand_key ];
205+
}
206+
207+
// 2. HostGator fallback: for hostgator-* keys not defined (e.g. hostgator-xy, or future regions
208+
// that are commented out), use hostgator-us as the default. Only US has help center capability.
209+
if ( 0 === strpos( $brand_key, 'hostgator' ) ) {
210+
return $data['hostgator-us'] ?? $data['bluehost'];
211+
}
212+
213+
// 3. Unknown brand: fall back to bluehost.
214+
return $data['bluehost'];
215+
}
216+
217+
/**
218+
* Returns the resource link (help URL) for the given brand.
41219
*
42-
* @param object $container The brand plugin container.
220+
* @param string $brand_key NFD_HELPCENTER_PLUGIN_BRAND.
221+
* @return string
222+
*/
223+
public static function get_resource_link_for_brand( $brand_key ) {
224+
$all_data = self::get_brand_data();
225+
if ( ! isset( $all_data[ $brand_key ] ) && 0 !== strpos( $brand_key, 'hostgator' ) ) {
226+
return '';
227+
}
228+
$data = self::get_data_for_brand( $brand_key );
229+
return $data['helpURL'] ?? '';
230+
}
231+
232+
/**
233+
* Sets the hosting brand and defines NFD_HELPCENTER_PLUGIN_BRAND.
234+
*
235+
* Called from the module bootstrap (before the help center loads). Uses the container's
236+
* plugin()->brand and plugin()->region to determine the brand key.
237+
*
238+
* For HostGator: appends region → hostgator-us, hostgator-br, etc. This is used by:
239+
* - HelpCenter.php (brandConfig, resourceLink)
240+
* - MultiSearchController (filter_by post_category) — the TypeSense index must have articles
241+
* with post_category matching this value (e.g. "hostgator-us" or "hostgator" depending on index).
242+
*
243+
* @param object $container The brand plugin container (from Newfold Module Loader).
43244
*/
44245
public static function set_current_brand( $container ) {
45246
if ( ! defined( 'NFD_HELPCENTER_PLUGIN_BRAND' ) ) {
247+
// Get brand from container (set in plugin)
46248
$brand = $container->plugin()->brand;
47249
if ( empty( $brand ) ) {
48250
$brand = 'WordPress';
49251
}
50252

253+
// Only HostGator uses region; Bluehost does not.
254+
// Region may be empty in the container but is populated as "us" in the runtime by default.
255+
// But only US has help center capability for now see canAccessHelpCenter in Site Model in Hiive.
51256
if ( false !== strpos( $brand, 'hostgator' ) ) {
52-
$region = strtolower( $container->plugin()->region );
53-
$brand = "hostgator-{$region}";
257+
$region = strtolower( $container->plugin()->region ?? '' );
258+
$brand = ! empty( $region ) ? 'hostgator-' . $region : 'hostgator';
54259
}
55260

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

58263
define( 'NFD_HELPCENTER_PLUGIN_BRAND', $brand );
59264
}
60265
}
61-
62-
/**
63-
* Returns the resource link.
64-
*
65-
* @param string $brand_name The brand name for which the link is to be fetched.
66-
* @return string
67-
*/
68-
public static function get_resource_link_for_brand( $brand_name ) {
69-
$brands = self::get_brands();
70-
if ( isset( $brands[ $brand_name ]['helpURL'] ) ) {
71-
return $brands[ $brand_name ]['helpURL'];
72-
}
73-
return '';
74-
}
75266
}

includes/HelpCenter.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,22 +192,36 @@ public function assets() {
192192
'screen'
193193
);
194194

195+
$brand_data = Brands::get_data_for_brand( NFD_HELPCENTER_PLUGIN_BRAND );
195196
\wp_add_inline_script(
196197
self::$handle,
197198
'var nfdHelpCenter =' . wp_json_encode(
198199
array(
199-
'restUrl' => \get_home_url() . '/index.php?rest_route=',
200-
'resourceLink' => Brands::get_resource_link_for_brand( NFD_HELPCENTER_PLUGIN_BRAND ),
200+
'restUrl' => \get_home_url() . '/index.php?rest_route=',
201+
'resourceLink' => Brands::get_resource_link_for_brand( NFD_HELPCENTER_PLUGIN_BRAND ),
202+
'brand' => NFD_HELPCENTER_PLUGIN_BRAND,
203+
'brandConfig' => $brand_data,
204+
/* translators: 1: account name, 2: phone link, 3: chat link */
205+
'supportMessageTemplate' => __( 'If you need help with your %1$s account, give us a call at %2$s or %3$s with one of our support agents — we\'re here for you!', 'wp-module-help-center' ),
206+
/* translators: 1: account name, 2: chat link */
207+
'supportMessageTemplateNoPhone' => __( 'If you need help with your %1$s account, %2$s with one of our support agents — we\'re here for you!', 'wp-module-help-center' ),
208+
/* translators: 1: phone link, 2: chat link */
209+
'noResultsSupportTemplate' => __( 'Call at %1$s or %2$s with one of our support agents — we will assist you as soon as possible.', 'wp-module-help-center' ),
210+
/* translators: 1: chat link */
211+
'noResultsSupportTemplateNoPhone' => __( 'Or %1$s with one of our support agents — we will assist you as soon as possible.', 'wp-module-help-center' ),
201212
)
202213
) . ';',
203214
'before'
204215
);
205216

206-
/* Hide the helpcenter on onboarding flow */
217+
/*
218+
* Hide the helpcenter on onboarding flow.
219+
*/
220+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reading page query param for display logic, not form submission.
207221
\wp_localize_script( self::$handle, 'newfoldHelpCenter', array( 'closeOnLoad' => ( isset( $_GET['page'] ) && 'nfd-onboarding' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) ) );
208222

209223
/* Remove values on log out */
210-
$logout_listener_js = <<<JS
224+
$logout_listener_js = <<<'JS'
211225
jQuery(document).ready(function ($) {
212226
$('a[href*="wp-login.php?action=logout"]').on('click', function () {
213227
localStorage.removeItem('helpResultContent');
@@ -220,7 +234,7 @@ public function assets() {
220234
\wp_add_inline_script( self::$handle, $logout_listener_js );
221235

222236
/* Remove values when the user is logged out */
223-
$session_expiration_js = <<<JS
237+
$session_expiration_js = <<<'JS'
224238
jQuery(document).on('heartbeat-tick', function (event, data) {
225239
if (data.hasOwnProperty('wp-auth-check') && data['wp-auth-check'] === false) {
226240
localStorage.removeItem('helpResultContent');

0 commit comments

Comments
 (0)