Skip to content
CoverKit CoverKit v0.1.13

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.

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:

  • PHPincludes/, bootstrapped by coverkit.php
  • Editorsrc/, compiled to build/ via webpack (npm run build)
  1. coverkit.php loads autoloaders and includes/functions.php.
  2. CoverKit\init() runs on plugins_loaded priority 1 and constructs:
    • Settings
    • REST
    • Post_Type
    • Use_Case_Registry
    • Use_Case_Storage
    • Post_List_Preview_Columns
    • Patterns
    • Examples (unless COVERKIT_LOAD_EXAMPLES is false)
  3. init priority 15: fire_coverkit_init() runs do_action( 'coverkit_init' ).
  4. coverkit_init priority 5: built-in and third-party code call coverkit_register_use_case().
  5. coverkit_init priority 10: Use_Case_Registry::boot() loads coverkit_usecases and calls Use_Case::maybe_init() on each active class.
  6. Activation runs Post_Type::activate() and Settings::activate() (starter templates from assets/templates/ when missing).
AreaSourceRole
Bootstrapcoverkit.phpConstants, autoload, init(), activation
Template CPTincludes/class-coverkit-post-type.phpcoverkit post type, meta, blocks, list preview, cache actions
RESTincludes/class-coverkit-rest.phpcoverkit/v1 routes (images, preview, use cases)
Renderingincludes/class-coverkit-renderer.phpgenerate(), generate_from_content()
Generatorincludes/class-coverkit-generator.php, includes/generator/Imagick canvas pipeline and cache
Template parsingincludes/class-coverkit-template.phpBlock → canvas/elements; field placeholders and mappings
Field pipelineincludes/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.phpCollect, format, apply use-case mappings and native block bindings
Use casesincludes/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
Settingsincludes/class-coverkit-settings.php, src/settings/Settings → CoverKit (coverkit_options, coverkit_presets); CoverKit → Settings links here when the CPT uses the top-level menu
Editorsrc/editor/, src/blocks/, src/editor/use-cases/Gutenberg UI, mapping sidebar, previews

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.

Meta keyTypePurpose
widthintegerCanvas width (default 500)
heightintegerCanvas height
backgroundstringCanvas background color
gradientstringCanvas gradient
_coverkit_use_casesobjectPer–use-case assignments (active, settings, mappings, optional instances) — Use_Case_Storage::META_KEY
_coverkit_active_use_casesarrayDerived slug list for editor/debug — Use_Case_Storage::SUMMARY_META_KEY
OptionPurpose
coverkit_optionsGlobal settings (e.g. image_format, menu_in_media) — schema in schemas/options.php; read via coverkit_option()
coverkit_presetsDimension presets for new templates — schemas/templates.php
coverkit_usecasesList of active use case slugs to boot — Use_Case_Registry::LOADER_MANIFEST_OPTION

When _coverkit_use_cases changes, Use_Case_Storage rebuilds coverkit_usecases.

  1. Edit — User designs coverkit/canvas + coverkit/layer blocks; use cases and mappings are saved in _coverkit_use_cases.
  2. GenerateRenderer::generate( $use_case_slug, $template_id, $post_id, $options ) builds a Template, runs apply_data() (placeholders + block bindings + apply_use_case_mappings()), then Generator::generate().
  3. Open GraphOpen_Graph_Image_Use_Case::init() hooks wp_head and points og:image at GET /wp-json/coverkit/v1/use-case/opengraph/{template_id}/{post_id}.{ext}.
  4. Serve — Cached files are exposed via /coverkit/v1/canvas/{filename} or /coverkit/v1/use-case/{use_case}/... routes.

Backend

  1. coverkit.php
  2. includes/class-coverkit-post-type.php
  3. includes/class-coverkit-rest.php
  4. includes/class-coverkit-template.php
  5. includes/class-coverkit-renderer.php
  6. includes/class-coverkit-use-case-registry.php
  7. use-cases-and-output-profiles.md

Frontend

  1. src/blocks/canvas/, src/blocks/layer/
  2. src/editor/index.js
  3. src/editor/use-cases/ (UseCasePanel, UseCaseAssignment, mapping components)