| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; // Exit if accessed directly. |
| 5 |
} |
| 6 |
|
| 7 |
class Bricksable_Floating extends \Bricks\Element { |
| 8 |
public $category = 'bricksable'; |
| 9 |
public $name = 'ba-floating'; |
| 10 |
public $icon = 'ti-layers-alt'; |
| 11 |
|
| 12 |
public function get_label() { |
| 13 |
return esc_html__( 'Floating', 'bricksable' ); |
| 14 |
} |
| 15 |
public function set_control_groups() { |
| 16 |
$this->control_groups['items'] = array( |
| 17 |
'title' => esc_html__( 'Float items', 'bricksable' ), |
| 18 |
'tab' => 'content', |
| 19 |
); |
| 20 |
$this->control_groups['item'] = array( |
| 21 |
'title' => esc_html__( 'Float item / layout', 'bricksable' ), |
| 22 |
'tab' => 'content', |
| 23 |
); |
| 24 |
$this->control_groups['image'] = array( |
| 25 |
'title' => esc_html__( 'Image', 'bricksable' ), |
| 26 |
'tab' => 'content', |
| 27 |
); |
| 28 |
$this->control_groups['icon'] = array( |
| 29 |
'title' => esc_html__( 'Icon', 'bricksable' ), |
| 30 |
'tab' => 'content', |
| 31 |
); |
| 32 |
$this->control_groups['title'] = array( |
| 33 |
'title' => esc_html__( 'Title', 'bricksable' ), |
| 34 |
'tab' => 'content', |
| 35 |
); |
| 36 |
$this->control_groups['settings'] = array( |
| 37 |
'title' => esc_html__( 'Floating Settings', 'bricksable' ), |
| 38 |
'tab' => 'content', |
| 39 |
); |
| 40 |
|
| 41 |
} |
| 42 |
public function set_controls() { |
| 43 |
// Items. |
| 44 |
$this->controls['items'] = array( |
| 45 |
'tab' => 'content', |
| 46 |
'group' => 'items', |
| 47 |
'placeholder' => esc_html__( 'Float items', 'bricksable' ), |
| 48 |
'type' => 'repeater', |
| 49 |
'titleProperty' => 'title', |
| 50 |
'fields' => array( |
| 51 |
'title' => array( |
| 52 |
'label' => esc_html__( 'Title', 'bricksable' ), |
| 53 |
'type' => 'text', |
| 54 |
'hasDynamicData' => 'text', |
| 55 |
'inlineEditing' => array( |
| 56 |
'selector' => '.title', |
| 57 |
), |
| 58 |
), |
| 59 |
'link' => array( |
| 60 |
'label' => esc_html__( 'Link', 'bricksable' ), |
| 61 |
'type' => 'link', |
| 62 |
), |
| 63 |
'top' => array( |
| 64 |
'label' => esc_html__( 'Vertical Position', 'bricksable' ), |
| 65 |
'type' => 'slider', |
| 66 |
'css' => array( |
| 67 |
array( |
| 68 |
'property' => 'top', |
| 69 |
// 'repeaterSelector' => '.ba-floating-item', |
| 70 |
), |
| 71 |
), |
| 72 |
'units' => array( |
| 73 |
'%' => array( |
| 74 |
'min' => 0, |
| 75 |
'max' => 100, |
| 76 |
'step' => 10, |
| 77 |
), |
| 78 |
|
| 79 |
), |
| 80 |
), |
| 81 |
'left' => array( |
| 82 |
'label' => esc_html__( 'Horizontal Position', 'bricksable' ), |
| 83 |
'type' => 'slider', |
| 84 |
'css' => array( |
| 85 |
array( |
| 86 |
'property' => 'left', |
| 87 |
// 'repeaterSelector' => '.ba-floating-item', |
| 88 |
), |
| 89 |
), |
| 90 |
'units' => array( |
| 91 |
'%' => array( |
| 92 |
'min' => 0, |
| 93 |
'max' => 100, |
| 94 |
'step' => 10, |
| 95 |
), |
| 96 |
|
| 97 |
), |
| 98 |
), |
| 99 |
'use_image' => array( |
| 100 |
'label' => esc_html__( 'Use Image', 'bricksable' ), |
| 101 |
'type' => 'checkbox', |
| 102 |
'inline' => true, |
| 103 |
), |
| 104 |
'image' => array( |
| 105 |
'label' => esc_html__( 'Image', 'bricksable' ), |
| 106 |
'type' => 'image', |
| 107 |
'required' => array( 'use_image', '=', true ), |
| 108 |
), |
| 109 |
'image_border' => array( |
| 110 |
'label' => esc_html__( 'Image Border', 'bricksable' ), |
| 111 |
'type' => 'border', |
| 112 |
'css' => array( |
| 113 |
array( |
| 114 |
'property' => 'border', |
| 115 |
'selector' => '.ba-floating-image', |
| 116 |
), |
| 117 |
), |
| 118 |
'required' => array( 'use_image', '=', true ), |
| 119 |
), |
| 120 |
'image_box_shadow' => array( |
| 121 |
'label' => esc_html__( 'Image Box Shadow', 'bricksable' ), |
| 122 |
'type' => 'box-shadow', |
| 123 |
'css' => array( |
| 124 |
array( |
| 125 |
'property' => 'box-shadow', |
| 126 |
'selector' => '.ba-floating-image', |
| 127 |
), |
| 128 |
), |
| 129 |
'required' => array( 'use_image', '=', true ), |
| 130 |
), |
| 131 |
'use_icon' => array( |
| 132 |
'label' => esc_html__( 'Use Icon', 'bricksable' ), |
| 133 |
'type' => 'checkbox', |
| 134 |
'inline' => true, |
| 135 |
), |
| 136 |
'icon' => array( |
| 137 |
'label' => esc_html__( 'Icon', 'bricksable' ), |
| 138 |
'type' => 'icon', |
| 139 |
'required' => array( 'use_icon', '=', true ), |
| 140 |
), |
| 141 |
'icon_typography' => array( |
| 142 |
'label' => esc_html__( 'Icon typography', 'bricksable' ), |
| 143 |
'type' => 'typography', |
| 144 |
'exclude' => array( |
| 145 |
'font-family', |
| 146 |
'font-weight', |
| 147 |
'font-style', |
| 148 |
'text-align', |
| 149 |
'text-transform', |
| 150 |
'text-decoration', |
| 151 |
'line-height', |
| 152 |
'letter-spacing', |
| 153 |
), |
| 154 |
'css' => array( |
| 155 |
array( |
| 156 |
'property' => 'font', |
| 157 |
'selector' => '.icon', |
| 158 |
), |
| 159 |
), |
| 160 |
'inline' => true, |
| 161 |
'small' => true, |
| 162 |
'required' => array( 'use_icon', '=', true ), |
| 163 |
), |
| 164 |
'use_gradient' => array( |
| 165 |
'label' => esc_html__( 'Use Gradient / Overlay', 'bricksable' ), |
| 166 |
'type' => 'checkbox', |
| 167 |
'inline' => true, |
| 168 |
), |
| 169 |
'gradient' => array( |
| 170 |
'label' => esc_html__( 'Gradient', 'bricksable' ), |
| 171 |
'type' => 'gradient', |
| 172 |
'css' => array( |
| 173 |
array( |
| 174 |
'property' => 'background-image', |
| 175 |
// 'repeaterSelector' => '.ba-floating-item', |
| 176 |
), |
| 177 |
), |
| 178 |
'required' => array( 'use_gradient', '=', true ), |
| 179 |
), |
| 180 |
'width' => array( |
| 181 |
'label' => esc_html__( 'Item Width', 'bricksable' ), |
| 182 |
'type' => 'slider', |
| 183 |
'default' => '100%', |
| 184 |
'css' => array( |
| 185 |
array( |
| 186 |
'property' => 'max-width', |
| 187 |
), |
| 188 |
), |
| 189 |
'units' => array( |
| 190 |
'%' => array( |
| 191 |
'min' => 1, |
| 192 |
'max' => 100, |
| 193 |
'step' => 1, |
| 194 |
), |
| 195 |
'px' => array( |
| 196 |
'min' => 1, |
| 197 |
'max' => 1600, |
| 198 |
'step' => 1, |
| 199 |
), |
| 200 |
), |
| 201 |
), |
| 202 |
'padding' => array( |
| 203 |
'label' => esc_html__( 'Item Padding', 'bricksable' ), |
| 204 |
'type' => 'dimensions', |
| 205 |
'css' => array( |
| 206 |
array( |
| 207 |
'property' => 'padding', |
| 208 |
), |
| 209 |
), |
| 210 |
), |
| 211 |
'border' => array( |
| 212 |
'label' => esc_html__( 'Item Border', 'bricksable' ), |
| 213 |
'type' => 'border', |
| 214 |
'css' => array( |
| 215 |
array( |
| 216 |
'property' => 'border', |
| 217 |
), |
| 218 |
array( |
| 219 |
'property' => 'overflow', |
| 220 |
'value' => 'hidden', |
| 221 |
), |
| 222 |
), |
| 223 |
), |
| 224 |
'box_shadow' => array( |
| 225 |
'label' => esc_html__( 'Item Box Shadow', 'bricksable' ), |
| 226 |
'type' => 'box-shadow', |
| 227 |
'css' => array( |
| 228 |
array( |
| 229 |
'property' => 'box-shadow', |
| 230 |
), |
| 231 |
), |
| 232 |
), |
| 233 |
), |
| 234 |
'default' => array( |
| 235 |
array( |
| 236 |
'use_gradient' => false, |
| 237 |
'use_image' => true, |
| 238 |
'use_icon' => false, |
| 239 |
'image' => array( |
| 240 |
'full' => 'https://source.unsplash.com/random/700x700?animal', |
| 241 |
'url' => 'https://source.unsplash.com/random/400x400?animal', |
| 242 |
), |
| 243 |
'top' => '0%', |
| 244 |
'left' => '0%', |
| 245 |
), |
| 246 |
array( |
| 247 |
'use_gradient' => false, |
| 248 |
'use_image' => true, |
| 249 |
'use_icon' => false, |
| 250 |
'image' => array( |
| 251 |
'full' => 'https://source.unsplash.com/random/700x700?human', |
| 252 |
'url' => 'https://source.unsplash.com/random/400x400?human', |
| 253 |
), |
| 254 |
'top' => '20%', |
| 255 |
'left' => '20%', |
| 256 |
), |
| 257 |
), |
| 258 |
); |
| 259 |
|
| 260 |
// Item. |
| 261 |
$this->controls['item_direction'] = array( |
| 262 |
'tab' => 'content', |
| 263 |
'group' => 'item', |
| 264 |
'label' => esc_html__( 'Content Direction (Title & Icon)', 'bricksable' ), |
| 265 |
'title' => 'flex-direction', |
| 266 |
'type' => 'select', |
| 267 |
'options' => $this->control_options['flexDirection'], |
| 268 |
'css' => array( |
| 269 |
array( |
| 270 |
'property' => 'flex-direction', |
| 271 |
'selector' => '.ba-floating-item .content-wrapper', |
| 272 |
), |
| 273 |
), |
| 274 |
'default' => 'column', |
| 275 |
'placeholder' => esc_html__( 'Stacked (Column)', 'bricksable' ), |
| 276 |
); |
| 277 |
|
| 278 |
$this->controls['item_padding'] = array( |
| 279 |
'tab' => 'content', |
| 280 |
'group' => 'item', |
| 281 |
'label' => esc_html__( 'Padding', 'bricksable' ), |
| 282 |
'type' => 'dimensions', |
| 283 |
'css' => array( |
| 284 |
array( |
| 285 |
'property' => 'padding', |
| 286 |
'selector' => '.ba-floating-item', |
| 287 |
), |
| 288 |
), |
| 289 |
); |
| 290 |
|
| 291 |
$this->controls['item_width'] = array( |
| 292 |
'tab' => 'content', |
| 293 |
'group' => 'item', |
| 294 |
'label' => esc_html__( 'Item width', 'bricksable' ), |
| 295 |
'type' => 'slider', |
| 296 |
'default' => '100%', |
| 297 |
'css' => array( |
| 298 |
array( |
| 299 |
'property' => 'max-width', |
| 300 |
'selector' => '.ba-floating-item', |
| 301 |
), |
| 302 |
), |
| 303 |
'units' => array( |
| 304 |
'%' => array( |
| 305 |
'min' => 1, |
| 306 |
'max' => 100, |
| 307 |
'step' => 1, |
| 308 |
), |
| 309 |
'px' => array( |
| 310 |
'min' => 1, |
| 311 |
'max' => 1600, |
| 312 |
'step' => 1, |
| 313 |
), |
| 314 |
), |
| 315 |
); |
| 316 |
|
| 317 |
$this->controls['item_border'] = array( |
| 318 |
'tab' => 'content', |
| 319 |
'group' => 'item', |
| 320 |
'label' => esc_html__( 'Item border', 'bricksable' ), |
| 321 |
'type' => 'border', |
| 322 |
'css' => array( |
| 323 |
array( |
| 324 |
'property' => 'border', |
| 325 |
'selector' => '.ba-floating-item', |
| 326 |
), |
| 327 |
), |
| 328 |
'inline' => true, |
| 329 |
'small' => true, |
| 330 |
); |
| 331 |
|
| 332 |
$this->controls['item_shadow'] = array( |
| 333 |
'tab' => 'content', |
| 334 |
'group' => 'item', |
| 335 |
'label' => esc_html__( 'Item shadow', 'bricksable' ), |
| 336 |
'type' => 'box-shadow', |
| 337 |
'css' => array( |
| 338 |
array( |
| 339 |
'property' => 'box-shadow', |
| 340 |
'selector' => '.ba-floating-item', |
| 341 |
), |
| 342 |
), |
| 343 |
'inline' => true, |
| 344 |
'small' => true, |
| 345 |
); |
| 346 |
|
| 347 |
// Title. |
| 348 |
$this->controls['title_margin'] = array( |
| 349 |
'tab' => 'content', |
| 350 |
'group' => 'title', |
| 351 |
'label' => esc_html__( 'Margin', 'bricksable' ), |
| 352 |
'type' => 'dimensions', |
| 353 |
'css' => array( |
| 354 |
array( |
| 355 |
'property' => 'margin', |
| 356 |
'selector' => '.content-wrapper .title-wrapper .title', |
| 357 |
), |
| 358 |
), |
| 359 |
); |
| 360 |
|
| 361 |
$this->controls['title_tag'] = array( |
| 362 |
'tab' => 'content', |
| 363 |
'group' => 'title', |
| 364 |
'label' => esc_html__( 'Tag', 'bricksable' ), |
| 365 |
'type' => 'select', |
| 366 |
'options' => array( |
| 367 |
'h1' => esc_html__( 'Heading 1 (h1)', 'bricksable' ), |
| 368 |
'h2' => esc_html__( 'Heading 2 (h2)', 'bricksable' ), |
| 369 |
'h3' => esc_html__( 'Heading 3 (h3)', 'bricksable' ), |
| 370 |
'h4' => esc_html__( 'Heading 4 (h4)', 'bricksable' ), |
| 371 |
'h5' => esc_html__( 'Heading 5 (h5)', 'bricksable' ), |
| 372 |
'h6' => esc_html__( 'Heading 6 (h6)', 'bricksable' ), |
| 373 |
'p' => esc_html__( 'Paragraph (p)', 'bricksable' ), |
| 374 |
'span' => esc_html__( 'Span (span)', 'bricksable' ), |
| 375 |
), |
| 376 |
'inline' => true, |
| 377 |
'placeholder' => 'h4', |
| 378 |
); |
| 379 |
|
| 380 |
$this->controls['title_JustifyContent'] = array( |
| 381 |
'tab' => 'content', |
| 382 |
'group' => 'title', |
| 383 |
'label' => esc_html__( 'Align', 'bricksable' ), |
| 384 |
'type' => 'select', |
| 385 |
'options' => $this->control_options['justifyContent'], |
| 386 |
'css' => array( |
| 387 |
array( |
| 388 |
'property' => 'justify-content', |
| 389 |
'selector' => '.content-wrapper', |
| 390 |
), |
| 391 |
), |
| 392 |
'inline' => true, |
| 393 |
); |
| 394 |
|
| 395 |
$this->controls['title_verticalAlign'] = array( |
| 396 |
'tab' => 'style', |
| 397 |
'group' => 'title', |
| 398 |
'label' => esc_html__( 'Vertical align', 'bricksable' ), |
| 399 |
'type' => 'select', |
| 400 |
'options' => $this->control_options['alignItems'], |
| 401 |
'css' => array( |
| 402 |
array( |
| 403 |
'property' => 'align-items', |
| 404 |
'selector' => '.content-wrapper', |
| 405 |
), |
| 406 |
), |
| 407 |
'inline' => true, |
| 408 |
'default' => 'center', |
| 409 |
'placeholder' => esc_html__( 'Center', 'bricksable' ), |
| 410 |
); |
| 411 |
|
| 412 |
$this->controls['titleTypography'] = array( |
| 413 |
'tab' => 'content', |
| 414 |
'group' => 'title', |
| 415 |
'label' => esc_html__( 'Typography', 'bricksable' ), |
| 416 |
'type' => 'typography', |
| 417 |
'css' => array( |
| 418 |
array( |
| 419 |
'property' => 'font', |
| 420 |
'selector' => '.title', |
| 421 |
), |
| 422 |
), |
| 423 |
'inline' => true, |
| 424 |
'small' => true, |
| 425 |
); |
| 426 |
|
| 427 |
// Image. |
| 428 |
$this->controls['imageWidth'] = array( |
| 429 |
'tab' => 'content', |
| 430 |
'group' => 'image', |
| 431 |
'label' => esc_html__( 'Image width', 'bricksable' ), |
| 432 |
'type' => 'slider', |
| 433 |
'default' => '100%', |
| 434 |
'css' => array( |
| 435 |
array( |
| 436 |
'property' => 'max-width', |
| 437 |
'selector' => '.ba-floating-image', |
| 438 |
), |
| 439 |
), |
| 440 |
'units' => array( |
| 441 |
'%' => array( |
| 442 |
'min' => 1, |
| 443 |
'max' => 100, |
| 444 |
'step' => 1, |
| 445 |
), |
| 446 |
'px' => array( |
| 447 |
'min' => 1, |
| 448 |
'max' => 1600, |
| 449 |
'step' => 1, |
| 450 |
), |
| 451 |
), |
| 452 |
); |
| 453 |
|
| 454 |
$this->controls['imageBorder'] = array( |
| 455 |
'tab' => 'content', |
| 456 |
'group' => 'image', |
| 457 |
'label' => esc_html__( 'Image border', 'bricksable' ), |
| 458 |
'type' => 'border', |
| 459 |
'css' => array( |
| 460 |
array( |
| 461 |
'property' => 'border', |
| 462 |
'selector' => '.ba-floating-image', |
| 463 |
), |
| 464 |
), |
| 465 |
'inline' => true, |
| 466 |
'small' => true, |
| 467 |
); |
| 468 |
|
| 469 |
$this->controls['imageShadow'] = array( |
| 470 |
'tab' => 'content', |
| 471 |
'group' => 'image', |
| 472 |
'label' => esc_html__( 'Image shadow', 'bricksable' ), |
| 473 |
'type' => 'box-shadow', |
| 474 |
'css' => array( |
| 475 |
array( |
| 476 |
'property' => 'box-shadow', |
| 477 |
'selector' => '.ba-floating-image', |
| 478 |
), |
| 479 |
), |
| 480 |
'inline' => true, |
| 481 |
'small' => true, |
| 482 |
); |
| 483 |
|
| 484 |
// Icon. |
| 485 |
$this->controls['icon_typography'] = array( |
| 486 |
'tab' => 'content', |
| 487 |
'group' => 'icon', |
| 488 |
'label' => esc_html__( 'Icon typography', 'bricksable' ), |
| 489 |
'type' => 'typography', |
| 490 |
'exclude' => array( |
| 491 |
'font-family', |
| 492 |
'font-weight', |
| 493 |
'text-align', |
| 494 |
'text-transform', |
| 495 |
'line-height', |
| 496 |
'letter-spacing', |
| 497 |
), |
| 498 |
'css' => array( |
| 499 |
array( |
| 500 |
'property' => 'font', |
| 501 |
'selector' => '.icon', |
| 502 |
), |
| 503 |
), |
| 504 |
'inline' => true, |
| 505 |
'small' => true, |
| 506 |
); |
| 507 |
$this->controls['icon_border'] = array( |
| 508 |
'tab' => 'content', |
| 509 |
'group' => 'icon', |
| 510 |
'label' => esc_html__( 'Icon border', 'bricksable' ), |
| 511 |
'type' => 'border', |
| 512 |
'css' => array( |
| 513 |
array( |
| 514 |
'property' => 'border', |
| 515 |
'selector' => '.icon', |
| 516 |
), |
| 517 |
), |
| 518 |
'inline' => true, |
| 519 |
'small' => true, |
| 520 |
); |
| 521 |
|
| 522 |
$this->controls['icon_boxshadow'] = array( |
| 523 |
'tab' => 'content', |
| 524 |
'group' => 'icon', |
| 525 |
'label' => esc_html__( 'Icon box shadow', 'bricksable' ), |
| 526 |
'type' => 'box-shadow', |
| 527 |
'css' => array( |
| 528 |
array( |
| 529 |
'property' => 'box-shadow', |
| 530 |
'selector' => '.icon', |
| 531 |
), |
| 532 |
), |
| 533 |
'inline' => true, |
| 534 |
'small' => true, |
| 535 |
); |
| 536 |
|
| 537 |
// Animation. |
| 538 |
$this->controls['height'] = array( |
| 539 |
'tab' => 'content', |
| 540 |
'group' => 'settings', |
| 541 |
'label' => esc_html__( 'Height', 'bricksable' ), |
| 542 |
'type' => 'slider', |
| 543 |
'css' => array( |
| 544 |
array( |
| 545 |
'property' => 'min-height', |
| 546 |
'selector' => '.ba-floating-wrapper', |
| 547 |
), |
| 548 |
), |
| 549 |
'units' => array( |
| 550 |
'px' => array( |
| 551 |
'min' => 1, |
| 552 |
'max' => 1600, |
| 553 |
'step' => 1, |
| 554 |
), |
| 555 |
), |
| 556 |
'default' => '460px', |
| 557 |
'description' => esc_html__( "Adjust the floating container's height.", 'bricksable' ), |
| 558 |
); |
| 559 |
|
| 560 |
$this->controls['animation'] = array( |
| 561 |
'tab' => 'content', |
| 562 |
'group' => 'settings', |
| 563 |
'label' => esc_html__( 'Animation Type', 'bricksable' ), |
| 564 |
'type' => 'select', |
| 565 |
'options' => array( |
| 566 |
'horizontal' => esc_html__( 'Horizontal', 'bricksable' ), |
| 567 |
'vertical' => esc_html__( 'Vertical', 'bricksable' ), |
| 568 |
), |
| 569 |
'default' => 'vertical', |
| 570 |
'inline' => true, |
| 571 |
'placeholder' => esc_html__( 'Vertical', 'bricksable' ), |
| 572 |
); |
| 573 |
|
| 574 |
$this->controls['animation_speed'] = array( |
| 575 |
'tab' => 'content', |
| 576 |
'group' => 'settings', |
| 577 |
'label' => esc_html__( 'Animation Speed', 'bricksable' ), |
| 578 |
'type' => 'slider', |
| 579 |
'css' => array( |
| 580 |
array( |
| 581 |
'property' => 'animation-duration', |
| 582 |
'selector' => '.ba-floating-wrapper .ba-floating-item', |
| 583 |
), |
| 584 |
), |
| 585 |
'units' => array( |
| 586 |
's' => array( |
| 587 |
'min' => 2, |
| 588 |
'max' => 10, |
| 589 |
'step' => 1, |
| 590 |
), |
| 591 |
), |
| 592 |
'default' => '6s', |
| 593 |
'placeholder' => esc_html__( '6', 'bricksable' ), |
| 594 |
'description' => esc_html__( 'Increase or decrease the speed.', 'bricksable' ), |
| 595 |
); |
| 596 |
} |
| 597 |
|
| 598 |
public function render() { |
| 599 |
$settings = $this->settings; |
| 600 |
|
| 601 |
$items = $settings['items']; |
| 602 |
// Wrapper. |
| 603 |
$wrapper_classes = array( 'ba-floating-wrapper', 'ba-floating-animation-' . $settings['animation'] ); |
| 604 |
$this->set_attribute( 'wrapper', 'class', $wrapper_classes ); |
| 605 |
|
| 606 |
?> |
| 607 |
<div <?php echo $this->render_attributes( 'wrapper' ); //phpcs:ignore ?>> |
| 608 |
<?php |
| 609 |
if ( count( $items ) ) { |
| 610 |
foreach ( $items as $index => $item ) { |
| 611 |
$content_image_classes = isset( $item['use_image'] ) && null !== $item['use_image'] || isset( $item['title'] ) && ! empty( $item['title'] ) ? 'ba-floating-image-title' : ''; |
| 612 |
$no_image_classes = null === $item['use_image'] ? 'ba-floating-no-image' : ''; |
| 613 |
$item_classes = array( 'ba-floating-item', 'repeater-item', $content_image_classes, $no_image_classes ); |
| 614 |
$temp_string = 'calc(500ms - '; |
| 615 |
$delay_animation = 'animation-delay: ' . $temp_string . $index . '000ms);'; |
| 616 |
$this->set_attribute( "floating-item-{$index}", 'class', $item_classes ); |
| 617 |
$this->set_attribute( "floating-item-{$index}", 'style', esc_attr( $delay_animation ) ); |
| 618 |
|
| 619 |
// Image. |
| 620 |
$image_atts = array(); |
| 621 |
$image_atts['id'] = isset( $image_atts['id'] ) ? 'image-' . $item['image']['id'] : ''; |
| 622 |
$item_image_classes = array( 'ba-floating-image', 'css-filter' ); |
| 623 |
$item_image_classes[] = isset( $item['image']['size'] ) ? 'size-' . $item['image']['size'] : ''; |
| 624 |
$image_atts['class'] = join( ' ', $item_image_classes ); |
| 625 |
$this->set_attribute( "floating-image-{$index}", 'class', $item_image_classes ); |
| 626 |
$this->set_attribute( "floating-image-{$index}", 'src', esc_url( $item['image']['url'] ) ); |
| 627 |
?> |
| 628 |
|
| 629 |
<div <?php echo $this->render_attributes( "floating-item-$index" ); //phpcs:ignore ?>> |
| 630 |
<?php |
| 631 |
if ( isset( $item['link'] ) ) { |
| 632 |
$this->set_link_attributes( "a-$index", $item['link'] ); |
| 633 |
echo '<a ' . $this->render_attributes( "a-$index" ) . '>'; //phpcs:ignore |
| 634 |
} |
| 635 |
if ( isset( $item['use_image'] ) && null !== $item['use_image'] ) { |
| 636 |
// Lazy load atts set via 'wp_get_attachment_image_attributes' filter. |
| 637 |
if ( isset( $item['image']['id'] ) ) { |
| 638 |
echo wp_get_attachment_image( $item['image']['id'], $item['image']['size'], false, $image_atts ); |
| 639 |
} elseif ( ! empty( $item['image']['url'] ) ) { |
| 640 |
echo '<img ' . $this->render_attributes( "floating-image-{$index}" ) . '>'; //phpcs:ignore |
| 641 |
} |
| 642 |
} |
| 643 |
|
| 644 |
// Title. |
| 645 |
if ( ( isset( $item['title'] ) && ! empty( $item['title'] ) ) || isset( $item['use_icon'] ) && null !== $item['use_icon'] ) { |
| 646 |
$title_tag = isset( $settings['title_tag'] ) ? esc_attr( $settings['title_tag'] ) : 'h4'; |
| 647 |
$title = isset( $item['title'] ) && ! empty( $item['title'] ) ? esc_html( $item['title'] ) : ''; |
| 648 |
$this->set_attribute( "title-$index", $title_tag ); |
| 649 |
$this->set_attribute( "title-$index", 'class', array( 'title' ) ); |
| 650 |
$this->set_attribute( "content-wrapper-$index", 'class', array( 'content-wrapper' ) ); |
| 651 |
|
| 652 |
// Icon. |
| 653 |
if ( isset( $item['icon']['icon'] ) ) { |
| 654 |
$this->set_attribute( |
| 655 |
"icon-{$index}", |
| 656 |
'class', |
| 657 |
array( |
| 658 |
'icon', |
| 659 |
$item['icon']['icon'], |
| 660 |
) |
| 661 |
); |
| 662 |
} |
| 663 |
$this->set_attribute( "icon-wrapper-$index", 'class', 'icon-wrapper' ); |
| 664 |
|
| 665 |
echo '<div ' . $this->render_attributes( "content-wrapper-{$index}" ) . '>'; //phpcs:ignore |
| 666 |
|
| 667 |
if ( isset( $item['icon']['icon'] ) && null !== $item['use_icon'] ) { |
| 668 |
echo '<div ' . $this->render_attributes( "icon-wrapper-{$index}" ) . '>'; //phpcs:ignore |
| 669 |
echo '<i ' . $this->render_attributes( "icon-{$index}" ) . '></i>'; //phpcs:ignore |
| 670 |
echo '</div>'; |
| 671 |
} |
| 672 |
echo '<div class="title-wrapper">'; |
| 673 |
echo '<' . $this->render_attributes( "title-$index" ) . '>' . esc_html( $title ) . '</' . esc_html( $title_tag ) . '>'; //phpcs:ignore |
| 674 |
echo '</div></div>'; |
| 675 |
} |
| 676 |
if ( isset( $item['link'] ) ) { |
| 677 |
echo '</a>'; |
| 678 |
} |
| 679 |
?> |
| 680 |
</div> |
| 681 |
|
| 682 |
<?php |
| 683 |
} |
| 684 |
?> |
| 685 |
<?php |
| 686 |
} else { |
| 687 |
esc_html_e( 'No items defined.', 'bricksable' ); |
| 688 |
} |
| 689 |
|
| 690 |
?> |
| 691 |
</div> |
| 692 |
<?php |
| 693 |
} |
| 694 |
} |
| 695 |
|