Skip to content

Commit

Permalink
updating block admin enque
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Jan 17, 2024
1 parent 1e2a88e commit ca51491
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Helpers/UtilsApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,30 @@ public static function getIntegrationApiPublicOutput(array $formDetails, string
);
}

/**
* This function will take form details and apply additional data to it before it is processed.
* It is used in both integrations and non integrations like mailer so it can share the same functionality.
*
* @param array<string, mixed> $formDetails Data passed from the `getFormDetailsApi` function.
* @return array<string, mixed>
*/
public function processCommonSubmitActionFormData(array $formDetails): array
{
// Pre response filter for addon data.
$filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'preResponseAddonData']);
if (\has_filter($filterName)) {
$formDetails[UtilsConfig::FD_ADDON] = \apply_filters($filterName, [], $formDetails);
}

// Pre response filter for success redirect data.
$filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'preResponseSuccessRedirectData']);
if (\has_filter($filterName)) {
$formDetails[UtilsConfig::FD_SUCCESS_REDIRECT] = UtilsEncryption::encryptor(\wp_json_encode(\apply_filters($filterName, [], $formDetails)));
}

return $formDetails;
}

/**
* Return API error response array.
*
Expand Down

0 comments on commit ca51491

Please sign in to comment.