| 1 |
<?php |
| 2 |
defined('ABSPATH') || exit; |
| 3 |
|
| 4 |
class Themify_Builder_Component_Subrow{ |
| 5 |
|
| 6 |
/** |
| 7 |
* Get template Sub-Row. |
| 8 |
* |
| 9 |
* @param array $mod |
| 10 |
* @param string $builder_id |
| 11 |
* @param boolean $echo |
| 12 |
*/ |
| 13 |
public static function template(array &$mod, $builder_id,bool $echo = true) { |
| 14 |
$mod = apply_filters('tf_builder_subrow', $mod, $builder_id); |
| 15 |
$print_sub_row_classes = array('module_subrow themify_builder_sub_row tf_w'); |
| 16 |
$subrow_tag_attrs = array(); |
| 17 |
$count = 0; |
| 18 |
$video_data = ''; |
| 19 |
$is_styling = !empty($mod['styling']); |
| 20 |
if ($is_styling === true) { |
| 21 |
if (!empty($mod['styling']['custom_css_subrow'])) { |
| 22 |
$print_sub_row_classes[] = $mod['styling']['custom_css_subrow']; |
| 23 |
} |
| 24 |
if (isset($mod['styling']['background_type'], $mod['styling']['background_zoom']) && $mod['styling']['background_type'] === 'image' && $mod['styling']['background_zoom'] === 'zoom' && $mod['styling']['background_repeat'] === 'repeat-none') { |
| 25 |
$print_sub_row_classes[] = 'themify-bg-zoom'; |
| 26 |
} |
| 27 |
// background video |
| 28 |
$video_data = Themify_Builder_Component_Row::get_video_background($mod['styling']); |
| 29 |
if ($video_data) { |
| 30 |
$video_data = ' ' . $video_data; |
| 31 |
} else { |
| 32 |
Themify_Builder_Component_Row::set_bg_mode($subrow_tag_attrs, $mod['styling']); |
| 33 |
} |
| 34 |
if (!empty($mod['styling']['global_styles'])) { |
| 35 |
Themify_Global_Styles::add_class_to_components($print_sub_row_classes, $mod['styling'], $builder_id); |
| 36 |
} |
| 37 |
} else { |
| 38 |
$mod['styling'] = array(); |
| 39 |
} |
| 40 |
if (Themify_Builder::$frontedit_active === false) { |
| 41 |
$display = apply_filters('themify_builder_subrow_display', true, $mod, $builder_id); |
| 42 |
if (false === $display || (isset($mod['styling']['visibility_all']) && $mod['styling']['visibility_all'] === 'hide_all' )) { |
| 43 |
return ''; |
| 44 |
} |
| 45 |
$count = !empty($mod['cols']) ? count($mod['cols']) : 0; |
| 46 |
if($count > 0 ){ |
| 47 |
$print_sub_row_classes=array_merge($print_sub_row_classes,Themify_Builder_Component_Row::get_responsive_cols($mod)); |
| 48 |
} |
| 49 |
$print_sub_row_classes[] = 'tb_' . $mod['element_id']; |
| 50 |
if ($is_styling === true) { |
| 51 |
Themify_Builder_Component_Module::sticky_element_props($subrow_tag_attrs, $mod['styling']); |
| 52 |
} |
| 53 |
$subrow_tag_attrs['data-lazy'] = 1; |
| 54 |
} |
| 55 |
$print_sub_row_classes = apply_filters('themify_builder_subrow_classes', $print_sub_row_classes, $mod, $builder_id); |
| 56 |
$subrow_tag_attrs['class'] = implode(' ', $print_sub_row_classes); |
| 57 |
$print_sub_row_classes = null; |
| 58 |
if ($is_styling === true) { |
| 59 |
Themify_Builder_Component_Row::clickable_component($subrow_tag_attrs,$mod['styling']); |
| 60 |
} |
| 61 |
$subrow_tag_attrs = apply_filters('themify_builder_subrow_attributes', Themify_Builder_Component_Module::parse_animation_effect($mod['styling'], $subrow_tag_attrs), $mod['styling'], $builder_id); |
| 62 |
|
| 63 |
if ($echo === false) { |
| 64 |
$output = PHP_EOL; // add line break |
| 65 |
ob_start(); |
| 66 |
} |
| 67 |
// Start Sub-Row Render ###### |
| 68 |
?> |
| 69 |
<div <?php echo themify_get_element_attributes($subrow_tag_attrs), $video_data; ?>> |
| 70 |
<?php |
| 71 |
$subrow_tag_attrs = $video_data = null; |
| 72 |
if ($is_styling === true) { |
| 73 |
Themify_Builder_Component_Row::background_styling($mod, 'subrow', $builder_id); |
| 74 |
} |
| 75 |
if ($count > 0) { |
| 76 |
if (isset($mod['desktop_dir']) && $mod['desktop_dir'] === 'rtl') {//backward compatibility |
| 77 |
$mod['cols'] = array_reverse($mod['cols']); |
| 78 |
} |
| 79 |
foreach ($mod['cols'] as $i => &$sub_col) { |
| 80 |
$cl = $i === 0 ? 'first' : ($i === ($count - 1) ? 'last' : null); //backward compatibility |
| 81 |
Themify_Builder_Component_Column::template($sub_col, $builder_id, true, true, $cl); |
| 82 |
} |
| 83 |
unset($sub_col); |
| 84 |
} |
| 85 |
if ($is_styling === true) {//always should be output after cols,otherwise grid can be broken |
| 86 |
do_action('themify_builder_background_styling', $builder_id, $mod, 'subrow', ''); |
| 87 |
} |
| 88 |
?> |
| 89 |
</div> |
| 90 |
<?php |
| 91 |
// End Sub-Row Render ###### |
| 92 |
if ($echo === false) { |
| 93 |
return PHP_EOL . ob_get_clean() . PHP_EOL; |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
|