Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 33 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Brands | |
0.00% |
0 / 33 |
|
0.00% |
0 / 3 |
56 | |
0.00% |
0 / 1 |
| get_brands | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
2 | |||
| set_current_brand | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |||
| get_resource_link_for_brand | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace NewfoldLabs\WP\Module\HelpCenter\Data; |
| 4 | |
| 5 | /** |
| 6 | * Contains Brand information. |
| 7 | */ |
| 8 | final class Brands { |
| 9 | |
| 10 | |
| 11 | /** |
| 12 | * Brand specific data - Bluehost, HostGator |
| 13 | * |
| 14 | * @return array |
| 15 | */ |
| 16 | public static function get_brands() { |
| 17 | return array( |
| 18 | 'bluehost' => array( |
| 19 | 'brand' => 'bluehost', |
| 20 | 'name' => 'Bluehost', |
| 21 | 'url' => 'https://bluehost.com', |
| 22 | 'helpURL' => 'https://www.bluehost.com/help', |
| 23 | ), |
| 24 | 'hostgator-us' => array( |
| 25 | 'brand' => 'hostgator', |
| 26 | 'name' => 'HostGator', |
| 27 | 'url' => 'https://www.hostgator.com', |
| 28 | 'helpUrl' => 'https://www.hostgator.com/help', |
| 29 | ), |
| 30 | 'hostgator-br' => array( |
| 31 | 'brand' => 'hostgator-br', |
| 32 | 'name' => 'HostGator', |
| 33 | 'url' => 'https://www.hostgator.com.br', |
| 34 | 'helpUrl' => 'https://suporte.hostgator.com.br/hc/pt-br', |
| 35 | ), |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Sets the hosting brand. |
| 41 | * |
| 42 | * @param object $container The brand plugin container. |
| 43 | */ |
| 44 | public static function set_current_brand( $container ) { |
| 45 | if ( ! defined( 'NFD_HELPCENTER_PLUGIN_BRAND' ) ) { |
| 46 | $brand = $container->plugin()->brand; |
| 47 | if ( empty( $brand ) ) { |
| 48 | $brand = 'WordPress'; |
| 49 | } |
| 50 | |
| 51 | if ( false !== strpos( $brand, 'hostgator' ) ) { |
| 52 | $region = strtolower( $container->plugin()->region ); |
| 53 | $brand = "hostgator-{$region}"; |
| 54 | } |
| 55 | |
| 56 | $brand = sanitize_title_with_dashes( str_replace( '_', '-', $brand ) ); |
| 57 | |
| 58 | define( 'NFD_HELPCENTER_PLUGIN_BRAND', $brand ); |
| 59 | } |
| 60 | } |
| 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 | } |
| 75 | } |