From a569d2a5cc96f6d297d8a024bcb1ec3564cad297 Mon Sep 17 00:00:00 2001 From: Alessio Torrisi Date: Mon, 18 Nov 2024 12:47:22 +0100 Subject: [PATCH] Tweak: parameter name Tweak: handling of exceptions and errors during option saving --- components/advancedSettings/JetpackBoost/index.js | 6 +++--- includes/RestApi/JetpackController.php | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/advancedSettings/JetpackBoost/index.js b/components/advancedSettings/JetpackBoost/index.js index af562da..54e5396 100644 --- a/components/advancedSettings/JetpackBoost/index.js +++ b/components/advancedSettings/JetpackBoost/index.js @@ -63,7 +63,7 @@ const JetpackBoost = ({ methods, constants }) => { } ]); - const [is_module_active, setModuleStatus] = useState(false); + const [moduleStatus, setModuleStatus] = useState(false); const [loading, setLoading] = useState(true); // Nuovo stato per il caricamento @@ -107,7 +107,7 @@ const JetpackBoost = ({ methods, constants }) => { setLoading(false) }) - }, [is_module_active]) + }, [moduleStatus]) if (loading) { @@ -116,7 +116,7 @@ const JetpackBoost = ({ methods, constants }) => { return ( <> - {!is_module_active ? ( + {!moduleStatus ? (
false, - 'error' => 'Il parametro "field" è mancante o non è valido.', + 'error' => __( "The parameter 'field' is missing or invalid.", 'newfold-performance-module' ), ), 400 ); @@ -104,7 +104,7 @@ public function set_options( $request ) { return new \WP_REST_Response( array( 'success' => false, - 'error' => 'I campi "id" e "value" sono richiesti.', + 'error' => __( "The fields 'id' and 'value' are required.", 'newfold-performance-module' ), ), 400 ); @@ -124,13 +124,13 @@ public function set_options( $request ) { return new \WP_REST_Response( array( 'success' => false, - 'error' => 'Errore durante l\'aggiornamento delle opzioni.', + 'error' => __( 'An error occurred while updating the option.', 'newfold-performance-module' ) ), 500 ); } - // Restituisci una risposta di successo. + // Success response. return new \WP_REST_Response( array( 'success' => true, @@ -140,11 +140,11 @@ public function set_options( $request ) { 200 ); } catch ( \Exception $e ) { - // Gestione delle eccezioni. + // Exceptions handling. return new \WP_REST_Response( array( 'success' => false, - 'error' => 'Si è verificato un errore: ' . $e->getMessage(), + 'error' => __( 'An error occurred while updating the option.', 'newfold-performance-module' ) . $e->getMessage(), ), 500 );