Reveal teacher content via core ?exe-teacher URL params, drop CSS/JS injection#58
Merged
Conversation
Contributor
Test in WordPress PlaygroundTest the plugin with the code from this branch:
|
…S injection eXeLearning packages hide teacher-only content by default and expose an in-page "teacher layer" selector through the ?exe-teacher=1 URL parameter (upstream exelearning/exelearning#1972, fixes exelearning/exelearning#1772). The plugin now appends that parameter to the embed instead of injecting CSS/JS into the package. - Shortcode (public/class-shortcodes.php): append ?exe-teacher=1 when teacher_mode or teacher_mode_visible is on; drop the toggler-hiding and activate-on-load inline scripts from render_preview_script. - Block (includes/class-elp-upload-block.php): append ?exe-teacher=1 in build_preview_url when teacherModeVisible is on; remove teacher_mode_hide_script. - Relabel the block control to "Show teacher layer selector" with homogeneous help; refresh the admin shortcode reference, SHORTCODES.md and readme.txt. - i18n: translate the three changed strings across all 10 catalogs; rebuild .mo and the elp-upload.js .json. - Tests: rewrite the teacher-mode shortcode/block tests for the URL-param model.
636e7d1 to
f8be520
Compare
erseco
added a commit
that referenced
this pull request
Jun 26, 2026
Reconcile teacher-mode handling with main (#58). main retired host-side CSS/JS injection in favour of the package's own ?exe-teacher=1 URL parameter, so the secure-iframe branch is aligned to the same contract: - public/class-shortcodes.php, includes/class-elp-upload-block.php: keep the secure-mode embed-relay enqueue and opaque-iframe rendering, but drop the legacy teacher injection. The selector is offered by appending ?exe-teacher=1 to the iframe src when teacher_mode_visible (or the legacy teacher_mode attr) is on. This rides through the secure-mode content proxy too: the package reads its own location.search even under the opaque origin, so no host injection is needed. - includes/class-content-proxy.php: retire inject_teacher_mode() and the exe-teacher-toggler / exe-teacher server-side rewriting. It injected the exact #teacher-mode-toggler-wrapper CSS that #58 retired and, worse, auto-activated mode-teacher on ?exe-teacher=1 — which contradicts core (the parameter only offers the selector, it never auto-reveals). Keep inject_embed_shim(). - Tests: update ShortcodesTest / ElpUploadBlockTest secure-mode cases to assert the param-based contract (exe-teacher=1, no exe-teacher-toggler, no contentDocument) and drop the ContentProxyTest inject_teacher_mode cases. Other conflicts: - package.json: union — main's @playwright/test and @wordpress/env bumps plus the branch's vitest + happy-dom (used by tests/js). Lockfile regenerated. - languages: msgcat union of both sides (main's strings authoritative, the branch's secure-mode admin strings preserved), .mo recompiled, JED .json taken from main (elp-upload.js is byte-identical to main), .pot unioned. CI regenerates references. The admin block-editor live preview (assets/js/elp-upload.js) keeps main's same-origin preview behaviour unchanged.
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
eXeLearning core hides teacher-only content by default and exposes an in-page "teacher layer" selector to reveal it via the
?exe-teacher=1URL parameter (see exelearning/exelearning#1972, fixes exelearning/exelearning#1772). This plugin now appends that parameter to the embed instead of injecting CSS/JS into the package.Base branch:
main.Core URL-param contract
?exe-teacher=1makes the in-package teacher-layer selector available. It is shown but stays OFF until the viewer turns it on — the parameter never reveals content on its own.Changes
public/class-shortcodes.php): append?exe-teacher=1to the iframe src whenteacher_modeorteacher_mode_visibleis on; removed the toggler-hiding and activate-on-load inline<script>s fromrender_preview_script()(it now only wires the poster/fullscreen behavior).includes/class-elp-upload-block.php): append?exe-teacher=1inbuild_preview_url()whenteacherModeVisibleis on; removedteacher_mode_hide_script()and its call.docs/SHORTCODES.mdandreadme.txt. Theteacher_modeattribute is kept for back-compat but no longer auto-reveals on load (it offers the selector; the viewer activates it)..mo+ theelp-upload.js.json, somake check-untranslatedpasses.Notes
teacher_mode,teacher_mode_visible) and the block attribute (teacherModeVisible) are unchanged; only the internal mechanism (URL param vs. CSS/JS injection) and the wording changed.#:reference churn thatwp i18n update-powould add is regenerated by CI and left out of the commit.Testing
ShortcodesTestandElpUploadBlockTestpass (29 tests); full suite green except one pre-existing, environment-dependentStaticEditorInstallerTestfailure unrelated to this change.phpcs --standard=.phpcs.xml.dist: clean on the changed PHP.make check-untranslated: passes — aftermake-pot+update-po, all 10.poreport 0 untranslated.