markup.
*
* @param mixed $icon Icon value: array { unicode, type, weight } or "unicode||type||weight".
* @param string $css_class Wrapper class.
*
* @return string
*/
public static function render_icon($icon, $css_class)
{
if (empty($icon)) {
return '';
}
if (is_array($icon)) {
$uni = $icon['unicode'] ?? '';
$type = $icon['type'] ?? 'divi';
$wt = $icon['weight'] ?? '400';
} else {
$parts = explode('||', (string) $icon);
$uni = $parts[0] ?? '';
$type = $parts[1] ?? 'divi';
$wt = $parts[2] ?? '400';
}
if ('' === $uni) {
return '';
}
$font = 'fa' === $type ? 'FontAwesome' : 'ETmodules';
if (function_exists('dtq_inject_fa_icons')) {
dtq_inject_fa_icons($uni . '||' . $type . '||' . $wt);
}
$glyph = function_exists('dtq_resolve_icon_unicode') ? dtq_resolve_icon_unicode($uni) : $uni;
return sprintf(
'%4$s',
esc_attr($css_class),
esc_attr($font),
esc_attr($wt),
esc_html($glyph)
);
}
/**
* Server-side render for the Image Carousel slide.
*
* @param array $attrs Block attributes.
* @param string $content Block content (unused).
* @param object $block Parsed block.
* @param object $elements Module elements helper.
*
* @return string
*/
public static function render_callback($attrs, $content, $block, $elements)
{
$advanced = $attrs['module']['advanced'] ?? [];
$card_preset = $advanced['cardPreset']['desktop']['value'] ?? 'custom';
$content_type = $advanced['contentType']['desktop']['value'] ?? 'normal';
$content_position = $advanced['contentPosition']['desktop']['value'] ?? 'bottom';
$content_alignment = $advanced['contentAlignment']['desktop']['value'] ?? 'left';
$image_hover_anim = $advanced['imageHoverAnimation']['desktop']['value'] ?? 'none';
$overlay_on_hover = $advanced['overlayOnHover']['desktop']['value'] ?? 'off';
$use_button = $advanced['useButton']['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'] ?? '';
$img = '';
// Pinch to Zoom and Parallax Captions are set on the carousel.
$slide_opts = CarouselEngine::slide_options(CarouselEngine::parent_advanced($block));
if (!empty($photo_src)) {
$img = sprintf(
'',
esc_url($photo_src),
esc_attr($photo_alt)
);
if ($slide_opts['zoom']) {
$img = '