--- name: content-egg-template-creator description: Create or modify custom PHP/HTML product output templates for the Content Egg WordPress plugin using its product fields, TemplateHelper, and bundled Bootstrap 5 styles. Use for block_*.php global shortcode templates, not Gutenberg EggBlocks articles, affiliate Deeplink configuration, or general WordPress theme development. --- # Content Egg Template Creator Turn the user's description or visual reference into a complete custom Content Egg product template. Templates combine PHP and HTML and run inside WordPress with Content Egg active. Respond in the user's language; use the requested language for customer-facing labels. ## Understand the design Use the supplied description, screenshot, or existing template. If no design is given, ask for a short description: desired layout (cards, list, or comparison table), visible fields, and any key style preferences. Ask about missing requirements only when they materially affect the result; do not require a lengthy questionnaire. If enough information is available, generate the template immediately and state any useful assumptions briefly. For modifications, preserve the existing data handling and requested behavior unless a change is necessary. Ask for the current file if an exact edit depends on code that was not supplied. Obtain the plugin/PHP version when version-specific helpers or features matter. ## Required template structure Every generated file must begin with this header and style enqueue call. Replace the example display name with a descriptive template name. Keep user-provided names within a valid PHP comment; do not insert an unescaped comment terminator into the header. ```php enqueueCeggStyle(true); ?> ``` Place the product layout inside a `cegg5-container` wrapper. Iterate over the supplied `$items` with: ```php
$item) : ?>
``` These snippets show structure, not a finished deliverable. Output actual product markup in the generated template; do not leave implementation placeholders. Handle empty `$items` gracefully. Do not redefine or load WordPress/Content Egg, add a full HTML document, or fetch products from external services inside the template. ## Product data and helpers Use these supplied product fields where relevant: `unique_id`, `title`, `description`, `img`, `url`, `price`, `priceOld`, `currency`, `currencyCode`, `percentageSaved`, `manufacturer`, `rating`, `domain`, `merchant`, `logo`, `ean`, `images`, `shipping_cost`, `last_update`, `subtitle`, `promo`, `badge`. Fields are not guaranteed to be populated. Guard optional keys before use. Do not invent prices, discounts, ratings, stock status, shipping terms, or merchant data. Do not assume a rating scale, timestamp format, shipping structure, or the shape of `images` without a sample or verified documentation. Use the provided affiliate URL rather than reconstructing tracking links. Use the following established API calls, with appropriate guards and output escaping: | Output | PHP expression or call | | --- | --- | | Current price | `TemplateHelper::formatPriceCurrency($item['price'], $item['currencyCode'])` | | Old price | `TemplateHelper::formatPriceCurrency($item['priceOld'], $item['currencyCode'])` | | Merchant logo URL | `TemplateHelper::getMerchantLogoUrl($item, true)` | | Merchant icon URL | `TemplateHelper::getMerchantIconUrl($item, true)` | | Stock status text | `TemplateHelper::getStockStatusStr($item)` | | Formatted update date | `TemplateHelper::getLastUpdateFormatted($item['module_id'])` | | Badge markup | `TemplateHelper::badge2($item);` | | Affiliate disclaimer markup | `TemplateHelper::disclaimer();` | | Amazon price update notice markup | `TemplateHelper::priceUpdateAmazon($items);` | The formatted update helper requires `module_id`, which may be absent from an individual item. Call it only when that value is available and valid for the target version; do not guess a module ID or claim it is a per-product timestamp. If the design needs a per-product date, verify the `last_update` format before formatting it. The badge, disclaimer, and Amazon notice helpers output markup directly: call them without `echo` and without escaping the complete helper output as plain text. Use the badge helper when requested; put the disclaimer and Amazon notice once per rendered template outside the product loop. Preserve these notices when modifying a template. Do not claim the helper calls alone establish compliance with an affiliate program's policies. For prices, verify that the value is present and numeric and that a currency code is available before formatting it. Do not use `empty()` alone to determine whether a numeric zero is present. Show an old price or savings only when supported by the data and the old price exceeds the current price. Omit unavailable optional elements instead of displaying broken images or misleading values. ## HTML, escaping, and responsive design - Use bundled Bootstrap 5 CSS classes inside `.cegg5-container`. Do not load another Bootstrap stylesheet, external fonts, or an icon library by default. The enqueue call establishes CSS availability, not Bootstrap JavaScript; use CSS-only layouts unless interactive behavior is requested and its dependencies are verified. - Use `esc_html()` for plain text and formatted price strings. Use `esc_url()` for URLs rendered in `href` or `src`, including image, merchant logo, and icon URLs. Do not use `esc_url_raw()` for HTML output. - Use `esc_attr()` for other attribute values, including image alt text. Use `wp_kses_post()` for product descriptions intended to retain permitted HTML. For a short plain-text description, use `wp_strip_all_tags()` and `wp_trim_words()` before `esc_html()`. - Keep conditional links and images valid when a URL is missing or is rejected by URL escaping. Avoid empty `href`, empty `src`, nested links, and repeated HTML IDs. Use `wp_unique_id()` when an ID is actually needed. - Give purchase links meaningful labels and `rel="sponsored nofollow"`; add `noopener` when opening a new tab. Use descriptive image alt text and accessible table headings where applicable. Do not communicate availability or discounts through color alone. - Keep custom CSS within a distinct template class beneath `.cegg5-container`. Support narrow screens and long titles without affecting the rest of the site. Avoid global selectors and fixed desktop widths. - Keep generated code compatible with the stated environment. Do not invent Content Egg helper methods, shortcode attributes, field schemas, or asset handles. Check the official docs or supplied plugin sources before using APIs beyond those listed here. ## Deliver and check Return a sensible filename beginning with `block_` and ending in `.php`, followed by the complete file in one PHP code block. Add short installation instructions unless the user requests code only. For later edits, provide the complete updated file unless a small patch is explicitly requested. Review PHP/HTML nesting, context-appropriate escaping, optional fields, responsive layout, repeated shortcode instances, and placement of notices. If file tools and PHP are available, save the exact generated file and run `php -l` before delivering; fix syntax failures. Syntax checking does not prove WordPress integration or visual correctness. If a suitable test site is available and authorized, check empty, single-product, and multi-product output, missing optional values, and mobile layout. State which checks were actually performed; never claim a live preview or plugin compatibility test that did not happen. ### Installation instructions for the customer 1. Save the PHP file, for example `block_custom_product_cards.php`. 2. Create `/wp-content/content-egg-templates/` if it does not exist, then upload the file there using the hosting file manager or another available file transfer method. Do not instruct users to edit the Content Egg plugin's own template files. 3. Select the new `[custom]` template for a Content Egg global shortcode. 4. Preview a page with real products and check links, images, prices, notices, and mobile layout before publishing it. For a nonstandard WordPress content directory, use that site's actual content directory. Do not overwrite an existing custom file without preserving its contents or confirming that replacement is intended. ## References Consult these for version-specific questions or additional capabilities. If retrieval is unavailable, work from the API above and disclose any unresolved compatibility questions. - [Create a Content Egg custom template](https://ce-docs.keywordrush.com/custom-templates/how-to-create-a-custom-template) - [Install a Content Egg custom template](https://ce-docs.keywordrush.com/custom-templates/how-to-install-a-custom-template) - [WordPress output escaping](https://developer.wordpress.org/apis/security/escaping/) Use WordPress's context-specific escaping guidance if an older template example uses `esc_url_raw()` or only `esc_attr()` for an HTML URL.