'website', 'icon' => 'website'],
['type' => 'email', 'icon' => 'email'],
['type' => 'facebook', 'icon' => 'facebook'],
['type' => 'twitter', 'icon' => 'twitter'],
['type' => 'linkedin', 'icon' => 'linkedin'],
['type' => 'instagram', 'icon' => 'instagram'],
['type' => 'github', 'icon' => 'github'],
['type' => 'behance', 'icon' => 'behance'],
['type' => 'dribbble', 'icon' => 'dribbble'],
];
$html = '';
$is_empty = true;
foreach ($links as $item) {
// Nine social URLs, all dynamic-content capable, read by a loop
// variable -- a name-based sweep cannot see them. Resolving here
// also repairs the empty() gate below: an unresolved structure is
// a non-empty array, so a blank dynamic value used to render.
$value = DynamicValue::resolve($advanced[$item['type']]['desktop']['value'] ?? '');
if (empty($value)) {
continue;
}
$is_empty = false;
$icon = $icons[$item['icon']] ?? '';
$href_prefix = ('email' === $item['type']) ? 'mailto:' : '';
$href = ('email' === $item['type']) ? sanitize_email($value) : esc_url($value);
$html .= sprintf(
'
%1$s',
$icon,
$href,
esc_html($href_prefix)
);
}
if ($is_empty) {
return '';
}
return sprintf(
'',
esc_attr($content_alignment),
$html
);
}
/**
* Server-side render for the TeamBox module.
*
* @param array $attrs Block attributes.
* @param string $content Block content (unused).
* @param WP_Block $block Parsed block.
* @param ModuleElements $elements Module elements helper.
*
* @return string
*/
public static function render_callback($attrs, $content, $block, $elements)
{
$advanced = $attrs['module']['advanced'] ?? [];
$content_on_hover = $advanced['contentOnHover']['desktop']['value'] ?? 'off';
$hover_style = $advanced['hoverStyle']['desktop']['value'] ?? 'hover_1';
$links_position = $advanced['linksPosition']['desktop']['value'] ?? 'content';
$photo_animation = $advanced['photoHoverAnimation']['desktop']['value'] ?? 'none';
$content_alignment = $advanced['contentAlignment']['desktop']['value'] ?? 'left';
$overlay_on_hover = $advanced['overlayOnHover']['desktop']['value'] ?? 'off';
// Photo. The D5 upload field stores the image as an object
// (`{ src, ... }`); accept both that and a plain URL string.
$photo_val = $attrs['photo']['innerContent']['desktop']['value'] ?? '';
$photo_src = is_array($photo_val) ? ($photo_val['src'] ?? '') : $photo_val;
$photo_alt = $attrs['photo']['advanced']['alt']['desktop']['value'] ?? '';
$photo = '';
if (!empty($photo_src)) {
// "Open Photo in Lightbox" was a declared option that emitted nothing.
// Use the same class/data hooks Review does (`.dtq-lightbox` +
// `data-mfp-src`), which src/divi5/frontend.js already binds magnific
// popup to, and load the library on the front end only.
$use_lightbox = ($advanced['useLightbox']['desktop']['value'] ?? 'off') === 'on';
$lightbox_class = '';
$lightbox_data = '';
if ($use_lightbox) {
$lightbox_class = ' dtq-lightbox';
$lightbox_data = sprintf(' data-mfp-src="%s"', esc_url($photo_src));
if (function_exists('wp_enqueue_script')) {
wp_enqueue_script('divi-torque-lite-magnific-popup');
wp_enqueue_style('divi-torque-lite-magnific-popup');
}
}
$photo = sprintf(
'
',
esc_url($photo_src),
esc_attr($photo_alt),
esc_attr($lightbox_class),
$lightbox_data
);
}
// Texts.
$member_name = $elements->render(['attrName' => 'memberName']);
$job_title = $elements->render(['attrName' => 'jobTitle']);
$short_bio = $elements->render(['attrName' => 'shortBio']);
// Classes.
$classes = ['dtq-module', 'dtq-team', 'dtq-bg-support', 'dtq-swapped-img-selector'];
if ('on' === $content_on_hover) {
$classes[] = $hover_style;
}
$classes[] = 'dtq-hover--' . $photo_animation;
// Overlay markup.
$overlay = '';
if ('on' === $overlay_on_hover) {
$overlay_icon = $advanced['overlayIcon']['desktop']['value'] ?? '';
$overlay_glyph = '';
if (!empty($overlay_icon)) {
if (is_array($overlay_icon)) {
$uni = $overlay_icon['unicode'] ?? '';
$type = $overlay_icon['type'] ?? 'divi';
$wt = $overlay_icon['weight'] ?? '400';
} else {
$parts = explode('||', (string) $overlay_icon);
$uni = $parts[0] ?? '';
$type = $parts[1] ?? 'divi';
$wt = $parts[2] ?? '400';
}
if ('' !== $uni) {
$font = 'fa' === $type ? 'FontAwesome' : 'ETmodules';
dtq_inject_fa_icons($uni . '||' . $type . '||' . $wt);
$overlay_glyph = sprintf(
'%3$s',
esc_attr($font),
esc_attr($wt),
dtq_resolve_icon_unicode($uni)
);
}
}
$overlay = sprintf(
'%1$s
',
$overlay_glyph
);
}
// Social links — placed near photo or content based on settings.
$links_for_photo = ('off' === $content_on_hover && 'photo' === $links_position)
? self::render_links($advanced, $content_alignment)
: '';
$links_for_content = ('on' === $content_on_hover || 'content' === $links_position)
? self::render_links($advanced, $content_alignment)
: '';
$children = sprintf(
'',
esc_attr(implode(' ', $classes)),
$links_for_photo,
$overlay,
$photo,
esc_attr($content_alignment),
$member_name,
$job_title,
$short_bio,
$links_for_content
);
return Module::render(
[
'attrs' => $attrs,
'elements' => $elements,
'id' => $block->parsed_block['id'],
'name' => $block->block_type->name,
'moduleCategory' => $block->block_type->category,
'classnamesFunction' => [self::class, 'module_classnames'],
'stylesComponent' => [self::class, 'module_styles'],
'scriptDataComponent' => [self::class, 'module_script_data'],
'orderIndex' => $block->parsed_block['orderIndex'] ?? 0,
'storeInstance' => $block->parsed_block['storeInstance'] ?? null,
'children' => [
// Background pattern/mask and the box-shadow overlay are DOM,
// not CSS. Without this call Divi renders them in the builder
// and nowhere else, so the options silently do nothing on the
// front end.
$elements->style_components(['attrName' => 'module']),
$children,
],
]
);
}
}