%3$s', $font, esc_attr($wt), dtq_resolve_icon_unicode($uni) ); } } } elseif (!empty($icon_image)) { $inner = sprintf( '%2$s', esc_url($icon_image), esc_attr($image_alt) ); } if (!empty($icon_value) || !empty($icon_image)) { return sprintf( '
%1$s
', $inner ); } return ''; } /** * Render the badge markup. * * @param array $advanced The `module.advanced` attrs array. * @return string */ public static function render_badge($advanced) { $badge_text = DynamicValue::resolve($advanced['badgeText']['desktop']['value'] ?? ''); if (empty($badge_text)) { return ''; } return sprintf( '
%1$s
', esc_html($badge_text) ); } /** * Server-side render for the IconBox module. * * `normal` and `absolute` mirror the D4 markup and the VB edit component * exactly: *
* [badge] [absolute icon] *
* [normal icon] [title] [description] *
*
* * `left`/`right` are a deliberate D5-only extension (D4 never had this * placement). They reuse the same markup but wrap title+description in a * `.dtq-iconbox__content` column so the icon can sit beside it in a flex * row (see edit.jsx for the matching VB markup): *
* [icon]
[title][description]
*
* * @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'] ?? []; $placement = $advanced['iconPlacement']['desktop']['value'] ?? 'normal'; $badge = self::render_badge($advanced); $icon = self::render_icon($advanced); $title = $elements->render(['attrName' => 'title']); // Divi skips an empty string itself, but a cleared rich text field can // leave "

" or "

 

", which printed an empty // .dtq-iconbox__desc that kept its margin (#112). $description = TextValue::any_visible($attrs['description']['innerContent'] ?? []) ? $elements->render(['attrName' => 'description']) : ''; $is_row = 'left' === $placement || 'right' === $placement; $inner_class = 'dtq-iconbox-inner dtq-bg-support' . ($is_row ? ' dtq-iconbox--' . $placement : ''); $content = $is_row ? sprintf('
%1$s%2$s
', $title, $description) : $title . $description; $children = sprintf( '
%1$s%2$s
%4$s%5$s
', $badge, 'absolute' === $placement ? $icon : '', esc_attr($inner_class), 'absolute' !== $placement ? $icon : '', $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, ], ] ); } }