| 1 |
<?php |
| 2 |
namespace Elementor; |
| 3 |
|
| 4 |
abstract class LP_Elementor_Widget_Base extends Widget_Base { |
| 5 |
|
| 6 |
public function get_keywords() { |
| 7 |
return array( 'learnpress' ); |
| 8 |
} |
| 9 |
|
| 10 |
public function get_icon() { |
| 11 |
return 'eicon-site-logo'; |
| 12 |
} |
| 13 |
|
| 14 |
public function get_categories() { |
| 15 |
return array( 'learnpress' ); |
| 16 |
} |
| 17 |
|
| 18 |
public function get_help_url() { |
| 19 |
return ''; |
| 20 |
} |
| 21 |
|
| 22 |
public function register_control_style_form_title( $title_selector = '' ) { |
| 23 |
if ( empty( $title_selector ) ) { |
| 24 |
return; |
| 25 |
} |
| 26 |
$this->start_controls_section( |
| 27 |
'section_style_title', |
| 28 |
array( |
| 29 |
'label' => esc_html__( 'Title', 'learnpress' ), |
| 30 |
'tab' => Controls_Manager::TAB_STYLE, |
| 31 |
) |
| 32 |
); |
| 33 |
|
| 34 |
$this->add_responsive_control( |
| 35 |
'title_align', |
| 36 |
array( |
| 37 |
'label' => esc_html__( 'Alignment', 'thim-elementorkits' ), |
| 38 |
'type' => Controls_Manager::CHOOSE, |
| 39 |
'options' => array( |
| 40 |
'left' => array( |
| 41 |
'title' => esc_html__( 'Left', 'thim-elementorkits' ), |
| 42 |
'icon' => 'eicon-text-align-left', |
| 43 |
), |
| 44 |
'center' => array( |
| 45 |
'title' => esc_html__( 'Center', 'thim-elementorkits' ), |
| 46 |
'icon' => 'eicon-text-align-center', |
| 47 |
), |
| 48 |
'right' => array( |
| 49 |
'title' => esc_html__( 'Right', 'thim-elementorkits' ), |
| 50 |
'icon' => 'eicon-text-align-right', |
| 51 |
), |
| 52 |
), |
| 53 |
'selectors' => array( |
| 54 |
'{{WRAPPER}} ' . $title_selector => 'text-align: {{VALUE}}', |
| 55 |
), |
| 56 |
) |
| 57 |
); |
| 58 |
|
| 59 |
$this->add_control( |
| 60 |
'title_color', |
| 61 |
array( |
| 62 |
'label' => esc_html__( 'Color', 'thim-elementorkits' ), |
| 63 |
'type' => Controls_Manager::COLOR, |
| 64 |
'selectors' => array( |
| 65 |
'{{WRAPPER}} ' . $title_selector => 'color: {{VALUE}}', |
| 66 |
), |
| 67 |
) |
| 68 |
); |
| 69 |
|
| 70 |
$this->add_group_control( |
| 71 |
Group_Control_Typography::get_type(), |
| 72 |
array( |
| 73 |
'name' => 'title_typography', |
| 74 |
'selector' => '{{WRAPPER}} ' . $title_selector, |
| 75 |
) |
| 76 |
); |
| 77 |
|
| 78 |
$this->add_group_control( |
| 79 |
Group_Control_Text_Shadow::get_type(), |
| 80 |
array( |
| 81 |
'name' => 'title_shadow', |
| 82 |
'selector' => '{{WRAPPER}} ' . $title_selector, |
| 83 |
) |
| 84 |
); |
| 85 |
|
| 86 |
$this->add_responsive_control( |
| 87 |
'title_spacing', |
| 88 |
array( |
| 89 |
'label' => esc_html__( 'Spacing', 'thim-elementorkits' ), |
| 90 |
'type' => Controls_Manager::SLIDER, |
| 91 |
'range' => array( |
| 92 |
'px' => array( |
| 93 |
'max' => 100, |
| 94 |
), |
| 95 |
), |
| 96 |
'selectors' => array( |
| 97 |
'{{WRAPPER}} ' . $title_selector => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 98 |
), |
| 99 |
) |
| 100 |
); |
| 101 |
|
| 102 |
$this->end_controls_section(); |
| 103 |
|
| 104 |
} |
| 105 |
|
| 106 |
public function register_control_style_form_button( $button_selector = '' ) { |
| 107 |
if ( empty( $button_selector ) ) { |
| 108 |
return; |
| 109 |
} |
| 110 |
|
| 111 |
$this->start_controls_section( |
| 112 |
'section_button_style', |
| 113 |
array( |
| 114 |
'label' => esc_html__( 'Buttons', 'learnpress' ), |
| 115 |
'tab' => Controls_Manager::TAB_STYLE, |
| 116 |
) |
| 117 |
); |
| 118 |
|
| 119 |
$this->add_control( |
| 120 |
'button_spacing', |
| 121 |
array( |
| 122 |
'label' => esc_html__( 'Spacing', 'learnpress' ), |
| 123 |
'type' => Controls_Manager::SLIDER, |
| 124 |
'range' => array( |
| 125 |
'px' => array( |
| 126 |
'min' => 0, |
| 127 |
'max' => 100, |
| 128 |
), |
| 129 |
), |
| 130 |
'selectors' => array( |
| 131 |
'body {{WRAPPER}} ' . $button_selector => 'margin-top: {{SIZE}}{{UNIT}};', |
| 132 |
), |
| 133 |
) |
| 134 |
); |
| 135 |
|
| 136 |
$this->add_group_control( |
| 137 |
Group_Control_Typography::get_type(), |
| 138 |
array( |
| 139 |
'name' => 'button_typography', |
| 140 |
'selector' => '{{WRAPPER}} ' . $button_selector, |
| 141 |
) |
| 142 |
); |
| 143 |
|
| 144 |
$this->add_group_control( |
| 145 |
Group_Control_Border::get_type(), |
| 146 |
array( |
| 147 |
'name' => 'button_border', |
| 148 |
'selector' => '{{WRAPPER}} ' . $button_selector, |
| 149 |
'exclude' => array( |
| 150 |
'color', |
| 151 |
), |
| 152 |
) |
| 153 |
); |
| 154 |
|
| 155 |
$this->start_controls_tabs( 'tabs_button_style' ); |
| 156 |
|
| 157 |
$this->start_controls_tab( |
| 158 |
'tab_button_normal', |
| 159 |
array( |
| 160 |
'label' => esc_html__( 'Normal', 'learnpress' ), |
| 161 |
) |
| 162 |
); |
| 163 |
|
| 164 |
$this->add_control( |
| 165 |
'button_background_color', |
| 166 |
array( |
| 167 |
'label' => esc_html__( 'Background Color', 'learnpress' ), |
| 168 |
'type' => Controls_Manager::COLOR, |
| 169 |
'selectors' => array( |
| 170 |
'{{WRAPPER}} ' . $button_selector => 'background-color: {{VALUE}};', |
| 171 |
), |
| 172 |
) |
| 173 |
); |
| 174 |
|
| 175 |
$this->add_control( |
| 176 |
'button_text_color', |
| 177 |
array( |
| 178 |
'label' => esc_html__( 'Text Color', 'learnpress' ), |
| 179 |
'type' => Controls_Manager::COLOR, |
| 180 |
'selectors' => array( |
| 181 |
'{{WRAPPER}} ' . $button_selector => 'color: {{VALUE}};', |
| 182 |
), |
| 183 |
) |
| 184 |
); |
| 185 |
|
| 186 |
$this->add_control( |
| 187 |
'button_border_color', |
| 188 |
array( |
| 189 |
'label' => esc_html__( 'Border Color', 'learnpress' ), |
| 190 |
'type' => Controls_Manager::COLOR, |
| 191 |
'default' => '', |
| 192 |
'selectors' => array( |
| 193 |
'{{WRAPPER}} ' . $button_selector => 'border-color: {{VALUE}};', |
| 194 |
), |
| 195 |
'condition' => array( |
| 196 |
'button_border_border!' => '', |
| 197 |
), |
| 198 |
) |
| 199 |
); |
| 200 |
|
| 201 |
$this->end_controls_tab(); |
| 202 |
|
| 203 |
$this->start_controls_tab( |
| 204 |
'tab_button_hover', |
| 205 |
array( |
| 206 |
'label' => __( 'Hover', 'elementor-pro' ), |
| 207 |
) |
| 208 |
); |
| 209 |
|
| 210 |
$this->add_control( |
| 211 |
'button_background_color_hover', |
| 212 |
array( |
| 213 |
'label' => esc_html__( 'Background Color', 'learnpress' ), |
| 214 |
'type' => Controls_Manager::COLOR, |
| 215 |
'selectors' => array( |
| 216 |
'{{WRAPPER}} ' . $button_selector . ':hover' => 'background-color: {{VALUE}};', |
| 217 |
), |
| 218 |
) |
| 219 |
); |
| 220 |
|
| 221 |
$this->add_control( |
| 222 |
'button_text_color_hover', |
| 223 |
array( |
| 224 |
'label' => esc_html__( 'Text Color', 'learnpress' ), |
| 225 |
'type' => Controls_Manager::COLOR, |
| 226 |
'selectors' => array( |
| 227 |
'{{WRAPPER}} ' . $button_selector . ':hover' => 'color: {{VALUE}};', |
| 228 |
), |
| 229 |
) |
| 230 |
); |
| 231 |
|
| 232 |
$this->add_control( |
| 233 |
'button_border_color_hover', |
| 234 |
array( |
| 235 |
'label' => esc_html__( 'Border Color', 'learnpress' ), |
| 236 |
'type' => Controls_Manager::COLOR, |
| 237 |
'default' => '', |
| 238 |
'selectors' => array( |
| 239 |
'{{WRAPPER}} ' . $button_selector . ':hover' => 'border-color: {{VALUE}};', |
| 240 |
), |
| 241 |
'condition' => array( |
| 242 |
'button_border_border!' => '', |
| 243 |
), |
| 244 |
) |
| 245 |
); |
| 246 |
|
| 247 |
$this->end_controls_tab(); |
| 248 |
|
| 249 |
$this->end_controls_tabs(); |
| 250 |
|
| 251 |
$this->add_control( |
| 252 |
'button_border_radius', |
| 253 |
array( |
| 254 |
'label' => esc_html__( 'Border Radius', 'learnpress' ), |
| 255 |
'type' => Controls_Manager::DIMENSIONS, |
| 256 |
'size_units' => array( 'px', '%' ), |
| 257 |
'selectors' => array( |
| 258 |
'{{WRAPPER}} ' . $button_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 259 |
), |
| 260 |
'separator' => 'before', |
| 261 |
) |
| 262 |
); |
| 263 |
|
| 264 |
$this->add_control( |
| 265 |
'button_text_padding', |
| 266 |
array( |
| 267 |
'label' => esc_html__( 'Text Padding', 'learnpress' ), |
| 268 |
'type' => Controls_Manager::DIMENSIONS, |
| 269 |
'size_units' => array( 'px', 'em', '%' ), |
| 270 |
'selectors' => array( |
| 271 |
'{{WRAPPER}} ' . $button_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 272 |
), |
| 273 |
) |
| 274 |
); |
| 275 |
|
| 276 |
$this->end_controls_section(); |
| 277 |
} |
| 278 |
|
| 279 |
public function register_control_style_form_field( $selector = '', $field = '' ) { |
| 280 |
if ( empty( $selector ) || empty( $field ) ) { |
| 281 |
return; |
| 282 |
} |
| 283 |
|
| 284 |
$this->start_controls_section( |
| 285 |
'section_style_form', |
| 286 |
array( |
| 287 |
'label' => esc_html__( 'Form', 'learnpress' ), |
| 288 |
'tab' => Controls_Manager::TAB_STYLE, |
| 289 |
) |
| 290 |
); |
| 291 |
|
| 292 |
$this->add_control( |
| 293 |
'row_gap', |
| 294 |
array( |
| 295 |
'label' => esc_html__( 'Rows Gap', 'learnpress' ), |
| 296 |
'type' => Controls_Manager::SLIDER, |
| 297 |
'default' => array( |
| 298 |
'size' => 10, |
| 299 |
), |
| 300 |
'range' => array( |
| 301 |
'px' => array( |
| 302 |
'min' => 0, |
| 303 |
'max' => 60, |
| 304 |
), |
| 305 |
), |
| 306 |
'selectors' => array( |
| 307 |
'{{WRAPPER}} ' . $selector . ' ' . $field => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 308 |
'{{WRAPPER}} ' . $selector => 'margin-bottom: -{{SIZE}}{{UNIT}};', |
| 309 |
), |
| 310 |
) |
| 311 |
); |
| 312 |
|
| 313 |
$this->add_control( |
| 314 |
'heading_label', |
| 315 |
array( |
| 316 |
'label' => esc_html__( 'Label', 'learnpress' ), |
| 317 |
'type' => Controls_Manager::HEADING, |
| 318 |
'separator' => 'before', |
| 319 |
) |
| 320 |
); |
| 321 |
|
| 322 |
$this->add_control( |
| 323 |
'label_spacing', |
| 324 |
array( |
| 325 |
'label' => esc_html__( 'Spacing', 'learnpress' ), |
| 326 |
'type' => Controls_Manager::SLIDER, |
| 327 |
'range' => array( |
| 328 |
'px' => array( |
| 329 |
'min' => 0, |
| 330 |
'max' => 60, |
| 331 |
), |
| 332 |
), |
| 333 |
'selectors' => array( |
| 334 |
'body {{WRAPPER}} ' . $selector . ' label' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 335 |
), |
| 336 |
) |
| 337 |
); |
| 338 |
|
| 339 |
$this->add_control( |
| 340 |
'label_color', |
| 341 |
array( |
| 342 |
'label' => esc_html__( 'Text Color', 'learnpress' ), |
| 343 |
'type' => Controls_Manager::COLOR, |
| 344 |
'selectors' => array( |
| 345 |
'{{WRAPPER}} ' . $selector . ' label' => 'color: {{VALUE}};', |
| 346 |
), |
| 347 |
) |
| 348 |
); |
| 349 |
|
| 350 |
$this->add_group_control( |
| 351 |
Group_Control_Typography::get_type(), |
| 352 |
array( |
| 353 |
'name' => 'label_typography', |
| 354 |
'selector' => '{{WRAPPER}} ' . $selector . ' label', |
| 355 |
) |
| 356 |
); |
| 357 |
|
| 358 |
$this->add_control( |
| 359 |
'field_label', |
| 360 |
array( |
| 361 |
'label' => esc_html__( 'Field', 'learnpress' ), |
| 362 |
'type' => Controls_Manager::HEADING, |
| 363 |
'separator' => 'before', |
| 364 |
) |
| 365 |
); |
| 366 |
|
| 367 |
$this->add_control( |
| 368 |
'field_text_color', |
| 369 |
array( |
| 370 |
'label' => esc_html__( 'Text Color', 'learnpress' ), |
| 371 |
'type' => Controls_Manager::COLOR, |
| 372 |
'selectors' => array( |
| 373 |
'{{WRAPPER}} ' . $selector . ' ' . $field . ' input, {{WRAPPER}} ' . $selector . ' ' . $field . ' textarea' => 'color: {{VALUE}};', |
| 374 |
), |
| 375 |
) |
| 376 |
); |
| 377 |
|
| 378 |
$this->add_control( |
| 379 |
'field_bg_color', |
| 380 |
array( |
| 381 |
'label' => esc_html__( 'Background Color', 'learnpress' ), |
| 382 |
'type' => Controls_Manager::COLOR, |
| 383 |
'selectors' => array( |
| 384 |
'{{WRAPPER}} ' . $selector . ' ' . $field . ' input, {{WRAPPER}} ' . $selector . ' ' . $field . ' textarea' => 'background-color: {{VALUE}};', |
| 385 |
), |
| 386 |
) |
| 387 |
); |
| 388 |
|
| 389 |
$this->add_group_control( |
| 390 |
Group_Control_Border::get_type(), |
| 391 |
array( |
| 392 |
'name' => 'field_border', |
| 393 |
'label' => esc_html__( 'Border', 'learnpress' ), |
| 394 |
'placeholder' => '1px', |
| 395 |
'default' => '1px', |
| 396 |
'selector' => '{{WRAPPER}} ' . $selector . ' ' . $field . ' input, {{WRAPPER}} ' . $selector . ' ' . $field . ' textarea', |
| 397 |
) |
| 398 |
); |
| 399 |
|
| 400 |
$this->add_control( |
| 401 |
'field_border_radius', |
| 402 |
array( |
| 403 |
'label' => esc_html__( 'Border Radius', 'learnpress' ), |
| 404 |
'type' => Controls_Manager::DIMENSIONS, |
| 405 |
'size_units' => array( 'px', '%' ), |
| 406 |
'selectors' => array( |
| 407 |
'{{WRAPPER}} ' . $selector . ' ' . $field . ' input, {{WRAPPER}} ' . $selector . ' ' . $field . ' textarea' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 408 |
), |
| 409 |
) |
| 410 |
); |
| 411 |
|
| 412 |
$this->end_controls_section(); |
| 413 |
} |
| 414 |
|
| 415 |
public function register_control_style_message() { |
| 416 |
$this->start_controls_section( |
| 417 |
'section_style_message', |
| 418 |
array( |
| 419 |
'label' => esc_html__( 'Message', 'learnpress' ), |
| 420 |
'tab' => Controls_Manager::TAB_STYLE, |
| 421 |
) |
| 422 |
); |
| 423 |
|
| 424 |
$this->add_group_control( |
| 425 |
Group_Control_Border::get_type(), |
| 426 |
array( |
| 427 |
'name' => 'message_border', |
| 428 |
'selector' => '{{WRAPPER}} .learn-press-message', |
| 429 |
'exclude' => array( 'color' ), |
| 430 |
) |
| 431 |
); |
| 432 |
|
| 433 |
$this->add_control( |
| 434 |
'message_border_color', |
| 435 |
array( |
| 436 |
'label' => esc_html__( 'Border Color', 'thim-elementorkits' ), |
| 437 |
'type' => Controls_Manager::COLOR, |
| 438 |
'selectors' => array( |
| 439 |
'{{WRAPPER}} .learn-press-message' => 'border-color: {{VALUE}}', |
| 440 |
'{{WRAPPER}} .learn-press-message::before, {{WRAPPER}} .learn-press-message::after' => 'background: {{VALUE}}', |
| 441 |
), |
| 442 |
) |
| 443 |
); |
| 444 |
|
| 445 |
$this->add_control( |
| 446 |
'message_bg_color', |
| 447 |
array( |
| 448 |
'label' => esc_html__( 'Background Color', 'thim-elementorkits' ), |
| 449 |
'type' => Controls_Manager::COLOR, |
| 450 |
'selectors' => array( |
| 451 |
'{{WRAPPER}} .learn-press-message' => 'background-color: {{VALUE}}', |
| 452 |
), |
| 453 |
) |
| 454 |
); |
| 455 |
|
| 456 |
$this->add_control( |
| 457 |
'message_color', |
| 458 |
array( |
| 459 |
'label' => esc_html__( 'Color', 'thim-elementorkits' ), |
| 460 |
'type' => Controls_Manager::COLOR, |
| 461 |
'selectors' => array( |
| 462 |
'{{WRAPPER}} .learn-press-message' => 'color: {{VALUE}}', |
| 463 |
), |
| 464 |
) |
| 465 |
); |
| 466 |
|
| 467 |
$this->end_controls_section(); |
| 468 |
} |
| 469 |
|
| 470 |
protected function register_controls() { |
| 471 |
|
| 472 |
} |
| 473 |
} |
| 474 |
|