markup.
*
* @param mixed $icon Icon value.
* @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 a logo 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'] ?? [];
$is_link = ($advanced['isLink']['desktop']['value'] ?? 'off') === 'on';
$overlay_on = ($advanced['overlayOnHover']['desktop']['value'] ?? 'off') === 'on';
// Logo image. The D5 upload field stores an object (`{ src, ... }`).
$logo_val = $attrs['logo']['innerContent']['desktop']['value'] ?? '';
$logo_src = is_array($logo_val) ? ($logo_val['src'] ?? '') : $logo_val;
$logo_alt = $attrs['logo']['advanced']['alt']['desktop']['value'] ?? '';
$img = '';
if (!empty($logo_src)) {
$img = sprintf(
'',
esc_url($logo_src),
esc_attr($logo_alt)
);
}
// Optional link wrapper. D4 stored target/nofollow in a single
// pipe-string `link_options` ("target|rel"); honour it as a fallback
// when the migrated D5 toggles aren't explicitly set.
if ($is_link) {
$legacy = explode('|', (string) ($advanced['linkOptions']['desktop']['value'] ?? ''));
$legacy_target = ($legacy[0] ?? 'off') === 'on';
$legacy_nf = ($legacy[1] ?? 'off') === 'on';
$url = DynamicValue::resolve($advanced['linkUrl']['desktop']['value'] ?? '');
$target = (($advanced['linkTarget']['desktop']['value'] ?? 'off') === 'on' || $legacy_target) ? ' target="_blank"' : '';
$nofollow = (($advanced['linkNofollow']['desktop']['value'] ?? 'off') === 'on' || $legacy_nf) ? ' rel="nofollow"' : '';
$logo = sprintf('%4$s', esc_url($url ?: '#'), $target, $nofollow, $img);
} else {
$logo = sprintf('