<?php
/**
 * Server-side render for the `encypher/ad-slot` dynamic block (PRD E4).
 *
 * WordPress includes this file for every block instance and captures its
 * output; `$attributes`, `$content`, and `$block` are provided by core. There
 * is no save-side markup and no view script: the block is purely server
 * rendered, which is why the layouts slice needs no client build step.
 *
 * Output is the fenced container from AdLayouts::container_html() — empty and
 * collapsed unless the publisher activated the slot AND pasted their own ad
 * tag for it. Encypher never injects ad JavaScript and never fetches a
 * creative.
 *
 * @var array $attributes Block attributes.
 */

if (! defined('ABSPATH')) {
    exit;
}

if (! class_exists('\\EncypherProvenance\\AdLayouts')) {
    return;
}

$encypher_ad_slot_html = \EncypherProvenance\AdLayouts::render_block_slot(
    isset($attributes) && is_array($attributes) ? $attributes : []
);
if ('' === $encypher_ad_slot_html) {
    return;
}

// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- container attributes are esc_attr()'d in AdLayouts::container_html(); the optional inner ad tag is publisher-pasted raw HTML stored under the unfiltered_html capability (same trust class as core's Custom HTML widget).
echo $encypher_ad_slot_html;
