Skip to content

Commit

Permalink
Process merge tags in redirect URLs inside the lightbox (#2221)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcasual authored Nov 27, 2024
2 parents a908e50 + 14f7b50 commit 790fb55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function process_rest_request( $request ) {
gravityview()->request = new GravityView_Lightbox_Entry_Request( $view, $entry );

if ( $delete_nonce ) {
return $this->process_delete_entry( $view );
return $this->process_delete_entry( $view, $entry, $form );
}

if ( $duplicate_nonce ) {
Expand Down Expand Up @@ -339,7 +339,11 @@ private function process_edit_entry( $nonce, $view, $entry, $form ) {
}

$reload_page = 1 === (int) $view->settings->get( 'edit_redirect' ) ? 'true' : 'false';
$redirect_to_url = 2 === (int) $view->settings->get( 'edit_redirect' ) ? esc_url( $view->settings->get( 'edit_redirect_url', '' ) ) : '';
$redirect_to_url = 2 === (int) $view->settings->get( 'edit_redirect' ) ? $view->settings->get( 'edit_redirect_url', '' ) : '';

if ( $redirect_to_url ) {
$redirect_to_url = esc_url( GravityView_API::replace_variables( $redirect_to_url, $form, $entry->as_entry() ) );
}

add_filter( 'gravityview/edit_entry/success', function ( $message ) use ( $view, $reload_page, $redirect_to_url ) {
return <<<JS
Expand All @@ -359,12 +363,15 @@ private function process_edit_entry( $nonce, $view, $entry, $form ) {
* Processes the delete entry action.
*
* @since 2.29.0
* @since TBD Added $entry and $form parameters.
*
* @param View $view The View object.
* @param View $view The View object.
* @param GF_Entry $entry The entry object.
* @param array $form The form data.
*
* @return WP_REST_Response
*/
private function process_delete_entry( $view ) {
private function process_delete_entry( $view, $entry, $form ) {
global $wp;

add_filter( 'wp_redirect', '__return_false' ); // Prevent redirection after the entry is deleted.
Expand All @@ -374,6 +381,10 @@ private function process_delete_entry( $view ) {
$reload_page = GravityView_Delete_Entry::REDIRECT_TO_MULTIPLE_ENTRIES_VALUE === (int) $view->settings->get( 'delete_redirect' ) ? 'true' : 'false';
$redirect_to_url = GravityView_Delete_Entry::REDIRECT_TO_URL_VALUE === (int) $view->settings->get( 'delete_redirect' ) ? esc_url( $view->settings->get( 'delete_redirect_url', '' ) ) : '';

if ( $redirect_to_url ) {
$redirect_to_url = esc_url( GravityView_API::replace_variables( $redirect_to_url, $form, $entry->as_entry() ) );
}

ob_start();

echo <<<JS
Expand Down Expand Up @@ -494,7 +505,7 @@ private function render_entry( $type, $view, $entry, $form ) {
GravityView_API::replace_variables(
$view->settings->get( 'single_title', '' ),
$form,
$entry
$entry->as_entry()
)
);

Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Beautifully display your Gravity Forms entries. Learn more on [gravitykit.com](h

= develop =

#### 🐛 Fixed
* Merge tags in redirect URLs were not processed after editing or deleting an entry in the lightbox.

= 2.32 on November 21, 2024 =

This release adds a new form notification option for updated entries, resolves file upload issues on the Edit Entry screen, and includes developer-focused enhancements.
Expand Down

0 comments on commit 790fb55

Please sign in to comment.