Changeset 1949555
- Timestamp:
- 10/01/2018 08:37:38 AM (8 years ago)
- Location:
- gf-fields-persistence/trunk
- Files:
-
- 4 edited
-
README.md (modified) (1 diff)
-
assets/js/gf-field-persistence.js (modified) (2 diffs)
-
classes/class-persistence.php (modified) (3 diffs)
-
gravityforms-fields-persistence.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gf-fields-persistence/trunk/README.md
r1918317 r1949555 11 11 ## What fields does it support 12 12 Currently only text and textarea fields are supported. We will add more fields along the way. Please also submit you requests as an issue! 13 13 14 14 ## Props 15 15 Thanks to https://wisdmlabs.com/blog/gravity-forms-data-persistent-for-save-progress/ which gave us the initial idea, however we needed it to work with Varnish, so we created this Javascript-based version. -
gf-fields-persistence/trunk/assets/js/gf-field-persistence.js
r1918319 r1949555 26 26 var dynamicName = $input.data('inputname'); 27 27 var value = $input.val(); 28 29 // Exclude defined variables. 30 if( $.inArray( dynamicName, rcgfp_data.exclude_variables ) > -1 ) { 31 return; 32 } 28 33 29 34 dataToSave.push({ … … 55 60 56 61 var field = cookieValue[item]; 62 63 if( $.inArray( field.name, rcgfp_data.exclude_variables ) > -1 ) { 64 continue; 65 } 57 66 58 67 $('[data-inputname="' + field.name + '"]', $form).val(field.value); -
gf-fields-persistence/trunk/classes/class-persistence.php
r1918317 r1949555 6 6 7 7 private static $instance; 8 private $_version = '1.0. 2';8 private $_version = '1.0.3'; 9 9 private $load_js_in_footer = true; 10 11 var $option_name = 'rcgfp_options'; 10 12 11 13 public function __construct() { … … 15 17 public function run() { 16 18 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); 17 add_action( 'init', array( $this, 'init_filters' ), 99 );19 add_action( 'init', array( $this, 'init_filters' ), 99 ); 18 20 } 19 21 20 22 public function init_filters() { 21 23 add_filter( 'gform_field_content', function ( $content, $field ) { 22 if ( ! empty( $field->inputName ) ) {24 if ( ! empty( $field->inputName ) ) { 23 25 $current_name_attr = "name='input_" . $field->id . "'"; 24 $new_attr = $current_name_attr . " data-inputname='" . esc_attr( $field->inputName ) . "'";26 $new_attr = $current_name_attr . " data-inputname='" . esc_attr( $field->inputName ) . "'"; 25 27 26 $content = str_replace( $current_name_attr, $new_attr, $content );28 $content = str_replace( $current_name_attr, $new_attr, $content ); 27 29 } 28 30 29 31 return $content; 30 }, 99, 2 );32 }, 99, 2 ); 31 33 } 32 34 … … 35 37 */ 36 38 public function enqueue_scripts() { 39 // Get options to include in JS. 40 $exclude_variables = Admin::get_option( 'exclude_variables' ); 41 if( ! empty( $exclude_variables ) ) { 42 $exclude_variables = explode( ',', $exclude_variables ); 43 $exclude_variables = array_map( 'trim', $exclude_variables ); 44 } 45 37 46 wp_enqueue_script( 'rcgfp_script', RCGFP_PLUGIN_URI . 'assets/js/gf-field-persistence.js', array( 'jquery' ), $this->_version, $this->load_js_in_footer ); 38 47 wp_localize_script( 'rcgfp_script', 'rcgfp_data', array( 39 'ajax_url' => admin_url( 'admin-ajax.php' ), 40 'sec_nonce' => wp_create_nonce('rcgfp_nonce' ), 48 'exclude_variables' => $exclude_variables, 41 49 ) ); 42 50 } -
gf-fields-persistence/trunk/gravityforms-fields-persistence.php
r1918317 r1949555 4 4 Plugin URI: https://github.com/radishconcepts/gravityforms-field-persistence/ 5 5 Description: Adds persistence to the Gravity Forms fields, so inputs will be saved in order to use it in other forms. This will improve user experience and boost your goals! 6 Version: 1.0. 26 Version: 1.0.3 7 7 Author: Radish Concepts <info@radishconcepts.com> 8 8 Author URI: https://www.radishconcepts.com … … 18 18 // Fire those classes. 19 19 new Radish\GravityForms\Persistence\Core(); 20 new Radish\GravityForms\Persistence\Admin();
Note: See TracChangeset
for help on using the changeset viewer.