88 * Plugin URI: https://gravitywiz.com/gravity-forms-all-fields-template/
99 * Description: Modify the {all_fields} merge tag output via a template file.
1010 * Author: Gravity Wiz
11- * Version: 0.10
11+ * Version: 0.11
1212 * Author URI: http://gravitywiz.com
1313 *
1414 * Usage:
6161 * `{all_fields:exclude[5,6]}`
6262 * `{all_fields:exclude[5],include[3,4]}`
6363 *
64+ * - **`:updated`**
65+ *
66+ * Only show fields that were most recently updated.
67+ *
68+ * `{all_fields:updated}`
69+ *
6470 */
6571class GW_All_Fields_Template {
6672
6773 private static $ instance = null ;
74+ private $ original_entry = array ();
6875
6976 public static function get_instance () {
7077 if ( self ::$ instance == null ) {
@@ -83,7 +90,7 @@ public function init() {
8390
8491 add_filter ( 'gform_pre_replace_merge_tags ' , array ( $ this , 'replace_merge_tags ' ), 9 , 7 );
8592 add_filter ( 'gform_merge_tag_filter ' , array ( $ this , 'all_fields_extra_options ' ), 21 , 6 );
86-
93+ add_action ( ' gform_post_update_entry ' , array ( $ this , ' save_original_entry ' ), 10 , 2 );
8794 }
8895
8996 /**
@@ -111,7 +118,7 @@ public function all_fields_extra_options( $value, $merge_tag, $modifiers, $field
111118 }
112119
113120 $ modifiers = $ this ->parse_modifiers ( $ modifiers );
114- $ whitelist = array ( 'filter ' , 'include ' , 'exclude ' , 'nopricingfields ' );
121+ $ whitelist = array ( 'filter ' , 'include ' , 'exclude ' , 'nopricingfields ' , ' updated ' );
115122 $ context = rgar ( $ modifiers , 'context ' , false );
116123
117124 foreach ( $ modifiers as $ modifier => $ mod_values ) {
@@ -255,6 +262,12 @@ public function all_fields_extra_options( $value, $merge_tag, $modifiers, $field
255262 }
256263 }
257264 break ;
265+ case 'updated ' :
266+ // If current value matches original value, it was not changed so we skip it.
267+ if ( $ this ->original_entry [ $ field ['id ' ] ] == $ value ) {
268+ $ value = false ;
269+ }
270+ break ;
258271 }
259272 }
260273
@@ -265,6 +278,10 @@ public function all_fields_extra_options( $value, $merge_tag, $modifiers, $field
265278 return $ value ;
266279 }
267280
281+ public function save_original_entry ( $ entry , $ original_entry ) {
282+ $ this ->original_entry = $ original_entry ;
283+ }
284+
268285 public function replace_merge_tags ( $ text , $ form , $ entry , $ url_encode , $ esc_html , $ nl2br , $ format ) {
269286
270287 $ matches = array ();
0 commit comments