Theme Framework How the LeaseLeads theme frontend works

Widgets

Literal WordPress widgets — the WP widget API, distinct from a Component.

On this page 3

A Widget in this theme means exactly what it means in WordPress: a registered WP_Widget, placed into a sidebar through the WP widget admin. The word is reserved for that — it is not a general term for a reusable UI piece. When you want "a reusable piece rendered inside a Module," you want a Component.

Widgets are registered in config/areas.php alongside the sidebars they drop into:

php
// config/areas.php
'widgets' => [
    Buttons::class,
    Lightbox::class,
],

The one example

The theme ships Lightbox, a widget that renders configurable lightbox content. It extends BaseWidget, declares its id, name, and ACF fields, and renders a view:

php
// app/Widgets/Lightbox.php
class Lightbox extends BaseWidget
{
    public function id(): string   { return 'lightbox_content'; }
    public function name(): string { return 'Lightbox Content'; }

    public function fields(): FieldsBuilder
    {
        $builder = new FieldsBuilder('lightbox');
        // …content + options groups…
        return $builder;
    }

    public function render(array $args, array $instance): void
    {
        View::widget('lightbox', [
            'instance' => $this,
            'content'  => get_field('content', 'widget_'.$args['widget_id']),
            'options'  => get_field('options', 'widget_'.$args['widget_id']),
            'data'     => $instance,
        ]);
    }
}

The render(array $args, array $instance) signature is the WordPress widget API — $args and $instance come straight from WP, and field data is read per-widget-instance via 'widget_'.$args['widget_id']. That's the tell that this is a real WP widget, not theme-internal composition.

The view lives under resources/public/views/widgets/ and, like everything else, composes Components for its actual content — the lightbox view builds a content-stack out of text, buttons, and list partials, then hands it to the lightbox Component.

Widget vs Component

Widget Component
API WordPress WP_Widget Theme's View::component()
Placed by An author, into a sidebar A host view, never by an author
Registered in config/areas.php Discovered by a host's HasX trait
The word Reserved for this Use this for "reusable UI piece"
Warning

Don't call a reusable UI piece a "widget." In this codebase "widget" means the WP widget API and nothing else. A carousel, a card, a button group inside a Module are Components.

  • Components — what a Widget's view is actually built from.
  • Modules — the author-placeable block a Widget is often confused with.