CoverKit codebase reference
Developer documentation aligned with the current plugin source. For architecture of use cases and output profiles, start with use-cases-and-output-profiles.md. For site-owner workflows, see the plugin README on GitHub and the user guide.
What the plugin does
Section titled “What the plugin does”CoverKit is a WordPress plugin for designing template-based images in the block editor and rendering them to image files on the server (Imagick). Built-in use cases route those images to the front end (social link previews including Open Graph, featured images), the editor sidebar, and custom integrations—each configured per coverkit template.
The codebase splits into:
- PHP —
includes/, bootstrapped bycoverkit.php - Editor —
src/, compiled tobuild/via webpack (npm run build)
Boot sequence
Section titled “Boot sequence”coverkit.phploads autoloaders andincludes/functions.php.CoverKit\init()runs onplugins_loadedpriority1and constructs:SettingsRESTPost_TypeUse_Case_RegistryUse_Case_StoragePost_List_Preview_ColumnsPatternsExamples(unlessCOVERKIT_LOAD_EXAMPLESisfalse)
initpriority15:fire_coverkit_init()runsdo_action( 'coverkit_init' ).coverkit_initpriority5: built-in and third-party code callcoverkit_register_use_case().coverkit_initpriority10:Use_Case_Registry::boot()loadscoverkit_usecasesand callsUse_Case::maybe_init()on each active class.- Activation runs
Post_Type::activate()andSettings::activate()(starter templates fromassets/templates/when missing).
Primary entry points
Section titled “Primary entry points”| Area | Source | Role |
|---|---|---|
| Bootstrap | coverkit.php | Constants, autoload, init(), activation |
| Template CPT | includes/class-coverkit-post-type.php | coverkit post type, meta, blocks, list preview, cache actions |
| REST | includes/class-coverkit-rest.php | coverkit/v1 routes (images, preview, use cases) |
| Rendering | includes/class-coverkit-renderer.php | generate(), generate_from_content() |
| Generator | includes/class-coverkit-generator.php, includes/generator/ | Imagick canvas pipeline and cache |
| Template parsing | includes/class-coverkit-template.php | Block → canvas/elements; field placeholders and mappings |
| Field pipeline | includes/class-coverkit-field-resolver.php, class-coverkit-field-formatter.php, class-coverkit-mapping-applicator.php, class-coverkit-block-bindings.php, class-coverkit-block-bindings-applicator.php | Collect, format, apply use-case mappings and native block bindings |
| Use cases | includes/class-coverkit-use-case.php, class-coverkit-use-case-registry.php, class-coverkit-use-case-storage.php, includes/use-cases/ | Registration, boot, assignments, Open Graph / sidebar |
| Settings | includes/class-coverkit-settings.php, src/settings/ | Settings → CoverKit (coverkit_options, coverkit_presets); CoverKit → Settings links here when the CPT uses the top-level menu |
| Editor | src/editor/, src/blocks/, src/editor/use-cases/ | Gutenberg UI, mapping sidebar, previews |
Data model
Section titled “Data model”coverkit post type
Section titled “coverkit post type”Private UI post type; admin menu is top-level CoverKit by default, or nested under Media when menu_in_media is enabled in Settings (coverkit_options). Supports title, editor, revisions, page-attributes, custom-fields.
Template post meta
Section titled “Template post meta”| Meta key | Type | Purpose |
|---|---|---|
width | integer | Canvas width (default 500) |
height | integer | Canvas height |
background | string | Canvas background color |
gradient | string | Canvas gradient |
_coverkit_use_cases | object | Per–use-case assignments (active, settings, mappings, optional instances) — Use_Case_Storage::META_KEY |
_coverkit_active_use_cases | array | Derived slug list for editor/debug — Use_Case_Storage::SUMMARY_META_KEY |
Options
Section titled “Options”| Option | Purpose |
|---|---|
coverkit_options | Global settings (e.g. image_format, menu_in_media) — schema in schemas/options.php; read via coverkit_option() |
coverkit_presets | Dimension presets for new templates — schemas/templates.php |
coverkit_usecases | List of active use case slugs to boot — Use_Case_Registry::LOADER_MANIFEST_OPTION |
When _coverkit_use_cases changes, Use_Case_Storage rebuilds coverkit_usecases.
Rendering flow (summary)
Section titled “Rendering flow (summary)”- Edit — User designs
coverkit/canvas+coverkit/layerblocks; use cases and mappings are saved in_coverkit_use_cases. - Generate —
Renderer::generate( $use_case_slug, $template_id, $post_id, $options )builds aTemplate, runsapply_data()(placeholders + block bindings +apply_use_case_mappings()), thenGenerator::generate(). - Open Graph —
Open_Graph_Image_Use_Case::init()hookswp_headand pointsog:imageatGET /wp-json/coverkit/v1/use-case/opengraph/{template_id}/{post_id}.{ext}. - Serve — Cached files are exposed via
/coverkit/v1/canvas/{filename}or/coverkit/v1/use-case/{use_case}/...routes.
Good first files to read
Section titled “Good first files to read”Backend
coverkit.phpincludes/class-coverkit-post-type.phpincludes/class-coverkit-rest.phpincludes/class-coverkit-template.phpincludes/class-coverkit-renderer.phpincludes/class-coverkit-use-case-registry.php- use-cases-and-output-profiles.md
Frontend
src/blocks/canvas/,src/blocks/layer/src/editor/index.jssrc/editor/use-cases/(UseCasePanel,UseCaseAssignment, mapping components)