Skip to content

Document [exelearning] shortcode; add teacher-mode activation and screenshot display#47

Merged
erseco merged 2 commits into
mainfrom
feat/shortcode-docs-teacher-mode-screenshot
Jun 3, 2026
Merged

Document [exelearning] shortcode; add teacher-mode activation and screenshot display#47
erseco merged 2 commits into
mainfrom
feat/shortcode-docs-teacher-mode-screenshot

Conversation

@erseco
Copy link
Copy Markdown
Contributor

@erseco erseco commented Jun 3, 2026

Summary

Adds a dedicated shortcode reference page and closes two capability gaps surfaced while documenting the [exelearning] shortcode.

Closes #46.

Documentation

  • New docs/SHORTCODES.md documenting the [exelearning] shortcode and every attribute (type, default, allowed values) with worked examples.
  • Cross-linked from README.md and AGENTS.md (mirroring how docs/HOOKS.md is referenced).

Teacher-mode activation (new)

  • New teacher_mode attribute (default 0). When enabled, the embed loads with teacher mode already active.
  • Implemented by extending the existing same-origin iframe injection: on load it adds the mode-teacher class to the iframe document, checks the teacher-mode-toggler, and sets localStorage.exeTeacherMode='1' (all best-effort, wrapped in try/catch).
  • Composes with the existing teacher_mode_visible (which only controls toggle visibility).

Screenshot display (new)

  • New screenshot attribute: no (default, unchanged), poster (click-to-load lazy embed behind the image), only (standalone image, no iframe).
  • Uses the screenshot.png shipped at the package root by eXeLearning ≥ 4.0.1, served via the existing content-proxy uploads URL.
  • Detected with a runtime file_exists() check; when absent, poster/only gracefully fall back to the normal iframe embed.

Implementation notes

  • All new output is escaped; user-facing strings use the exelearning text domain.
  • display_exelearning() complexity kept within the repo PHPMD thresholds by extracting render_embed() and render_preview_script() helpers (no thresholds raised).
  • Existing exelearning_shortcode_atts / exelearning_preview_url / exelearning_shortcode_output filters keep working unchanged.

Testing

  • TDD: added 7 cases to tests/unit/ShortcodesTest.php (teacher-mode on/off, screenshot only/poster, both fallbacks, screenshot=no regression).
  • make test FILE=tests/unit/ShortcodesTest.php28 tests, 49 assertions, OK.
  • make lint → clean. make phpmd → no violations.
  • Full make test → only one pre-existing, unrelated environmental failure (StaticEditorInstallerTest::test_is_editor_installed_returns_false_when_missing, which also fails on main in this environment).

Add a dedicated docs/SHORTCODES.md reference and close two capability gaps
surfaced while documenting the [exelearning] shortcode:

- teacher_mode attribute: embed content with teacher mode already active,
  by injecting an activation script into the same-origin preview iframe
  (adds the mode-teacher class, checks the toggler, sets exeTeacherMode).
- screenshot attribute (no|poster|only): show the package screenshot.png
  shipped by eXeLearning >= 4.0.1, either as a click-to-load poster or a
  standalone image; detected at render time and gracefully falling back to
  the iframe when absent.

Cross-link the new reference from README.md and AGENTS.md.

Closes #46
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Test in WordPress Playground

Test the plugin with the code from this branch:

Preview in WordPress Playground

⚠️ The embedded eXeLearning editor is not included in this preview. You can install it from Settings > eXeLearning using the "Download & Install Editor" button. All other plugin features (ELP upload, shortcode, Gutenberg block, preview) work normally.

Register the new "Load interactive content" string in the POT/PO catalogs
and translate it to Spanish, then rebuild the es_ES .mo.
@erseco erseco merged commit 63c89a1 into main Jun 3, 2026
4 checks passed
@erseco erseco deleted the feat/shortcode-docs-teacher-mode-screenshot branch June 3, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document [exelearning] shortcode; add teacher-mode activation and screenshot display

1 participant