'#f4f5fa',
'card_color' => '#ffffff',
'text_color' => '#374151',
'accent_color' => '',
'font' => 'Helvetica, Arial, sans-serif',
'font_size' => 15,
'heading_size' => 20,
'radius' => 12,
'align' => 'left',
'shadow' => 'box-shadow:0 4px 16px rgba(15,23,42,0.08);',
'logo_height' => 40,
];
public static function wrap_template(string $content_html, string $heading = ''): string
{
$style = array_merge(self::STYLE, (array) apply_filters('funnelnode_email_style', []));
$branding = Settings::branding();
$site = (string) get_bloginfo('name');
$bg = (string) $style['bg_color'];
$card = (string) $style['card_color'];
$text = (string) $style['text_color'];
$accent = (string) $style['accent_color']
?: ((string) ($branding['primary_color'] ?? '') ?: '#6366f1');
$font = (string) $style['font'];
$size = (int) $style['font_size'];
$hsize = (int) $style['heading_size'];
$radius = (int) $style['radius'];
$align = 'center' === $style['align'] ? 'center' : 'left';
$shadow = (string) $style['shadow'];
$lheight = (int) $style['logo_height'];
$logo = (string) ($branding['logo_url'] ?? '');
$dim = '' !== $logo ? self::image_dimensions($logo) : null;
$lwidth = ($dim && $dim[1] > 0) ? (int) round($dim[0] * $lheight / $dim[1]) : 0;
$lmargin = 'center' === $align ? '0 auto' : '0';
$header = '' !== $logo
? '
0 ? ' width="' . $lwidth . '" height="' . $lheight . '"' : '')
. ' style="display:block;margin:' . $lmargin . ';border:0;outline:none;text-decoration:none;'
. 'width:' . ($lwidth > 0 ? $lwidth . 'px' : 'auto') . ';height:auto;max-height:' . $lheight . 'px;" />'
: '' . esc_html($site) . '';
$heading_html = '' !== $heading
? '
'
. esc_html($heading) . '
'
: '';
$content_html = (string) preg_replace('/'
. esc_html($site) . '';
}
return ''
. ''
. ''
. ''
. '| ' . $header . ' | '
. '| '
. $heading_html
. $content_html
. ' | '
. '| ' . $footer . ' | '
. ' |
';
}
public static function answers_table(array $rows): string
{
$out = '';
foreach ($rows as $index => $row) {
$border = 0 === $index ? '' : 'border-top:1px solid #e5e7eb;';
$out .= ''
. '| '
. esc_html($row['label']) . ' | '
. ''
. esc_html($row['value']) . ' | '
. '
';
}
return $out . '
';
}
public static function last_error(): string
{
return self::$last_error;
}
public static function configure_phpmailer(object $phpmailer): void
{
if (! self::$sending) {
return;
}
$email = Settings::all()['email'];
$from_email = (string) $email['from_email'];
$from_name = (string) $email['from_name'];
if ('' !== $from_email && is_email($from_email)) {
try {
$phpmailer->setFrom($from_email, $from_name ?: $from_email, false);
} catch (\Throwable) {
}
}
do_action('funnelnode_phpmailer_init', $phpmailer, $email);
}
private static function image_dimensions(string $url): ?array
{
$id = attachment_url_to_postid($url);
$path = '';
if ($id) {
$meta = wp_get_attachment_metadata($id);
if (is_array($meta) && ! empty($meta['width']) && ! empty($meta['height'])) {
return [(int) $meta['width'], (int) $meta['height']];
}
$path = (string) get_attached_file($id);
}
if ('' === $path || ! is_readable($path)) {
return null;
}
if (preg_match('/\.svg$/i', $path)) {
$svg = (string) file_get_contents($path);
if (preg_match('/