Contents

Hooks - Plugixa Image Map

For developers. Everything is prefixed plugixa_image_map_.

Events in the browser

A map sends these on its own element, and they bubble, so one listener on document hears every map on the page.

Event When event.detail
plugixa-image-map:ready A map has finished setting itself up { mapId }
plugixa-image-map:tooltip-show A tooltip opens { id }
plugixa-image-map:tooltip-hide A tooltip closes { id }
plugixa-image-map:action A hotspot set to Send an event is clicked { mapId, id, event }
the event’s own name The same click { mapId, id, event }
document.addEventListener( 'plugixa-image-map:tooltip-show', ( e ) => {
    myAnalytics.track( 'hotspot opened', e.detail.id );
} );

Filters: what is printed

Filter Arguments Use
plugixa_image_map_render_markup $html, $doc, $map_id, $title, $trusted The map’s whole HTML, last chance to change it.
plugixa_image_map_render_object $object, $map_id One hotspot’s data just before it is drawn.
plugixa_image_map_show_object $show, $object, $map_id Return false to leave a hotspot out for this visitor.
plugixa_image_map_hotspot_attributes $attributes, $object Extra attributes on a hotspot. Only names starting data-pxim- are kept.
plugixa_image_map_spot_icon $svg, $object The icon drawn inside a spot.
plugixa_image_map_tooltip_kses $tags, $trusted The HTML tags allowed in tooltips.
plugixa_image_map_render_cache_parts $parts, $row Printed maps are cached. If what you print changes without the map being saved, add a value here that changes with it, so the cache does not go stale. $parts starts empty; $row is the map’s row.
// Add a credit line under one map.
add_filter( 'plugixa_image_map_render_markup', function ( $html, $doc, $map_id ) {
    if ( 12 === (int) $map_id ) {
        $html .= '<p class="map-credit">Floor plan: Northwind Facilities</p>';
    }
    return $html;
}, 10, 3 );

Filters: what is stored

Filter Arguments Use
plugixa_image_map_before_insert $data, $entity Change a record before it is created.
plugixa_image_map_before_update $data, $entity, $id, $old Change a record before it is updated.
plugixa_image_map_can_delete $allowed, $entity, $id, $old Return false to refuse a trash.
plugixa_image_map_can_purge $allowed, $entity, $id, $row Return false to refuse a permanent delete.
plugixa_image_map_sanitize_settings $clean, $input The plugin’s settings as they are saved.
plugixa_image_map_filter_output $data, $entity What the REST API returns for a record.
plugixa_image_map_sanitize_ext $kept, $sent, $trusted A map can carry extra data of your own under ext. Nothing is kept unless a filter keeps it: return $kept with your cleaned part of $sent added.
plugixa_image_map_sanitize_object_ext $kept, $sent, $trusted The same, for the ext of one hotspot.
plugixa_image_map_query_clauses $clauses, $entity, $context Narrow which records a list shows. Each entry is array( 'sql' => ..., 'params' => array( ... ) ): a complete condition and the values for its placeholders, in order. $context is list or count.

$entity is the kind of record. For maps it is map.

Filters: settings and the admin screens

Filter Arguments Use
plugixa_image_map_settings_defaults $defaults The default value of every setting.
plugixa_image_map_settings_choices $choices The lists the Settings screen offers, such as the date formats.
plugixa_image_map_config_settings_keys $keys Which settings are handed to the admin screens when they load.
plugixa_image_map_admin_config $config Everything handed to the admin screens when they load.
plugixa_image_map_bootstrap_payload $payload What GET /bootstrap returns.
plugixa_image_map_admin_i18n_strings $strings The translated texts of the admin screens.
plugixa_image_map_modules $classes The class names of the modules the plugin loads.

Filters: who may do what

Filter Arguments Use
plugixa_image_map_user_can $allowed, $action, $entity_type, $record, $user_id The final say on one action by one user on one record.
plugixa_image_map_capabilities $map The list of what the current user may do, as true or false per permission, handed to the admin screens so they can hide buttons. It hides controls only: every route checks the real capability again, so this filter cannot grant anything.

Actions

Action Arguments Fires when
plugixa_image_map_map_saved $id, $kind, $map A map is created or saved, by any route: the editor, restoring a version, an import, the REST API. $kind is create or update and nothing else; $map is the map as stored.
plugixa_image_map_map_imported $id, $data A map arrives from a file or from Image Map Pro. $data is the decoded contents it was made from: the export file, or the Image Map Pro map.
plugixa_image_map_entity_created $entity, $id, $data A record is created.
plugixa_image_map_entity_updated $entity, $id, $data, $old A record is changed.
plugixa_image_map_entity_deleted $entity, $id, $old A record goes to the trash.
plugixa_image_map_entity_restored $entity, $id, $row A record comes back from the trash.
plugixa_image_map_entity_purged $entity, $id, $row A record is deleted for good.
plugixa_image_map_before_delete $entity, $id, $old Just before a record goes to the trash, once it has been allowed.
plugixa_image_map_before_purge $entity, $id, $row Just before a record is deleted for good, once it has been allowed.
plugixa_image_map_settings_saved $settings The settings are saved.
plugixa_image_map_render_enqueue $html, $map_id A map has been printed; enqueue your own assets for it here.
plugixa_image_map_loaded $container The plugin has started.
plugixa_image_map_fs_loaded The licensing library has started.
plugixa_image_map_register_rest_routes $namespace, $container The plugin’s REST routes are being registered. $namespace is plugixa-image-map/v1.
plugixa_image_map_admin_submenus $parent_slug, $render The admin menu is being built; add a submenu under $parent_slug.
plugixa_image_map_enqueue_assets $hook_suffix The plugin’s admin screen is loading its scripts and styles.
plugixa_image_map_activated The plugin was activated.
plugixa_image_map_deactivated The plugin was deactivated.
plugixa_image_map_uninstall The plugin is being deleted with Delete all maps when the plugin is deleted on, just before its tables are removed.
plugixa_image_map_migration_failed $failures A database table could not be created or updated. $failures says which, per module.
// Clear a full-page cache whenever a map changes.
add_action( 'plugixa_image_map_map_saved', function ( $id ) {
    if ( function_exists( 'my_cache_purge_all' ) ) {
        my_cache_purge_all();
    }
} );

What there is no hook for

There is no filter that lets a map run a script, and none that switches a feature on by licence. Pro features exist because their code is installed.

Quick Links