Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 65 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| WonderCart | |
0.00% |
0 / 65 |
|
0.00% |
0 / 6 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| init | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| get_panel_page | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_main_panel_page | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_main_app_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| filter_scripts_data | |
0.00% |
0 / 56 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | namespace NewfoldLabs\WP\Module\ECommerce; |
| 3 | |
| 4 | use NewfoldLabs\WP\ModuleLoader\Container; |
| 5 | /** |
| 6 | * WonderCart Integration Class |
| 7 | */ |
| 8 | class WonderCart { |
| 9 | /** |
| 10 | * Holds the container object |
| 11 | * |
| 12 | * @var Container |
| 13 | */ |
| 14 | public $container; |
| 15 | |
| 16 | /** |
| 17 | * Constructor |
| 18 | * |
| 19 | * @param Container $container Plugin container |
| 20 | */ |
| 21 | public function __construct( Container $container ) { |
| 22 | $this->container = $container; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Initialize WonderCart Integrations |
| 27 | * |
| 28 | * @return void |
| 29 | */ |
| 30 | public function init() { |
| 31 | // For now these are only customized on Hostgator. |
| 32 | // If in the future we need to expand this to other brands, |
| 33 | // the brand checks could be moved into the individual methods. |
| 34 | if ( $this->container->plugin()->id === 'hostgator' ) { |
| 35 | add_filter( 'yith_sales_panel_page', array( $this, 'get_panel_page' ) ); |
| 36 | add_filter( 'yith_sales_main_panel_page', array( $this, 'get_main_panel_page' ) ); |
| 37 | add_filter( 'yith_sales_main_app_id', array( $this, 'get_main_app_id' ) ); |
| 38 | add_filter( 'yith_sales_get_scripts_data', array( $this, 'filter_scripts_data' ), 10, 2 ); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Returns the panel page |
| 44 | * |
| 45 | * @return string |
| 46 | */ |
| 47 | public function get_panel_page() { |
| 48 | // Only for Hostgator |
| 49 | return 'hostgator#/home/store/sales_discounts'; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Returns the main panel page |
| 54 | * |
| 55 | * @return string |
| 56 | */ |
| 57 | public function get_main_panel_page() { |
| 58 | // Only for Hostgator |
| 59 | return 'hostgator'; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Returns the main app ID |
| 64 | * |
| 65 | * @return string |
| 66 | */ |
| 67 | public function get_main_app_id() { |
| 68 | // Only for Hostgator |
| 69 | return '#hwa-app'; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Modifies and returns the primary scripts data array to apply themeing |
| 74 | * |
| 75 | * @param array $params Array of data being filtered |
| 76 | * @param string $handle The handle of the page in wp-admin where this is being loaded |
| 77 | * @return array The filtered array |
| 78 | */ |
| 79 | public function filter_scripts_data( $params, $handle ) { |
| 80 | // Ensure we only apply this on the correct admin page |
| 81 | if ( 'yith-sales-admin' === $handle ) { |
| 82 | // Hostgator Branding |
| 83 | $params['uiLibraryColors'] = array( |
| 84 | 'button' => array( |
| 85 | 'borderRadius' => '6px', |
| 86 | 'contained' => array( |
| 87 | 'background' => '#2E93EE!important', |
| 88 | 'backgroundColor' => '#2E93EE', |
| 89 | 'color' => '#fff!important', |
| 90 | '&:hover' => array( |
| 91 | 'background' => '#1F2044!important', |
| 92 | 'backgroundColor' => '#1F2044', |
| 93 | 'color' => '#FFF!important', |
| 94 | ), |
| 95 | '&:focus, &:focus-visible' => array( |
| 96 | 'boxShadow' => '0 0 0 1px #fff, 0 0 0 2px #2E93EE', |
| 97 | ), |
| 98 | '&:disabled' => array( |
| 99 | 'opacity' => 1, |
| 100 | 'background' => '#CDD8DF', |
| 101 | 'backgroundColor' => '#CDD8DF', |
| 102 | 'color' => '#999', |
| 103 | ), |
| 104 | ), |
| 105 | 'outlined' => array( |
| 106 | 'background' => '#fff!important', |
| 107 | 'backgroundColor' => '#fff', |
| 108 | 'color' => '#000!important', |
| 109 | 'border' => '1px solid #2E93EE', |
| 110 | '&:hover' => array( |
| 111 | 'background' => '#cadded!important', |
| 112 | 'backgroundColor' => '#cadded', |
| 113 | 'border' => '#949fb2', |
| 114 | ), |
| 115 | '&:focus, &:focus-visible' => array( |
| 116 | 'boxShadow' => '0 0 0 1px #fff, 0 0 0 2px #2E93EE', |
| 117 | ), |
| 118 | '&:disabled' => array( |
| 119 | 'opacity' => 1, |
| 120 | 'background' => '#fff', |
| 121 | 'backgroundColor' => '#fff', |
| 122 | 'border' => '1px solid #949fb2', |
| 123 | 'color' => '#999999', |
| 124 | ), |
| 125 | ), |
| 126 | ), |
| 127 | 'primary' => '#2E93EE', |
| 128 | 'primaryHover' => '#1F2044!important', |
| 129 | 'primaryHoverBorder' => '#2E93EE', |
| 130 | 'focusedBorderColor' => '#2E93EE!important', |
| 131 | 'success' => '#348528', |
| 132 | 'tabs' => array( |
| 133 | 'activeTab' => '#1f2044', |
| 134 | 'hoverTab' => '#cdd8df', |
| 135 | ), |
| 136 | ); |
| 137 | } |
| 138 | return $params; |
| 139 | } |
| 140 | } |