| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget; |
| 3 | 3 | |
| 4 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | - exit; // Exit if accessed directly | |
| 5 | + exit; // Exit if accessed directly | |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | use Elementor\Controls_Manager; |
| 9 | 9 | use Elementor\Group_Control_Typography; |
| @@ -10,109 +10,251 @@ | ||
| 10 | 10 | use WPDeveloper\BetterDocs\Editors\Elementor\BaseWidget; |
| 11 | 11 | |
| 12 | 12 | class Navigation extends BaseWidget { |
| 13 | 13 | |
| 14 | - public function get_name() { | |
| 15 | - return 'betterdocs-navigation'; | |
| 16 | - } | |
| 14 | + public function get_name() { | |
| 15 | + return 'betterdocs-navigation'; | |
| 16 | + } | |
| 17 | 17 | |
| 18 | - public function get_title() { | |
| 19 | - return __( 'Doc Navigation', 'betterdocs' ); | |
| 20 | - } | |
| 18 | + public function get_title() { | |
| 19 | + return __( 'Doc Navigation', 'betterdocs' ); | |
| 20 | + } | |
| 21 | 21 | |
| 22 | - public function get_icon() { | |
| 23 | - return 'betterdocs-icon-Navigation'; | |
| 24 | - } | |
| 22 | + public function get_icon() { | |
| 23 | + return 'betterdocs-icon-Navigation'; | |
| 24 | + } | |
| 25 | 25 | |
| 26 | - public function get_categories() { | |
| 27 | - return ['betterdocs-elements-single']; | |
| 28 | - } | |
| 26 | + public function get_categories() { | |
| 27 | + return [ 'betterdocs-elements-single' ]; | |
| 28 | + } | |
| 29 | 29 | |
| 30 | - public function get_keywords() { | |
| 31 | - return ['betterdocs-elements', 'navigation', 'betterdocs', 'docs']; | |
| 32 | - } | |
| 30 | + public function get_keywords() { | |
| 31 | + return [ 'betterdocs-elements', 'navigation', 'betterdocs', 'docs' ]; | |
| 32 | + } | |
| 33 | 33 | |
| 34 | - public function get_style_depends() { | |
| 35 | - return ['betterdocs-el-navigation']; | |
| 36 | - } | |
| 34 | + public function get_style_depends() { | |
| 35 | + return [ 'betterdocs-el-navigation' ]; | |
| 36 | + } | |
| 37 | 37 | |
| 38 | - public function get_custom_help_url() { | |
| 39 | - return 'https://betterdocs.co/docs/single-doc-in-elementor'; | |
| 40 | - } | |
| 38 | + public function get_custom_help_url() { | |
| 39 | + return 'https://betterdocs.co/docs/single-doc-in-elementor'; | |
| 40 | + } | |
| 41 | 41 | |
| 42 | - protected function register_controls() { | |
| 42 | + protected function register_controls() { | |
| 43 | + $this->layout_select(); | |
| 44 | + $this->style_controls(); | |
| 45 | + $this->style_controls_layout_2(); | |
| 46 | + } | |
| 43 | 47 | |
| 44 | - $this->start_controls_section( | |
| 45 | - 'section_column_settings', | |
| 46 | - [ | |
| 47 | - 'label' => __( 'Style', 'betterdocs' ), | |
| 48 | - 'tab' => Controls_Manager::TAB_STYLE | |
| 49 | - ] | |
| 50 | - ); | |
| 48 | + public function layout_select() { | |
| 49 | + $this->start_controls_section( | |
| 50 | + 'navigation_section_title', | |
| 51 | + [ | |
| 52 | + 'label' => __( 'Controls', 'betterdocs' ) | |
| 53 | + ] | |
| 54 | + ); | |
| 51 | 55 | |
| 52 | - $this->add_control( | |
| 53 | - 'navigation_text_color', | |
| 54 | - [ | |
| 55 | - 'label' => esc_html__( 'Color', 'betterdocs' ), | |
| 56 | - 'type' => Controls_Manager::COLOR, | |
| 57 | - 'selectors' => [ | |
| 58 | - '{{WRAPPER}} .docs-navigation a' => 'color: {{VALUE}};' | |
| 59 | - ] | |
| 60 | - ] | |
| 61 | - ); | |
| 56 | + $this->add_control( | |
| 57 | + 'navigation_layout_select', | |
| 58 | + [ | |
| 59 | + 'label' => esc_html__( 'Select layout', 'betterdocs' ), | |
| 60 | + 'type' => Controls_Manager::SELECT, | |
| 61 | + 'default' => 'layout-1', | |
| 62 | + 'label_block' => false, | |
| 63 | + 'options' => [ | |
| 64 | + 'layout-1' => esc_html__( 'Layout 1', 'betterdocs' ), | |
| 65 | + 'layout-2' => esc_html__( 'Layout 2', 'betterdocs' ) | |
| 66 | + ] | |
| 67 | + ] | |
| 68 | + ); | |
| 62 | 69 | |
| 63 | - $this->add_group_control( | |
| 64 | - Group_Control_Typography::get_type(), | |
| 65 | - [ | |
| 66 | - 'name' => 'navigation_text_typography', | |
| 67 | - 'selector' => '{{WRAPPER}} .docs-navigation a' | |
| 68 | - ] | |
| 69 | - ); | |
| 70 | + $this->end_controls_section(); | |
| 71 | + } | |
| 70 | 72 | |
| 71 | - $this->add_control( | |
| 72 | - 'navigation_arrow_size', | |
| 73 | - [ | |
| 74 | - 'label' => __( 'Size', 'betterdocs' ), | |
| 75 | - 'type' => Controls_Manager::SLIDER, | |
| 76 | - 'default' => [ | |
| 77 | - 'unit' => 'px', | |
| 78 | - 'size' => 35 | |
| 79 | - ], | |
| 80 | - 'size_units' => ['px'], | |
| 81 | - 'range' => [ | |
| 82 | - 'px' => [ | |
| 83 | - 'max' => 500, | |
| 84 | - 'step' => 1 | |
| 85 | - ] | |
| 86 | - ], | |
| 87 | - 'selectors' => [ | |
| 88 | - '{{WRAPPER}} .docs-navigation svg' => 'width: {{SIZE}}px;height: {{SIZE}}px;' | |
| 89 | - ] | |
| 90 | - ] | |
| 91 | - ); | |
| 73 | + public function style_controls() { | |
| 74 | + $this->start_controls_section( | |
| 75 | + 'section_column_settings', | |
| 76 | + [ | |
| 77 | + 'label' => __( 'Style', 'betterdocs' ), | |
| 78 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 79 | + 'condition' => [ | |
| 80 | + 'navigation_layout_select' => [ 'layout-1' ] | |
| 81 | + ] | |
| 82 | + ] | |
| 83 | + ); | |
| 92 | 84 | |
| 93 | - $this->add_control( | |
| 94 | - 'navigation_arrow_color', | |
| 95 | - [ | |
| 96 | - 'label' => esc_html__( 'Arrow Color', 'betterdocs' ), | |
| 97 | - 'type' => Controls_Manager::COLOR, | |
| 98 | - 'selectors' => [ | |
| 99 | - '{{WRAPPER}} .docs-navigation svg' => 'fill: {{VALUE}};' | |
| 100 | - ] | |
| 101 | - ] | |
| 102 | - ); | |
| 85 | + $this->add_control( | |
| 86 | + 'navigation_text_color', | |
| 87 | + [ | |
| 88 | + 'label' => esc_html__( 'Color', 'betterdocs' ), | |
| 89 | + 'type' => Controls_Manager::COLOR, | |
| 90 | + 'selectors' => [ | |
| 91 | + '{{WRAPPER}} .docs-navigation a' => 'color: {{VALUE}};' | |
| 92 | + ] | |
| 93 | + ] | |
| 94 | + ); | |
| 103 | 95 | |
| 104 | - $this->end_controls_section(); | |
| 105 | - } | |
| 96 | + $this->add_group_control( | |
| 97 | + Group_Control_Typography::get_type(), | |
| 98 | + [ | |
| 99 | + 'name' => 'navigation_text_typography', | |
| 100 | + 'selector' => '{{WRAPPER}} .docs-navigation a' | |
| 101 | + ] | |
| 102 | + ); | |
| 106 | 103 | |
| 107 | - protected function render_callback() { | |
| 108 | - $this->views( 'templates/parts/navigation' ); | |
| 109 | - } | |
| 104 | + $this->add_control( | |
| 105 | + 'navigation_arrow_size', | |
| 106 | + [ | |
| 107 | + 'label' => __( 'Size', 'betterdocs' ), | |
| 108 | + 'type' => Controls_Manager::SLIDER, | |
| 109 | + 'default' => [ | |
| 110 | + 'unit' => 'px', | |
| 111 | + 'size' => 35 | |
| 112 | + ], | |
| 113 | + 'size_units' => [ 'px' ], | |
| 114 | + 'range' => [ | |
| 115 | + 'px' => [ | |
| 116 | + 'max' => 500, | |
| 117 | + 'step' => 1 | |
| 118 | + ] | |
| 119 | + ], | |
| 120 | + 'selectors' => [ | |
| 121 | + '{{WRAPPER}} .docs-navigation svg' => 'width: {{SIZE}}px;height: {{SIZE}}px;' | |
| 122 | + ] | |
| 123 | + ] | |
| 124 | + ); | |
| 110 | 125 | |
| 111 | - public function view_params() { | |
| 112 | - return [ | |
| 113 | - 'wrapper_attr' => [ | |
| 114 | - 'class' => ['betterdocs-elementor-navigation'] | |
| 115 | - ] | |
| 116 | - ]; | |
| 117 | - } | |
| 126 | + $this->add_control( | |
| 127 | + 'navigation_arrow_color', | |
| 128 | + [ | |
| 129 | + 'label' => esc_html__( 'Arrow Color', 'betterdocs' ), | |
| 130 | + 'type' => Controls_Manager::COLOR, | |
| 131 | + 'selectors' => [ | |
| 132 | + '{{WRAPPER}} .docs-navigation svg' => 'fill: {{VALUE}};' | |
| 133 | + ] | |
| 134 | + ] | |
| 135 | + ); | |
| 136 | + | |
| 137 | + $this->end_controls_section(); | |
| 138 | + } | |
| 139 | + | |
| 140 | + public function style_controls_layout_2() { | |
| 141 | + $this->start_controls_section( | |
| 142 | + 'section_column_settings_layout_2', | |
| 143 | + [ | |
| 144 | + 'label' => __( 'Style', 'betterdocs' ), | |
| 145 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 146 | + 'condition' => [ | |
| 147 | + 'navigation_layout_select' => [ 'layout-2' ] | |
| 148 | + ] | |
| 149 | + ] | |
| 150 | + ); | |
| 151 | + | |
| 152 | + $this->add_control( | |
| 153 | + 'navigation_text_background_color_layout_2', | |
| 154 | + [ | |
| 155 | + 'label' => esc_html__( 'Background Color', 'betterdocs' ), | |
| 156 | + 'type' => Controls_Manager::COLOR, | |
| 157 | + 'selectors' => [ | |
| 158 | + '{{WRAPPER}} .docs-navigation.layout-2' => 'background-color: {{VALUE}};' | |
| 159 | + ] | |
| 160 | + ] | |
| 161 | + ); | |
| 162 | + | |
| 163 | + $this->add_control( | |
| 164 | + 'navigation_text_color_layout_2', | |
| 165 | + [ | |
| 166 | + 'label' => esc_html__( 'Color', 'betterdocs' ), | |
| 167 | + 'type' => Controls_Manager::COLOR, | |
| 168 | + 'selectors' => [ | |
| 169 | + '{{WRAPPER}} .docs-navigation.layout-2 a' => 'color: {{VALUE}};' | |
| 170 | + ] | |
| 171 | + ] | |
| 172 | + ); | |
| 173 | + | |
| 174 | + $this->add_group_control( | |
| 175 | + Group_Control_Typography::get_type(), | |
| 176 | + [ | |
| 177 | + 'name' => 'navigation_text_typography_layout_2', | |
| 178 | + 'selector' => '{{WRAPPER}} .docs-navigation.layout-2 a' | |
| 179 | + ] | |
| 180 | + ); | |
| 181 | + | |
| 182 | + $this->add_control( | |
| 183 | + 'navigation_arrow_size_layout_2', | |
| 184 | + [ | |
| 185 | + 'label' => __( 'Size', 'betterdocs' ), | |
| 186 | + 'type' => Controls_Manager::SLIDER, | |
| 187 | + 'default' => [ | |
| 188 | + 'unit' => 'px', | |
| 189 | + 'size' => 35 | |
| 190 | + ], | |
| 191 | + 'size_units' => [ 'px' ], | |
| 192 | + 'range' => [ | |
| 193 | + 'px' => [ | |
| 194 | + 'max' => 500, | |
| 195 | + 'step' => 1 | |
| 196 | + ] | |
| 197 | + ], | |
| 198 | + 'selectors' => [ | |
| 199 | + '{{WRAPPER}} .docs-navigation.layout-2 a svg' => 'width: {{SIZE}}px;height: {{SIZE}}px;' | |
| 200 | + ] | |
| 201 | + ] | |
| 202 | + ); | |
| 203 | + | |
| 204 | + $this->add_control( | |
| 205 | + 'navigation_arrow_color_layout_2', | |
| 206 | + [ | |
| 207 | + 'label' => esc_html__( 'Arrow Color', 'betterdocs' ), | |
| 208 | + 'type' => Controls_Manager::COLOR, | |
| 209 | + 'selectors' => [ | |
| 210 | + '{{WRAPPER}} .docs-navigation.layout-2 a svg' => 'fill: {{VALUE}};' | |
| 211 | + ] | |
| 212 | + ] | |
| 213 | + ); | |
| 214 | + | |
| 215 | + $this->add_responsive_control( | |
| 216 | + 'navigation_margin_layout_2', | |
| 217 | + [ | |
| 218 | + 'label' => __( 'Margin', 'betterdocs' ), | |
| 219 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 220 | + 'size_units' => [ 'px', 'em', '%' ], | |
| 221 | + 'selectors' => [ | |
| 222 | + '{{WRAPPER}} .docs-navigation.layout-2' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' | |
| 223 | + ] | |
| 224 | + ] | |
| 225 | + ); | |
| 226 | + | |
| 227 | + $this->add_responsive_control( | |
| 228 | + 'navigation_padding_layout_2', | |
| 229 | + [ | |
| 230 | + 'label' => __( 'Padding', 'betterdocs' ), | |
| 231 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 232 | + 'size_units' => [ 'px', 'em', '%' ], | |
| 233 | + 'selectors' => [ | |
| 234 | + '{{WRAPPER}} .docs-navigation.layout-2' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' | |
| 235 | + ] | |
| 236 | + ] | |
| 237 | + ); | |
| 238 | + | |
| 239 | + $this->end_controls_section(); | |
| 240 | + } | |
| 241 | + | |
| 242 | + protected function render_callback() { | |
| 243 | + $this->views( 'templates/parts/navigation' ); | |
| 244 | + } | |
| 245 | + | |
| 246 | + public function view_params() { | |
| 247 | + $layout = $this->attributes['navigation_layout_select']; | |
| 248 | + $default_params = [ | |
| 249 | + 'wrapper_attr' => [ | |
| 250 | + 'class' => [ 'betterdocs-elementor-navigation' ] | |
| 251 | + ] | |
| 252 | + ]; | |
| 253 | + | |
| 254 | + if ( $layout == 'layout-2' ) { | |
| 255 | + $default_params['wraper_class'] = 'layout-2'; | |
| 256 | + } | |
| 257 | + | |
| 258 | + return $default_params; | |
| 259 | + } | |
| 118 | 260 | } |