| 1 |
<?php |
| 2 |
defined('ABSPATH') || exit; |
| 3 |
|
| 4 |
class Themify_Builder_Component_Column{ |
| 5 |
|
| 6 |
/** |
| 7 |
* Get template column. |
| 8 |
* |
| 9 |
* @param array $col |
| 10 |
* @param string $builder_id |
| 11 |
* @param boolean $echo |
| 12 |
*/ |
| 13 |
public static function template(array &$col, $builder_id,bool $echo = true,bool $is_SubCol = false, $cl = null) { |
| 14 |
$print_column_classes = array('module_column'); |
| 15 |
$print_column_classes[] = $is_SubCol === false ? 'tb-column' : 'sub_column'; |
| 16 |
if (isset($col['grid_class'])) { |
| 17 |
$print_column_classes[] = strtr($col['grid_class'], array('first' => '', 'last' => '')); |
| 18 |
} |
| 19 |
$column_tag_attrs = array(); |
| 20 |
$is_styling = !empty($col['styling']); |
| 21 |
$video_data = ''; |
| 22 |
if (Themify_Builder::$frontedit_active === false) { |
| 23 |
$print_column_classes[] = 'tb_' . $col['element_id']; |
| 24 |
$column_tag_attrs['data-lazy'] = 1; |
| 25 |
} |
| 26 |
if ($is_styling === true) { |
| 27 |
if (!empty($col['styling']['global_styles'])) { |
| 28 |
Themify_Global_Styles::add_class_to_components($print_column_classes, $col['styling'], $builder_id); |
| 29 |
} |
| 30 |
if (isset($col['styling']['background_type'], $col['styling']['background_zoom']) && $col['styling']['background_type'] === 'image' && $col['styling']['background_zoom'] === 'zoom' && $col['styling']['background_repeat'] === 'repeat-none') { |
| 31 |
$print_column_classes[] = 'themify-bg-zoom'; |
| 32 |
} |
| 33 |
if (!empty($col['styling']['custom_css_column'])) { |
| 34 |
$print_column_classes[] = themify_sanitize_css_classes( $col['styling']['custom_css_column'] ); |
| 35 |
} |
| 36 |
// background video |
| 37 |
$video_data = Themify_Builder_Component_Row::get_video_background($col['styling']); |
| 38 |
if ($video_data) { |
| 39 |
$video_data = ' ' . $video_data; |
| 40 |
} else { |
| 41 |
Themify_Builder_Component_Row::set_bg_mode($column_tag_attrs, $col['styling']); |
| 42 |
} |
| 43 |
} |
| 44 |
if ($cl !== null) { |
| 45 |
$print_column_classes[] = $cl; |
| 46 |
} |
| 47 |
$column_tag_attrs['class'] = implode(' ', $print_column_classes); |
| 48 |
if ($is_styling === true) { |
| 49 |
Themify_Builder_Component_Row::clickable_component($column_tag_attrs,$col['styling']); |
| 50 |
} |
| 51 |
unset($print_column_classes); |
| 52 |
if ($echo === false) { |
| 53 |
ob_start(); |
| 54 |
} |
| 55 |
// Start Column Render ###### |
| 56 |
?> |
| 57 |
<div <?php echo themify_get_element_attributes($column_tag_attrs), $video_data; ?>> |
| 58 |
<?php |
| 59 |
$column_tag_attrs = $video_data = null; |
| 60 |
if ($is_styling === true) { |
| 61 |
do_action('themify_builder_background_styling', $builder_id, $col, 'column', ''); |
| 62 |
Themify_Builder_Component_Row::background_styling($col, 'column', $builder_id); |
| 63 |
} |
| 64 |
?> |
| 65 |
<?php if (!empty($col['modules'])){ |
| 66 |
foreach ($col['modules'] as &$mod) { |
| 67 |
if (isset($mod['mod_name'])) { |
| 68 |
Themify_Builder_Component_Module::template($mod, $builder_id); |
| 69 |
} |
| 70 |
if (!empty($mod['cols'])) {// Check for Sub-rows |
| 71 |
Themify_Builder_Component_SubRow::template($mod, $builder_id); |
| 72 |
} |
| 73 |
} |
| 74 |
unset($mod); |
| 75 |
} ?> |
| 76 |
</div> |
| 77 |
<?php |
| 78 |
// End Column Render ###### |
| 79 |
|
| 80 |
if ($echo === false) { |
| 81 |
return PHP_EOL . ob_get_clean() . PHP_EOL; |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|