getOneColumnTemplate($styles, $class) : $this->getMultipleColumnsTemplate($styles, $width, $alignment, $class); $result = array_map(function($content) use ($template) { $content = self::removePaddingFromLastElement($content); return $template['content_start'] . $content . $template['content_end']; }, $columns_data); $result = implode('', $result); if($columns_count !== 1) { $result = $template['container_start'] . $result . $template['container_end']; } return $result; } function getOneColumnTemplate($styles, $class) { $background_color = $this->getBackgroundColor($styles); $template['content_start'] = '
'; $template['content_end'] = '
'; return $template; } function getMultipleColumnsTemplate($styles, $width, $alignment, $class) { $background_color = $this->getBackgroundColor($styles); $template['container_start'] = '
'; $template['content_end'] = '
'; return $template; } function removePaddingFromLastElement($element) { return preg_replace('/mailpoet_padded_bottom(?!.*mailpoet_padded_bottom)/ism', '', $element); } function getBackgroundColor($styles) { if(!isset($styles['backgroundColor'])) return false; $background_color = $styles['backgroundColor']; return ($background_color !== 'transparent') ? sprintf('background-color:%s!important;" bgcolor="%s', $background_color, $background_color) : false; } }