Skip to content

Hooks: Actions & Filters ​

Every action and filter the plugin fires, what it's for, and the ones you probably want.

All hooks are prefixed shaped_gallery_. Add them from a plugin or your theme's functions.php unless a hook's note says otherwise.

Actions ​

HookFires whenArguments
shaped_gallery_register_providersMedia providers are being registered. The seam for adding your own media source.$registry — the provider registry class name
shaped_gallery_integrations_loadedPage-builder integrations have booted. The seam for registering an integration of your own.$builders — the key → class map
shaped_gallery_flush_cacheBetween invalidating and reclaiming, during Clear Gallery Cache.—
shaped_gallery_watermark_generatedA watermarked derivative has been written.Details of the generated file
shaped_gallery_watermark_failedA derivative could not be generated.The failure details
shaped_gallery_watermark_purgedPurge Watermark Cache has run.What was removed
shaped_gallery_watermark_signature_changedThe watermark configuration changed, making existing derivatives unreachable.—
shaped_gallery_debug_noteA note or counter was recorded while Debug Performance is on. The seam for contributing your own line.The note

Filters ​

Rendering and layout ​

HookWhat it filters
shaped_gallery_style_contributorsThe ordered list of CSS contributors. The only supported way to add a style the plugin emits — a contributor returns CSS custom properties; there's no raw-CSS escape hatch.
shaped_gallery_image_sizesThe sizes hint used for responsive images.
shaped_gallery_item_categoriesAn item's category memberships, before filtering. The seam for sourcing memberships from elsewhere — a taxonomy, a provider album — allow-listed against the gallery's own vocabulary.
shaped_gallery_shortcode_outputThe rendered output of [shaped_gallery].

Caching ​

HookWhat it filtersNote
shaped_gallery_cache_ttlThe plugin's cache lifetime, in seconds.Floored at one hour — returning 0 would make entries permanent.
shaped_gallery_ajax_context_ttlThe lifetime of one gallery's Ajax render context.Wraps the value above and wins.
shaped_gallery_browser_cachingWhether browser caching is on.Mirrors the Advanced Controls setting.
shaped_gallery_retina_imagesWhether responsive candidates are emitted.Mirrors the Advanced Controls setting.

Licensing ​

HookWhat it filters
shaped_gallery_license_requiredWhether front-end output is gated on a valid license. Return false to disable enforcement — for a migration, an air-gapped install, or a support session.
shaped_gallery_license_noticeThe administrator notice shown when the license isn't active.
shaped_gallery_license_site_urlThe site URL sent to the store when activating. Useful for staging environments.
shaped_gallery_license_updater_enabledWhether the update checker registers its hooks.

Watermark ​

HookWhat it filters
shaped_gallery_watermark_lazyWhether derivatives are generated on first request (the default) or synchronously during render. Returning false is the only sanctioned way a render composites.
shaped_gallery_watermark_backendWhich image backend is used — ImageMagick or GD.
shaped_gallery_watermark_geometryThe computed placement of every mark before it's drawn.
shaped_gallery_watermark_slotsWhich item fields (url, full, thumb) get a derivative, and at which registered size.
shaped_gallery_watermark_alphaThe mark's alpha.
shaped_gallery_watermark_max_pixelsThe ceiling on image size the composer will attempt.
shaped_gallery_watermark_skip_attachmentReturn true to exclude an attachment from watermarking.
shaped_gallery_watermark_font_pathThe TrueType font used for a text watermark.
shaped_gallery_watermark_dirnameThe folder derivatives are written to, inside uploads.
shaped_gallery_watermark_endpoint_urlThe URL that generates a cold derivative.
shaped_gallery_watermark_cache_headersThe cache headers on a served derivative.
shaped_gallery_watermark_signature_saltExtra input to the cache signature. Changing it invalidates every derivative.

Editor and admin ​

HookWhat it filters
shaped_gallery_editor_allowed_blocksWhich blocks may be inserted on the gallery post type. Defaults to the gallery block alone.
shaped_gallery_block_starter_post_typeThe post type the dashboard's Create New Gallery button opens.
shaped_gallery_dashboard_configThe whole dashboard payload — every label, link and section. Anything a filter changes is re-validated before it ships.
shaped_gallery_dashboard_routesThe dashboard's route map.
shaped_gallery_dashboard_hide_noticesWhether other plugins' admin notices are suppressed on the dashboard.

Ready Patterns and lightbox ​

HookWhat it filters
shaped_gallery_patterns_provider_baseThe base URL the pattern catalogue is fetched from.
shaped_gallery_lightbox_slideshow_intervalHow long the lightbox slideshow holds each slide.

Bootstrap ​

HookWhat it filtersNote
shaped_gallery_pro_free_basenameThe free plugin's basename that Pro checks for.Must be added from an mu-plugin. It runs while WordPress is still including plugin files, long before plugins_loaded.

Examples ​

Turn off license enforcement temporarily ​

php
add_filter( 'shaped_gallery_license_required', '__return_false' );

Useful during a migration or on a staging copy. Remove it when you're done.

Exclude some images from watermarking ​

php
add_filter(
    'shaped_gallery_watermark_skip_attachment',
    function ( $skip, $attachment_id ) {
        // Never watermark anything tagged as a logo.
        return has_term( 'logo', 'media_tag', $attachment_id ) ? true : $skip;
    },
    10,
    2
);

Lengthen the cache lifetime on a low-traffic site ​

php
add_filter(
    'shaped_gallery_cache_ttl',
    function () {
        return WEEK_IN_SECONDS;
    }
);

The value is floored at one hour, so you can't accidentally make entries permanent.

Add a line to the debug output ​

php
add_action(
    'shaped_gallery_debug_note',
    function ( $note ) {
        error_log( 'Shaped Gallery: ' . wp_json_encode( $note ) );
    }
);

Nothing is collected at all while Debug Performance is off, so this costs nothing in production.

Things worth knowing ​

There's no raw-CSS hook, deliberately. Every style the plugin emits derives from a setting. To add one, register a contributor via shaped_gallery_style_contributors that returns CSS custom properties. The site-wide and per-gallery CSS fields that used to exist were both removed. Why →

Unprefixed constants are aliases. SHAPED_GALLERY_* point at whichever build booted, so code that reads them works under free or Pro without a change. Pro's own identity is SHAPED_GALLERY_PRO_*.

Identifiers never change. The namespace, the shaped_gallery post type, the shaped-gallery/gallery block, the shaped_gallery_settings option, the shaped-gallery/v1 REST namespace and the [shaped_gallery] shortcode are fixed. Stored galleries depend on them.

Where to go next ​