Native interaction owners
Register public theme and application behavior for read-only source inspection.
Reusable site interactions can be part of the native theme model. Give them real controls in the theme's styles groups, preserve each element's choices, and make every option affect the installed interaction. Ordinary content editing and duplication must keep working without the Custom JavaScript authoring permission.
Declare their public source in the theme's cantata-edit.json:
{
"nativeBehaviors": [
{
"match": ".site-gallery",
"label": "Photo viewer",
"source": "assets/gallery.js",
"symbol": "gallery"
}
]
}
The selected element and its matching native ancestors show this source in Developer > Advanced > Custom JavaScript. The source is read-only. A relative, existing public assets/*.js file is required, with a 256 KB limit. The inspector fetches same-origin JavaScript as text when its details are opened; it never executes that response or approves page code. PHP paths, absolute or external source paths in the configuration, traversal and missing files are refused. When WordPress serves theme assets through an external CDN, the inspector provides the public source link without fetching that host. A public source link remains available if the inspector cannot fetch it.
Registration documents a native implementation and its owning controls. It does not turn arbitrary page-provided code into a native feature. Implement reusable behavior in the installed theme, initialize it once, clean up listeners, observers and timers, respect reduced motion and keyboard access, and keep it off while Kindly Edit is open.
An exception to those native settings belongs to the selected element's Custom JavaScript field, with the existing code-author permission and explicit Apply operation. The PHP and CSS ownership rules remain unchanged. Do not place executable source in unregistered attributes, script tags or inline event handlers.
Native application JavaScript#
Installed applications keep their browser behavior with their native operational owner. A plugin can register its
already-public JavaScript through the trusted PHP filter cantata_edit_native_application_behaviors:
add_filter( 'cantata_edit_native_application_behaviors', static function ( array $items ): array {
$items[] = [
'match' => '[data-school-directory]',
'label' => 'School directory filters',
'source' => 'plugins/school-directory/assets/directory.js',
'symbol' => 'School_Directory::render',
];
return $items;
} );
The source is relative to wp-content, names an existing .js file inside an installed plugin, and is at most 256 KB.
Root-level plugin assets are supported as well as nested assets. Canonical filesystem containment rejects file or
plugin-directory symlinks escaping the plugins directory or the registered plugin. Missing files, server source,
external URLs, traversal, query strings, fragments and malformed selectors are refused. This hook is installed PHP;
page markup and theme JSON cannot supply plugin paths. There is no browser registration or file-reading endpoint.
Advanced uses the same read-only public-source link and same-origin text preview as theme interactions. Inspection does not run that response or grant Custom JavaScript, Developer mode or PHP permissions. Ordinary editors receive only public metadata through their existing editor configuration; Developer source inspection retains its existing mode access. Externalized native application scripts must still keep form validation, authorization, privacy, notifications and submissions in the application. Do not copy application behavior into a theme or page snippet to make it inspectable. Verify the installed script remains off over the editor, where appropriate, and that all native settings and operational rules retain their owners.
Verify native option changes, reset, Undo, ordinary-editor duplication, draft/reload/publish and public behavior. A per-element custom-code limit must never make an ordinary native interaction impossible to duplicate.