# Template library build scripts

The files in `library/` (info.json, templates, thumbnails) are generated — edit these
scripts and regenerate rather than hand-editing the JSON.

```bash
php library/build/build-core-library.php /path/to/plugin/library
php -d memory_limit=1024M library/build/render-thumbnails.php   # after the JSON changes
```

The second step needs the local site running (Elementor generates the CSS and the
photos are loaded over http) plus Google Chrome installed — it screenshots each
template headlessly. Counters and progress bars are animated by Elementor's frontend
script, which never runs during a screenshot, so the page injects a small script to
set their final values before the capture.

| File | What it holds |
| --- | --- |
| `build-core-library.php` | Element helpers and the section builders (grid, hero, split, pricing, CTA, FAQ, quotes, footer, timeline, images, content) |
| `library-catalog.php` | One entry per template: id, title, tags, thumbnail shape and which builder to call |
| `library-content.php` | All the copy — item sets, quotes, plans, FAQs, stats, footer links |
| `render-thumbnails.php` | Renders each template with Elementor, screenshots it with headless Chrome and saves `thumbnails/<id>.jpg` |
| `library-thumbnails.php` | The old SVG wireframe generator — no longer used, kept for reference |
| `validate-library.php` | Checks the generated library against a real Elementor install |
| `download-images.php` | Fetches the bundled photos (CC0 / public domain only) and writes `images/LICENSES.md` |

## Rules the templates follow

- **Core Elementor widgets only.** Nothing in the library depends on Elite Kit widgets,
  so a template inserts correctly no matter which widgets a site has switched on.
- **Real media, no baked-in site URLs.** Every image and video slot is filled. Media
  URLs are written as `{{EK_LIBRARY_URL}}images/…` and the token is swapped for the
  real library URL when a template is served, so nothing is tied to one install.
- **Photos are CC0 or public domain only** (see `../images/LICENSES.md`), which keeps
  the plugin GPL compatible. Videos are Blender's Creative Commons open movies, so
  only an embed URL ships — no media file.
- **No photographs of identifiable people.** Team members and testimonial authors use
  generated monogram avatars; casting a real person as a fictional employee is not
  something a template kit should do. Client logos are generated marks for the same
  reason — no third party branding.
- **Buttons set `text-decoration: none`** so a theme that underlines links cannot
  underline button labels.
- **Font Awesome 5 icon names.** Elementor bundles FA5, so FA6-only names (`fa-house`,
  `fa-shield-halved`, …) render nothing. The build fails if it finds one.
- **Column widths are `calc()`.** A row of N columns has N-1 gaps to pay for, so each
  column is `calc(share% - (gap × (N-1) × share/100)px)`; percentages alone make the
  last column wrap.
- **Logical alignment values.** Elementor 4 expects `start`/`center`/`end` on most
  widgets (and `block-start` on the icon box), not `left`/`right`.

## Elite Kit Pro's library

Pro ships its own folder of templates built by the same script. It sets three
globals and points this one at its catalogue and its output folder, so there is
one set of section builders rather than two that drift apart:

```bash
php ../elite-kit-pro/library/build/build-pro-library.php
php -d memory_limit=1024M library/build/render-thumbnails.php ../elite-kit-pro/library
```

The Pro plugin then registers its folder through
`elite_kit_template_library_local_libraries`, and the browser shows both
libraries as one — each template read from, and its images resolved against,
the plugin it came from.

## Validating

`validate-library.php` boots WordPress, turns off Elementor's frontend control
optimisation so the full control set is visible, then for every template checks that
each element type exists, each settings key is a real control, each select value is a
registered option, and that the template renders without notices:

```bash
php library/build/validate-library.php /path/to/plugin/library
```

It needs a working WordPress bootstrap; `wp-boot.php` in the same directory as the
script is used when present (see the header of `validate-library.php`).
