| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Addons; |
| 4 |
|
| 5 |
// Elementor Classes |
| 6 |
use MasterAddons\Inc\Classes\Base\Master_Widget; |
| 7 |
use \Elementor\Utils; |
| 8 |
use \Elementor\Controls_Manager; |
| 9 |
use \Elementor\Repeater; |
| 10 |
use Elementor\Icons_Manager; |
| 11 |
use \Elementor\Group_Control_Border; |
| 12 |
use \Elementor\Group_Control_Typography; |
| 13 |
use \Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 14 |
use \Elementor\Group_Control_Background; |
| 15 |
|
| 16 |
use MasterAddons\Inc\Classes\Helper; |
| 17 |
use MasterAddons\Inc\Admin\Config; |
| 18 |
|
| 19 |
/** |
| 20 |
* Author Name: Liton Arefin |
| 21 |
* Author URL : https: //jeweltheme.com |
| 22 |
* Date : 19/02/2020 |
| 23 |
*/ |
| 24 |
|
| 25 |
// Exit if accessed directly. |
| 26 |
if (!defined('ABSPATH')) { |
| 27 |
exit; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Master Addons Table |
| 32 |
*/ |
| 33 |
|
| 34 |
class Dynamic_Table extends Master_Widget |
| 35 |
{ |
| 36 |
use \MasterAddons\Inc\Traits\Widget_Notice; |
| 37 |
use \MasterAddons\Inc\Traits\Widget_Assets_Trait; |
| 38 |
|
| 39 |
public function get_name() |
| 40 |
{ |
| 41 |
return 'ma-table'; |
| 42 |
} |
| 43 |
|
| 44 |
public function get_title() |
| 45 |
{ |
| 46 |
return __('Dynamic Table', 'master-addons'); |
| 47 |
} |
| 48 |
|
| 49 |
public function get_icon() |
| 50 |
{ |
| 51 |
return 'jltma-icon ' . Config::get_addon_icon($this->get_name()); |
| 52 |
} |
| 53 |
|
| 54 |
public function get_keywords() |
| 55 |
{ |
| 56 |
return ['table', 'tables', 'data tables', 'responsive table', 'pricing table', 'comparison table']; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
protected function register_controls() |
| 61 |
{ |
| 62 |
|
| 63 |
/* |
| 64 |
* MA Table: Header Section |
| 65 |
*/ |
| 66 |
$this->start_controls_section( |
| 67 |
'ma_el_table_section', |
| 68 |
[ |
| 69 |
'label' => __('Table Head', 'master-addons'), |
| 70 |
] |
| 71 |
); |
| 72 |
|
| 73 |
$this->add_control( |
| 74 |
'ma_el_show_table_head', |
| 75 |
[ |
| 76 |
'label' => __('Table Head', 'master-addons'), |
| 77 |
'type' => Controls_Manager::SWITCHER, |
| 78 |
'label_on' => __('Show', 'master-addons'), |
| 79 |
'label_off' => __('Hide', 'master-addons'), |
| 80 |
'default' => 'yes', |
| 81 |
'return_value' => 'yes', |
| 82 |
] |
| 83 |
); |
| 84 |
|
| 85 |
$repeater = new Repeater(); |
| 86 |
$repeater->start_controls_tabs('ma_el_table_head_contents'); |
| 87 |
$repeater->start_controls_tab('head_tab_contents', ['label' => __('Content', 'master-addons')]); |
| 88 |
|
| 89 |
$repeater->add_control( |
| 90 |
'title', |
| 91 |
[ |
| 92 |
'type' => Controls_Manager::TEXT, |
| 93 |
'label_block' => true, |
| 94 |
'label' => __('Column Name', 'master-addons'), |
| 95 |
'default' => __('Table Header', 'master-addons'), |
| 96 |
'dynamic' => [ |
| 97 |
'active' => true, |
| 98 |
] |
| 99 |
] |
| 100 |
); |
| 101 |
|
| 102 |
$repeater->add_control( |
| 103 |
'icon_type', |
| 104 |
[ |
| 105 |
'label' => __('Type', 'master-addons'), |
| 106 |
'type' => Controls_Manager::CHOOSE, |
| 107 |
'default' => 'none', |
| 108 |
'options' => [ |
| 109 |
'none' => [ |
| 110 |
'title' => esc_html__('None', 'master-addons'), |
| 111 |
'icon' => 'fa fa-ban', |
| 112 |
], |
| 113 |
'icon' => [ |
| 114 |
'title' => esc_html__('Icon', 'master-addons'), |
| 115 |
'icon' => 'fa fa-star', |
| 116 |
], |
| 117 |
'image' => [ |
| 118 |
'title' => esc_html__('Image', 'master-addons'), |
| 119 |
'icon' => 'fa fa-picture-o', |
| 120 |
], |
| 121 |
] |
| 122 |
] |
| 123 |
); |
| 124 |
|
| 125 |
$repeater->add_control( |
| 126 |
'header_icon', |
| 127 |
[ |
| 128 |
'label' => esc_html__('Icon', 'master-addons'), |
| 129 |
'description' => esc_html__('Please choose an icon from the list.', 'master-addons'), |
| 130 |
'type' => Controls_Manager::ICONS, |
| 131 |
'fa4compatibility' => 'icon', |
| 132 |
'default' => [ |
| 133 |
'value' => 'fab fa-elementor', |
| 134 |
'library' => 'brand', |
| 135 |
], |
| 136 |
'render_type' => 'template', |
| 137 |
'condition' => [ |
| 138 |
'icon_type' => 'icon' |
| 139 |
], |
| 140 |
] |
| 141 |
); |
| 142 |
|
| 143 |
$repeater->add_control( |
| 144 |
'header_image', |
| 145 |
[ |
| 146 |
'label' => __('Image', 'master-addons'), |
| 147 |
'type' => Controls_Manager::MEDIA, |
| 148 |
'default' => [ |
| 149 |
'url' => Utils::get_placeholder_image_src(), |
| 150 |
], |
| 151 |
'condition' => [ |
| 152 |
'icon_type' => 'image' |
| 153 |
], |
| 154 |
] |
| 155 |
); |
| 156 |
|
| 157 |
$repeater->add_control( |
| 158 |
'header_image_size', |
| 159 |
[ |
| 160 |
'label' => __('Image Size(px)', 'master-addons'), |
| 161 |
'type' => Controls_Manager::NUMBER, |
| 162 |
'label_block' => false, |
| 163 |
'default' => '30', |
| 164 |
'condition' => [ |
| 165 |
'icon_type' => 'image' |
| 166 |
], |
| 167 |
] |
| 168 |
); |
| 169 |
$repeater->end_controls_tab(); |
| 170 |
|
| 171 |
$repeater->start_controls_tab('ma_el_table_head_tab_options', ['label' => __('Options', 'master-addons')]); |
| 172 |
|
| 173 |
$repeater->add_control( |
| 174 |
'colspannumber', |
| 175 |
[ |
| 176 |
'label' => __('Column Span', 'master-addons'), |
| 177 |
'type' => Controls_Manager::TEXT |
| 178 |
] |
| 179 |
); |
| 180 |
|
| 181 |
$repeater->add_control( |
| 182 |
'customwidth', |
| 183 |
[ |
| 184 |
'label' => __('Custom Width', 'master-addons'), |
| 185 |
'type' => Controls_Manager::SWITCHER, |
| 186 |
'label_off' => __('No', 'master-addons'), |
| 187 |
'label_on' => __('Yes', 'master-addons'), |
| 188 |
] |
| 189 |
); |
| 190 |
|
| 191 |
$repeater->add_control( |
| 192 |
'width', |
| 193 |
[ |
| 194 |
'label' => __('Width', 'master-addons'), |
| 195 |
'type' => Controls_Manager::SLIDER, |
| 196 |
'range' => [ |
| 197 |
'%' => [ |
| 198 |
'min' => 0, |
| 199 |
'max' => 100, |
| 200 |
], |
| 201 |
'px' => [ |
| 202 |
'min' => 1, |
| 203 |
'max' => 1000, |
| 204 |
], |
| 205 |
'em' => [ |
| 206 |
'min' => 1, |
| 207 |
'max' => 10, |
| 208 |
], |
| 209 |
], |
| 210 |
'default' => [ |
| 211 |
'size' => 30, |
| 212 |
'unit' => '%', |
| 213 |
], |
| 214 |
'size_units' => ['%', 'px'], |
| 215 |
'condition' => [ |
| 216 |
'customwidth' => 'yes', |
| 217 |
], |
| 218 |
'selectors' => [ |
| 219 |
'{{WRAPPER}} .jltma-table {{CURRENT_ITEM}}' => 'width: {{SIZE}}{{UNIT}};', |
| 220 |
] |
| 221 |
] |
| 222 |
); |
| 223 |
|
| 224 |
$repeater->add_control( |
| 225 |
'align', |
| 226 |
[ |
| 227 |
'label' => __('Alignment', 'master-addons'), |
| 228 |
'type' => Controls_Manager::CHOOSE, |
| 229 |
'default' => '', |
| 230 |
'options' => Helper::jltma_content_alignments(), |
| 231 |
'selectors' => [ |
| 232 |
'{{WRAPPER}} .jltma-table {{CURRENT_ITEM}}' => 'text-align: {{VALUE}};', |
| 233 |
] |
| 234 |
] |
| 235 |
); |
| 236 |
|
| 237 |
$repeater->add_control( |
| 238 |
'decoration', |
| 239 |
[ |
| 240 |
'label' => __('Decoration', 'master-addons'), |
| 241 |
'type' => Controls_Manager::SELECT, |
| 242 |
'options' => [ |
| 243 |
'' => __('Default', 'master-addons'), |
| 244 |
'underline' => __('Underline', 'master-addons'), |
| 245 |
'overline' => __('Overline', 'master-addons'), |
| 246 |
'line-through' => __('Line Through', 'master-addons'), |
| 247 |
'none' => __('None', 'master-addons'), |
| 248 |
], |
| 249 |
'default' => '', |
| 250 |
'selectors' => [ |
| 251 |
'{{WRAPPER}} .jltma-table {{CURRENT_ITEM}}' => 'text-decoration: {{VALUE}};', |
| 252 |
], |
| 253 |
] |
| 254 |
); |
| 255 |
$repeater->end_controls_tab(); |
| 256 |
|
| 257 |
$repeater->end_controls_tabs(); |
| 258 |
|
| 259 |
$this->add_control( |
| 260 |
'ma_el_table_header', |
| 261 |
[ |
| 262 |
'label' => __('Table Header Cell', 'master-addons'), |
| 263 |
'type' => Controls_Manager::REPEATER, |
| 264 |
'seperator' => 'before', |
| 265 |
'default' => [ |
| 266 |
[ |
| 267 |
'title' => __('First Name', 'master-addons'), |
| 268 |
], |
| 269 |
[ |
| 270 |
'title' => __('Last Name', 'master-addons'), |
| 271 |
], |
| 272 |
[ |
| 273 |
'title' => __('Job Title', 'master-addons'), |
| 274 |
], |
| 275 |
[ |
| 276 |
'title' => __('Twitter', 'master-addons'), |
| 277 |
] |
| 278 |
], |
| 279 |
'fields' => $repeater->get_controls(), |
| 280 |
'title_field' => '{{{ title }}}', |
| 281 |
'condition' => [ |
| 282 |
'ma_el_show_table_head' => 'yes', |
| 283 |
], |
| 284 |
] |
| 285 |
); |
| 286 |
$this->end_controls_section(); |
| 287 |
|
| 288 |
/* |
| 289 |
* MA Table Body Section |
| 290 |
*/ |
| 291 |
$this->start_controls_section( |
| 292 |
'ma_el_table_body_section', |
| 293 |
[ |
| 294 |
'label' => __('Table Body', 'master-addons'), |
| 295 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 296 |
] |
| 297 |
); |
| 298 |
|
| 299 |
$repeater = new Repeater(); |
| 300 |
$repeater->add_control( |
| 301 |
'body_row', |
| 302 |
[ |
| 303 |
'label' => __('New Row?', 'master-addons'), |
| 304 |
'type' => Controls_Manager::SWITCHER, |
| 305 |
'label_off' => __('No', 'master-addons'), |
| 306 |
'label_on' => __('Yes', 'master-addons'), |
| 307 |
] |
| 308 |
); |
| 309 |
|
| 310 |
$repeater->start_controls_tabs('ma_el_table_body_contents'); |
| 311 |
|
| 312 |
$repeater->start_controls_tab('body_tab_contents', ['label' => __('Content', 'master-addons')]); |
| 313 |
|
| 314 |
$repeater->add_control( |
| 315 |
'text', |
| 316 |
[ |
| 317 |
'type' => Controls_Manager::TEXTAREA, |
| 318 |
'label_block' => true, |
| 319 |
'label' => __('Body Text', 'master-addons'), |
| 320 |
'default' => __('Table Body', 'master-addons'), |
| 321 |
'dynamic' => [ |
| 322 |
'active' => true, |
| 323 |
] |
| 324 |
] |
| 325 |
); |
| 326 |
|
| 327 |
$repeater->add_control( |
| 328 |
'icon_type', |
| 329 |
[ |
| 330 |
'label' => __('Type', 'master-addons'), |
| 331 |
'type' => Controls_Manager::CHOOSE, |
| 332 |
'default' => 'none', |
| 333 |
'options' => [ |
| 334 |
'none' => [ |
| 335 |
'title' => esc_html__('None', 'master-addons'), |
| 336 |
'icon' => 'fa fa-ban', |
| 337 |
], |
| 338 |
'icon' => [ |
| 339 |
'title' => esc_html__('Icon', 'master-addons'), |
| 340 |
'icon' => 'fa fa-star', |
| 341 |
], |
| 342 |
'image' => [ |
| 343 |
'title' => esc_html__('Image', 'master-addons'), |
| 344 |
'icon' => 'fa fa-picture-o', |
| 345 |
], |
| 346 |
], |
| 347 |
] |
| 348 |
); |
| 349 |
|
| 350 |
$repeater->add_control( |
| 351 |
'body_icon', |
| 352 |
[ |
| 353 |
'label' => esc_html__('Icon', 'master-addons'), |
| 354 |
'description' => esc_html__('Please choose an icon from the list.', 'master-addons'), |
| 355 |
'type' => Controls_Manager::ICONS, |
| 356 |
'fa4compatibility' => 'icon', |
| 357 |
'default' => [ |
| 358 |
'value' => 'fab fa-elementor', |
| 359 |
'library' => 'brand', |
| 360 |
], |
| 361 |
'render_type' => 'template', |
| 362 |
'condition' => [ |
| 363 |
'icon_type' => 'icon' |
| 364 |
], |
| 365 |
] |
| 366 |
); |
| 367 |
|
| 368 |
$repeater->add_control( |
| 369 |
'body_image', |
| 370 |
[ |
| 371 |
'label' => __('Image', 'master-addons'), |
| 372 |
'type' => Controls_Manager::MEDIA, |
| 373 |
'default' => [ |
| 374 |
'url' => Utils::get_placeholder_image_src(), |
| 375 |
], |
| 376 |
'condition' => [ |
| 377 |
'icon_type' => 'image' |
| 378 |
], |
| 379 |
] |
| 380 |
); |
| 381 |
|
| 382 |
$repeater->add_control( |
| 383 |
'body_image_size', |
| 384 |
[ |
| 385 |
'label' => __('Image Size(px)', 'master-addons'), |
| 386 |
'type' => Controls_Manager::NUMBER, |
| 387 |
'label_block' => false, |
| 388 |
'default' => '30', |
| 389 |
'condition' => [ |
| 390 |
'icon_type' => 'image' |
| 391 |
], |
| 392 |
] |
| 393 |
); |
| 394 |
|
| 395 |
$repeater->end_controls_tab(); |
| 396 |
|
| 397 |
$repeater->start_controls_tab('ma_el_table_body_tab_options', ['label' => __('Options', 'master-addons')]); |
| 398 |
$repeater->add_control( |
| 399 |
'colspannumber', |
| 400 |
[ |
| 401 |
'label' => __('Column Span', 'master-addons'), |
| 402 |
'type' => Controls_Manager::TEXT |
| 403 |
] |
| 404 |
); |
| 405 |
$repeater->add_control( |
| 406 |
'rowspannumber', |
| 407 |
[ |
| 408 |
'label' => __('Row Span', 'master-addons'), |
| 409 |
'type' => Controls_Manager::TEXT, |
| 410 |
'placeholder' => __('', 'master-addons'), |
| 411 |
'default' => __('', 'master-addons'), |
| 412 |
] |
| 413 |
); |
| 414 |
|
| 415 |
$repeater->add_control( |
| 416 |
'customwidth', |
| 417 |
[ |
| 418 |
'label' => __('Custom Width', 'master-addons'), |
| 419 |
'type' => Controls_Manager::SWITCHER, |
| 420 |
'label_off' => __('No', 'master-addons'), |
| 421 |
'label_on' => __('Yes', 'master-addons'), |
| 422 |
] |
| 423 |
); |
| 424 |
|
| 425 |
$repeater->add_control( |
| 426 |
'width', |
| 427 |
[ |
| 428 |
'label' => __('Width', 'master-addons'), |
| 429 |
'type' => Controls_Manager::SLIDER, |
| 430 |
'range' => [ |
| 431 |
'%' => [ |
| 432 |
'min' => 0, |
| 433 |
'max' => 100, |
| 434 |
], |
| 435 |
'px' => [ |
| 436 |
'min' => 1, |
| 437 |
'max' => 1000, |
| 438 |
], |
| 439 |
], |
| 440 |
'default' => [ |
| 441 |
'size' => 30, |
| 442 |
'unit' => '%', |
| 443 |
], |
| 444 |
'size_units' => ['%', 'px'], |
| 445 |
'condition' => [ |
| 446 |
'customwidth' => 'yes', |
| 447 |
], |
| 448 |
'selectors' => [ |
| 449 |
'{{WRAPPER}} .jltma-table {{CURRENT_ITEM}}' => 'width: {{SIZE}}{{UNIT}};', |
| 450 |
] |
| 451 |
] |
| 452 |
); |
| 453 |
|
| 454 |
$repeater->add_control( |
| 455 |
'body_align', |
| 456 |
[ |
| 457 |
'label' => __('Alignment', 'master-addons'), |
| 458 |
'type' => Controls_Manager::CHOOSE, |
| 459 |
'default' => '', |
| 460 |
'options' => Helper::jltma_content_alignments(), |
| 461 |
'selectors' => [ |
| 462 |
'{{WRAPPER}} .jltma-table {{CURRENT_ITEM}}' => 'text-align: {{VALUE}};', |
| 463 |
] |
| 464 |
] |
| 465 |
); |
| 466 |
|
| 467 |
$repeater->add_control( |
| 468 |
'decoration', |
| 469 |
[ |
| 470 |
'label' => __('Decoration', 'master-addons'), |
| 471 |
'type' => Controls_Manager::SELECT, |
| 472 |
'options' => [ |
| 473 |
'' => __('Default', 'master-addons'), |
| 474 |
'underline' => __('Underline', 'master-addons'), |
| 475 |
'overline' => __('Overline', 'master-addons'), |
| 476 |
'line-through' => __('Line Through', 'master-addons'), |
| 477 |
'none' => __('None', 'master-addons'), |
| 478 |
], |
| 479 |
'default' => '', |
| 480 |
'selectors' => [ |
| 481 |
'{{WRAPPER}} .jltma-table {{CURRENT_ITEM}}' => 'text-decoration: {{VALUE}};' |
| 482 |
], |
| 483 |
] |
| 484 |
); |
| 485 |
|
| 486 |
$repeater->end_controls_tab(); |
| 487 |
|
| 488 |
$repeater->end_controls_tabs(); |
| 489 |
|
| 490 |
$this->add_control( |
| 491 |
'ma_el_table_body', |
| 492 |
[ |
| 493 |
'label' => __('Table Body Cell', 'master-addons'), |
| 494 |
'type' => Controls_Manager::REPEATER, |
| 495 |
'seperator' => 'before', |
| 496 |
'default' => [ |
| 497 |
[ |
| 498 |
'text' => __('Liton', 'master-addons'), |
| 499 |
], |
| 500 |
[ |
| 501 |
'text' => __('Arefin', 'master-addons'), |
| 502 |
], |
| 503 |
[ |
| 504 |
'text' => __('Developer', 'master-addons'), |
| 505 |
], |
| 506 |
[ |
| 507 |
'text' => __('Litonice11', 'master-addons'), |
| 508 |
], |
| 509 |
[ |
| 510 |
'body_row' => 'yes', |
| 511 |
'text' => __('Roy', 'master-addons'), |
| 512 |
], |
| 513 |
[ |
| 514 |
'text' => __('Jemee', 'master-addons'), |
| 515 |
], |
| 516 |
[ |
| 517 |
'text' => __('Content Writer', 'master-addons'), |
| 518 |
], |
| 519 |
[ |
| 520 |
'text' => __('@Litonice11', 'master-addons'), |
| 521 |
], |
| 522 |
|
| 523 |
[ |
| 524 |
'body_row' => 'yes', |
| 525 |
'text' => __('Akbar', 'master-addons'), |
| 526 |
], |
| 527 |
[ |
| 528 |
'text' => __('Hossain', 'master-addons'), |
| 529 |
], |
| 530 |
[ |
| 531 |
'text' => __('Designer', 'master-addons'), |
| 532 |
], |
| 533 |
[ |
| 534 |
'text' => __('@AkbarHo33850947', 'master-addons'), |
| 535 |
], |
| 536 |
|
| 537 |
[ |
| 538 |
'body_row' => 'yes', |
| 539 |
'text' => __('Jewel', 'master-addons'), |
| 540 |
], |
| 541 |
[ |
| 542 |
'text' => __('Theme', 'master-addons'), |
| 543 |
], |
| 544 |
[ |
| 545 |
'text' => __('Website', 'master-addons'), |
| 546 |
], |
| 547 |
[ |
| 548 |
'text' => __('@jwthemeltd', 'master-addons'), |
| 549 |
] |
| 550 |
], |
| 551 |
'fields' => $repeater->get_controls(), |
| 552 |
'title_field' => '{{{ text }}}' |
| 553 |
] |
| 554 |
); |
| 555 |
|
| 556 |
$this->end_controls_section(); |
| 557 |
|
| 558 |
// Responsive settings section |
| 559 |
$this->start_controls_section( |
| 560 |
'ma_el_table_settings_section', |
| 561 |
[ |
| 562 |
'label' => __('Settings', 'master-addons'), |
| 563 |
] |
| 564 |
); |
| 565 |
$this->add_control( |
| 566 |
'ma_el_table_body_responsiveness', |
| 567 |
[ |
| 568 |
'label' => __('Responsive Table?', 'master-addons'), |
| 569 |
'type' => Controls_Manager::SWITCHER, |
| 570 |
'default' => 'yes', |
| 571 |
'return_value' => 'yes' |
| 572 |
] |
| 573 |
); |
| 574 |
|
| 575 |
$this->end_controls_section(); |
| 576 |
|
| 577 |
// Help Docs section (links from config.php) |
| 578 |
$this->jltma_help_docs(); |
| 579 |
|
| 580 |
$this->upgrade_to_pro_message(); |
| 581 |
|
| 582 |
/* |
| 583 |
* MA Table: Style |
| 584 |
*/ |
| 585 |
|
| 586 |
$this->start_controls_section( |
| 587 |
'ma_el_table_style_section', |
| 588 |
[ |
| 589 |
'label' => __('Global Style', 'master-addons'), |
| 590 |
'tab' => Controls_Manager::TAB_STYLE, |
| 591 |
] |
| 592 |
); |
| 593 |
|
| 594 |
$this->add_control( |
| 595 |
'ma_el_table_body_striped_bg', |
| 596 |
[ |
| 597 |
'label' => __('Striped Table?', 'master-addons'), |
| 598 |
'type' => Controls_Manager::SWITCHER, |
| 599 |
'default' => 'yes', |
| 600 |
'return_value' => 'yes' |
| 601 |
] |
| 602 |
); |
| 603 |
$this->add_control( |
| 604 |
'ma_el_table_body_striped_bg_color', |
| 605 |
[ |
| 606 |
'label' => __('Striped Background Color', 'master-addons'), |
| 607 |
'type' => Controls_Manager::COLOR, |
| 608 |
'condition' => [ |
| 609 |
'ma_el_table_body_striped_bg' => 'yes', |
| 610 |
], |
| 611 |
'default' => '#eee', |
| 612 |
'selectors' => [ |
| 613 |
'{{WRAPPER}} .jltma-table tr:nth-of-type(odd) td' => 'background-color: {{VALUE}};', |
| 614 |
] |
| 615 |
] |
| 616 |
); |
| 617 |
|
| 618 |
$this->add_control( |
| 619 |
'ma_el_table_background', |
| 620 |
[ |
| 621 |
'label' => __('Background Color', 'master-addons'), |
| 622 |
'type' => Controls_Manager::COLOR, |
| 623 |
'selectors' => [ |
| 624 |
'{{WRAPPER}} .jltma-table tr:nth-of-type(even) td' => 'background-color: {{VALUE}};', |
| 625 |
] |
| 626 |
] |
| 627 |
); |
| 628 |
|
| 629 |
$this->add_control( |
| 630 |
'ma_el_table_padding', |
| 631 |
[ |
| 632 |
'label' => __('Inner Cell Padding', 'master-addons'), |
| 633 |
'type' => Controls_Manager::DIMENSIONS, |
| 634 |
'size_units' => ['px', '%', 'em'], |
| 635 |
'selectors' => [ |
| 636 |
'{{WRAPPER}} .jltma-table td,{{WRAPPER}} .jltma-table th' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 637 |
], |
| 638 |
] |
| 639 |
); |
| 640 |
|
| 641 |
$this->add_group_control( |
| 642 |
Group_Control_Border::get_type(), |
| 643 |
[ |
| 644 |
'name' => 'ma_el_table_border', |
| 645 |
'label' => __('Border', 'master-addons'), |
| 646 |
'selector' => '{{WRAPPER}} .jltma-table td,{{WRAPPER}} .jltma-table th', |
| 647 |
] |
| 648 |
); |
| 649 |
|
| 650 |
$this->add_control( |
| 651 |
'ma_el_table_border_radius', |
| 652 |
[ |
| 653 |
'label' => __('Border Radius', 'master-addons'), |
| 654 |
'type' => Controls_Manager::DIMENSIONS, |
| 655 |
'size_units' => ['px', '%'], |
| 656 |
'selectors' => [ |
| 657 |
'{{WRAPPER}} .jltma-table' => 'border-collapse: separate; border-spacing: 0;', |
| 658 |
'{{WRAPPER}} .jltma-table thead tr:first-child th:first-child' => 'border-top-left-radius: {{TOP}}{{UNIT}};', |
| 659 |
'{{WRAPPER}} .jltma-table thead tr:first-child th:last-child' => 'border-top-right-radius: {{RIGHT}}{{UNIT}};', |
| 660 |
'{{WRAPPER}} .jltma-table tbody tr:last-child td:first-child' => 'border-bottom-left-radius: {{BOTTOM}}{{UNIT}};', |
| 661 |
'{{WRAPPER}} .jltma-table tbody tr:last-child td:last-child' => 'border-bottom-right-radius: {{LEFT}}{{UNIT}};', |
| 662 |
], |
| 663 |
] |
| 664 |
); |
| 665 |
|
| 666 |
$this->end_controls_section(); |
| 667 |
|
| 668 |
/* |
| 669 |
* Table Header |
| 670 |
*/ |
| 671 |
|
| 672 |
$this->start_controls_section( |
| 673 |
'ma_el_table_header_style', |
| 674 |
[ |
| 675 |
'label' => __('Table Header Style', 'master-addons'), |
| 676 |
'tab' => Controls_Manager::TAB_STYLE, |
| 677 |
'condition' => [ |
| 678 |
'ma_el_show_table_head' => 'yes', |
| 679 |
], |
| 680 |
] |
| 681 |
|
| 682 |
); |
| 683 |
|
| 684 |
$this->add_control( |
| 685 |
'ma_el_table_header_bg_color', |
| 686 |
[ |
| 687 |
'label' => __('Background Color', 'master-addons'), |
| 688 |
'type' => Controls_Manager::COLOR, |
| 689 |
'default' => '#020817', |
| 690 |
'selectors' => [ |
| 691 |
'{{WRAPPER}} .jltma-table .jltma-table-header th' => 'background-color: {{VALUE}};', |
| 692 |
], |
| 693 |
'condition' => [ |
| 694 |
'ma_el_show_table_head' => 'yes', |
| 695 |
], |
| 696 |
] |
| 697 |
); |
| 698 |
|
| 699 |
$this->add_control( |
| 700 |
'ma_el_table_header_icon_size', |
| 701 |
[ |
| 702 |
'label' => esc_html__('Icon Size (px)', 'master-addons'), |
| 703 |
'type' => Controls_Manager::SLIDER, |
| 704 |
'size_units' => ['px'], |
| 705 |
'range' => [ |
| 706 |
'px' => [ |
| 707 |
'min' => 0, |
| 708 |
'max' => 100, |
| 709 |
], |
| 710 |
], |
| 711 |
'default' => [ |
| 712 |
'unit' => 'px', |
| 713 |
'size' => 18, |
| 714 |
], |
| 715 |
'selectors' => array( |
| 716 |
'{{WRAPPER}} .jltma-table .jltma-table-header span i' => 'font-size:{{SIZE}}{{UNIT}} !important;', |
| 717 |
'{{WRAPPER}} .jltma-table .jltma-table-header span svg' => 'width:{{SIZE}}{{UNIT}} !important;', |
| 718 |
), |
| 719 |
'style_transfer' => true, |
| 720 |
'condition' => [ |
| 721 |
'ma_el_show_table_head' => 'yes', |
| 722 |
], |
| 723 |
] |
| 724 |
); |
| 725 |
|
| 726 |
$this->add_control( |
| 727 |
'ma_el_table_header_icon_color', |
| 728 |
[ |
| 729 |
'label' => __('Icon Color', 'master-addons'), |
| 730 |
'type' => Controls_Manager::COLOR, |
| 731 |
'selectors' => [ |
| 732 |
'{{WRAPPER}} .jltma-table .jltma-table-header span i' => 'color: {{VALUE}};', |
| 733 |
'{{WRAPPER}} .jltma-table .jltma-table-header span svg path' => 'fill: {{VALUE}};', |
| 734 |
], |
| 735 |
'condition' => [ |
| 736 |
'ma_el_show_table_head' => 'yes', |
| 737 |
], |
| 738 |
] |
| 739 |
); |
| 740 |
|
| 741 |
$this->add_control( |
| 742 |
'ma_el_table_header_text_color', |
| 743 |
[ |
| 744 |
'label' => __('Text Color', 'master-addons'), |
| 745 |
'type' => Controls_Manager::COLOR, |
| 746 |
'selectors' => [ |
| 747 |
'{{WRAPPER}} .jltma-table .jltma-table-header th' => 'color: {{VALUE}};', |
| 748 |
], |
| 749 |
'condition' => [ |
| 750 |
'ma_el_show_table_head' => 'yes', |
| 751 |
], |
| 752 |
] |
| 753 |
); |
| 754 |
|
| 755 |
$this->add_responsive_control( |
| 756 |
'ma_el_table_header_align', |
| 757 |
[ |
| 758 |
'label' => __('Alignment', 'master-addons'), |
| 759 |
'type' => Controls_Manager::CHOOSE, |
| 760 |
'options' => Helper::jltma_content_alignments(), |
| 761 |
'default' => 'left', |
| 762 |
'selectors' => [ |
| 763 |
'{{WRAPPER}} .jltma-table .jltma-table-header th' => 'text-align: {{VALUE}} !important;', |
| 764 |
], |
| 765 |
'condition' => [ |
| 766 |
'ma_el_show_table_head' => 'yes', |
| 767 |
], |
| 768 |
] |
| 769 |
); |
| 770 |
|
| 771 |
$this->add_group_control( |
| 772 |
Group_Control_Typography::get_type(), |
| 773 |
[ |
| 774 |
'name' => 'ma_el_table_header_typography', |
| 775 |
'selector' => '{{WRAPPER}} .jltma-table .jltma-table-header th', |
| 776 |
'global' => [ |
| 777 |
'default' => Global_Typography::TYPOGRAPHY_TEXT, |
| 778 |
], |
| 779 |
'condition' => [ |
| 780 |
'ma_el_show_table_head' => 'yes', |
| 781 |
], |
| 782 |
] |
| 783 |
); |
| 784 |
|
| 785 |
$this->add_control( |
| 786 |
'ma_el_table_header_padding', |
| 787 |
[ |
| 788 |
'label' => __('Inner Cell Padding', 'master-addons'), |
| 789 |
'type' => Controls_Manager::DIMENSIONS, |
| 790 |
'size_units' => ['px', '%', 'em'], |
| 791 |
'selectors' => [ |
| 792 |
'{{WRAPPER}} .jltma-table .jltma-table-header td,{{WRAPPER}} .jltma-table .jltma-table-header th' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 793 |
], |
| 794 |
'condition' => [ |
| 795 |
'ma_el_show_table_head' => 'yes', |
| 796 |
], |
| 797 |
] |
| 798 |
); |
| 799 |
$this->end_controls_section(); |
| 800 |
|
| 801 |
$this->start_controls_section( |
| 802 |
'ma_el_table_body_style', |
| 803 |
[ |
| 804 |
'label' => __('Table Body', 'master-addons'), |
| 805 |
'tab' => Controls_Manager::TAB_STYLE, |
| 806 |
] |
| 807 |
); |
| 808 |
|
| 809 |
$this->add_control( |
| 810 |
'ma_el_table_body_bg_color', |
| 811 |
[ |
| 812 |
'label' => __('Background Color', 'master-addons'), |
| 813 |
'type' => Controls_Manager::COLOR, |
| 814 |
'selectors' => [ |
| 815 |
'{{WRAPPER}} .jltma-table .jltma-table-body' => 'background-color: {{VALUE}};', |
| 816 |
] |
| 817 |
] |
| 818 |
); |
| 819 |
|
| 820 |
$this->add_control( |
| 821 |
'ma_el_table_body_text_color', |
| 822 |
[ |
| 823 |
'label' => __('Text Color', 'master-addons'), |
| 824 |
'type' => Controls_Manager::COLOR, |
| 825 |
'selectors' => [ |
| 826 |
'{{WRAPPER}} .jltma-table .jltma-table-body' => 'color: {{VALUE}};', |
| 827 |
] |
| 828 |
] |
| 829 |
); |
| 830 |
|
| 831 |
$this->add_control( |
| 832 |
'ma_el_table_body_icon_size', |
| 833 |
[ |
| 834 |
'label' => esc_html__('Icon Size (px)', 'master-addons'), |
| 835 |
'type' => Controls_Manager::SLIDER, |
| 836 |
'size_units' => ['px'], |
| 837 |
'range' => [ |
| 838 |
'px' => [ |
| 839 |
'min' => 0, |
| 840 |
'max' => 100, |
| 841 |
], |
| 842 |
], |
| 843 |
'default' => [ |
| 844 |
'unit' => 'px', |
| 845 |
'size' => 18, |
| 846 |
], |
| 847 |
'selectors' => array( |
| 848 |
'{{WRAPPER}} .jltma-table .jltma-table-body span i' => 'font-size:{{SIZE}}{{UNIT}} !important;', |
| 849 |
'{{WRAPPER}} .jltma-table .jltma-table-body span svg' => 'width:{{SIZE}}{{UNIT}}; box-sizing: content-box;', |
| 850 |
), |
| 851 |
'style_transfer' => true |
| 852 |
] |
| 853 |
); |
| 854 |
|
| 855 |
$this->add_control( |
| 856 |
'ma_el_table_body_icon_color', |
| 857 |
[ |
| 858 |
'label' => __('Icon Color', 'master-addons'), |
| 859 |
'type' => Controls_Manager::COLOR, |
| 860 |
'selectors' => [ |
| 861 |
'{{WRAPPER}} .jltma-table .jltma-table-body span i' => 'color: {{VALUE}};', |
| 862 |
'{{WRAPPER}} .jltma-table .jltma-table-body span svg path' => 'fill: {{VALUE}};', |
| 863 |
] |
| 864 |
] |
| 865 |
); |
| 866 |
|
| 867 |
$this->add_control( |
| 868 |
'ma_el_table_body_icon_padding', |
| 869 |
[ |
| 870 |
'label' => __('Icon Padding', 'master-addons'), |
| 871 |
'type' => Controls_Manager::DIMENSIONS, |
| 872 |
'size_units' => ['px', '%', 'em'], |
| 873 |
'selectors' => [ |
| 874 |
'{{WRAPPER}} .jltma-table .jltma-table-body span i,svg' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 875 |
], |
| 876 |
] |
| 877 |
); |
| 878 |
|
| 879 |
$this->add_responsive_control( |
| 880 |
'ma_el_table_body_align', |
| 881 |
[ |
| 882 |
'label' => __('Alignment', 'master-addons'), |
| 883 |
'type' => Controls_Manager::CHOOSE, |
| 884 |
'options' => Helper::jltma_content_alignments(), |
| 885 |
'selectors' => [ |
| 886 |
'{{WRAPPER}} .jltma-table .jltma-table-body tr, {{WRAPPER}} .jltma-table .jltma-table-body td' => 'text-align: {{VALUE}};', |
| 887 |
], |
| 888 |
] |
| 889 |
); |
| 890 |
|
| 891 |
$this->add_group_control( |
| 892 |
Group_Control_Typography::get_type(), |
| 893 |
[ |
| 894 |
'name' => 'ma_el_table_body_typography', |
| 895 |
'selector' => '{{WRAPPER}} .jltma-table .jltma-table-body tr, {{WRAPPER}} .jltma-table .jltma-table-body td', |
| 896 |
'global' => [ |
| 897 |
'default' => Global_Typography::TYPOGRAPHY_TEXT, |
| 898 |
], |
| 899 |
] |
| 900 |
); |
| 901 |
|
| 902 |
$this->add_control( |
| 903 |
'ma_el_table_body_padding', |
| 904 |
[ |
| 905 |
'label' => __('Inner Cell Padding', 'master-addons'), |
| 906 |
'type' => Controls_Manager::DIMENSIONS, |
| 907 |
'size_units' => ['px', '%', 'em'], |
| 908 |
'selectors' => [ |
| 909 |
'{{WRAPPER}} .jltma-table .jltma-table-body tr,{{WRAPPER}} .jltma-table .jltma-table-body td' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 910 |
], |
| 911 |
] |
| 912 |
); |
| 913 |
|
| 914 |
$this->end_controls_section(); |
| 915 |
} |
| 916 |
|
| 917 |
protected function render() |
| 918 |
{ |
| 919 |
$settings = $this->get_settings_for_display(); |
| 920 |
|
| 921 |
$this->add_render_attribute( |
| 922 |
'ma_el_table_wrap', |
| 923 |
'class', |
| 924 |
[ |
| 925 |
'jltma-table', |
| 926 |
'table', |
| 927 |
('yes' === $settings['ma_el_table_body_striped_bg']) ? "table-striped" : "", |
| 928 |
('yes' !== $settings['ma_el_table_body_responsiveness']) ? "not-responsive" : "" |
| 929 |
] |
| 930 |
); |
| 931 |
?> |
| 932 |
|
| 933 |
<table <?php echo $this->get_render_attribute_string('ma_el_table_wrap'); ?>> |
| 934 |
<?php if ('yes' === $settings['ma_el_show_table_head']) : ?> |
| 935 |
<thead class="jltma-table-header"> |
| 936 |
<tr> |
| 937 |
<?php foreach ($settings['ma_el_table_header'] as $index => $thead) { |
| 938 |
$repeater_setting_key = $this->get_repeater_setting_key('title', 'ma_el_table_header', $index); |
| 939 |
$icon_key = $this->get_repeater_setting_key('icon', 'ma_el_table_header', $index); |
| 940 |
$this->add_inline_editing_attributes($repeater_setting_key); |
| 941 |
|
| 942 |
$colspan = !empty($thead['colspannumber']) ? ' colspan="' . esc_attr($thead['colspannumber']) . '"' : ''; |
| 943 |
?> |
| 944 |
|
| 945 |
<th scope="jltma-row" |
| 946 |
class="elementor-inline-editing elementor-repeater-item-<?php echo esc_attr($thead['_id']); ?>"<?php echo $colspan; ?> <?php echo $this->get_render_attribute_string($repeater_setting_key); ?>> |
| 947 |
|
| 948 |
<?php if ('icon' === $thead['icon_type'] && (!empty($thead['header_icon']) || !empty($thead['header_icon']['value']))) { ?> |
| 949 |
<span <?php echo $this->get_render_attribute_string($repeater_setting_key); ?>> |
| 950 |
<?php |
| 951 |
$migrated = isset($thead['__fa4_migrated']['header_icon']); |
| 952 |
$is_new = empty($thead['icon']) && Icons_Manager::is_migration_allowed(); |
| 953 |
if ($is_new || $migrated) { |
| 954 |
Icons_Manager::render_icon($thead['header_icon'], ['aria-hidden' => 'true']); |
| 955 |
} else { ?> |
| 956 |
<i class="<?php echo esc_attr($thead['icon']); ?>" aria-hidden="true"></i> |
| 957 |
<?php } ?> |
| 958 |
</span> |
| 959 |
|
| 960 |
<?php } elseif ('image' === $thead['icon_type']) { |
| 961 |
|
| 962 |
$this->add_render_attribute('ma_el_thead_img' . $index, [ |
| 963 |
'src' => esc_url($thead['header_image']['url']), |
| 964 |
'class' => 'jltma-thead-img', |
| 965 |
'style' => "width:{$thead['header_image_size']}px;", |
| 966 |
'alt' => esc_attr(get_post_meta($thead['header_image']['id'], '_wp_attachment_image_alt', true)) |
| 967 |
]); |
| 968 |
?> |
| 969 |
<img <?php echo $this->get_render_attribute_string('ma_el_thead_img' . $index); ?>> |
| 970 |
<?php } ?> |
| 971 |
|
| 972 |
<?php echo $this->parse_text_editor($thead['title']); ?> |
| 973 |
|
| 974 |
</th> |
| 975 |
|
| 976 |
<?php } ?> |
| 977 |
</tr> |
| 978 |
</thead> |
| 979 |
<?php endif; ?> |
| 980 |
|
| 981 |
<tbody class="jltma-table-body"> |
| 982 |
<tr> |
| 983 |
<?php |
| 984 |
$th_values = is_array($settings['ma_el_table_header']) ? $settings['ma_el_table_header'] : []; |
| 985 |
$show_head = ('yes' === $settings['ma_el_show_table_head']); |
| 986 |
$counter = 0; |
| 987 |
foreach ($settings['ma_el_table_body'] as $index => $tbody) { |
| 988 |
$table_body_key = $this->get_repeater_setting_key('text', 'ma_el_table_body', $index); |
| 989 |
$icon_key = $this->get_repeater_setting_key('icon', 'ma_el_table_body', $index); |
| 990 |
|
| 991 |
$this->add_render_attribute($table_body_key, 'class', 'elementor-repeater-item-' . esc_attr($tbody['_id'])); |
| 992 |
$this->add_inline_editing_attributes($table_body_key); |
| 993 |
|
| 994 |
if ($tbody['body_row'] == 'yes') { |
| 995 |
echo '</tr><tr>'; |
| 996 |
$counter = 0; |
| 997 |
} |
| 998 |
|
| 999 |
$colspan = ($tbody['colspannumber']) ? 'colSpan="' . esc_attr($tbody['colspannumber']) . '"' : ''; |
| 1000 |
$rowspan = ($tbody['rowspannumber']) ? 'rowSpan="' . esc_attr($tbody['rowspannumber']) . '"' : ''; |
| 1001 |
$data_column = ($show_head && isset($th_values[$counter]['title'])) ? $th_values[$counter]['title'] : ''; |
| 1002 |
?> |
| 1003 |
|
| 1004 |
<td data-column="<?php echo esc_attr($data_column); ?>" <?php echo esc_attr($colspan); ?> |
| 1005 |
<?php echo esc_attr($rowspan); ?> <?php echo $this->get_render_attribute_string($table_body_key); ?>> |
| 1006 |
|
| 1007 |
<?php echo $this->parse_text_editor($tbody['text']); ?> |
| 1008 |
|
| 1009 |
<?php if ('icon' === $tbody['icon_type'] && (!empty($tbody['body_icon']) || !empty($tbody['body_icon']['value']))) { ?> |
| 1010 |
<span <?php echo $this->get_render_attribute_string($table_body_key); ?>> |
| 1011 |
<?php |
| 1012 |
$migrated = isset($tbody['__fa4_migrated']['body_icon']); |
| 1013 |
$is_new = empty($tbody['icon']) && Icons_Manager::is_migration_allowed(); |
| 1014 |
if ($is_new || $migrated) { |
| 1015 |
Icons_Manager::render_icon($tbody['body_icon'], ['aria-hidden' => 'true']); |
| 1016 |
} else { ?> |
| 1017 |
<i class="<?php echo esc_attr($tbody['icon']); ?>" aria-hidden="true"></i> |
| 1018 |
<?php } ?> |
| 1019 |
</span> |
| 1020 |
<?php } elseif ('image' === $tbody['icon_type']) { |
| 1021 |
|
| 1022 |
$this->add_render_attribute('ma_el_tbody_img' . esc_attr($index), [ |
| 1023 |
'src' => esc_url($tbody['body_image']['url']), |
| 1024 |
'class' => 'jltma-tbody-img', |
| 1025 |
'style' => "width:{$tbody['body_image_size']}px;", |
| 1026 |
'alt' => esc_attr(get_post_meta($tbody['body_image']['id'], '_wp_attachment_image_alt', true)) |
| 1027 |
]); |
| 1028 |
?> |
| 1029 |
<img <?php echo $this->get_render_attribute_string('ma_el_tbody_img' . esc_attr($index)); ?>> |
| 1030 |
<?php } ?> |
| 1031 |
|
| 1032 |
</td> |
| 1033 |
<?php |
| 1034 |
$counter++; |
| 1035 |
} |
| 1036 |
?> |
| 1037 |
|
| 1038 |
</tr> |
| 1039 |
</tbody> |
| 1040 |
</table> |
| 1041 |
|
| 1042 |
<?php |
| 1043 |
} |
| 1044 |
} |
| 1045 |
|