-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from newfold-labs/dynamic-resource-link
making the resource link dynamic
- Loading branch information
Showing
7 changed files
with
109 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('lodash', 'react', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '47871efacaa34562e3f9'); | ||
<?php return array('dependencies' => array('lodash', 'react', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '14909b5dc8e12284ee9c'); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace NewfoldLabs\WP\Module\HelpCenter\Data; | ||
|
||
/** | ||
* Contains Brand information. | ||
*/ | ||
final class Brands | ||
{ | ||
|
||
/** | ||
* Brand specific data - Bluehost, HostGator | ||
* | ||
* @return array | ||
*/ | ||
public static function get_brands() | ||
{ | ||
return array( | ||
'bluehost' => array( | ||
'brand' => 'bluehost', | ||
'name' => 'Bluehost', | ||
'url' => 'https://bluehost.com', | ||
'helpURL' => 'https://www.bluehost.com/help', | ||
), | ||
'hostgator-us' => array( | ||
'brand' => 'hostgator', | ||
'name' => 'HostGator', | ||
'url' => 'https://www.hostgator.com', | ||
'helpUrl' => 'https://www.hostgator.com/help', | ||
), | ||
'hostgator-br' => array( | ||
'brand' => 'hostgator-br', | ||
'name' => 'HostGator', | ||
'url' => 'https://www.hostgator.com.br', | ||
'helpUrl' => 'https://suporte.hostgator.com.br/hc/pt-br', | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* Sets the hosting brand. | ||
* | ||
* @param object $container The brand plugin container. | ||
*/ | ||
public static function set_current_brand( $container ) { | ||
if ( ! defined('NFD_HELPCENTER_PLUGIN_BRAND') ) { | ||
$brand = $container->plugin()->brand; | ||
if (empty($brand)) { | ||
$brand = 'wordpress'; | ||
} | ||
|
||
if (false !== strpos($brand, 'hostgator')) { | ||
$region = strtolower($container->plugin()->region); | ||
$brand = "hostgator-{$region}"; | ||
} | ||
|
||
$brand = sanitize_title_with_dashes(str_replace('_', '-', $brand)); | ||
|
||
define('NFD_HELPCENTER_PLUGIN_BRAND', $brand); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the resource link. | ||
* | ||
* @param string $brand_name The brand name for which the link is to be fetched. | ||
* @return string | ||
*/ | ||
public static function get_resource_link_for_brand( $brand_name ) { | ||
$brands = self::get_brands(); | ||
if ( isset( $brands[ $brand_name ][ 'helpURL' ] ) ) { | ||
return $brands[ $brand_name ][ 'helpURL' ]; | ||
} | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
const ResourceLink = () => { | ||
if ( window?.nfdHelpCenter?.resourceLink ) { | ||
return ( | ||
<p> | ||
{ __( | ||
'In the meantime, try searching our', | ||
'wp-module-help-center' | ||
) }{ ' ' } | ||
<a href={ window?.nfdHelpCenter?.resourceLink }> | ||
{ __( 'Resource center.', 'wp-module-help-center' ) } | ||
</a> | ||
</p> | ||
); | ||
} | ||
}; | ||
|
||
export default ResourceLink; |