$prop) { if (!is_array($prop)) { $resolved[$key] = $prop; continue; } $type = $prop['type'] ?? 'static'; if ($type === 'static') { $resolved[$key] = $prop['value'] ?? ''; } elseif ($type === 'dynamic' && $post_data) { $source = $prop['source'] ?? ''; $resolved[$key] = PlaceholderRenderer::get_value($source, $post_data); } else { $resolved[$key] = $prop['value'] ?? ''; } } return $resolved; } // ======================================== // Section Renderers // ======================================== /** * Render Hero section */ public static function render_hero($props, $layout, $color_scheme, $id) { $title = esc_html($props['title'] ?? ''); $subtitle = esc_html($props['subtitle'] ?? ''); $image = esc_url($props['image'] ?? ''); $cta_text = esc_html($props['cta_text'] ?? ''); $cta_url = esc_url($props['cta_url'] ?? ''); $html = "
"; if ($image) { $html .= "\"{$title}\""; } $html .= '
'; if ($title) { $html .= "

{$title}

"; } if ($subtitle) { $html .= "

{$subtitle}

"; } if ($cta_text && $cta_url) { $html .= "{$cta_text}"; } $html .= '
'; $html .= '
'; return $html; } /** * Render Content section (for post body, rich text) */ public static function render_content($props, $layout, $color_scheme, $id) { $content = $props['content'] ?? ''; // Apply WordPress content filters (shortcodes, autop, etc.) $content = apply_filters('the_content', $content); return "
{$content}
"; } /** * Render Image + Text section */ public static function render_image_text($props, $layout, $color_scheme, $id) { $title = esc_html($props['title'] ?? ''); $text = wp_kses_post($props['text'] ?? ''); $image = esc_url($props['image'] ?? ''); $html = "
"; if ($image) { $html .= "
\"{$title}\"
"; } $html .= '
'; if ($title) { $html .= "

{$title}

"; } if ($text) { $html .= "
{$text}
"; } $html .= '
'; $html .= '
'; return $html; } /** * Render Feature Grid section */ public static function render_feature_grid($props, $layout, $color_scheme, $id) { $heading = esc_html($props['heading'] ?? ''); $items = $props['items'] ?? []; $html = "
"; if ($heading) { $html .= "

{$heading}

"; } $html .= '
'; foreach ($items as $item) { $item_title = esc_html($item['title'] ?? ''); $item_desc = esc_html($item['description'] ?? ''); $item_icon = esc_html($item['icon'] ?? ''); $html .= '
'; if ($item_icon) { $html .= "{$item_icon}"; } if ($item_title) { $html .= "

{$item_title}

"; } if ($item_desc) { $html .= "

{$item_desc}

"; } $html .= '
'; } $html .= '
'; $html .= '
'; return $html; } /** * Render CTA Banner section */ public static function render_cta_banner($props, $layout, $color_scheme, $id) { $title = esc_html($props['title'] ?? ''); $text = esc_html($props['text'] ?? ''); $button_text = esc_html($props['button_text'] ?? ''); $button_url = esc_url($props['button_url'] ?? ''); $html = "
"; $html .= '
'; if ($title) { $html .= "

{$title}

"; } if ($text) { $html .= "

{$text}

"; } if ($button_text && $button_url) { $html .= "{$button_text}"; } $html .= '
'; $html .= '
'; return $html; } /** * Render Contact Form section */ public static function render_contact_form($props, $layout, $color_scheme, $id) { $title = esc_html($props['title'] ?? ''); $webhook_url = esc_url($props['webhook_url'] ?? ''); $redirect_url = esc_url($props['redirect_url'] ?? ''); $fields = $props['fields'] ?? ['name', 'email', 'message']; $html = "
"; if ($title) { $html .= "

{$title}

"; } // Form is rendered but won't work for bots (they just see the structure) $html .= '
'; foreach ($fields as $field) { $field_label = ucfirst(str_replace('_', ' ', $field)); $html .= '
'; $html .= ""; if ($field === 'message') { $html .= ""; } else { $html .= ""; } $html .= '
'; } $html .= ''; $html .= '
'; $html .= '
'; return $html; } /** * Generic section fallback */ public static function render_generic($props, $type, $id) { $content = ''; foreach ($props as $key => $value) { if (is_string($value)) { $content .= "
" . wp_kses_post($value) . "
"; } } return "
{$content}
"; } }