account-navigation.php
207 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | use ShopEngine\Widgets\Products; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | |
| 10 | class ShopEngine_Account_Navigation extends \ShopEngine\Base\Widget |
| 11 | { |
| 12 | |
| 13 | public function config() { |
| 14 | return new ShopEngine_Account_Navigation_Config(); |
| 15 | } |
| 16 | |
| 17 | |
| 18 | protected function register_controls() { |
| 19 | |
| 20 | |
| 21 | /* |
| 22 | ---------------------------- |
| 23 | list Styles |
| 24 | ---------------------------- |
| 25 | */ |
| 26 | |
| 27 | $this->start_controls_section( |
| 28 | 'shopengine_account_navigation_list', [ |
| 29 | 'label' => esc_html__('Navigation List', 'shopengine'), |
| 30 | 'tab' => Controls_Manager::TAB_STYLE, |
| 31 | ] |
| 32 | ); |
| 33 | |
| 34 | $this->add_control( |
| 35 | 'shopengine_account_navigation_list_color', |
| 36 | [ |
| 37 | 'label' => esc_html__('List Color', 'shopengine'), |
| 38 | 'type' => Controls_Manager::COLOR, |
| 39 | 'alpha' => false, |
| 40 | 'default' => '#B1ADAD', |
| 41 | 'selectors' => [ |
| 42 | '{{WRAPPER}} .shopengine-account-navigation ul li a' => 'color: {{VALUE}};', |
| 43 | '{{WRAPPER}} .shopengine-account-navigation ul li a::before' => 'background-color: {{VALUE}};', |
| 44 | ], |
| 45 | ] |
| 46 | ); |
| 47 | |
| 48 | |
| 49 | $this->add_control( |
| 50 | 'shopengine_account_navigation_list_hover_color', |
| 51 | [ |
| 52 | 'label' => esc_html__('Hover and Active Color', 'shopengine'), |
| 53 | 'type' => Controls_Manager::COLOR, |
| 54 | 'alpha' => false, |
| 55 | 'default' => '#3A3A3A', |
| 56 | 'selectors' => [ |
| 57 | '{{WRAPPER}} .shopengine-account-navigation ul li a:hover' => 'color: {{VALUE}};', |
| 58 | '{{WRAPPER}} .shopengine-account-navigation ul li a:hover:before' => 'background-color: {{VALUE}};', |
| 59 | '{{WRAPPER}} .shopengine-account-navigation ul li.is-active a' => 'color: {{VALUE}};', |
| 60 | '{{WRAPPER}} .shopengine-account-navigation ul li.is-active a:before' => 'background-color: {{VALUE}};', |
| 61 | ], |
| 62 | ] |
| 63 | ); |
| 64 | |
| 65 | $this->add_control( |
| 66 | 'shopengine_account_navigation_list_active_bg', |
| 67 | [ |
| 68 | 'label' => esc_html__('Active Background', 'shopengine'), |
| 69 | 'type' => Controls_Manager::COLOR, |
| 70 | 'alpha' => false, |
| 71 | 'default' => '#F2F2F2', |
| 72 | 'selectors' => [ |
| 73 | '{{WRAPPER}} .shopengine-account-navigation ul li.is-active' => 'background: {{VALUE}};', |
| 74 | ], |
| 75 | ] |
| 76 | ); |
| 77 | |
| 78 | $this->add_group_control( |
| 79 | Group_Control_Typography::get_type(), |
| 80 | [ |
| 81 | 'name' => 'shopengine_account_navigation_list_Typography', |
| 82 | 'label' => esc_html__('Typography', 'shopengine'), |
| 83 | 'selector' => '{{WRAPPER}} .shopengine-account-navigation ul li', |
| 84 | 'exclude' => ['letter_spacing', 'font_style', 'text_decoration'], |
| 85 | |
| 86 | 'fields_options' => [ |
| 87 | 'typography' => [ |
| 88 | 'default' => 'custom', |
| 89 | ], |
| 90 | 'font_weight' => [ |
| 91 | 'default' => '600', |
| 92 | ], |
| 93 | 'font_size' => [ |
| 94 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 95 | 'default' => [ |
| 96 | 'size' => '16', |
| 97 | 'unit' => 'px' |
| 98 | ], |
| 99 | 'size_units' => ['px'] |
| 100 | ], |
| 101 | 'line_height' => [ |
| 102 | 'label' => esc_html__('Line-Height (px)', 'shopengine'), |
| 103 | 'default' => [ |
| 104 | 'size' => '55', |
| 105 | 'unit' => 'px' |
| 106 | ], |
| 107 | 'size_units' => ['px'] |
| 108 | ], |
| 109 | ], |
| 110 | ] |
| 111 | ); |
| 112 | |
| 113 | $this->add_group_control( |
| 114 | Group_Control_Box_Shadow::get_type(), |
| 115 | [ |
| 116 | 'name' => 'shopengine_account_navigation_box_shadow', |
| 117 | 'label' => esc_html__('List Box Shadow', 'shopengine'), |
| 118 | 'selector' => '{{WRAPPER}} .shopengine-account-navigation ul li.is-active', |
| 119 | 'exclude' => ['box_shadow_position'], |
| 120 | 'fields_options' => [ |
| 121 | 'box_shadow' => [ |
| 122 | 'default' => [ |
| 123 | 'horizontal' => 0, |
| 124 | 'vertical' => 10, |
| 125 | 'blur' => 20, |
| 126 | 'spread' => 0, |
| 127 | 'color' => 'rgba(0,0,0,0.08)', |
| 128 | ], |
| 129 | ], |
| 130 | |
| 131 | ], |
| 132 | |
| 133 | ] |
| 134 | ); |
| 135 | |
| 136 | |
| 137 | $this->end_controls_section(); // end ./ list style |
| 138 | |
| 139 | /* |
| 140 | ---------------------------- |
| 141 | Container Styles |
| 142 | ---------------------------- |
| 143 | */ |
| 144 | |
| 145 | $this->start_controls_section( |
| 146 | 'shopengine_account_navigation_section', [ |
| 147 | 'label' => esc_html__('Navigation Container', 'shopengine'), |
| 148 | 'tab' => Controls_Manager::TAB_STYLE, |
| 149 | ] |
| 150 | ); |
| 151 | |
| 152 | $this->add_control( |
| 153 | 'shopengine_account_navigation_container_border_color', |
| 154 | [ |
| 155 | 'label' => esc_html__('Border Color', 'shopengine'), |
| 156 | 'type' => Controls_Manager::COLOR, |
| 157 | 'alpha' => false, |
| 158 | 'default' => '#F2F2F2', |
| 159 | 'selectors' => [ |
| 160 | '{{WRAPPER}} .shopengine-account-navigation ul' => 'border-color: {{VALUE}};', |
| 161 | ], |
| 162 | ] |
| 163 | ); |
| 164 | |
| 165 | $this->add_control( |
| 166 | 'shopengine_account_navigation_container_padding', |
| 167 | [ |
| 168 | 'label' => esc_html__('Container Padding', 'shopengine'), |
| 169 | 'type' => Controls_Manager::DIMENSIONS, |
| 170 | 'size_units' => ['px'], |
| 171 | 'default' => [ |
| 172 | 'top' => '0', |
| 173 | 'right' => '40', |
| 174 | 'bottom' => '0', |
| 175 | 'left' => '40', |
| 176 | 'unit' => 'px', |
| 177 | 'isLinked' => false, |
| 178 | ], |
| 179 | 'selectors' => [ |
| 180 | '{{WRAPPER}} .shopengine-account-navigation ul' => 'padding: {{TOP}}{{UNIT}} 0 {{BOTTOM}}{{UNIT}} 0;', |
| 181 | '{{WRAPPER}} .shopengine-account-navigation ul li' => 'padding: 0 {{RIGHT}}{{UNIT}} 0 {{LEFT}}{{UNIT}};', |
| 182 | ], |
| 183 | ] |
| 184 | ); |
| 185 | |
| 186 | $this->end_controls_section(); // end ./ Container Styles |
| 187 | } |
| 188 | |
| 189 | |
| 190 | protected function screen() { |
| 191 | |
| 192 | |
| 193 | if(!is_user_logged_in()) { |
| 194 | ?> |
| 195 | <div class="shopengine shopengine-editor-alert shopengine-editor-alert-warning"> |
| 196 | <?php echo esc_html__('You need first to be logged in', 'shopengine') ?> |
| 197 | </div> |
| 198 | <?php |
| 199 | return; |
| 200 | } |
| 201 | |
| 202 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 203 | include $tpl; |
| 204 | |
| 205 | } |
| 206 | } |
| 207 |