Plugin Directory

Changeset 1965853


Ignore:
Timestamp:
10/30/2018 01:27:17 PM (7 years ago)
Author:
radishconcepts
Message:

Added option to exclude complete forms from persistence

Location:
gf-fields-persistence/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • gf-fields-persistence/trunk/assets/js/gf-field-persistence.js

    r1955348 r1965853  
    1212            // Read data on page load and prefill the form.
    1313            $formWrapper.each(function () {
    14                 rcgfp.post_render($(this));
     14                var $form = $(this);
     15                var formId = $form.attr('id').replace('gform_wrapper_', '');
     16
     17                if( $.inArray( formId, rcgfp_data.exclude_forms ) >= -1 ) {
     18                    rcgfp.post_render($form);
     19                }
    1520            });
    1621
     
    2025        var $this = $(this);
    2126        var $form = $this.parents('form');
     27        var formId = $(this).attr('id').replace('gform_wrapper_', '');
    2228        var dataToSave = [];
     29
     30        if( $.inArray( formId, rcgfp_data.exclude_forms ) >= -1 ) {
     31            return true;
     32        }
    2333
    2434        $('[data-inputname]', $form).each(function () {
  • gf-fields-persistence/trunk/classes/class-admin.php

    r1949566 r1965853  
    5353        add_settings_section(
    5454            'general_section',
    55             __( 'Exclude variables', $this->textdomain ),
     55            __( 'Exclude options', $this->textdomain ),
    5656            function () {
    57                 echo '<div class="description">' . __( 'In this sections you can add variable names, which should be excluded from persistence. ', $this->textdomain ) . '</div>';
     57                echo '<div class="description">' . __( 'In this section you can enter complete forms or specific variable names, which should be excluded from persistence. ', $this->textdomain ) . '</div>';
    5858            },
    5959            self::$option_name
     60        );
     61       
     62        add_settings_field(
     63            'excluded_forms',
     64            __( 'Exclude forms', $this->textdomain ),
     65            array( $this, 'add_field_exclude_forms' ),
     66            self::$option_name,
     67            'general_section'
    6068        );
    6169       
     
    7482        echo '<input type="text" name="' . self::$option_name . '[exclude_variables]" id="' . self::$option_name . '-exclude_variables" class="regular-text" value="' . $exclude_variables . '">';
    7583        echo '<br><small>' . __( 'Enter, comma-separated, the names of the variables you want to exclude.', $this->textdomain ) . '</small>';
     84    }
     85   
     86    public function add_field_exclude_forms() {
     87        if( ! class_exists( 'RGFormsModel' ) ) {
     88            return false;
     89        }
     90       
     91        $exclude_forms = self::get_option( 'exclude_forms' );
     92        $forms = \RGFormsModel::get_forms( $active, 'title' );
     93       
     94        echo '<pre>';
     95        print_r( $exclude_forms );
     96        echo'</pre>';
     97       
     98        echo '<select name="' . self::$option_name . '[exclude_forms][]" id="' . self::$option_name . '-exclude_forms" class="regular-text widefat" multiple>';
     99        foreach ( $forms as $form ) {
     100            echo '<option value="' . esc_attr( $form->id ) . '" ' . ( in_array( $form->id, $exclude_forms ) ? ' selected="selected"' : '' ) . '>' . esc_html( $form->title ) . '</option>';
     101        }
     102        echo '</select>';
    76103    }
    77104   
  • gf-fields-persistence/trunk/classes/class-persistence.php

    r1955348 r1965853  
    66   
    77    private static $instance;
    8     private $_version = '1.0.7';
     8    private $_version = '1.0.8';
    99    private $load_js_in_footer = true;
    1010   
     
    3838    public function enqueue_scripts() {
    3939        // Get options to include in JS.
     40        $exclude_forms = Admin::get_option( 'exclude_forms' );
    4041        $exclude_variables = Admin::get_option( 'exclude_variables' );
    4142        if( ! empty( $exclude_variables ) ) {
     
    4647        wp_enqueue_script( 'rcgfp_script', RCGFP_PLUGIN_URI . 'assets/js/gf-field-persistence.js', array( 'jquery' ), $this->_version, $this->load_js_in_footer );
    4748        wp_localize_script( 'rcgfp_script', 'rcgfp_data', array(
     49            'exclude_forms' => $exclude_forms,
    4850            'exclude_variables' => $exclude_variables,
    4951        ) );
  • gf-fields-persistence/trunk/gravityforms-fields-persistence.php

    r1955348 r1965853  
    44Plugin URI: https://github.com/radishconcepts/gravityforms-field-persistence/
    55Description: 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.7
     6Version: 1.0.8
    77Author: Radish Concepts <info@radishconcepts.com>
    88Author URI: https://www.radishconcepts.com
  • gf-fields-persistence/trunk/readme.txt

    r1955348 r1965853  
    2828== Changelog ==
    2929
     30= 1.0.8 =
     31* Add option to exclude complete forms from persistance.
     32
    3033= 1.0.7 =
    3134* Cookie name change.
Note: See TracChangeset for help on using the changeset viewer.