Skip to content
Open
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
9 changes: 5 additions & 4 deletions admin/class-admin-upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ public function handle_upload() {
exit;
}

// Include required WordPress files for handling uploads.
// wp_handle_upload() lives in this admin file, which is not loaded on
// every request. Required here, immediately before the call that needs it.
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/image.php';
require_once ABSPATH . 'wp-admin/includes/media.php';

// Process the file upload.
$upload_overrides = array( 'test_form' => false );
Expand All @@ -81,7 +80,9 @@ public function handle_upload() {

$attachment_id = wp_insert_attachment( $attachment, $uploaded_file['file'] );

// Generate and update attachment metadata.
// Generate and update attachment metadata. wp_generate_attachment_metadata()
// lives in wp-admin/includes/image.php, required here right before it is used.
require_once ABSPATH . 'wp-admin/includes/image.php';
$attach_data = wp_generate_attachment_metadata( $attachment_id, $uploaded_file['file'] );
wp_update_attachment_metadata( $attachment_id, $attach_data );

Expand Down
16 changes: 5 additions & 11 deletions includes/class-exelearning-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ private function maybe_start_buffer() {
return;
}

// Suppress error display for this request to prevent output corruption.
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.IniSet.display_errors_Disallowed, Squiz.PHP.DiscouragedFunctions.Discouraged -- Required to prevent output corruption in standalone editor page.
@ini_set( 'display_errors', '0' );
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting, WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting
@error_reporting( 0 );

// Start output buffering to capture any warnings/notices.
// Buffer everything this request prints. Whatever lands here -- a
// deprecation notice from another plugin, a stray echo -- is discarded
// before the editor document is written, so the page never needs to
// change the site's error_reporting or display_errors settings to keep
// its first byte clean.
ob_start();

// Register to render the page and discard buffered output (very early priority).
Expand All @@ -59,10 +57,6 @@ private function maybe_start_buffer() {
* Render the editor page and exit, discarding any buffered output.
*/
public function render_editor_page_and_exit() {
// Suppress error display for this request to prevent output corruption.
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.IniSet.display_errors_Disallowed, Squiz.PHP.DiscouragedFunctions.Discouraged -- Required to prevent output corruption in standalone editor page.
@ini_set( 'display_errors', '0' );

// Discard any buffered output (warnings, notices, etc.).
while ( ob_get_level() > 0 ) {
ob_end_clean();
Expand Down
5 changes: 2 additions & 3 deletions includes/class-exelearning-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,9 @@ public function create_elp_file( $request ) { // phpcs:ignore Generic.CodeAnalys
);
}

// Use WordPress media handling.
// wp_handle_upload() lives in this admin file, which a REST request does
// not load on its own. Nothing else from wp-admin is used here.
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/media.php';
require_once ABSPATH . 'wp-admin/includes/image.php';

// Sanitize filename and ensure the .elpx extension. The plugin only
// registers and edits .elpx files, so any other extension is normalized.
Expand Down
68 changes: 34 additions & 34 deletions languages/exelearning-ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ msgstr "Estil instal·lat."

#: admin/class-admin-styles.php:83
#: includes/class-exelearning-rest-api.php:227
#: includes/class-exelearning-rest-api.php:581
#: includes/class-exelearning-rest-api.php:580
msgid "No file uploaded."
msgstr "No s'ha pujat cap fitxer."

#: admin/class-admin-styles.php:87
#: includes/class-exelearning-rest-api.php:239
#: includes/class-exelearning-rest-api.php:592
#: includes/class-exelearning-rest-api.php:591
msgid "File upload failed."
msgstr "Error en pujar el fitxer."

Expand Down Expand Up @@ -335,8 +335,8 @@ msgid "Template Error"
msgstr "Error de plantilla"

#: admin/views/editor-bootstrap.php:93
#: includes/class-exelearning-editor.php:266
#: includes/class-exelearning-editor.php:299
#: includes/class-exelearning-editor.php:260
#: includes/class-exelearning-editor.php:293
msgid "Saving..."
msgstr "Desant..."

Expand All @@ -345,9 +345,9 @@ msgid "Saved to WordPress successfully"
msgstr "Desat a WordPress correctament"

#: admin/views/editor-bootstrap.php:95
#: includes/class-exelearning-editor.php:265
#: includes/class-exelearning-editor.php:298
#: includes/class-exelearning-editor.php:328
#: includes/class-exelearning-editor.php:259
#: includes/class-exelearning-editor.php:292
#: includes/class-exelearning-editor.php:322
msgid "Save to WordPress"
msgstr "Desa a WordPress"

Expand Down Expand Up @@ -438,8 +438,8 @@ msgid "Edit"
msgstr "Edita"

#: includes/class-elp-reprocessor.php:57
#: includes/class-exelearning-rest-api.php:564
#: includes/class-exelearning-rest-api.php:697
#: includes/class-exelearning-rest-api.php:563
#: includes/class-exelearning-rest-api.php:696
msgid "Invalid attachment ID."
msgstr "ID d'adjunt no vàlid."

Expand All @@ -448,8 +448,8 @@ msgid "The eXeLearning file could not be found on disk."
msgstr "No s'ha trobat el fitxer eXeLearning al disc."

#: includes/class-elp-reprocessor.php:75
#: includes/class-exelearning-rest-api.php:621
#: includes/class-exelearning-rest-api.php:710
#: includes/class-exelearning-rest-api.php:620
#: includes/class-exelearning-rest-api.php:709
msgid "This is not an eXeLearning file (.elpx)."
msgstr "Aquest no és un fitxer eXeLearning (.elpx)."

Expand Down Expand Up @@ -482,88 +482,88 @@ msgstr "Veure a pantalla completa"
msgid "Loading content…"
msgstr "S'està carregant el contingut…"

#: includes/class-exelearning-editor.php:82
#: includes/class-exelearning-editor.php:83
#: includes/class-exelearning-editor.php:76
#: includes/class-exelearning-editor.php:77
msgid "eXeLearning Editor"
msgstr "Editor d'eXeLearning"

#: includes/class-exelearning-editor.php:112
#: includes/class-exelearning-editor.php:106
msgid "Security check failed."
msgstr "La verificació de seguretat ha fallat."

#: includes/class-exelearning-editor.php:117
#: includes/class-exelearning-editor.php:111
msgid "You do not have permission to access this page."
msgstr "No tens permís per accedir a aquesta pàgina."

#: includes/class-exelearning-editor.php:124
#: includes/class-exelearning-editor.php:118
#: includes/class-export-bootstrap.php:131
msgid "No attachment specified."
msgstr "No s'ha especificat cap adjunt."

#: includes/class-exelearning-editor.php:132
#: includes/class-exelearning-editor.php:126
#: includes/class-export-bootstrap.php:150
msgid "This file is not an eXeLearning file (.elpx)."
msgstr "Aquest fitxer no és un fitxer eXeLearning (.elpx)."

#: includes/class-exelearning-editor.php:137
#: includes/class-exelearning-editor.php:131
#: includes/class-exelearning-rest-api.php:178
msgid "You do not have permission to edit this file."
msgstr "No tens permís per editar aquest fitxer."

#: includes/class-exelearning-editor.php:263
#: includes/class-exelearning-editor.php:296
#: includes/class-exelearning-editor.php:257
#: includes/class-exelearning-editor.php:290
#: includes/integrations/class-media-library.php:195
#: includes/integrations/class-media-library.php:349
#: assets/js/elp-upload.js:470
#: assets/js/elp-upload.js:510
msgid "Edit in eXeLearning"
msgstr "Edita a eXeLearning"

#: includes/class-exelearning-editor.php:264
#: includes/class-exelearning-editor.php:297
#: includes/class-exelearning-editor.php:331
#: includes/class-exelearning-editor.php:258
#: includes/class-exelearning-editor.php:291
#: includes/class-exelearning-editor.php:325
msgid "Close"
msgstr "Tanca"

#: includes/class-exelearning-editor.php:267
#: includes/class-exelearning-editor.php:300
#: includes/class-exelearning-editor.php:261
#: includes/class-exelearning-editor.php:294
msgid "Please wait while the file is being saved."
msgstr "Si us plau, espereu mentre es desa l'arxiu."

#: includes/class-exelearning-editor.php:268
#: includes/class-exelearning-editor.php:301
#: includes/class-exelearning-editor.php:262
#: includes/class-exelearning-editor.php:295
msgid "You have unsaved changes. Are you sure you want to close?"
msgstr "Teniu canvis sense desar. Esteu segurs que voleu tancar?"

#: includes/class-exelearning-editor.php:323
#: includes/class-exelearning-editor.php:317
msgid "Edit eXeLearning File"
msgstr "Edita el fitxer eXeLearning"

#: includes/class-exelearning-rest-api.php:198
msgid "You do not have permission to read this file."
msgstr "No tens permís per llegir aquest fitxer."

#: includes/class-exelearning-rest-api.php:311
#: includes/class-exelearning-rest-api.php:310
msgid "File created successfully."
msgstr "Fitxer creat correctament."

#: includes/class-exelearning-rest-api.php:351
#: includes/class-exelearning-rest-api.php:350
msgid "Another save is already in progress for this file. Please retry shortly."
msgstr "Ja hi ha un desament en curs per a aquest fitxer. Torneu-ho a provar d'aquí a poc."

#: includes/class-exelearning-rest-api.php:442
#: includes/class-exelearning-rest-api.php:441
msgid "Failed to save the file."
msgstr "Error en desar el fitxer."

#: includes/class-exelearning-rest-api.php:454
#: includes/class-exelearning-rest-api.php:453
msgid "File copy appears truncated."
msgstr "La còpia del fitxer sembla estar truncada."

#: includes/class-exelearning-rest-api.php:612
#: includes/class-exelearning-rest-api.php:611
msgid "Original file not found."
msgstr "Fitxer original no trobat."

#: includes/class-exelearning-rest-api.php:677
#: includes/class-exelearning-rest-api.php:676
msgid "File saved successfully."
msgstr "Fitxer desat correctament."

Expand Down
Loading
Loading