Skip to content

Commit

Permalink
Tweak: parameter name
Browse files Browse the repository at this point in the history
Tweak: handling of exceptions and errors during option saving
  • Loading branch information
AleTorrisi committed Nov 18, 2024
1 parent 6bf3faf commit a569d2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions components/advancedSettings/JetpackBoost/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -107,7 +107,7 @@ const JetpackBoost = ({ methods, constants }) => {

setLoading(false)
})
}, [is_module_active])
}, [moduleStatus])

if (loading) {

Expand All @@ -116,7 +116,7 @@ const JetpackBoost = ({ methods, constants }) => {

return (
<>
{!is_module_active ? (
{!moduleStatus ? (
<div className="nfd-container-upsell" >
<InstallActivatePluginButton methods={methods} constants={constants} setModuleStatus={setModuleStatus} />
<FeatureUpsell
Expand Down
12 changes: 6 additions & 6 deletions includes/RestApi/JetpackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function set_options( $request ) {
return new \WP_REST_Response(
array(
'success' => false,
'error' => 'Il parametro "field" è mancante o non è valido.',
'error' => __( "The parameter 'field' is missing or invalid.", 'newfold-performance-module' ),
),
400
);
Expand All @@ -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
);
Expand All @@ -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,
Expand All @@ -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
);
Expand Down

0 comments on commit a569d2a

Please sign in to comment.