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: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ po:
mo:
composer make-mo

# Generate JS translation JSON files from .po files
json:
composer make-json

# Check the untranslated strings
check-untranslated:
composer check-untranslated
Expand Down
89 changes: 89 additions & 0 deletions admin/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,95 @@ public function display_settings_page() {

<?php $this->render_editor_status_section(); ?>
<?php $this->render_styles_section(); ?>
<?php $this->render_help_section(); ?>
</div>
<?php
}

/**
* Render the help section.
*
* Summarizes how to embed eXeLearning content with the [exelearning]
* shortcode and points to the full reference on GitHub. Kept intentionally
* lightweight: the canonical documentation lives in docs/SHORTCODES.md and
* docs/HOOKS.md.
*/
private function render_help_section() {
$shortcode_docs = 'https://github.com/exelearning/wp-exelearning/blob/main/docs/SHORTCODES.md';
$hooks_docs = 'https://github.com/exelearning/wp-exelearning/blob/main/docs/HOOKS.md';
?>
<div class="card" id="exelearning-help-card" style="max-width: 900px; margin-bottom: 20px;">
<h2><?php esc_html_e( 'Help', 'exelearning' ); ?></h2>
<p class="description">
<?php esc_html_e( 'Embed an uploaded .elpx package anywhere with the [exelearning] shortcode, referencing the file by its Media Library attachment ID.', 'exelearning' ); ?>
</p>

<h3><?php esc_html_e( 'Shortcode examples', 'exelearning' ); ?></h3>
<p><code style="display: block; padding: 8px; background: #f0f0f1;">[exelearning id="123"]</code></p>
<p><code style="display: block; padding: 8px; background: #f0f0f1;">[exelearning id="123" height="800" teacher_mode="1" screenshot="poster"]</code></p>

<h3><?php esc_html_e( 'Attributes', 'exelearning' ); ?></h3>
<table class="widefat striped">
<thead>
<tr>
<th><?php esc_html_e( 'Attribute', 'exelearning' ); ?></th>
<th><?php esc_html_e( 'Default', 'exelearning' ); ?></th>
<th><?php esc_html_e( 'Description', 'exelearning' ); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><code>id</code></td>
<td><code>0</code></td>
<td><?php esc_html_e( 'Required. Media Library attachment ID of the .elpx package.', 'exelearning' ); ?></td>
</tr>
<tr>
<td><code>height</code></td>
<td><code>600</code></td>
<td><?php esc_html_e( 'Height of the preview, in pixels.', 'exelearning' ); ?></td>
</tr>
<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>
</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>
</tr>
<tr>
<td><code>show_download</code></td>
<td><code>0</code></td>
<td><?php esc_html_e( 'When enabled, shows a multi-format download button.', 'exelearning' ); ?></td>
</tr>
<tr>
<td><code>download_formats</code></td>
<td><em><?php esc_html_e( 'all', 'exelearning' ); ?></em></td>
<td><?php esc_html_e( 'Comma-separated formats to offer: elpx, html5, scorm12, ims, epub3.', 'exelearning' ); ?></td>
</tr>
<tr>
<td><code>screenshot</code></td>
<td><code>no</code></td>
<td><?php esc_html_e( 'Show the package screenshot: no, poster (click to load), or only (image only). Requires eXeLearning 4.0.1 or newer.', 'exelearning' ); ?></td>
</tr>
</tbody>
</table>

<h3><?php esc_html_e( 'Developer hooks', 'exelearning' ); ?></h3>
<p class="description">
<?php esc_html_e( 'The shortcode output can be customized with the exelearning_shortcode_atts, exelearning_preview_url, and exelearning_shortcode_output filters, among other actions and filters.', 'exelearning' ); ?>
</p>

<p>
<a href="<?php echo esc_url( $shortcode_docs ); ?>" target="_blank" rel="noopener noreferrer">
<?php esc_html_e( 'Full shortcode reference', 'exelearning' ); ?>
</a>
&nbsp;|&nbsp;
<a href="<?php echo esc_url( $hooks_docs ); ?>" target="_blank" rel="noopener noreferrer">
<?php esc_html_e( 'Developer hooks reference', 'exelearning' ); ?>
</a>
</p>
</div>
<?php
}
Expand Down
20 changes: 12 additions & 8 deletions assets/js/elp-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@
// Mirrors ExeLearning_Download_Formats::all() (id, label, suffix, client).
// `client` formats are generated client-side by the static editor, so they
// require the editor to be installed; `.elpx` is a direct download.
// Labels are wrapped in literal __() calls (not via a variable key) so that
// `wp i18n make-pot`/`make-json` can statically extract them. With
// wp_set_script_translations() the locale data is printed before this script
// runs, so resolving the labels at module load is correct.
var DOWNLOAD_FORMAT_DEFINITIONS = [
{ id: 'elpx', labelKey: 'Download .elpx', suffix: '.elpx', client: false },
{ id: 'html5', labelKey: 'Web (_web.zip)', suffix: '_web.zip', client: true },
{ id: 'scorm12', labelKey: 'SCORM 1.2 (_scorm.zip)', suffix: '_scorm.zip', client: true },
{ id: 'ims', labelKey: 'IMS Package (_ims.zip)', suffix: '_ims.zip', client: true },
{ id: 'epub3', labelKey: 'EPUB3 (.epub)', suffix: '.epub', client: true }
{ id: 'elpx', label: __( 'Download .elpx', 'exelearning' ), suffix: '.elpx', client: false },
{ id: 'html5', label: __( 'Web (_web.zip)', 'exelearning' ), suffix: '_web.zip', client: true },
{ id: 'scorm12', label: __( 'SCORM 1.2 (_scorm.zip)', 'exelearning' ), suffix: '_scorm.zip', client: true },
{ id: 'ims', label: __( 'IMS Package (_ims.zip)', 'exelearning' ), suffix: '_ims.zip', client: true },
{ id: 'epub3', label: __( 'EPUB3 (.epub)', 'exelearning' ), suffix: '.epub', client: true }
];
var DEFAULT_DOWNLOAD_FORMATS = DOWNLOAD_FORMAT_DEFINITIONS.map( function( f ) { return f.id; } );

