st $request Request object. * * @return WP_Error|WP_REST_Response */ public function save_themes( WP_REST_Request $request ) { // Determine custom themes file path. $themes_file = $this->themes_data_obj->get_custom_themes_file_path(); // In the case of error. if ( ! $themes_file ) { return rest_ensure_response( [ 'result' => false, 'error' => esc_html__( 'Can\'t create themes storage file.', 'wpforms-lite' ), ] ); } $custom_themes = (array) ( $request->get_param( 'customThemes' ) ?? [] ); // Save custom themes data and return REST response. $result = $this->themes_data_obj->update_custom_themes_file( $custom_themes ); if ( ! $result ) { return rest_ensure_response( [ 'result' => false, 'error' => esc_html__( 'Can\'t save theme data.', 'wpforms-lite' ), ] ); } return rest_ensure_response( [ 'result' => true ] ); } }