| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; // Exit if accessed directly. |
| 5 |
} |
| 6 |
|
| 7 |
class Bricksable_IconList extends \Bricks\Element { |
| 8 |
|
| 9 |
public $category = 'bricksable'; |
| 10 |
public $name = 'ba-icon-list'; |
| 11 |
public $icon = 'ti-list'; |
| 12 |
|
| 13 |
public function get_label() { |
| 14 |
return esc_html__( 'Icon List', 'bricksable' ); |
| 15 |
} |
| 16 |
|
| 17 |
public function set_control_groups() { |
| 18 |
|
| 19 |
$this->control_groups['items'] = array( |
| 20 |
'title' => esc_html__( 'Items', 'bricksable' ), |
| 21 |
'tab' => 'content', |
| 22 |
); |
| 23 |
|
| 24 |
$this->control_groups['item'] = array( |
| 25 |
'title' => esc_html__( 'List item', 'bricksable' ), |
| 26 |
'tab' => 'content', |
| 27 |
); |
| 28 |
|
| 29 |
$this->control_groups['highlight'] = array( |
| 30 |
'title' => esc_html__( 'Highlight', 'bricksable' ), |
| 31 |
'tab' => 'content', |
| 32 |
); |
| 33 |
|
| 34 |
$this->control_groups['title'] = array( |
| 35 |
'title' => esc_html__( 'Title', 'bricksable' ), |
| 36 |
'tab' => 'content', |
| 37 |
); |
| 38 |
|
| 39 |
$this->control_groups['icon'] = array( |
| 40 |
'title' => esc_html__( 'Icon', 'bricksable' ), |
| 41 |
'tab' => 'content', |
| 42 |
); |
| 43 |
|
| 44 |
$this->control_groups['meta'] = array( |
| 45 |
'title' => esc_html__( 'Meta', 'bricksable' ), |
| 46 |
'tab' => 'content', |
| 47 |
); |
| 48 |
|
| 49 |
$this->control_groups['description'] = array( |
| 50 |
'title' => esc_html__( 'Description', 'bricksable' ), |
| 51 |
'tab' => 'content', |
| 52 |
); |
| 53 |
|
| 54 |
$this->control_groups['separator'] = array( |
| 55 |
'title' => esc_html__( 'Separator', 'bricksable' ), |
| 56 |
'tab' => 'content', |
| 57 |
); |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
public function set_controls() { |
| 62 |
|
| 63 |
/** |
| 64 |
* Items |
| 65 |
*/ |
| 66 |
|
| 67 |
$this->controls['items'] = array( |
| 68 |
'tab' => 'content', |
| 69 |
'group' => 'items', |
| 70 |
'placeholder' => esc_html__( 'List items', 'bricksable' ), |
| 71 |
'type' => 'repeater', |
| 72 |
'titleProperty' => 'title', |
| 73 |
'fields' => array( |
| 74 |
'title' => array( |
| 75 |
'label' => esc_html__( 'Title', 'bricksable' ), |
| 76 |
'type' => 'text', |
| 77 |
'hasDynamicData' => 'text', |
| 78 |
'inlineEditing' => array( |
| 79 |
'selector' => '.title', |
| 80 |
), |
| 81 |
), |
| 82 |
|
| 83 |
'icon' => array( |
| 84 |
'label' => esc_html__( 'Icon', 'bricksable' ), |
| 85 |
'type' => 'icon', |
| 86 |
'required' => array( 'use_icon_text', '!=', true ), |
| 87 |
), |
| 88 |
|
| 89 |
'use_icon_text' => array( |
| 90 |
'label' => esc_html__( 'Use Icon Text', 'bricksable' ), |
| 91 |
'type' => 'checkbox', |
| 92 |
'inline' => true, |
| 93 |
), |
| 94 |
|
| 95 |
'icon_text' => array( |
| 96 |
'label' => esc_html__( 'Icon Text', 'bricksable' ), |
| 97 |
'type' => 'text', |
| 98 |
'hasDynamicData' => 'text', |
| 99 |
'required' => array( 'use_icon_text', '=', true ), |
| 100 |
), |
| 101 |
|
| 102 |
'use_icon_image' => array( |
| 103 |
'label' => esc_html__( 'Use Icon Image', 'bricksable' ), |
| 104 |
'type' => 'checkbox', |
| 105 |
'inline' => true, |
| 106 |
), |
| 107 |
|
| 108 |
'icon_image' => array( |
| 109 |
'label' => esc_html__( 'Icon Image', 'bricksable' ), |
| 110 |
'type' => 'image', |
| 111 |
'hasDynamicData' => 'image', |
| 112 |
'required' => array( 'use_icon_image', '=', true ), |
| 113 |
), |
| 114 |
|
| 115 |
'link' => array( |
| 116 |
'label' => esc_html__( 'Link title', 'bricksable' ), |
| 117 |
'type' => 'link', |
| 118 |
), |
| 119 |
|
| 120 |
'meta' => array( |
| 121 |
'label' => esc_html__( 'Meta', 'bricksable' ), |
| 122 |
'type' => 'text', |
| 123 |
'hasDynamicData' => 'text', |
| 124 |
), |
| 125 |
|
| 126 |
'description' => array( |
| 127 |
'label' => esc_html__( 'Description', 'bricksable' ), |
| 128 |
'type' => 'textarea', |
| 129 |
'hasDynamicData' => 'text', |
| 130 |
), |
| 131 |
|
| 132 |
'highlight' => array( |
| 133 |
'label' => esc_html__( 'Highlight', 'bricksable' ), |
| 134 |
'type' => 'checkbox', |
| 135 |
), |
| 136 |
|
| 137 |
'highlightLabel' => array( |
| 138 |
'label' => esc_html__( 'Highlight label', 'bricksable' ), |
| 139 |
'type' => 'text', |
| 140 |
'inline' => true, |
| 141 |
'required' => array( 'highlight', '!=', '' ), |
| 142 |
), |
| 143 |
), |
| 144 |
'default' => array( |
| 145 |
array( |
| 146 |
'title' => esc_html__( 'Icon List item #1', 'bricksable' ), |
| 147 |
'icon' => array( |
| 148 |
'library' => 'themify', |
| 149 |
'icon' => 'ti-check-box', |
| 150 |
), |
| 151 |
), |
| 152 |
array( |
| 153 |
'title' => esc_html__( 'Icon List item #2', 'bricksable' ), |
| 154 |
'icon' => array( |
| 155 |
'library' => 'themify', |
| 156 |
'icon' => 'ti-check-box', |
| 157 |
), |
| 158 |
), |
| 159 |
), |
| 160 |
); |
| 161 |
|
| 162 |
/** |
| 163 |
* List item |
| 164 |
*/ |
| 165 |
|
| 166 |
$this->controls['itemMargin'] = array( |
| 167 |
'tab' => 'content', |
| 168 |
'group' => 'item', |
| 169 |
'label' => esc_html__( 'Margin', 'bricksable' ), |
| 170 |
'type' => 'dimensions', |
| 171 |
'css' => array( |
| 172 |
array( |
| 173 |
'property' => 'margin', |
| 174 |
'selector' => 'li.list-item:not(:last-child)', |
| 175 |
), |
| 176 |
), |
| 177 |
); |
| 178 |
|
| 179 |
$this->controls['itemPadding'] = array( |
| 180 |
'tab' => 'content', |
| 181 |
'group' => 'item', |
| 182 |
'label' => esc_html__( 'Padding', 'bricksable' ), |
| 183 |
'type' => 'dimensions', |
| 184 |
'css' => array( |
| 185 |
array( |
| 186 |
'property' => 'padding', |
| 187 |
'selector' => '.content-wrapper', |
| 188 |
), |
| 189 |
), |
| 190 |
); |
| 191 |
|
| 192 |
$this->controls['item_verticalAlign'] = array( |
| 193 |
'tab' => 'content', |
| 194 |
'group' => 'item', |
| 195 |
'label' => esc_html__( 'Vertical align', 'bricksable' ), |
| 196 |
'type' => 'select', |
| 197 |
'options' => $this->control_options['alignItems'], |
| 198 |
'css' => array( |
| 199 |
array( |
| 200 |
'property' => 'align-items', |
| 201 |
'selector' => '.title-wrapper', |
| 202 |
), |
| 203 |
), |
| 204 |
'inline' => true, |
| 205 |
'default' => 'center', |
| 206 |
'placeholder' => esc_html__( 'Center', 'bricksable' ), |
| 207 |
); |
| 208 |
|
| 209 |
$this->controls['itemJustifyContent'] = array( |
| 210 |
'tab' => 'content', |
| 211 |
'group' => 'item', |
| 212 |
'label' => esc_html__( 'Align', 'bricksable' ), |
| 213 |
'type' => 'select', |
| 214 |
'options' => $this->control_options['justifyContent'], |
| 215 |
'css' => array( |
| 216 |
array( |
| 217 |
'property' => 'justify-content', |
| 218 |
'selector' => '.title-wrapper', |
| 219 |
), |
| 220 |
), |
| 221 |
'inline' => true, |
| 222 |
); |
| 223 |
|
| 224 |
$this->controls['itemDirection'] = array( |
| 225 |
'tab' => 'content', |
| 226 |
'group' => 'item', |
| 227 |
'label' => esc_html__( 'Direction', 'bricksable' ), |
| 228 |
'title' => 'flex-direction', |
| 229 |
'type' => 'select', |
| 230 |
'options' => array( |
| 231 |
'row' => esc_html__( 'Horizontal', 'bricksable' ), |
| 232 |
'row-reverse' => esc_html__( 'Horizontal reversed', 'bricksable' ), |
| 233 |
), |
| 234 |
'css' => array( |
| 235 |
array( |
| 236 |
'property' => 'flex-direction', |
| 237 |
'selector' => '.title-wrapper', |
| 238 |
), |
| 239 |
), |
| 240 |
'default' => 'row', |
| 241 |
'inline' => true, |
| 242 |
); |
| 243 |
|
| 244 |
$this->controls['item_indent'] = array( |
| 245 |
'tab' => 'content', |
| 246 |
'group' => 'item', |
| 247 |
'label' => esc_html__( 'Indent Gap', 'bricksable' ), |
| 248 |
'type' => 'slider', |
| 249 |
'css' => array( |
| 250 |
array( |
| 251 |
'property' => 'gap', |
| 252 |
'selector' => '.title-wrapper', |
| 253 |
), |
| 254 |
), |
| 255 |
'units' => array( |
| 256 |
'px' => array( |
| 257 |
'min' => 1, |
| 258 |
'max' => 40, |
| 259 |
'step' => 1, |
| 260 |
), |
| 261 |
'em' => array( |
| 262 |
'min' => 1, |
| 263 |
'max' => 20, |
| 264 |
'step' => 0.1, |
| 265 |
), |
| 266 |
), |
| 267 |
'default' => '7px', |
| 268 |
'description' => esc_html__( 'Set the gap distance element within container.', 'bricksable' ), |
| 269 |
); |
| 270 |
|
| 271 |
$this->controls['itemOddBackground'] = array( |
| 272 |
'tab' => 'content', |
| 273 |
'group' => 'item', |
| 274 |
'label' => esc_html__( 'Odd background', 'bricksable' ), |
| 275 |
'type' => 'color', |
| 276 |
'css' => array( |
| 277 |
array( |
| 278 |
'property' => 'background-color', |
| 279 |
'selector' => 'li:nth-child(odd)', |
| 280 |
), |
| 281 |
), |
| 282 |
'inline' => true, |
| 283 |
'small' => true, |
| 284 |
); |
| 285 |
|
| 286 |
$this->controls['itemEvenBackground'] = array( |
| 287 |
'tab' => 'content', |
| 288 |
'group' => 'item', |
| 289 |
'label' => esc_html__( 'Even background', 'bricksable' ), |
| 290 |
'type' => 'color', |
| 291 |
'css' => array( |
| 292 |
array( |
| 293 |
'property' => 'background-color', |
| 294 |
'selector' => 'li:nth-child(even)', |
| 295 |
), |
| 296 |
), |
| 297 |
'inline' => true, |
| 298 |
'small' => true, |
| 299 |
); |
| 300 |
|
| 301 |
$this->controls['itemBorder'] = array( |
| 302 |
'tab' => 'content', |
| 303 |
'group' => 'settings', |
| 304 |
'label' => esc_html__( 'Border', 'bricksable' ), |
| 305 |
'type' => 'border', |
| 306 |
'css' => array( |
| 307 |
array( |
| 308 |
'property' => 'border', |
| 309 |
'selector' => 'li', |
| 310 |
), |
| 311 |
), |
| 312 |
'inline' => true, |
| 313 |
'small' => true, |
| 314 |
); |
| 315 |
|
| 316 |
$this->controls['itemAutoWidth'] = array( |
| 317 |
'tab' => 'content', |
| 318 |
'group' => 'item', |
| 319 |
'label' => esc_html__( 'Auto width', 'bricksable' ), |
| 320 |
'type' => 'checkbox', |
| 321 |
'css' => array( |
| 322 |
array( |
| 323 |
'property' => 'justify-content', |
| 324 |
'selector' => '.title-wrapper', |
| 325 |
'value' => 'initial', |
| 326 |
), |
| 327 |
array( |
| 328 |
'property' => 'flex-grow', |
| 329 |
'selector' => '.separator', |
| 330 |
'value' => '0', |
| 331 |
), |
| 332 |
), |
| 333 |
); |
| 334 |
|
| 335 |
/** |
| 336 |
* Highlight |
| 337 |
*/ |
| 338 |
|
| 339 |
$this->controls['highlightBlock'] = array( |
| 340 |
'tab' => 'content', |
| 341 |
'group' => 'highlight', |
| 342 |
'label' => esc_html__( 'Block', 'bricksable' ), |
| 343 |
'type' => 'checkbox', |
| 344 |
'css' => array( |
| 345 |
array( |
| 346 |
'property' => 'display', |
| 347 |
'selector' => '.highlight', |
| 348 |
'value' => 'block', |
| 349 |
), |
| 350 |
), |
| 351 |
); |
| 352 |
|
| 353 |
$this->controls['highlightLabelPadding'] = array( |
| 354 |
'tab' => 'content', |
| 355 |
'group' => 'highlight', |
| 356 |
'label' => esc_html__( 'Label padding', 'bricksable' ), |
| 357 |
'type' => 'dimensions', |
| 358 |
'css' => array( |
| 359 |
array( |
| 360 |
'property' => 'padding', |
| 361 |
'selector' => '.highlight', |
| 362 |
), |
| 363 |
), |
| 364 |
); |
| 365 |
|
| 366 |
$this->controls['highlightLabelBackground'] = array( |
| 367 |
'tab' => 'content', |
| 368 |
'group' => 'highlight', |
| 369 |
'label' => esc_html__( 'Label background', 'bricksable' ), |
| 370 |
'type' => 'color', |
| 371 |
'css' => array( |
| 372 |
array( |
| 373 |
'property' => 'background-color', |
| 374 |
'selector' => '.highlight', |
| 375 |
), |
| 376 |
), |
| 377 |
'inline' => true, |
| 378 |
'small' => true, |
| 379 |
); |
| 380 |
|
| 381 |
$this->controls['highlightLabelBorder'] = array( |
| 382 |
'tab' => 'content', |
| 383 |
'group' => 'highlight', |
| 384 |
'label' => esc_html__( 'Label border', 'bricksable' ), |
| 385 |
'type' => 'border', |
| 386 |
'css' => array( |
| 387 |
array( |
| 388 |
'property' => 'border', |
| 389 |
'selector' => '.highlight', |
| 390 |
), |
| 391 |
), |
| 392 |
'inline' => true, |
| 393 |
'small' => true, |
| 394 |
); |
| 395 |
|
| 396 |
$this->controls['highlightLabelTypography'] = array( |
| 397 |
'tab' => 'content', |
| 398 |
'group' => 'highlight', |
| 399 |
'label' => esc_html__( 'Label typography', 'bricksable' ), |
| 400 |
'type' => 'typography', |
| 401 |
'css' => array( |
| 402 |
array( |
| 403 |
'property' => 'font', |
| 404 |
'selector' => '.highlight', |
| 405 |
), |
| 406 |
), |
| 407 |
'inline' => true, |
| 408 |
'small' => true, |
| 409 |
); |
| 410 |
|
| 411 |
$this->controls['highlightContentPadding'] = array( |
| 412 |
'tab' => 'content', |
| 413 |
'group' => 'highlight', |
| 414 |
'label' => esc_html__( 'Content padding', 'bricksable' ), |
| 415 |
'type' => 'dimensions', |
| 416 |
'css' => array( |
| 417 |
array( |
| 418 |
'property' => 'padding', |
| 419 |
'selector' => '.highlighted .content-wrapper', |
| 420 |
), |
| 421 |
), |
| 422 |
); |
| 423 |
|
| 424 |
$this->controls['highlightContentBackground'] = array( |
| 425 |
'tab' => 'content', |
| 426 |
'group' => 'highlight', |
| 427 |
'label' => esc_html__( 'Content background', 'bricksable' ), |
| 428 |
'type' => 'color', |
| 429 |
'css' => array( |
| 430 |
array( |
| 431 |
'property' => 'background-color', |
| 432 |
'selector' => '.highlighted .content-wrapper', |
| 433 |
), |
| 434 |
), |
| 435 |
'inline' => true, |
| 436 |
'small' => true, |
| 437 |
); |
| 438 |
|
| 439 |
$this->controls['highlightContentBorder'] = array( |
| 440 |
'tab' => 'content', |
| 441 |
'group' => 'highlight', |
| 442 |
'label' => esc_html__( 'Content border', 'bricksable' ), |
| 443 |
'type' => 'border', |
| 444 |
'css' => array( |
| 445 |
array( |
| 446 |
'property' => 'border', |
| 447 |
'selector' => '.highlighted .content-wrapper', |
| 448 |
), |
| 449 |
), |
| 450 |
'inline' => true, |
| 451 |
'small' => true, |
| 452 |
); |
| 453 |
|
| 454 |
$this->controls['highlightContentColor'] = array( |
| 455 |
'tab' => 'content', |
| 456 |
'group' => 'highlight', |
| 457 |
'label' => esc_html__( 'Content text color', 'bricksable' ), |
| 458 |
'type' => 'color', |
| 459 |
'css' => array( |
| 460 |
array( |
| 461 |
'property' => 'color', |
| 462 |
'selector' => '.highlighted .content-wrapper .title', |
| 463 |
), |
| 464 |
array( |
| 465 |
'property' => 'color', |
| 466 |
'selector' => '.highlighted .content-wrapper .meta', |
| 467 |
), |
| 468 |
array( |
| 469 |
'property' => 'color', |
| 470 |
'selector' => '.highlighted .content-wrapper .description', |
| 471 |
), |
| 472 |
), |
| 473 |
'inline' => true, |
| 474 |
'small' => true, |
| 475 |
); |
| 476 |
|
| 477 |
// Icon. |
| 478 |
$this->controls['icon_margin'] = array( |
| 479 |
'tab' => 'content', |
| 480 |
'group' => 'icon', |
| 481 |
'label' => esc_html__( 'Margin', 'bricksable' ), |
| 482 |
'type' => 'dimensions', |
| 483 |
'css' => array( |
| 484 |
array( |
| 485 |
'property' => 'margin', |
| 486 |
'selector' => '.icon', |
| 487 |
), |
| 488 |
array( |
| 489 |
'property' => 'margin', |
| 490 |
'selector' => '.ba-icon-list-icon', |
| 491 |
), |
| 492 |
array( |
| 493 |
'property' => 'margin', |
| 494 |
'selector' => '.ba-icon-list-icon-image', |
| 495 |
), |
| 496 |
), |
| 497 |
); |
| 498 |
|
| 499 |
$this->controls['icon_padding'] = array( |
| 500 |
'tab' => 'content', |
| 501 |
'group' => 'icon', |
| 502 |
'label' => esc_html__( 'Padding', 'bricksable' ), |
| 503 |
'type' => 'dimensions', |
| 504 |
'css' => array( |
| 505 |
array( |
| 506 |
'property' => 'padding', |
| 507 |
'selector' => '.icon', |
| 508 |
), |
| 509 |
array( |
| 510 |
'property' => 'padding', |
| 511 |
'selector' => '.ba-icon-list-icon', |
| 512 |
), |
| 513 |
array( |
| 514 |
'property' => 'padding', |
| 515 |
'selector' => '.ba-icon-list-icon-image', |
| 516 |
), |
| 517 |
), |
| 518 |
); |
| 519 |
|
| 520 |
$this->controls['icon_circle'] = array( |
| 521 |
'tab' => 'content', |
| 522 |
'group' => 'icon', |
| 523 |
'label' => esc_html__( 'Circle', 'bricksable' ), |
| 524 |
'type' => 'checkbox', |
| 525 |
); |
| 526 |
|
| 527 |
$this->controls['iconHeight'] = array( |
| 528 |
'tab' => 'content', |
| 529 |
'group' => 'icon', |
| 530 |
'label' => esc_html__( 'Icon height', 'bricksable' ), |
| 531 |
'type' => 'slider', |
| 532 |
'units' => array( |
| 533 |
'px' => array( |
| 534 |
'min' => 1, |
| 535 |
'max' => 200, |
| 536 |
'step' => 1, |
| 537 |
), |
| 538 |
), |
| 539 |
'css' => array( |
| 540 |
array( |
| 541 |
'property' => 'height', |
| 542 |
'selector' => '.icon', |
| 543 |
), |
| 544 |
array( |
| 545 |
'property' => 'line-height', |
| 546 |
'selector' => '.icon', |
| 547 |
), |
| 548 |
array( |
| 549 |
'property' => 'height', |
| 550 |
'selector' => '.ba-icon-list-icon', |
| 551 |
), |
| 552 |
array( |
| 553 |
'property' => 'line-height', |
| 554 |
'selector' => '.ba-icon-list-icon', |
| 555 |
), |
| 556 |
), |
| 557 |
); |
| 558 |
|
| 559 |
$this->controls['iconWidth'] = array( |
| 560 |
'tab' => 'content', |
| 561 |
'group' => 'icon', |
| 562 |
'label' => esc_html__( 'Icon width', 'bricksable' ), |
| 563 |
'type' => 'slider', |
| 564 |
'units' => array( |
| 565 |
'px' => array( |
| 566 |
'min' => 1, |
| 567 |
'max' => 200, |
| 568 |
'step' => 1, |
| 569 |
), |
| 570 |
), |
| 571 |
'css' => array( |
| 572 |
array( |
| 573 |
'property' => 'width', |
| 574 |
'selector' => '.icon', |
| 575 |
), |
| 576 |
array( |
| 577 |
'property' => 'width', |
| 578 |
'selector' => '.ba-icon-list-icon', |
| 579 |
), |
| 580 |
), |
| 581 |
); |
| 582 |
|
| 583 |
$this->controls['icon_image_width'] = array( |
| 584 |
'tab' => 'content', |
| 585 |
'group' => 'icon', |
| 586 |
'label' => esc_html__( 'Icon Image Width', 'bricksable' ), |
| 587 |
'type' => 'slider', |
| 588 |
'css' => array( |
| 589 |
array( |
| 590 |
'property' => 'max-width', |
| 591 |
'selector' => '.ba-icon-list-icon-image', |
| 592 |
), |
| 593 |
), |
| 594 |
'units' => array( |
| 595 |
'%' => array( |
| 596 |
'min' => 1, |
| 597 |
'max' => 100, |
| 598 |
'step' => 1, |
| 599 |
), |
| 600 |
), |
| 601 |
'description' => esc_html__( 'Adjust the icon image width.', 'bricksable' ), |
| 602 |
); |
| 603 |
|
| 604 |
$this->controls['icon_background'] = array( |
| 605 |
'tab' => 'content', |
| 606 |
'group' => 'icon', |
| 607 |
'label' => esc_html__( 'Icon background', 'bricksable' ), |
| 608 |
'type' => 'color', |
| 609 |
'css' => array( |
| 610 |
array( |
| 611 |
'property' => 'background-color', |
| 612 |
'selector' => '.icon', |
| 613 |
), |
| 614 |
array( |
| 615 |
'property' => 'background-color', |
| 616 |
'selector' => '.ba-icon-list-icon', |
| 617 |
), |
| 618 |
array( |
| 619 |
'property' => 'background-color', |
| 620 |
'selector' => '.ba-icon-list-icon-image', |
| 621 |
), |
| 622 |
), |
| 623 |
'inline' => true, |
| 624 |
'small' => true, |
| 625 |
); |
| 626 |
|
| 627 |
$this->controls['icon_typography'] = array( |
| 628 |
'tab' => 'content', |
| 629 |
'group' => 'icon', |
| 630 |
'label' => esc_html__( 'Icon typography', 'bricksable' ), |
| 631 |
'type' => 'typography', |
| 632 |
'exclude' => array( |
| 633 |
'font-family', |
| 634 |
'font-weight', |
| 635 |
'text-align', |
| 636 |
'text-transform', |
| 637 |
'line-height', |
| 638 |
'letter-spacing', |
| 639 |
), |
| 640 |
'css' => array( |
| 641 |
array( |
| 642 |
'property' => 'font', |
| 643 |
'selector' => '.icon', |
| 644 |
), |
| 645 |
), |
| 646 |
'inline' => true, |
| 647 |
'small' => true, |
| 648 |
); |
| 649 |
|
| 650 |
$this->controls['icon_text_typography'] = array( |
| 651 |
'tab' => 'content', |
| 652 |
'group' => 'icon', |
| 653 |
'label' => esc_html__( 'Icon Text typography', 'bricksable' ), |
| 654 |
'type' => 'typography', |
| 655 |
'css' => array( |
| 656 |
array( |
| 657 |
'property' => 'font', |
| 658 |
'selector' => '.ba-icon-list-icon', |
| 659 |
), |
| 660 |
), |
| 661 |
'inline' => true, |
| 662 |
'small' => true, |
| 663 |
); |
| 664 |
|
| 665 |
$this->controls['icon_border'] = array( |
| 666 |
'tab' => 'content', |
| 667 |
'group' => 'icon', |
| 668 |
'label' => esc_html__( 'Icon border', 'bricksable' ), |
| 669 |
'type' => 'border', |
| 670 |
'css' => array( |
| 671 |
array( |
| 672 |
'property' => 'border', |
| 673 |
'selector' => '.icon', |
| 674 |
), |
| 675 |
array( |
| 676 |
'property' => 'border', |
| 677 |
'selector' => '.ba-icon-list-icon', |
| 678 |
), |
| 679 |
array( |
| 680 |
'property' => 'border', |
| 681 |
'selector' => '.ba-icon-list-icon-image', |
| 682 |
), |
| 683 |
), |
| 684 |
'inline' => true, |
| 685 |
'small' => true, |
| 686 |
); |
| 687 |
|
| 688 |
$this->controls['icon_boxshadow'] = array( |
| 689 |
'tab' => 'content', |
| 690 |
'group' => 'icon', |
| 691 |
'label' => esc_html__( 'Icon box shadow', 'bricksable' ), |
| 692 |
'type' => 'box-shadow', |
| 693 |
'css' => array( |
| 694 |
array( |
| 695 |
'property' => 'box-shadow', |
| 696 |
'selector' => '.icon', |
| 697 |
), |
| 698 |
array( |
| 699 |
'property' => 'box-shadow', |
| 700 |
'selector' => '.ba-icon-list-icon', |
| 701 |
), |
| 702 |
array( |
| 703 |
'property' => 'box-shadow', |
| 704 |
'selector' => '.ba-icon-list-icon-image', |
| 705 |
), |
| 706 |
), |
| 707 |
'inline' => true, |
| 708 |
'small' => true, |
| 709 |
); |
| 710 |
|
| 711 |
/** |
| 712 |
* Title |
| 713 |
*/ |
| 714 |
|
| 715 |
$this->controls['titleMargin'] = array( |
| 716 |
'tab' => 'content', |
| 717 |
'group' => 'title', |
| 718 |
'label' => esc_html__( 'Margin', 'bricksable' ), |
| 719 |
'type' => 'dimensions', |
| 720 |
'css' => array( |
| 721 |
array( |
| 722 |
'property' => 'margin', |
| 723 |
'selector' => '.title', |
| 724 |
), |
| 725 |
), |
| 726 |
); |
| 727 |
|
| 728 |
$this->controls['titleTag'] = array( |
| 729 |
'tab' => 'content', |
| 730 |
'group' => 'title', |
| 731 |
'label' => esc_html__( 'Tag', 'bricksable' ), |
| 732 |
'type' => 'select', |
| 733 |
'options' => array( |
| 734 |
'h2' => esc_html__( 'Heading 2 (h2)', 'bricksable' ), |
| 735 |
'h3' => esc_html__( 'Heading 3 (h3)', 'bricksable' ), |
| 736 |
'h4' => esc_html__( 'Heading 4 (h4)', 'bricksable' ), |
| 737 |
'h5' => esc_html__( 'Heading 5 (h5)', 'bricksable' ), |
| 738 |
'h6' => esc_html__( 'Heading 6 (h6)', 'bricksable' ), |
| 739 |
), |
| 740 |
'inline' => true, |
| 741 |
'placeholder' => 'span', |
| 742 |
); |
| 743 |
|
| 744 |
$this->controls['titleTypography'] = array( |
| 745 |
'tab' => 'content', |
| 746 |
'group' => 'title', |
| 747 |
'label' => esc_html__( 'Typography', 'bricksable' ), |
| 748 |
'type' => 'typography', |
| 749 |
'css' => array( |
| 750 |
array( |
| 751 |
'property' => 'font', |
| 752 |
'selector' => '.title', |
| 753 |
), |
| 754 |
), |
| 755 |
'inline' => true, |
| 756 |
'small' => true, |
| 757 |
); |
| 758 |
|
| 759 |
/** |
| 760 |
* Meta |
| 761 |
*/ |
| 762 |
|
| 763 |
$this->controls['metaMargin'] = array( |
| 764 |
'tab' => 'content', |
| 765 |
'group' => 'meta', |
| 766 |
'label' => esc_html__( 'Margin', 'bricksable' ), |
| 767 |
'type' => 'dimensions', |
| 768 |
'css' => array( |
| 769 |
array( |
| 770 |
'property' => 'margin', |
| 771 |
'selector' => '.meta', |
| 772 |
), |
| 773 |
), |
| 774 |
); |
| 775 |
|
| 776 |
$this->controls['metaTypography'] = array( |
| 777 |
'tab' => 'content', |
| 778 |
'group' => 'meta', |
| 779 |
'label' => esc_html__( 'Typography', 'bricksable' ), |
| 780 |
'type' => 'typography', |
| 781 |
'css' => array( |
| 782 |
array( |
| 783 |
'property' => 'font', |
| 784 |
'selector' => '.meta', |
| 785 |
), |
| 786 |
), |
| 787 |
'inline' => true, |
| 788 |
'small' => true, |
| 789 |
); |
| 790 |
|
| 791 |
/** |
| 792 |
* Description |
| 793 |
*/ |
| 794 |
|
| 795 |
$this->controls['descriptionTypography'] = array( |
| 796 |
'tab' => 'content', |
| 797 |
'group' => 'description', |
| 798 |
'label' => esc_html__( 'Typography', 'bricksable' ), |
| 799 |
'type' => 'typography', |
| 800 |
'css' => array( |
| 801 |
array( |
| 802 |
'property' => 'font', |
| 803 |
'selector' => '.description', |
| 804 |
), |
| 805 |
), |
| 806 |
'inline' => true, |
| 807 |
'small' => true, |
| 808 |
); |
| 809 |
|
| 810 |
/** |
| 811 |
* Separator |
| 812 |
*/ |
| 813 |
|
| 814 |
$this->controls['separatorDisable'] = array( |
| 815 |
'tab' => 'content', |
| 816 |
'group' => 'separator', |
| 817 |
'label' => esc_html__( 'Disable', 'bricksable' ), |
| 818 |
'type' => 'checkbox', |
| 819 |
'css' => array( |
| 820 |
array( |
| 821 |
'property' => 'display', |
| 822 |
'selector' => '.separator', |
| 823 |
'value' => 'none', |
| 824 |
), |
| 825 |
), |
| 826 |
'default' => true, |
| 827 |
); |
| 828 |
|
| 829 |
$this->controls['separatorStyle'] = array( |
| 830 |
'tab' => 'content', |
| 831 |
'group' => 'separator', |
| 832 |
'label' => esc_html__( 'Style', 'bricksable' ), |
| 833 |
'type' => 'select', |
| 834 |
'options' => $this->control_options['borderStyle'], |
| 835 |
'css' => array( |
| 836 |
array( |
| 837 |
'property' => 'border-top-style', |
| 838 |
'selector' => '.separator', |
| 839 |
), |
| 840 |
), |
| 841 |
'inline' => true, |
| 842 |
'required' => array( 'separatorDisable', '=', '' ), |
| 843 |
); |
| 844 |
|
| 845 |
$this->controls['separatorWidth'] = array( |
| 846 |
'tab' => 'content', |
| 847 |
'group' => 'separator', |
| 848 |
'label' => esc_html__( 'Width in px', 'bricksable' ), |
| 849 |
'type' => 'number', |
| 850 |
'unit' => 'px', |
| 851 |
'css' => array( |
| 852 |
array( |
| 853 |
'property' => 'flex-basis', |
| 854 |
'selector' => '.separator', |
| 855 |
), |
| 856 |
array( |
| 857 |
'property' => 'flex-grow', |
| 858 |
'selector' => '.separator', |
| 859 |
'value' => '0', |
| 860 |
), |
| 861 |
), |
| 862 |
'inline' => true, |
| 863 |
'required' => array( 'separatorDisable', '=', '' ), |
| 864 |
); |
| 865 |
|
| 866 |
$this->controls['separatorHeight'] = array( |
| 867 |
'tab' => 'content', |
| 868 |
'group' => 'separator', |
| 869 |
'label' => esc_html__( 'Height in px', 'bricksable' ), |
| 870 |
'type' => 'number', |
| 871 |
'unit' => 'px', |
| 872 |
'css' => array( |
| 873 |
array( |
| 874 |
'property' => 'border-top-width', |
| 875 |
'selector' => '.separator', |
| 876 |
), |
| 877 |
), |
| 878 |
'inline' => true, |
| 879 |
'required' => array( 'separatorDisable', '=', '' ), |
| 880 |
); |
| 881 |
|
| 882 |
$this->controls['separatorColor'] = array( |
| 883 |
'tab' => 'content', |
| 884 |
'group' => 'separator', |
| 885 |
'label' => esc_html__( 'Color', 'bricksable' ), |
| 886 |
'type' => 'color', |
| 887 |
'css' => array( |
| 888 |
array( |
| 889 |
'property' => 'border-top-color', |
| 890 |
'selector' => '.separator', |
| 891 |
), |
| 892 |
), |
| 893 |
'inline' => true, |
| 894 |
'small' => true, |
| 895 |
'required' => array( 'separatorDisable', '=', '' ), |
| 896 |
); |
| 897 |
|
| 898 |
} |
| 899 |
|
| 900 |
public function render() { |
| 901 |
$settings = $this->settings; |
| 902 |
|
| 903 |
// Element placeholder. |
| 904 |
if ( ! isset( $settings['items'] ) || empty( $settings['items'] ) ) { |
| 905 |
return $this->render_element_placeholder( array( 'text' => esc_html__( 'No list items defined.', 'bricksable' ) ) ); |
| 906 |
} |
| 907 |
|
| 908 |
$output = '<ul>'; |
| 909 |
|
| 910 |
foreach ( $settings['items'] as $index => $list_item ) { |
| 911 |
$list_item_classes = array( 'list-item' ); |
| 912 |
|
| 913 |
if ( isset( $list_item['highlight'] ) ) { |
| 914 |
$list_item_classes[] = 'highlighted'; |
| 915 |
} |
| 916 |
|
| 917 |
$this->set_attribute( "list-item-$index", 'class', $list_item_classes ); |
| 918 |
|
| 919 |
$output .= '<li ' . $this->render_attributes( "list-item-$index" ) . '>'; |
| 920 |
|
| 921 |
if ( isset( $list_item['highlightLabel'] ) && ! empty( $list_item['highlightLabel'] ) ) { |
| 922 |
$output .= '<div class="highlight">' . esc_html( $list_item['highlightLabel'] ) . '</div>'; |
| 923 |
} |
| 924 |
|
| 925 |
$output .= '<div class="content-wrapper">'; |
| 926 |
|
| 927 |
$output .= '<div class="title-wrapper">'; |
| 928 |
|
| 929 |
if ( isset( $list_item['title'] ) && ! empty( $list_item['title'] ) ) { |
| 930 |
$title_tag = isset( $settings['titleTag'] ) ? esc_attr( $settings['titleTag'] ) : 'span'; |
| 931 |
|
| 932 |
$this->set_attribute( "title-$index", $title_tag ); |
| 933 |
$this->set_attribute( "title-$index", 'class', array( 'title' ) ); |
| 934 |
|
| 935 |
if ( isset( $list_item['link'] ) ) { |
| 936 |
$this->set_link_attributes( "a-$index", $list_item['link'] ); |
| 937 |
$output .= '<a ' . $this->render_attributes( "a-$index" ) . '>'; |
| 938 |
} |
| 939 |
|
| 940 |
// Icon. |
| 941 |
if ( isset( $list_item['icon']['icon'] ) ) { |
| 942 |
$this->set_attribute( |
| 943 |
"icon-{$index}", |
| 944 |
'class', |
| 945 |
array( |
| 946 |
'icon', |
| 947 |
isset( $settings['icon_circle'] ) && null !== $settings['icon_circle'] ? 'ba-icon-list-circle' : '', |
| 948 |
$list_item['icon']['icon'], |
| 949 |
) |
| 950 |
); |
| 951 |
} |
| 952 |
$this->set_attribute( "icon-wrapper-$index", 'class', 'icon-wrapper' ); |
| 953 |
$this->set_attribute( |
| 954 |
"ba-icon-list-icon-$index", |
| 955 |
'class', |
| 956 |
array( |
| 957 |
'ba-icon-list-icon', |
| 958 |
isset( $settings['icon_circle'] ) && null !== $settings['icon_circle'] ? 'ba-icon-list-circle' : '', |
| 959 |
) |
| 960 |
); |
| 961 |
|
| 962 |
if ( true === isset( $list_item['use_icon_text'] ) ) { |
| 963 |
if ( isset( $list_item['icon_text'] ) ) { |
| 964 |
$output .= '<span ' . $this->render_attributes( "icon-wrapper-{$index}" ) . '>'; //phpcs:ignore |
| 965 |
$output .= '<span ' . $this->render_attributes( "ba-icon-list-icon-{$index}" ) . '>' . esc_html( $list_item['icon_text'] ) . '</span>'; //phpcs:ignore |
| 966 |
$output .= '</span>'; |
| 967 |
} |
| 968 |
} elseif ( true === isset( $list_item['use_icon_image'] ) ) { |
| 969 |
// Image. |
| 970 |
$image_atts = array(); |
| 971 |
$image_atts['id'] = 'image-' . $list_item['icon_image']['id']; |
| 972 |
$item_image_classes = array( 'ba-icon-list-icon-image', 'css-filter' ); |
| 973 |
$item_image_classes[] = 'size-' . $list_item['icon_image']['size']; |
| 974 |
$image_atts['class'] = join( ' ', $item_image_classes ); |
| 975 |
$this->set_attribute( "icon-list-icon-image-{$index}", 'class', $item_image_classes ); |
| 976 |
$this->set_attribute( "icon-list-icon-image-{$index}", 'src', esc_url( $list_item['icon_image']['url'] ) ); |
| 977 |
|
| 978 |
// Lazy load atts set via 'wp_get_attachment_image_attributes' filter. |
| 979 |
if ( isset( $list_item['icon_image']['id'] ) ) { |
| 980 |
$output .= wp_get_attachment_image( $list_item['icon_image']['id'], $list_item['icon_image']['size'], false, $image_atts ); |
| 981 |
} elseif ( ! empty( $list_item['icon_image']['url'] ) ) { |
| 982 |
$output .= '<img ' . $this->render_attributes( "icon-list-icon-image-{$index}" ) . '>'; //phpcs:ignore |
| 983 |
} |
| 984 |
} else { |
| 985 |
if ( isset( $list_item['icon']['icon'] ) ) { |
| 986 |
$output .= '<span ' . $this->render_attributes( "icon-wrapper-{$index}" ) . '>'; //phpcs:ignore |
| 987 |
$output .= '<i ' . $this->render_attributes( "icon-{$index}" ) . '></i>'; //phpcs:ignore |
| 988 |
$output .= '</span>'; |
| 989 |
} |
| 990 |
} |
| 991 |
|
| 992 |
$output .= '<' . $this->render_attributes( "title-$index" ) . '>' . $list_item['title'] . '</' . $title_tag . '>'; |
| 993 |
|
| 994 |
if ( isset( $list_item['link'] ) ) { |
| 995 |
$output .= '</a>'; |
| 996 |
} |
| 997 |
} |
| 998 |
|
| 999 |
if ( ! isset( $list_item['separatorDisable'] ) ) { |
| 1000 |
$output .= '<span class="separator"></span>'; |
| 1001 |
} |
| 1002 |
|
| 1003 |
if ( isset( $list_item['meta'] ) && ! empty( $list_item['meta'] ) ) { |
| 1004 |
$this->set_attribute( "meta-$index", 'class', array( 'meta' ) ); |
| 1005 |
|
| 1006 |
$output .= '<span ' . $this->render_attributes( "meta-$index" ) . '>' . $list_item['meta'] . '</span>'; |
| 1007 |
} |
| 1008 |
|
| 1009 |
$output .= '</div>'; |
| 1010 |
|
| 1011 |
if ( isset( $list_item['description'] ) && ! empty( $list_item['description'] ) ) { |
| 1012 |
$this->set_attribute( "description-$index", 'class', array( 'description' ) ); |
| 1013 |
|
| 1014 |
$output .= '<div ' . $this->render_attributes( "description-$index" ) . '>' . $list_item['description'] . '</div>'; |
| 1015 |
} |
| 1016 |
|
| 1017 |
$output .= '</div>'; // .content-wrapper |
| 1018 |
|
| 1019 |
$output .= '</li>'; |
| 1020 |
} |
| 1021 |
|
| 1022 |
$output .= '</ul>'; |
| 1023 |
|
| 1024 |
echo $output; //phpcs:ignore |
| 1025 |
} |
| 1026 |
|
| 1027 |
} |
| 1028 |
|