Expand Down Expand Up @@ -83,7 +87,7 @@
var items = DOWNLOAD_FORMAT_DEFINITIONS.filter( function( f ) {
return enabledIds.indexOf( f.id ) !== -1;
} ).map( function( f ) {
return { id: f.id, labelKey: f.labelKey, suffix: f.suffix, disabled: f.client && ! editorInstalled };
return { id: f.id, label: f.label, suffix: f.suffix, disabled: f.client && ! editorInstalled };
} );
if ( ! editorInstalled ) {
items.sort( function( a, b ) {
Expand Down Expand Up @@ -153,7 +157,7 @@
onClick: function( ev ) { run( fmt, ev ); },
},
el( 'span', { className: 'dashicons dashicons-download' } ),
el( 'span', { className: 'exelearning-download__label' }, __( fmt.labelKey, 'exelearning' ) )
el( 'span', { className: 'exelearning-download__label' }, fmt.label )
);
}

Expand Down Expand Up @@ -435,7 +439,7 @@
var checked = current.indexOf( fmt.id ) !== -1;
return el( CheckboxControl, {
key: fmt.id,
label: __( fmt.labelKey, 'exelearning' ),
label: fmt.label,
checked: checked,
onChange: function( value ) {
var next = current.filter( function( id ) { return id !== fmt.id; } );
Expand Down
2 changes: 0 additions & 2 deletions assets/js/exelearning-media-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ jQuery( document ).ready( function( $ ) {
var attachmentId = attachment.get( 'id' );

var $editButton = $( '<button type="button" class="button button-primary exelearning-edit-button" style="margin-top: 10px; width: 100%;">' +
'<span class="dashicons dashicons-edit" style="vertical-align: middle; margin-right: 5px;"></span>' +
( strings.editInExe || 'Edit in eXeLearning' ) + '</button>' );

$editButton.on( 'click', function( e ) {
Expand Down Expand Up @@ -536,7 +535,6 @@ jQuery( document ).ready( function( $ ) {
var $editButton = $(
'<a href="' + editUrl + '" class="button button-primary exelearning-edit-button-actions" ' +
'style="display: inline-block; margin-bottom: 10px; padding: 6px 12px; font-size: 13px;">' +
'<span class="dashicons dashicons-edit" style="vertical-align: text-top; margin-right: 4px; font-size: 16px;"></span>' +
( strings.editInExe || 'Edit in eXeLearning' ) + '</a>' +
'<br>'
);
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"phpcs": "phpcs --standard=WordPress . --ignore=vendor/,assets/,node_modules/,tests/js/,wp/,wp-content/,tests/ --colors --warning-severity=0 --extensions=php",
"phpcbf": "phpcbf --standard=WordPress . --ignore=vendor/,assets/,node_modules/,tests/js/,wp/,wp-content/ --colors --warning-severity=0 --extensions=php",
"make-pot": "wp i18n make-pot . languages/exelearning.pot --domain=exelearning --exclude=vendor,node_modules,tests,wp,wp-content,dist,exelearning",
"update-po": "wp i18n update-po languages/exelearning.pot languages/exelearning-es_ES.po",
"update-po": "wp i18n update-po languages/exelearning.pot languages/",
"make-mo": "wp i18n make-mo languages/ languages/",
"make-json": "wp i18n make-json languages/ --no-purge --pretty-print",
"pot-remove-ctime": "sed -i.bak '/POT-Creation-Date:/d' languages/exelearning.pot && rm languages/exelearning.pot.bak",
"pot-remove-refs": "sed -i.bak '/^#: /d' languages/exelearning.pot && rm languages/exelearning.pot.bak",
"untranslated": "msgattrib --untranslated languages/exelearning-es_ES.po && [ $(msgattrib --untranslated languages/exelearning-es_ES.po | wc -l) -eq 0 ]",
"check-untranslated": "composer make-pot && composer pot-remove-ctime && composer pot-remove-refs && composer update-po && composer untranslated && composer make-mo"
"untranslated": "for f in languages/exelearning-*.po; do if [ \"$(msgattrib --untranslated \"$f\" | wc -l)\" -ne 0 ]; then echo \"Untranslated strings in $f\"; exit 1; fi; done",
"check-untranslated": "composer make-pot && composer pot-remove-ctime && composer update-po && composer untranslated && composer make-mo"
},
"config": {
"allow-plugins": {
Expand Down
58 changes: 15 additions & 43 deletions includes/class-elp-upload-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,28 @@ public function enqueue_block_scripts() {
// edit-mode download toolbar can reuse the same export pipeline.
ExeLearning_Download_Button_Renderer::enqueue_assets();

// Use the plugin-root file as the base so the registered URL is clean
// (no "includes/../"). wp_set_script_translations() derives the JSON
// filename from md5 of the script's path relative to the plugin, so an
// unnormalized "includes/../assets/..." would never match the
// make-json output (md5 of "assets/js/elp-upload.js").
wp_enqueue_script(
'exelearning-elp-block',
plugins_url( '../assets/js/elp-upload.js', __FILE__ ),
plugins_url( 'assets/js/elp-upload.js', EXELEARNING_PLUGIN_FILE ),
array( 'wp-blocks', 'wp-element', 'wp-block-editor', 'wp-components', 'wp-i18n', 'exelearning-editor', 'exelearning-download' ),
EXELEARNING_VERSION,
true
);

$this->inject_block_translations();
// Load JavaScript translations the standard way: WordPress serves the
// generated languages/exelearning-{locale}-{md5}.json files for this
// handle (md5 of assets/js/elp-upload.js). Strings must be literal
// __( 'x', 'exelearning' ) calls so `wp i18n make-json` can extract them.
wp_set_script_translations(
'exelearning-elp-block',
'exelearning',
EXELEARNING_PLUGIN_DIR . 'languages'
);

// Frontend styles carry the .exelearning-download split-button rules used
// by the edit-mode toolbar; the admin sheet covers the block preview.
Expand Down Expand Up @@ -295,45 +308,4 @@ private function teacher_mode_hide_script( $container_id ) {
esc_js( $container_id )
);
}

/**
* Inject JS translations from the already-loaded MO textdomain.
* This avoids needing separate JSON translation files.
*/
private function inject_block_translations() {
$strings = array(
'Settings',
'Height (px)',
'Show Teacher Mode toggler',
'Edit in eXeLearning',
'eXeLearning Content',
'Upload or select a .elpx file from your media library',
'Upload .elpx File',
'Media Library',
'Change file',
'Remove',
'No preview available',
'This is an eXeLearning v2 source file. The content will be displayed on the frontend if exported HTML is available.',
);

$locale_data = array();
foreach ( $strings as $s ) {
$t = __( $s, 'exelearning' ); // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
if ( $t !== $s ) {
$locale_data[ $s ] = array( $t );
}
}

if ( empty( $locale_data ) ) {
return;
}

$locale_data[''] = array( 'domain' => 'exelearning' );

wp_add_inline_script(
'exelearning-elp-block',
'wp.i18n.setLocaleData(' . wp_json_encode( $locale_data ) . ',"exelearning");',
'before'
);
}
}
1 change: 0 additions & 1 deletion includes/integrations/class-media-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ public function render_preview_meta_box( $post ) {
echo '<a href="' . esc_url( $edit_url ) . '" class="button button-primary button-large exelearning-edit-page-button" ';
echo 'data-attachment-id="' . esc_attr( $post->ID ) . '" ';
echo 'style="width: 100%; text-align: center;">';
echo '<span class="dashicons dashicons-edit" style="vertical-align: middle; margin-right: 5px;"></span>';
echo esc_html__( 'Edit in eXeLearning', 'exelearning' );
echo '</a>';
echo '</p>';
Expand Down
84 changes: 84 additions & 0 deletions languages/exelearning-ca-4cf813b039eac98ce62f176afa8fc8fe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"translation-revision-date": "2025-11-29 00:20+0000",
"generator": "WP-CLI\/2.12.0",
"source": "assets\/js\/elp-upload.js",
"domain": "messages",
"locale_data": {
"messages": {
"": {
"domain": "messages",
"lang": "ca",
"plural-forms": "nplurals=2; plural=(n != 1);"
},
"Settings": [
"Configuraci\u00f3"
],
"Edit in eXeLearning": [
"Edita a eXeLearning"
],
"No preview available": [
"Previsualitzaci\u00f3 no disponible"
],
"eXeLearning Content": [
"Contingut eXeLearning"
],
"Upload or select a .elpx file from your media library": [
"Puja o selecciona un fitxer .elpx de la teva biblioteca de mitjans"
],
"Upload .elpx File": [
"Puja un fitxer .elpx"
],
"Media Library": [
"Biblioteca de mitjans"
],
"Height (px)": [
"Al\u00e7ada (px)"
],
"Change file": [
"Canvia el fitxer"
],
"Remove": [
"Elimina"
],
"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"
],
"More download formats": [
"M\u00e9s formats de baixada"
],
"Install the eXeLearning editor from the plugin settings page to enable this format.": [
"Instal\u00b7la l'editor d'eXeLearning des de la p\u00e0gina de configuraci\u00f3 del connector per habilitar aquest format."
],
"Download failed. Please try again.": [
"La baixada ha fallat. Torneu-ho a provar."
],
"Download .elpx": [
"Baixa .elpx"
],
"Web (_web.zip)": [
"Web (_web.zip)"
],
"SCORM 1.2 (_scorm.zip)": [
"SCORM 1.2 (_scorm.zip)"
],
"IMS Package (_ims.zip)": [
"Paquet IMS (_ims.zip)"
],
"EPUB3 (.epub)": [
"EPUB3 (.epub)"
],
"Download options": [
"Opcions de baixada"
],
"Show download button": [
"Mostra el bot\u00f3 de baixada"
],
"Available formats": [
"Formats disponibles"
]
}
}
}
Binary file modified languages/exelearning-ca.mo
Binary file not shown.
Loading