Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions admin/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ private function render_help_section() {
<tr>
<td><code>teacher_mode</code></td>
<td><code>0</code></td>
<td><?php esc_html_e( 'When enabled, the content loads with teacher mode active.', 'exelearning' ); ?></td>
<td><?php esc_html_e( 'When enabled, the teacher layer selector is offered so viewers can reveal teacher content.', 'exelearning' ); ?></td>
</tr>
<tr>
<td><code>teacher_mode_visible</code></td>
<td><code>1</code></td>
<td><?php esc_html_e( 'Whether the teacher-mode toggle button is shown.', 'exelearning' ); ?></td>
<td><?php esc_html_e( 'If disabled, the teacher layer selector is hidden in the embedded eXeLearning content.', 'exelearning' ); ?></td>
</tr>
<tr>
<td><code>show_download</code></td>
Expand Down
9 changes: 5 additions & 4 deletions assets/js/elp-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
},
teacherModeVisible: {
type: 'boolean',
default: true,
default: false,
},
showDownload: {
type: 'boolean',
Expand Down Expand Up @@ -344,7 +344,7 @@
previewUrl: undefined,
title: undefined,
hasPreview: false,
teacherModeVisible: true,
teacherModeVisible: false,
});
}

Expand Down Expand Up @@ -410,8 +410,9 @@
step: 10,
}),
el( ToggleControl, {
label: __( 'Show Teacher Mode toggler', 'exelearning' ),
checked: attributes.teacherModeVisible !== false,
label: __( 'Show teacher layer selector', 'exelearning' ),
help: __( 'If disabled, the teacher layer selector is hidden in the embedded eXeLearning content.', 'exelearning' ),
checked: attributes.teacherModeVisible === true,
onChange: function( value ) {
setAttributes( { teacherModeVisible: value } );
},
Expand Down
34 changes: 20 additions & 14 deletions docs/SHORTCODES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,31 @@ Library, e.g. in the URL `…/upload.php?item=123`).
|-----------|------|---------|----------------|-------------|
| `id` | int | `0` | Any attachment ID | **Required.** Media Library attachment ID of the `.elpx` package. Nothing renders without a valid ID. |
| `height` | int | `600` | Pixels | Height of the preview iframe (and of the screenshot poster) in pixels. |
| `teacher_mode` | bool | `0` | `0`/`1`, `false`/`true`, `no`/`yes` | When enabled, the embedded content loads with **teacher mode active**, so teacher-only content is shown from the start. |
| `teacher_mode_visible` | bool | `1` | `0`/`1`, `false`/`true`, `no`/`yes` | Controls whether the teacher-mode **toggle button** is visible inside the embed. Set to `0` to hide it. |
| `teacher_mode` | bool | `0` | `0`/`1`, `false`/`true`, `no`/`yes` | When enabled, the **teacher layer selector** is offered in the embed so viewers can reveal teacher-only content. It no longer auto-reveals on load — the viewer turns it on. |
| `teacher_mode_visible` | bool | `0` | `0`/`1`, `false`/`true`, `no`/`yes` | Controls whether the **teacher layer selector** is available inside the embed. Off by default; set to `1` to make it available. |
| `show_download` | bool | `0` | `0`/`1`, `false`/`true`, `no`/`yes` | When enabled, renders a multi-format download button in the toolbar. |
| `download_formats` | string | *(empty → all)* | Comma-separated list of `elpx`, `html5`, `scorm12`, `ims`, `epub3` | Restricts the download button to the listed formats. Empty means all available formats. Only applies when `show_download` is enabled. |
| `screenshot` | string | `no` | `no`, `poster`, `only` | Controls whether the package screenshot is shown. See [Screenshots](#screenshots). |

### Teacher mode

eXeLearning packages can mark content as *teacher-only*. The embedded viewer
ships a toggle that switches teacher mode on and off; the two attributes above
control it independently:
eXeLearning packages can mark content as *teacher-only*. Exported packages hide
that content by default and expose an in-page **teacher layer selector** to
reveal it through the `?exe-teacher=1` URL parameter. The plugin appends that
parameter to the embed instead of injecting any CSS or JavaScript into the
package:

- `teacher_mode` decides the **initial state** (off by default).
- `teacher_mode_visible` decides whether the **toggle button** is shown.
- `teacher_mode_visible` (default `0`) decides whether the **selector is
available** in the embed. It is hidden by default; set it to `1` to make it
available.
- `teacher_mode` (default `0`), when enabled, also makes the selector available.
It no longer auto-reveals teacher content on load — the selector is shown but
stays off until the viewer turns it on.

They compose freely. For example, to always present teacher content and hide the
toggle so visitors cannot switch it off:
For example, to offer the selector explicitly:

```text
[exelearning id="123" teacher_mode="1" teacher_mode_visible="0"]
[exelearning id="123" teacher_mode_visible="1"]
```

### Screenshots
Expand Down Expand Up @@ -81,16 +86,17 @@ Custom height:
[exelearning id="123" height="800"]
```

Activate teacher mode on load:
Offer the teacher layer selector (hidden by default):

```text
[exelearning id="123" teacher_mode="1"]
[exelearning id="123" teacher_mode_visible="1"]
```

Hide the teacher-mode toggle:
The selector is hidden unless you enable it, so a bare embed keeps teacher-only
content hidden:

```text
[exelearning id="123" teacher_mode_visible="0"]
[exelearning id="123"]
```

Show a download button limited to specific formats:
Expand Down
35 changes: 13 additions & 22 deletions includes/class-elp-upload-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function register_block() {
),
'teacherModeVisible' => array(
'type' => 'boolean',
'default' => true,
'default' => false,
),
'showDownload' => array(
'type' => 'boolean',
Expand Down Expand Up @@ -189,7 +189,7 @@ private function prepare_block_render_data( $attributes ) {
'extracted_dir' => get_post_meta( $attachment_id, '_exelearning_extracted', true ),
'has_preview' => get_post_meta( $attachment_id, '_exelearning_has_preview', true ),
'height' => isset( $attributes['height'] ) ? absint( $attributes['height'] ) : 600,
'teacher_mode_visible' => ! isset( $attributes['teacherModeVisible'] ) || (bool) $attributes['teacherModeVisible'],
'teacher_mode_visible' => isset( $attributes['teacherModeVisible'] ) && (bool) $attributes['teacherModeVisible'],
'show_download' => isset( $attributes['showDownload'] ) && (bool) $attributes['showDownload'],
'download_formats' => isset( $attributes['downloadFormats'] )
? ExeLearning_Download_Formats::sanitize( $attributes['downloadFormats'] )
Expand Down Expand Up @@ -220,7 +220,17 @@ private function maybe_render_download_button( $data ) {
* @return string Escaped preview URL.
*/
private function build_preview_url( $data ) {
return esc_url( ExeLearning_Content_Proxy::get_proxy_url( $data['extracted_dir'] ) );
$url = ExeLearning_Content_Proxy::get_proxy_url( $data['extracted_dir'] );

// eXeLearning core hides teacher-only content by default and exposes an in-page
// "teacher layer" selector via ?exe-teacher=1 (shown but off until the viewer
// turns it on). No host-side CSS/JS injection is needed — opt in by carrying the
// parameter on the iframe src when this block should offer the selector.
if ( ! empty( $data['teacher_mode_visible'] ) ) {
$url .= ( false === strpos( $url, '?' ) ? '?' : '&' ) . 'exe-teacher=1';
}

return esc_url( $url );
}

/**
Expand Down Expand Up @@ -287,25 +297,6 @@ private function render_block_preview( $data, $download_html ) {
esc_attr( get_the_title( $data['attachment_id'] ) )
);

if ( ! $data['teacher_mode_visible'] ) {
$html .= $this->teacher_mode_hide_script( $data['container_id'] );
}

return $html;
}

/**
* Inline script that hides the teacher-mode toggler inside the preview
* iframe. The iframe is same-origin, so we inject a small stylesheet into
* its document on load.
*
* @param string $container_id Wrapper element id.
* @return string Script HTML.
*/
private function teacher_mode_hide_script( $container_id ) {
return sprintf(
'<script>(function(){var c=document.getElementById("%1$s");if(!c)return;var f=c.querySelector("iframe");if(!f)return;var css="#teacher-mode-toggler-wrapper { visibility: hidden !important; }";var inject=function(){try{if(!f.contentDocument)return;var d=f.contentDocument;if(d.getElementById("exelearning-teacher-mode-style"))return;var st=d.createElement("style");st.id="exelearning-teacher-mode-style";st.textContent=css;(d.head||d.documentElement).appendChild(st);}catch(e){}};f.addEventListener("load",inject);inject();})();</script>',
esc_js( $container_id )
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@
"This is an eXeLearning v2 source file. The content will be displayed on the frontend if exported HTML is available.": [
"Aquest \u00e9s un fitxer font d'eXeLearning v2. El contingut es mostrar\u00e0 al frontend si hi ha HTML exportat disponible."
],
"Show Teacher Mode toggler": [
"Mostra el commutador de Mode Professor"
"Show teacher layer selector": [
"Mostrar el selector de capa docent"
],
"If disabled, the teacher layer selector is hidden in the embedded eXeLearning content.": [
"Si es desactiva, el selector de capa docent s'ocultar\u00e0 al contingut eXeLearning incrustat."
],
"More download formats": [
"M\u00e9s formats de baixada"
Expand Down
Binary file modified languages/exelearning-ca.mo
Binary file not shown.
13 changes: 7 additions & 6 deletions languages/exelearning-ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ msgid "File copy appears truncated."
msgstr "La còpia del fitxer sembla estar truncada."

#: assets/js/elp-upload.js:413
msgid "Show Teacher Mode toggler"
msgstr "Mostra el commutador de Mode Professor"
msgid "Show teacher layer selector"
msgstr "Mostrar el selector de capa docent"

#: includes/class-exelearning-editor.php:179
#: includes/class-exelearning-editor.php:212
Expand Down Expand Up @@ -652,12 +652,13 @@ msgid "Height of the preview, in pixels."
msgstr "Alçada de la previsualització, en píxels."

#: admin/class-admin-settings.php:125
msgid "When enabled, the content loads with teacher mode active."
msgstr "Quan s'activa, el contingut es carrega amb el mode docent actiu."
msgid "When enabled, the teacher layer selector is offered so viewers can reveal teacher content."
msgstr "Quan s'activa, s'ofereix el selector de capa docent perquè qui el vegi pugui mostrar el contingut docent."

#: admin/class-admin-settings.php:130
msgid "Whether the teacher-mode toggle button is shown."
msgstr "Si es mostra el botó per commutar el mode docent."
#: assets/js/elp-upload.js:414
msgid "If disabled, the teacher layer selector is hidden in the embedded eXeLearning content."
msgstr "Si es desactiva, el selector de capa docent s'ocultarà al contingut eXeLearning incrustat."

#: admin/class-admin-settings.php:135
msgid "When enabled, shows a multi-format download button."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@
"This is an eXeLearning v2 source file. The content will be displayed on the frontend if exported HTML is available.": [
"Este \u00e9s un fitxer font d'eXeLearning v2. El contingut es mostrar\u00e0 en el frontend si hi ha HTML exportat disponible."
],
"Show Teacher Mode toggler": [
"Mostrar el commutador de Mode Professor"
"Show teacher layer selector": [
"Mostrar el selector de capa docent"
],
"If disabled, the teacher layer selector is hidden in the embedded eXeLearning content.": [
"Si es desactiva, el selector de capa docent s'ocultar\u00e0 al contingut eXeLearning incrustat."
],
"More download formats": [
"M\u00e9s formats de baixada"
Expand Down
Binary file modified languages/exelearning-ca_valencia.mo
Binary file not shown.
13 changes: 7 additions & 6 deletions languages/exelearning-ca_valencia.po
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ msgid "File copy appears truncated."
msgstr "La còpia del fitxer pareix estar truncada."

#: assets/js/elp-upload.js:413
msgid "Show Teacher Mode toggler"
msgstr "Mostrar el commutador de Mode Professor"
msgid "Show teacher layer selector"
msgstr "Mostrar el selector de capa docent"

#: includes/class-exelearning-editor.php:179
#: includes/class-exelearning-editor.php:212
Expand Down Expand Up @@ -652,12 +652,13 @@ msgid "Height of the preview, in pixels."
msgstr "Alçada de la previsualització, en píxels."

#: admin/class-admin-settings.php:125
msgid "When enabled, the content loads with teacher mode active."
msgstr "Quan s'activa, el contingut es carrega amb el mode docent actiu."
msgid "When enabled, the teacher layer selector is offered so viewers can reveal teacher content."
msgstr "Quan s'activa, s'ofereix el selector de capa docent perquè qui el veja puga mostrar el contingut docent."

#: admin/class-admin-settings.php:130
msgid "Whether the teacher-mode toggle button is shown."
msgstr "Si es mostra el botó per commutar el mode docent."
#: assets/js/elp-upload.js:414
msgid "If disabled, the teacher layer selector is hidden in the embedded eXeLearning content."
msgstr "Si es desactiva, el selector de capa docent s'ocultarà al contingut eXeLearning incrustat."

#: admin/class-admin-settings.php:135
msgid "When enabled, shows a multi-format download button."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@
"This is an eXeLearning v2 source file. The content will be displayed on the frontend if exported HTML is available.": [
"Dies ist eine eXeLearning v2-Quelldatei. Der Inhalt wird im Frontend angezeigt, wenn exportiertes HTML verf\u00fcgbar ist."
],
"Show Teacher Mode toggler": [
"Umschalter f\u00fcr Lehrermodus anzeigen"
"Show teacher layer selector": [
"Lehrerebenen-Auswahl anzeigen"
],
"If disabled, the teacher layer selector is hidden in the embedded eXeLearning content.": [
"Wenn deaktiviert, wird die Lehrerebenen-Auswahl im eingebetteten eXeLearning-Inhalt ausgeblendet."
],
"More download formats": [
"Weitere Download-Formate"
Expand Down
Binary file modified languages/exelearning-de_DE.mo
Binary file not shown.
13 changes: 7 additions & 6 deletions languages/exelearning-de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ msgid "File copy appears truncated."
msgstr "Die Dateikopie scheint abgeschnitten zu sein."

#: assets/js/elp-upload.js:413
msgid "Show Teacher Mode toggler"
msgstr "Umschalter für Lehrermodus anzeigen"
msgid "Show teacher layer selector"
msgstr "Lehrerebenen-Auswahl anzeigen"

#: includes/class-exelearning-editor.php:179
#: includes/class-exelearning-editor.php:212
Expand Down Expand Up @@ -652,12 +652,13 @@ msgid "Height of the preview, in pixels."
msgstr "Höhe der Vorschau in Pixeln."

#: admin/class-admin-settings.php:125
msgid "When enabled, the content loads with teacher mode active."
msgstr "Wenn aktiviert, wird der Inhalt mit aktivem Lehrermodus geladen."
msgid "When enabled, the teacher layer selector is offered so viewers can reveal teacher content."
msgstr "Wenn aktiviert, wird die Lehrerebenen-Auswahl angeboten, damit Betrachter Lehrinhalte einblenden können."

#: admin/class-admin-settings.php:130
msgid "Whether the teacher-mode toggle button is shown."
msgstr "Legt fest, ob die Umschaltfläche für den Lehrermodus angezeigt wird."
#: assets/js/elp-upload.js:414
msgid "If disabled, the teacher layer selector is hidden in the embedded eXeLearning content."
msgstr "Wenn deaktiviert, wird die Lehrerebenen-Auswahl im eingebetteten eXeLearning-Inhalt ausgeblendet."

#: admin/class-admin-settings.php:135
msgid "When enabled, shows a multi-format download button."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@
"This is an eXeLearning v2 source file. The content will be displayed on the frontend if exported HTML is available.": [
"\u0108i tio estas eXeLearning v2 fontdosiero. La enhavo estos montrata en la fasado se eksportita HTML estas disponebla."
],
"Show Teacher Mode toggler": [
"Montri la \u015daltilon de Instruista Re\u011dimo"
"Show teacher layer selector": [
"Montri la elekton de instruista tavolo"
],
"If disabled, the teacher layer selector is hidden in the embedded eXeLearning content.": [
"Se mal\u015daltita, la elekto de instruista tavolo estas ka\u015dita en la enkorpigita eXeLearning-enhavo."
],
"More download formats": [
"Pliaj el\u015dutformatoj"
Expand Down
Binary file modified languages/exelearning-eo.mo
Binary file not shown.
13 changes: 7 additions & 6 deletions languages/exelearning-eo.po
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ msgid "File copy appears truncated."
msgstr "La dosiera kopio ŝajnas esti trunkita."

#: assets/js/elp-upload.js:413
msgid "Show Teacher Mode toggler"
msgstr "Montri la ŝaltilon de Instruista Reĝimo"
msgid "Show teacher layer selector"
msgstr "Montri la elekton de instruista tavolo"

#: includes/class-exelearning-editor.php:179
#: includes/class-exelearning-editor.php:212
Expand Down Expand Up @@ -652,12 +652,13 @@ msgid "Height of the preview, in pixels."
msgstr "Alteco de la antaŭrigardo, en bilderoj."

#: admin/class-admin-settings.php:125
msgid "When enabled, the content loads with teacher mode active."
msgstr "Kiam ŝaltita, la enhavo ŝargiĝas kun la instruista reĝimo aktiva."
msgid "When enabled, the teacher layer selector is offered so viewers can reveal teacher content."
msgstr "Kiam ŝaltita, la elekto de instruista tavolo estas proponata por ke spektantoj povu malkaŝi instruistan enhavon."

#: admin/class-admin-settings.php:130
msgid "Whether the teacher-mode toggle button is shown."
msgstr "Ĉu la ŝaltbutono de la instruista reĝimo estas montrata."
#: assets/js/elp-upload.js:414
msgid "If disabled, the teacher layer selector is hidden in the embedded eXeLearning content."
msgstr "Se malŝaltita, la elekto de instruista tavolo estas kaŝita en la enkorpigita eXeLearning-enhavo."

#: admin/class-admin-settings.php:135
msgid "When enabled, shows a multi-format download button."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"Height (px)": [
"Altura (px)"
],
"Show Teacher Mode toggler": [
"Mostrar el conmutador de Modo Docente"
"Show teacher layer selector": [
"Mostrar el selector de capa docente"
],
"Download options": [
"Opciones de descarga"
Expand All @@ -67,6 +67,9 @@
"This is an eXeLearning v2 source file. The content will be displayed on the frontend if exported HTML is available.": [
"Este es un archivo fuente de eXeLearning v2. El contenido se mostrar\u00e1 en el frontend si hay HTML exportado disponible."
],
"If disabled, the teacher layer selector is hidden in the embedded eXeLearning content.": [
"Si se desactiva, se ocultar\u00e1 el selector de capa docente en el contenido eXeLearning embebido."
],
"Web (_web.zip)": [
"Web (_web.zip)"
],
Expand Down
Binary file modified languages/exelearning-es_ES.mo
Binary file not shown.
Loading