Skip to content

Custom use cases (developers)

Site owners use built-in use cases from the template editor. Developers can add new output types by registering a PHP class and hooking it into CoverKit’s registry.

This page is a checklist; architecture and APIs are documented in Use cases and output profiles. Built-in variants are summarized in the Use cases overview.

  1. Subclass CoverKit\Use_Case (or an existing built-in if you are extending behavior safely).

  2. Register on coverkit_init (priority before 10 if you need to load before built-ins):

    add_action( 'coverkit_init', function () {
    coverkit_register_use_case(
    'my_output',
    array(
    'class' => My_Output_Use_Case::class,
    'label' => __( 'My output', 'my-plugin' ),
    )
    );
    } );
  3. Implement protected function init(): void — register only hooks/filters; keep it cheap.

  4. Define optional settings schema, recommended dimensions/formats, and mapping sources on the class.

  5. Document required mappings for editors (labels, required vs. recommended).

  6. Test enablement on a template, save assignments, and confirm render + cache behavior.

Mandatory registration data: slug, label, class.

ApproachWhen
Filter on mapping sources or labelsSmall tweak to an existing use case
New slug + subclassA distinct option in the UI (for example sidebar_image_product extending sidebar behavior)
New class extending Use_Case directlySubstantially different behavior

Do not mutate a built-in registration globally to fork behavior—register a new slug instead.

After registration, your use case appears in the template editor Use cases sidebar like built-ins: enable, settings (if any), and field-to-layer mapping.

Cardinality (one assignment per template vs. multiple instances) is defined on the use case class—editors cannot override that in the UI.

Study these implementations in the plugin:

  • CoverKit\Use_Cases\Sidebar_Image_Use_Case
  • CoverKit\Use_Cases\Open_Graph_Image_Use_Case
  • CoverKit\Use_Cases\Minimal_Use_Case

Registration: includes/use-cases/bootstrap.php.