| 1 |
<?php |
| 2 |
use Bricksable\Classes\Bricksable_Helpers; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
class Bricksable_Content_Toggle extends \Bricks\Element { |
| 9 |
public $category = 'bricksable'; |
| 10 |
public $name = 'ba-content-toggle'; |
| 11 |
public $icon = 'ti-layout-menu-separated'; |
| 12 |
public $scripts = array( 'bricksableContentToggle' ); |
| 13 |
|
| 14 |
public function get_label() { |
| 15 |
return esc_html__( 'Content Toggle', 'bricksable' ); |
| 16 |
} |
| 17 |
|
| 18 |
public function set_control_groups() { |
| 19 |
$this->control_groups['content'] = array( |
| 20 |
'title' => esc_html__( 'Tab Content', 'bricksable' ), |
| 21 |
'tab' => 'content', |
| 22 |
); |
| 23 |
|
| 24 |
$this->control_groups['switcher_settings'] = array( |
| 25 |
'title' => esc_html__( 'Switcher Settings', 'bricksable' ), |
| 26 |
'tab' => 'content', |
| 27 |
); |
| 28 |
|
| 29 |
$this->control_groups['label_settings'] = array( |
| 30 |
'title' => esc_html__( 'Label Settings', 'bricksable' ), |
| 31 |
'tab' => 'content', |
| 32 |
); |
| 33 |
|
| 34 |
$this->control_groups['content_settings'] = array( |
| 35 |
'title' => esc_html__( 'Content Settings', 'bricksable' ), |
| 36 |
'tab' => 'content', |
| 37 |
); |
| 38 |
} |
| 39 |
public function set_controls() { |
| 40 |
// Delete control '_typography'. |
| 41 |
unset( $this->controls['_typography'] ); |
| 42 |
|
| 43 |
$this->controls['content_toggle_item'] = array( |
| 44 |
'tab' => 'content', |
| 45 |
'group' => 'content', |
| 46 |
'label' => esc_html__( 'Content Toggle', 'bricksable' ), |
| 47 |
'type' => 'repeater', |
| 48 |
'titleProperty' => 'label', |
| 49 |
'placeholder' => esc_html__( 'Tab Content', 'bricksable' ), |
| 50 |
'fields' => array( |
| 51 |
'label' => array( |
| 52 |
'type' => 'text', |
| 53 |
'hasDynamicData' => 'text', |
| 54 |
), |
| 55 |
'content_type' => array( |
| 56 |
'label' => esc_html__( 'Content Type', 'bricksable' ), |
| 57 |
'type' => 'select', |
| 58 |
'options' => array( |
| 59 |
'content' => esc_html__( 'Content', 'bricksable' ), |
| 60 |
'templates' => esc_html__( 'Templates', 'bricksable' ), |
| 61 |
), |
| 62 |
'clearable' => false, |
| 63 |
'pasteStyles' => false, |
| 64 |
'placeholder' => esc_html__( 'Content', 'bricksable' ), |
| 65 |
), |
| 66 |
'content_template' => array( |
| 67 |
'label' => esc_html__( 'Template', 'bricksable' ), |
| 68 |
'type' => 'select', |
| 69 |
'options' => bricks_is_builder() ? Bricksable_Helpers::get_templates_list( get_the_ID() ) : array(), |
| 70 |
'searchable' => true, |
| 71 |
'placeholder' => esc_html__( 'Select template', 'bricksable' ), |
| 72 |
'required' => array( 'content_type', '=', 'templates' ), |
| 73 |
'description' => esc_html__( 'Note: A reload is required in order to get the styles of the template.', 'bricksable' ), |
| 74 |
), |
| 75 |
'content' => array( |
| 76 |
'label' => esc_html__( 'Content', 'bricksable' ), |
| 77 |
'type' => 'textarea', |
| 78 |
'hasDynamicData' => 'text', |
| 79 |
'required' => array( 'content_type', '=', 'content' ), |
| 80 |
), |
| 81 |
), |
| 82 |
'default' => array( |
| 83 |
array( |
| 84 |
'label' => esc_html__( 'Monthly', 'bricksable' ), |
| 85 |
'content_type' => 'content', |
| 86 |
'content' => 'Lorem ipsum dolor ist amte. Consectetuer adipiscing eilt. Aenean commodo ligula egget dolor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.', |
| 87 |
), |
| 88 |
array( |
| 89 |
'label' => esc_html__( 'Yearly', 'bricksable' ), |
| 90 |
'content_type' => 'content', |
| 91 |
'content' => 'Lorem ipsum dolor ist amte. Consectetuer adipiscing eilt. Aenean commodo ligula egget dolor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.', |
| 92 |
), |
| 93 |
), |
| 94 |
); |
| 95 |
|
| 96 |
$this->controls['toggle_style'] = array( |
| 97 |
'tab' => 'content', |
| 98 |
'group' => 'content', |
| 99 |
'label' => esc_html__( 'Toggle Style', 'bricksable' ), |
| 100 |
'type' => 'select', |
| 101 |
'options' => array( |
| 102 |
'animated' => esc_html__( 'Animated Tab Style', 'bricksable' ), |
| 103 |
'tab' => esc_html__( 'Normal Tab Style', 'bricksable' ), |
| 104 |
), |
| 105 |
'inline' => true, |
| 106 |
'reset' => true, |
| 107 |
'default' => 'animated', |
| 108 |
'placeholder' => esc_html__( 'Animated Tab Style', 'bricksable' ), |
| 109 |
); |
| 110 |
|
| 111 |
// Switcher. |
| 112 |
$this->controls['switcher_text_align'] = array( |
| 113 |
'tab' => 'content', |
| 114 |
'group' => 'switcher_settings', |
| 115 |
'label' => esc_html__( 'Text align', 'bricksable' ), |
| 116 |
'type' => 'text-align', |
| 117 |
'css' => array( |
| 118 |
array( |
| 119 |
'property' => 'text-align', |
| 120 |
'selector' => '.ba-content-toggle-wrapper', |
| 121 |
), |
| 122 |
), |
| 123 |
'default' => 'center', |
| 124 |
'inline' => true, |
| 125 |
'placeholder' => esc_html__( 'Center', 'bricksable' ), |
| 126 |
); |
| 127 |
|
| 128 |
$this->controls['switcher_background_color'] = array( |
| 129 |
'tab' => 'content', |
| 130 |
'group' => 'switcher_settings', |
| 131 |
'label' => esc_html__( 'Switcher Background Color', 'bricksable' ), |
| 132 |
'type' => 'color', |
| 133 |
'inline' => true, |
| 134 |
'small' => true, |
| 135 |
'css' => array( |
| 136 |
array( |
| 137 |
'property' => 'background-color', |
| 138 |
'selector' => '.ba-content-toggle-switcher', |
| 139 |
), |
| 140 |
), |
| 141 |
'default' => array( |
| 142 |
'hex' => '#f7f7fb', |
| 143 |
), |
| 144 |
'pasteStyles' => false, |
| 145 |
'description' => esc_html__( 'Define the switcher background color.', 'bricksable' ), |
| 146 |
); |
| 147 |
|
| 148 |
$this->controls['switcher_bottom_gap'] = array( |
| 149 |
'tab' => 'content', |
| 150 |
'group' => 'switcher_settings', |
| 151 |
'label' => esc_html__( 'Bottom Gap', 'bricksable' ), |
| 152 |
'type' => 'slider', |
| 153 |
'css' => array( |
| 154 |
array( |
| 155 |
'property' => 'margin-bottom', |
| 156 |
'selector' => '.ba-content-toggle-switcher', |
| 157 |
), |
| 158 |
), |
| 159 |
'units' => array( |
| 160 |
'px' => array( |
| 161 |
'min' => 1, |
| 162 |
'max' => 150, |
| 163 |
'step' => 1, |
| 164 |
), |
| 165 |
), |
| 166 |
'default' => '15px', |
| 167 |
'description' => esc_html__( 'Set the bottom gap distance between the switcher and content container.', 'bricksable' ), |
| 168 |
); |
| 169 |
|
| 170 |
$this->controls['switcher_border'] = array( |
| 171 |
'tab' => 'content', |
| 172 |
'group' => 'switcher_settings', |
| 173 |
'label' => esc_html__( 'Border', 'bricksable' ), |
| 174 |
'type' => 'border', |
| 175 |
'css' => array( |
| 176 |
array( |
| 177 |
'property' => 'border', |
| 178 |
'selector' => '.ba-content-toggle-switcher', |
| 179 |
), |
| 180 |
), |
| 181 |
'default' => array( |
| 182 |
'width' => array( |
| 183 |
'top' => 1, |
| 184 |
'right' => 1, |
| 185 |
'bottom' => 1, |
| 186 |
'left' => 1, |
| 187 |
), |
| 188 |
'style' => 'solid', |
| 189 |
'color' => array( |
| 190 |
'hex' => '#e5e5e5', |
| 191 |
), |
| 192 |
'radius' => array( |
| 193 |
'top' => 50, |
| 194 |
'right' => 50, |
| 195 |
'bottom' => 50, |
| 196 |
'left' => 50, |
| 197 |
), |
| 198 |
), |
| 199 |
'inline' => true, |
| 200 |
'small' => true, |
| 201 |
); |
| 202 |
$this->controls['switcher_box_shadow'] = array( |
| 203 |
'tab' => 'content', |
| 204 |
'group' => 'switcher_settings', |
| 205 |
'label' => esc_html__( 'Box Shadow', 'bricksable' ), |
| 206 |
'type' => 'box-shadow', |
| 207 |
'css' => array( |
| 208 |
array( |
| 209 |
'property' => 'box-shadow', |
| 210 |
'selector' => '.ba-content-toggle-switcher', |
| 211 |
), |
| 212 |
), |
| 213 |
); |
| 214 |
$this->controls['switcher_padding'] = array( |
| 215 |
'tab' => 'content', |
| 216 |
'group' => 'switcher_settings', |
| 217 |
'label' => esc_html__( 'Padding', 'bricksable' ), |
| 218 |
'type' => 'dimensions', |
| 219 |
'css' => array( |
| 220 |
array( |
| 221 |
'property' => 'padding', |
| 222 |
'selector' => '.ba-content-toggle-switcher', |
| 223 |
), |
| 224 |
), |
| 225 |
'default' => array( |
| 226 |
'top' => 5, |
| 227 |
'right' => 5, |
| 228 |
'bottom' => 5, |
| 229 |
'left' => 5, |
| 230 |
), |
| 231 |
); |
| 232 |
|
| 233 |
// Label. |
| 234 |
$this->controls['label_active_background'] = array( |
| 235 |
'tab' => 'content', |
| 236 |
'group' => 'label_settings', |
| 237 |
'label' => esc_html__( 'Label Active Background', 'bricksable' ), |
| 238 |
'type' => 'background', |
| 239 |
'css' => array( |
| 240 |
array( |
| 241 |
'property' => 'background', |
| 242 |
'selector' => '.ba-content-toggle-slider, .ba-content-toggle-style-tab .ba-content-toggle-item.active', |
| 243 |
), |
| 244 |
), |
| 245 |
'exclude' => array( |
| 246 |
'parallax', |
| 247 |
'attachment', |
| 248 |
'videoUrl', |
| 249 |
'videoScale', |
| 250 |
), |
| 251 |
'inline' => true, |
| 252 |
'small' => true, |
| 253 |
'default' => array( |
| 254 |
'color' => array( |
| 255 |
'hex' => '#29b5a8', |
| 256 |
), |
| 257 |
), |
| 258 |
); |
| 259 |
$this->controls['label_active_typography'] = array( |
| 260 |
'tab' => 'content', |
| 261 |
'group' => 'label_settings', |
| 262 |
'label' => esc_html__( 'Label Active Typography', 'bricksable' ), |
| 263 |
'type' => 'typography', |
| 264 |
'css' => array( |
| 265 |
array( |
| 266 |
'property' => 'typography', |
| 267 |
'selector' => '.ba-content-toggle-item.active .ba-content-label-title', |
| 268 |
), |
| 269 |
), |
| 270 |
'default' => array( |
| 271 |
'color' => array( |
| 272 |
'hex' => '#ffffff', |
| 273 |
), |
| 274 |
), |
| 275 |
'rerender' => true, |
| 276 |
'inline' => true, |
| 277 |
); |
| 278 |
$this->controls['label_typography'] = array( |
| 279 |
'tab' => 'content', |
| 280 |
'group' => 'label_settings', |
| 281 |
'label' => esc_html__( 'Label Typography', 'bricksable' ), |
| 282 |
'type' => 'typography', |
| 283 |
'css' => array( |
| 284 |
array( |
| 285 |
'property' => 'typography', |
| 286 |
'selector' => '.ba-content-toggle-item .ba-content-label-title', |
| 287 |
), |
| 288 |
), |
| 289 |
'inline' => true, |
| 290 |
'rerender' => true, |
| 291 |
); |
| 292 |
$this->controls['label_padding'] = array( |
| 293 |
'tab' => 'content', |
| 294 |
'group' => 'label_settings', |
| 295 |
'label' => esc_html__( 'Label Padding', 'bricksable' ), |
| 296 |
'type' => 'dimensions', |
| 297 |
'css' => array( |
| 298 |
array( |
| 299 |
'property' => 'padding', |
| 300 |
'selector' => '.ba-content-toggle-item', |
| 301 |
), |
| 302 |
), |
| 303 |
'default' => array( |
| 304 |
'top' => 7, |
| 305 |
'right' => 15, |
| 306 |
'bottom' => 7, |
| 307 |
'left' => 15, |
| 308 |
), |
| 309 |
); |
| 310 |
|
| 311 |
// Content Settings. |
| 312 |
$this->controls['content_animationSeparator'] = array( |
| 313 |
'type' => 'separator', |
| 314 |
'tab' => 'content', |
| 315 |
'group' => 'content_settings', |
| 316 |
'label' => esc_html__( 'Animation', 'bricksable' ), |
| 317 |
); |
| 318 |
|
| 319 |
$this->controls['content_animation'] = array( |
| 320 |
'tab' => 'content', |
| 321 |
'group' => 'content_settings', |
| 322 |
'label' => esc_html__( 'Entry animation', 'bricksable' ), |
| 323 |
'type' => 'select', |
| 324 |
'searchable' => true, |
| 325 |
'options' => array( |
| 326 |
'bounce' => esc_html__( 'bounce', 'bricksable' ), |
| 327 |
'flash' => esc_html__( 'flash', 'bricksable' ), |
| 328 |
'pulse' => esc_html__( 'pulse', 'bricksable' ), |
| 329 |
'rubberBand' => esc_html__( 'rubberBand', 'bricksable' ), |
| 330 |
'shake' => esc_html__( 'shake', 'bricksable' ), |
| 331 |
'swing' => esc_html__( 'swing', 'bricksable' ), |
| 332 |
'tada' => esc_html__( 'tada', 'bricksable' ), |
| 333 |
'wobble' => esc_html__( 'wobble', 'bricksable' ), |
| 334 |
'jello' => esc_html__( 'jello', 'bricksable' ), |
| 335 |
'bounceIn' => esc_html__( 'bounceIn', 'bricksable' ), |
| 336 |
'bounceInDown' => esc_html__( 'bounceInDown', 'bricksable' ), |
| 337 |
'bounceInLeft' => esc_html__( 'bounceInLeft', 'bricksable' ), |
| 338 |
'bounceInRight' => esc_html__( 'bounceInRight', 'bricksable' ), |
| 339 |
'bounceInUp' => esc_html__( 'bounceInUp', 'bricksable' ), |
| 340 |
'fadeIn' => esc_html__( 'fadeIn', 'bricksable' ), |
| 341 |
'fadeInDown' => esc_html__( 'fadeInDown', 'bricksable' ), |
| 342 |
'fadeInDownBig' => esc_html__( 'fadeInDownBig', 'bricksable' ), |
| 343 |
'fadeInLeft' => esc_html__( 'fadeInLeft', 'bricksable' ), |
| 344 |
'fadeInLeftBig' => esc_html__( 'fadeInLeftBig', 'bricksable' ), |
| 345 |
'fadeInRight' => esc_html__( 'fadeInRight', 'bricksable' ), |
| 346 |
'fadeInRightBig' => esc_html__( 'fadeInRightBig', 'bricksable' ), |
| 347 |
'fadeInUp' => esc_html__( 'fadeInUp', 'bricksable' ), |
| 348 |
'fadeInUpBig' => esc_html__( 'fadeInUpBig', 'bricksable' ), |
| 349 |
'flip' => esc_html__( 'flip', 'bricksable' ), |
| 350 |
'flipInX' => esc_html__( 'flipInX', 'bricksable' ), |
| 351 |
'flipInY' => esc_html__( 'flipInY', 'bricksable' ), |
| 352 |
'lightSpeedIn' => esc_html__( 'lightSpeedIn', 'bricksable' ), |
| 353 |
'rotateIn' => esc_html__( 'rotateIn', 'bricksable' ), |
| 354 |
'rotateInDownLeft' => esc_html__( 'rotateInDownLeft', 'bricksable' ), |
| 355 |
'rotateInDownRight' => esc_html__( 'rotateInDownRight', 'bricksable' ), |
| 356 |
'rotateInUpLeft' => esc_html__( 'rotateInUpLeft', 'bricksable' ), |
| 357 |
'rotateInUpRight' => esc_html__( 'rotateInUpRight', 'bricksable' ), |
| 358 |
'slideInUp' => esc_html__( 'slideInUp', 'bricksable' ), |
| 359 |
'slideInDown' => esc_html__( 'slideInDown', 'bricksable' ), |
| 360 |
'slideInLeft' => esc_html__( 'slideInLeft', 'bricksable' ), |
| 361 |
'slideInRight' => esc_html__( 'slideInRight', 'bricksable' ), |
| 362 |
'zoomIn' => esc_html__( 'zoomIn', 'bricksable' ), |
| 363 |
'zoomInDown' => esc_html__( 'zoomInDown', 'bricksable' ), |
| 364 |
'zoomInLeft' => esc_html__( 'zoomInLeft', 'bricksable' ), |
| 365 |
'zoomInRight' => esc_html__( 'zoomInRight', 'bricksable' ), |
| 366 |
'zoomInUp' => esc_html__( 'zoomInUp', 'bricksable' ), |
| 367 |
'jackInTheBox' => esc_html__( 'jackInTheBox', 'bricksable' ), |
| 368 |
'rollIn' => esc_html__( 'rollIn', 'bricksable' ), |
| 369 |
), |
| 370 |
'inline' => true, |
| 371 |
'default' => 'fadeIn', |
| 372 |
'placeholder' => esc_html__( 'fadeIn', 'bricksable' ), |
| 373 |
); |
| 374 |
|
| 375 |
$this->controls['content_animationDuration'] = array( |
| 376 |
'tab' => 'content', |
| 377 |
'group' => 'content_settings', |
| 378 |
'label' => esc_html__( 'Animation duration', 'bricksable' ), |
| 379 |
'type' => 'select', |
| 380 |
'searchable' => true, |
| 381 |
'options' => array( |
| 382 |
'very-slow' => esc_html__( 'Very slow', 'bricksable' ), |
| 383 |
'slow' => esc_html__( 'Slow', 'bricksable' ), |
| 384 |
'normal' => esc_html__( 'Normal', 'bricksable' ), |
| 385 |
'fast' => esc_html__( 'Fast', 'bricksable' ), |
| 386 |
'very-fast' => esc_html__( 'Very fast', 'bricksable' ), |
| 387 |
'custom' => esc_html__( 'Custom', 'bricksable' ), |
| 388 |
), |
| 389 |
'inline' => true, |
| 390 |
'placeholder' => esc_html__( 'Normal', 'bricksable' ) . ' (1s)', |
| 391 |
'required' => array( 'content_animation', '!=', '' ), |
| 392 |
); |
| 393 |
|
| 394 |
$this->controls['content_animationDurationCustom'] = array( |
| 395 |
'tab' => 'content', |
| 396 |
'group' => 'content_settings', |
| 397 |
'label' => esc_html__( 'Animation duration', 'bricksable' ) . ' (' . esc_html__( 'Custom', 'bricksable' ) . ')', |
| 398 |
'type' => 'text', |
| 399 |
'css' => array( |
| 400 |
array( |
| 401 |
'property' => 'animation-duration', |
| 402 |
'selector' => '.ba-content-toggle-tab-item', |
| 403 |
), |
| 404 |
), |
| 405 |
'description' => esc_html__( 'For example: "1s" or "500ms"', 'bricksable' ), |
| 406 |
'inline' => true, |
| 407 |
'required' => array( 'content_animationDuration', '=', 'custom' ), |
| 408 |
); |
| 409 |
|
| 410 |
$this->controls['content_animationDelay'] = array( |
| 411 |
'tab' => 'content', |
| 412 |
'group' => 'content_settings', |
| 413 |
'label' => esc_html__( 'Animation delay', 'bricksable' ), |
| 414 |
'type' => 'text', |
| 415 |
'css' => array( |
| 416 |
array( |
| 417 |
'property' => 'animation-delay', |
| 418 |
'selector' => '.ba-content-toggle-tab-item', |
| 419 |
), |
| 420 |
), |
| 421 |
'inline' => true, |
| 422 |
'description' => esc_html__( 'For example: "1s" or "500ms" or "-2.5s"', 'bricksable' ), |
| 423 |
'placeholder' => 0, |
| 424 |
'required' => array( 'content_animation', '!=', '' ), |
| 425 |
); |
| 426 |
} |
| 427 |
|
| 428 |
public function enqueue_scripts() { |
| 429 |
if ( '' === get_option( 'bricksable_combine_minify_js' ) || false === get_option( 'bricksable_combine_minify_js' ) ) { |
| 430 |
wp_enqueue_script( 'ba-content-toggle' ); |
| 431 |
} |
| 432 |
} |
| 433 |
|
| 434 |
public function render() { |
| 435 |
$settings = $this->settings; |
| 436 |
|
| 437 |
$wrapper_classes = array( |
| 438 |
'ba-content-toggle-wrapper', |
| 439 |
); |
| 440 |
|
| 441 |
$this->set_attribute( 'wrapper', 'div' ); |
| 442 |
$this->set_attribute( 'wrapper', 'class', $wrapper_classes ); |
| 443 |
|
| 444 |
// Render. |
| 445 |
//phpcs:ignore |
| 446 |
$output = '<' . $this->render_attributes( 'wrapper' ) . '>'; |
| 447 |
|
| 448 |
$toggle_style = isset( $settings['toggle_style'] ) ? $settings['toggle_style'] : 'animated'; |
| 449 |
|
| 450 |
$label_classes = array( |
| 451 |
'ba-content-toggle-switcher', |
| 452 |
'ba-content-toggle-style-' . $settings['toggle_style'], |
| 453 |
); |
| 454 |
|
| 455 |
$this->set_attribute( 'label-wrapper', 'div' ); |
| 456 |
$this->set_attribute( 'label-wrapper', 'class', $label_classes ); |
| 457 |
|
| 458 |
$output .= '<' . $this->render_attributes( 'label-wrapper' ) . '>'; |
| 459 |
|
| 460 |
foreach ( $settings['content_toggle_item'] as $index => $item ) { |
| 461 |
$content_toggle_item_classes = array( |
| 462 |
'ba-content-toggle-item', |
| 463 |
); |
| 464 |
if ( 0 === $index ) { |
| 465 |
$content_toggle_item_classes[] = 'active'; |
| 466 |
$content_toggle_item_aria = 'true'; |
| 467 |
} else { |
| 468 |
$content_toggle_item_aria = 'false'; |
| 469 |
} |
| 470 |
|
| 471 |
$this->set_attribute( "content-toggle-item-$index", 'div' ); |
| 472 |
$this->set_attribute( "content-toggle-item-$index", 'aria-hidden', $content_toggle_item_aria ); |
| 473 |
$this->set_attribute( "content-toggle-item-$index", 'class', $content_toggle_item_classes ); |
| 474 |
|
| 475 |
$content_toggle_label_title_classes = array( |
| 476 |
'ba-content-label-title', |
| 477 |
); |
| 478 |
|
| 479 |
$this->set_attribute( "content-toggle-label-title-$index", 'span' ); |
| 480 |
$this->set_attribute( "content-toggle-label-title-$index", 'class', $content_toggle_label_title_classes ); |
| 481 |
|
| 482 |
// Label. |
| 483 |
if ( isset( $item['label'] ) ) { |
| 484 |
$output .= '<' . $this->render_attributes( "content-toggle-item-$index" ) . '><' . $this->render_attributes( "content-toggle-label-title-$index" ) . '>' . $item['label'] . '</span></div>'; |
| 485 |
} |
| 486 |
} |
| 487 |
// Slider. |
| 488 |
if ( 'animated' === $settings['toggle_style'] ) { |
| 489 |
$output .= '<div class="ba-content-toggle-slider"></div>'; |
| 490 |
} |
| 491 |
|
| 492 |
$output .= '</div>'; |
| 493 |
$output .= '</div>'; |
| 494 |
|
| 495 |
// Content. |
| 496 |
$content_wrapper_classes = array( |
| 497 |
'ba-content-toggle-tab', |
| 498 |
); |
| 499 |
|
| 500 |
$this->set_attribute( 'content-wrapper', 'div' ); |
| 501 |
$this->set_attribute( 'content-wrapper', 'class', $content_wrapper_classes ); |
| 502 |
|
| 503 |
$output .= '<' . $this->render_attributes( 'content-wrapper' ) . '>'; |
| 504 |
foreach ( $settings['content_toggle_item'] as $index => $item ) { |
| 505 |
$content_toggle_tab_classes = array( |
| 506 |
'ba-content-toggle-tab-item', |
| 507 |
isset( $settings['content_animationDuration'] ) && '' !== $settings['content_animationDuration'] ? 'animation-duration-' . $settings['content_animationDuration'] : '', |
| 508 |
); |
| 509 |
|
| 510 |
if ( 0 === $index ) { |
| 511 |
$content_toggle_tab_classes[] = 'show-content'; |
| 512 |
$content_toggle_tab_aria = 'true'; |
| 513 |
} else { |
| 514 |
$content_toggle_tab_aria = 'false'; |
| 515 |
} |
| 516 |
|
| 517 |
$this->set_attribute( "content-toggle-tab-$index", 'div' ); |
| 518 |
$this->set_attribute( "content-toggle-tab-$index", 'class', $content_toggle_tab_classes ); |
| 519 |
$this->set_attribute( "content-toggle-tab-$index", 'aria-hidden', $content_toggle_tab_aria ); |
| 520 |
if ( isset( $settings['content_animation'] ) && '' !== $settings['content_animation'] ) { |
| 521 |
$this->set_attribute( "content-toggle-tab-$index", 'data-animation', $settings['content_animation'] ); |
| 522 |
} |
| 523 |
|
| 524 |
$output .= '<' . $this->render_attributes( "content-toggle-tab-$index" ) . '>'; |
| 525 |
|
| 526 |
// Template. |
| 527 |
if ( isset( $item['content_type'] ) && 'templates' === $item['content_type'] ) { |
| 528 |
|
| 529 |
$template_id = ! empty( $item['content_template'] ) ? intval( $item['content_template'] ) : false; |
| 530 |
if ( ! $template_id ) { |
| 531 |
return $this->render_element_placeholder( |
| 532 |
array( |
| 533 |
'title' => esc_html__( 'No template selected.', 'bricksable' ), |
| 534 |
) |
| 535 |
); |
| 536 |
} |
| 537 |
|
| 538 |
$output .= do_shortcode( '[bricks_template id="' . $template_id . '" ]' ); |
| 539 |
} else { |
| 540 |
if ( isset( $item['content'] ) ) { |
| 541 |
$output .= $item['content']; |
| 542 |
} |
| 543 |
} |
| 544 |
|
| 545 |
$output .= '</div>'; |
| 546 |
} |
| 547 |
|
| 548 |
$output .= '</div>'; |
| 549 |
|
| 550 |
//phpcs:ignore |
| 551 |
echo $output; |
| 552 |
|
| 553 |
} |
| 554 |
} |
| 555 |
|