PluginProbe
Repeater Fields for Gravity Forms / 2.4.5
Repeater Fields for Gravity Forms v2.4.5
3.2.0 3.1.1 3.1.0 3.0.4 3.0.3 3.0.2 3.0.1 3.0.0 2.5.1 2.5.0 2.4.6 trunk 2.0.5 2.0.9 2.1.0 2.3.2 2.3.7 2.4.1 2.4.3 2.4.4 2.4.5
repeater-for-gravity-forms / add_on.php

add_on.php in Repeater Fields for Gravity Forms 2.4.5, at add_on.php

110 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! class_exists( 'GFForms' ) ) {
3 die();
4 }
5 GFForms::include_addon_framework();
6 class Superaddons_Grepeater_Field_Addon extends GFAddOn{
7 protected $_version = "1.0";
8 protected $_min_gravityforms_version = '1.9';
9 protected $_slug = 'repeater-for-gravity-forms';
10 protected $_path = 'repeater-for-gravity-forms/repeater-for-gravity-forms.php';
11 protected $_full_path = __FILE__;
12 protected $_title = 'Gravity Forms Repeater Fields Add-On';
13 protected $_short_title = 'Gravity Repeater';
14 private static $_instance = null;
15 public static function get_instance() {
16 if ( self::$_instance == null ) {
17 self::$_instance = new self();
18 }
19 return self::$_instance;
20 }
21 public function init_admin() {
22 parent::init_admin();
23 }
24 public function init_frontend() {
25 parent::init_frontend();
26 // add tasks or filters here that you want to perform only in the front end
27 }
28 function type( $position, $form_id ) {
29 if ( $position == 1550 ) {
30 ?>
31 <li class="field_field_repeater_title_setting field_setting">
32 <label class="section_label">
33 <?php esc_html_e('Title', 'repeater-for-gravity-forms'); ?>
34 </label>
35 <input type="text" id="repeater_title" placeholder="Person" value="" onchange="SetFieldProperty('repeater_title', this.value);">
36 <?php esc_html_e("An optional title before each row of the repeater",'repeater-for-gravity-forms') ?>
37 </li>
38 <?php do_action( "yeeaddons_gf_repeater_settings") ?>
39 <li class="field_field_repeater_end_text_setting field_setting">
40 <label class="section_label">
41 <?php esc_html_e('Text button', 'repeater-for-gravity-forms'); ?>
42 </label>
43 <input type="text" id="field_repeater_end_text" placeholder="Add more" value="" onchange="SetFieldProperty('field_repeater_end_text', this.value);">
44 <?php esc_html_e("add button text",'repeater-for-gravity-forms') ?>
45 </li>
46 <?php
47 }
48 }
49 function editor_script(){
50 ?>
51 <script type='text/javascript'>
52 ( function( $ ) {
53 "use strict";
54 jQuery(document).ready(function($) {
55 jQuery(document).on('gform_load_field_settings', function(event, field, form){
56 jQuery('#repeater_title').val( field.repeater_title);
57 jQuery('#repeater_initial_rows').val( field.repeater_initial_rows);
58 jQuery('#repeater_max').val( field.repeater_max);
59 jQuery('#repeater_initial_rows_map').val( field.repeater_initial_rows_map);
60 jQuery('#field_repeater_end_text').val( field.field_repeater_end_text);
61 });
62 });
63 } )( jQuery );
64 </script>
65 <?php
66 }
67 public function pre_init() {
68 parent::pre_init();
69 add_filter( "gform_input_mask_script",array($this,"gform_input_mask_script"),10,4 );
70 add_action( 'gform_field_standard_settings', array($this,'type'), 10, 2 );
71 add_action( 'gform_editor_js', array($this,'editor_script') );
72 include SUPERADDONS_GF_REPEATER_PLUGIN_PATH."fields/repeater_field.php";
73 include SUPERADDONS_GF_REPEATER_PLUGIN_PATH."fields/repeater_start_field.php";
74 add_filter( 'gform_pre_validation', array( "Superaddons_GFRepeater_Field", 'remove_validation' ) );
75 add_action( 'gform_enqueue_scripts', array($this,"add_data"),10,2 );
76 }
77 function gform_input_mask_script($script_str,$form_id,$field_id,$mask){
78 $input_mask = get_option( "yeeaddons_gf_input_mask",array());
79 $input_mask["input_".$form_id."_".$field_id] = esc_js( $mask );
80 update_option( "yeeaddons_gf_input_mask",$input_mask );
81 return $script_str;
82 }
83 function add_data($form, $is_ajax ){
84 $input_mask = get_option( "yeeaddons_gf_input_mask",array());
85 wp_enqueue_script( 'gf_repeater', SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/wp_repeater.js", array('jquery',"gform_masked_input"),time());
86 $check_pro = get_option( '_redmuber_item_1540');
87 wp_localize_script("gf_repeater","yeeaddons_gf_repeater_data",array("input_mask"=>($input_mask),"pro"=>$check_pro));
88 }
89 public function styles() {
90 $styles = array(
91 array(
92 'handle' => 'repeater_icon',
93 'src' => SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/css/repeatericons.css",
94 'version' => time(),
95 'enqueue' => array(
96 array( 'field_types' => array( 'repeater_end' ) )
97 )
98 ),
99 array(
100 'handle' => 'gf_repeater',
101 'src' => SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/wp_repeater.css",
102 'version' => time(),
103 'enqueue' => array(
104 array( 'field_types' => array( 'repeater_end' ) )
105 )
106 ),
107 );
108 return array_merge( parent::styles(), $styles );
109 }
110 }