Add developer lifecycle hooks#45
Merged
Merged
Conversation
Add a documented set of WordPress actions and filters (all prefixed exelearning_) at the plugin's main lifecycle boundaries so third-party developers and integrations can observe events and enrich presentation or metadata. - ELPX extraction: exelearning_before_elpx_extract, exelearning_after_elpx_extract - Metadata: exelearning_elpx_metadata (filter), exelearning_after_elpx_metadata_saved - REST save: exelearning_before_elpx_save, exelearning_after_elpx_save - Shortcode: exelearning_shortcode_atts, exelearning_preview_url, exelearning_shortcode_output (filters) - Styles: exelearning_after_style_installed, exelearning_after_style_deleted, exelearning_after_style_enabled_changed, exelearning_style_registry_entry (filter) - Static editor: exelearning_before_editor_install, exelearning_after_editor_install, exelearning_editor_install_failed All filters validate their return value defensively and restore required internal keys, so callbacks can add data but cannot drop or corrupt the plugin's own metadata, extraction hash, or style integrity fields. No hook weakens validation, capability/nonce checks, path-traversal protection, checksum verification, or the content-proxy security model. Adds tests/unit/DeveloperHooksTest.php and docs/HOOKS.md with a README section. Closes #44
Contributor
Test in WordPress PlaygroundTest the plugin with the code from this branch:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docs/HOOKS.mdand a "Developer hooks" section in the README.All hook names are prefixed with
exelearning_and carry complete docblocks with@since 1.0.0.Hooks added
exelearning_before_elpx_extract,exelearning_after_elpx_extractexelearning_elpx_metadata(filter),exelearning_after_elpx_metadata_savedexelearning_before_elpx_save,exelearning_after_elpx_saveexelearning_shortcode_atts,exelearning_preview_url,exelearning_shortcode_output(filters)exelearning_after_style_installed,exelearning_after_style_deleted,exelearning_after_style_enabled_changed,exelearning_style_registry_entry(filter)exelearning_before_editor_install,exelearning_after_editor_install,exelearning_editor_install_failedSecurity
The new hooks do not allow bypassing validation, archive safety checks, capability checks, nonce checks, path-traversal protections, CSP headers, checksum/digest verification, or trusted-directory restrictions. They are limited to observation and presentation/metadata enrichment:
exelearning_elpx_metadataandexelearning_style_registry_entrydiscard non-array returns and restore required internal keys, so a callback can enrich but never drop or forge the extraction hash or style integrity fields.exelearning_shortcode_atts; the preview URL stays behind the content proxy and is escaped at output time.Testing
tests/unit/DeveloperHooksTest.php(13 tests, 39 assertions) covering: the metadata filter (enrichment, non-array handling, required-key protection, real-flow persistence), the metadata-saved action, the shortcodeatts/outputfilters (including re-sanitization of unsafe values), the style install/delete/enable actions and registry filter, and the editor install before/failed actions.make test FILTER=DeveloperHooks→ OK (13 tests, 39 assertions).make lint→ clean (WordPress Coding Standards).make test→ all pass except the pre-existingStaticEditorInstallerTest::test_is_editor_installed_returns_false_when_missing, which fails only becausedist/static/is built in this local environment (confirmed it fails identically on a clean tree without these changes; it is unrelated to this PR).Closes #44