Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions gravity-forms/gw-all-fields-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Plugin URI: https://gravitywiz.com/gravity-forms-all-fields-template/
* Description: Modify the {all_fields} merge tag output via a template file.
* Author: Gravity Wiz
* Version: 0.10
* Version: 0.11
* Author URI: http://gravitywiz.com
*
* Usage:
Expand Down Expand Up @@ -61,10 +61,17 @@
* `{all_fields:exclude[5,6]}`
* `{all_fields:exclude[5],include[3,4]}`
*
* - **`:updated`**
*
* Only show fields that were most recently updated.
*
* `{all_fields:updated}`
*
*/
class GW_All_Fields_Template {

private static $instance = null;
private $original_entry = array();

public static function get_instance() {
if ( self::$instance == null ) {
Expand All @@ -83,7 +90,7 @@ public function init() {

add_filter( 'gform_pre_replace_merge_tags', array( $this, 'replace_merge_tags' ), 9, 7 );
add_filter( 'gform_merge_tag_filter', array( $this, 'all_fields_extra_options' ), 21, 6 );

add_action( 'gform_post_update_entry', array( $this, 'save_original_entry' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -111,7 +118,7 @@ public function all_fields_extra_options( $value, $merge_tag, $modifiers, $field
}

$modifiers = $this->parse_modifiers( $modifiers );
$whitelist = array( 'filter', 'include', 'exclude', 'nopricingfields' );
$whitelist = array( 'filter', 'include', 'exclude', 'nopricingfields', 'updated' );
$context = rgar( $modifiers, 'context', false );

foreach ( $modifiers as $modifier => $mod_values ) {
Expand Down Expand Up @@ -255,6 +262,12 @@ public function all_fields_extra_options( $value, $merge_tag, $modifiers, $field
}
}
break;
case 'updated':
// If current value matches original value, it was not changed so we skip it.
if ( $this->original_entry[ $field['id'] ] == $value ) {
$value = false;
}
break;
}
}

Expand All @@ -265,6 +278,10 @@ public function all_fields_extra_options( $value, $merge_tag, $modifiers, $field
return $value;
}

public function save_original_entry( $entry, $original_entry ) {
$this->original_entry = $original_entry;
}

public function replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {

$matches = array();
Expand Down
Loading