Skip to content

Commit

Permalink
Fix issues with edit entry paged messages/notices
Browse files Browse the repository at this point in the history
Adjustments to #718
  • Loading branch information
soulseekah committed Oct 29, 2019
1 parent 8cb1745 commit 3d2dcc9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions includes/extensions/edit-entry/class-edit-entry-render.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class GravityView_Edit_Entry_Render {
public $show_previous_button;
public $show_next_button;
public $show_update_button;
public $is_paged_submitted;

function __construct( GravityView_Edit_Entry $loader ) {
$this->loader = $loader;
Expand Down Expand Up @@ -1043,6 +1044,27 @@ private function maybe_print_message() {

if ( \GV\Utils::_POST( 'action' ) === 'update' ) {

if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) {
$labels = array(
'cancel' => __( 'Cancel', 'gravityview' ),
'submit' => __( 'Update', 'gravityview' ),
'next' => __( 'Next', 'gravityview' ),
'previous' => __( 'Previous', 'gravityview' ),
);

/**
* @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
* @since 1.16.3
* @param array $labels Default button labels associative array
* @param array $form The Gravity Forms form
* @param array $entry The Gravity Forms entry
* @param int $view_id The current View ID
*/
$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );

$this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit'];
}

$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );

if( ! $this->is_valid ){
Expand All @@ -1053,6 +1075,20 @@ private function maybe_print_message() {

echo GVCommon::generate_notice( $message , 'gv-error' );

} elseif ( false === $this->is_paged_submitted ) {
// Paged form that hasn't been submitted on the last page yet
$entry_updated_message = sprintf( esc_attr__( 'Entry Updated.', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' );

/**
* @filter `gravityview/edit_entry/page/success` Modify the edit entry success message on pages
* @since develop
* @param string $entry_updated_message Existing message
* @param int $view_id View ID
* @param array $entry Gravity Forms entry array
*/
$message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry );

echo GVCommon::generate_notice( $message );
} else {
$view = \GV\View::by_id( $this->view_id );
$edit_redirect = $view->settings->get( 'edit_redirect' );
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ __Developer Updates:__
* Added: `gravityview/features/paged-edit` A super-secret early-bird filter to enable multiple page forms in Edit Entry
* Added: `$form_id` parameter for the `gravityview_template_$field_type_options` filter
* Added: `gravityview/security/require_unfiltered_html` filter now has 3 additional parameters: `user_id`, `cap` and `args`.
* Added: `gravityview/edit_entry/page/success` filter to alter the message between edit entry pages.
* Fixed: Intermittent `[gvlogic2]` and nested `else` issues
* Modified: Cookies will no longer be set for Single Entry back links
* Modified: Default 250px `image_width` setting for File Upload images is now easily overrideable
Expand Down

0 comments on commit 3d2dcc9

Please sign in to comment.