| @@ -1,159 +1,0 @@ | ||
| 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 = 'gravityforms-repeater'; | |
| 10 | - protected $_path = 'gravityforms-repeater/index.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 | - // add tasks or filters here that you want to perform only in admin | |
| 24 | - } | |
| 25 | - public function init_frontend() { | |
| 26 | - parent::init_frontend(); | |
| 27 | - // add tasks or filters here that you want to perform only in the front end | |
| 28 | - } | |
| 29 | - function type( $position, $form_id ) { | |
| 30 | - $check_pro = get_option( '_redmuber_item_1540'); | |
| 31 | - if ( $position == 1550 ) { | |
| 32 | - ?> | |
| 33 | - <li class="field_field_repeater_title_setting field_setting"> | |
| 34 | - <label class="section_label"> | |
| 35 | - <?php esc_html_e('Title', 'gravityforms-repeater'); ?> | |
| 36 | - </label> | |
| 37 | - <input type="text" id="repeater_title" placeholder="Person" value="" onchange="SetFieldProperty('repeater_title', this.value);"> | |
| 38 | - <?php esc_html_e("An optional title before each row of the repeater",'gravityforms-repeater') ?> | |
| 39 | - </li> | |
| 40 | - <?php if($check_pro == "ok") {?> | |
| 41 | - <li class="field_field_repeater_initial_rows_setting field_setting"> | |
| 42 | - <label class="section_label"> | |
| 43 | - <?php esc_html_e('Initial Rows', 'gravityforms-repeater'); ?> | |
| 44 | - </label> | |
| 45 | - <input type="text" id="repeater_initial_rows" placeholder="0" value="" onchange="SetFieldProperty('repeater_initial_rows', this.value);"> | |
| 46 | - <?php esc_html_e("The number of rows at start, if empty no rows will be created",'gravityforms-repeater') ?> | |
| 47 | - </li> | |
| 48 | - <li class="field_field_repeater_initial_rows_setting field_setting"> | |
| 49 | - <label class="section_label"> | |
| 50 | - <?php esc_html_e('Map field with Initial Rows', 'gravityforms-repeater'); ?> | |
| 51 | - </label> | |
| 52 | - <input type="text" id="repeater_initial_rows_map" placeholder="" value="" onchange="SetFieldProperty('repeater_initial_rows_map', this.value);"> | |
| 53 | - <?php esc_html_e("Map field with Initial Rows (ID field)",'gravityforms-repeater') ?> | |
| 54 | - </li> | |
| 55 | - <li class="field_field_repeater_max_setting field_setting"> | |
| 56 | - <label class="section_label"> | |
| 57 | - <?php esc_html_e('Limit', 'gravityforms-repeater'); ?> | |
| 58 | - </label> | |
| 59 | - <input type="text" id="repeater_max" placeholder="9999" value="" onchange="SetFieldProperty('repeater_max', this.value);"> | |
| 60 | - <?php esc_html_e("Max number of rows applicable by the user, leave empty for no limit",'gravityforms-repeater') ?> | |
| 61 | - </li> | |
| 62 | - <?php }else{ ?> | |
| 63 | - <li class="field_field_repeater_initial_rows_setting field_setting"> | |
| 64 | - <label class="section_label"> | |
| 65 | - <?php esc_html_e('Initial Rows', 'gravityforms-repeater'); ?> | |
| 66 | - </label> | |
| 67 | - <div class="pro_disable"> | |
| 68 | - <input type="text" id="repeater_initial_rows" placeholder="Upgrade to pro version" value="" readonly="true"> | |
| 69 | - </div> | |
| 70 | - <?php esc_html_e("The number of rows at start, if empty no rows will be created",'gravityforms-repeater') ?> | |
| 71 | - </li> | |
| 72 | - <li class="field_field_repeater_initial_rows_setting field_setting"> | |
| 73 | - <label class="section_label"> | |
| 74 | - <?php esc_html_e('Map field with Initial Rows', 'gravityforms-repeater'); ?> | |
| 75 | - </label> | |
| 76 | - <div class="pro_disable"> | |
| 77 | - <input type="text" id="repeater_initial_rows_map" placeholder="Upgrade to pro version" value="" readonly="true" > | |
| 78 | - </div> | |
| 79 | - <?php esc_html_e("Map field with Initial Rows (ID field)",'gravityforms-repeater') ?> | |
| 80 | - </li> | |
| 81 | - <li class="field_field_repeater_max_setting field_setting"> | |
| 82 | - <label class="section_label"> | |
| 83 | - <?php esc_html_e('Limit', 'gravityforms-repeater'); ?> | |
| 84 | - </label> | |
| 85 | - <input type="text" id="repeater_max" placeholder="5" value="" onchange="SetFieldProperty('repeater_max', this.value);"> | |
| 86 | - <?php esc_html_e("Max number of rows applicable by the user, leave empty for no limit (Free version limit = 5 )",'gravityforms-repeater') ?> | |
| 87 | - </li> | |
| 88 | - <?php } ?> | |
| 89 | - <li class="field_field_repeater_end_text_setting field_setting"> | |
| 90 | - <label class="section_label"> | |
| 91 | - <?php esc_html_e('Text button', 'gravityforms-repeater'); ?> | |
| 92 | - </label> | |
| 93 | - <input type="text" id="field_repeater_end_text" placeholder="Add more" value="" onchange="SetFieldProperty('field_repeater_end_text', this.value);"> | |
| 94 | - <?php esc_html_e("add button text",'gravityforms-repeater') ?> | |
| 95 | - </li> | |
| 96 | - <?php | |
| 97 | - } | |
| 98 | - } | |
| 99 | - function editor_script(){ | |
| 100 | - ?> | |
| 101 | - <script type='text/javascript'> | |
| 102 | - ( function( $ ) { | |
| 103 | - "use strict"; | |
| 104 | - jQuery(document).ready(function($) { | |
| 105 | - jQuery(document).on('gform_load_field_settings', function(event, field, form){ | |
| 106 | - jQuery('#repeater_title').val( field.repeater_title); | |
| 107 | - jQuery('#repeater_initial_rows').val( field.repeater_initial_rows); | |
| 108 | - jQuery('#repeater_max').val( field.repeater_max); | |
| 109 | - jQuery('#repeater_initial_rows_map').val( field.repeater_initial_rows_map); | |
| 110 | - jQuery('#field_repeater_end_text').val( field.field_repeater_end_text); | |
| 111 | - }); | |
| 112 | - }); | |
| 113 | - } )( jQuery ); | |
| 114 | - </script> | |
| 115 | - <?php | |
| 116 | - } | |
| 117 | - public function pre_init() { | |
| 118 | - parent::pre_init(); | |
| 119 | - add_filter( "gform_input_mask_script",array($this,"gform_input_mask_script"),10,4 ); | |
| 120 | - add_action( 'gform_field_standard_settings', array($this,'type'), 10, 2 ); | |
| 121 | - add_action( 'gform_editor_js', array($this,'editor_script') ); | |
| 122 | - include SUPERADDONS_GF_REPEATER_PLUGIN_PATH."fields/repeater_field.php"; | |
| 123 | - include SUPERADDONS_GF_REPEATER_PLUGIN_PATH."fields/repeater_start_field.php"; | |
| 124 | - add_filter( 'gform_pre_validation', array( "Superaddons_GFRepeater_Field", 'remove_validation' ) ); | |
| 125 | - add_action( 'gform_enqueue_scripts', array($this,"add_data"),10,2 ); | |
| 126 | - } | |
| 127 | - function gform_input_mask_script($script_str,$form_id,$field_id,$mask){ | |
| 128 | - $input_mask = get_option( "yeeaddons_gf_input_mask",array()); | |
| 129 | - $input_mask["input_".$form_id."_".$field_id] = esc_js( $mask ); | |
| 130 | - update_option( "yeeaddons_gf_input_mask",$input_mask ); | |
| 131 | - return $script_str; | |
| 132 | - } | |
| 133 | - function add_data($form, $is_ajax ){ | |
| 134 | - $input_mask = get_option( "yeeaddons_gf_input_mask",array()); | |
| 135 | - wp_enqueue_script( 'gf_repeater', SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/wp_repeater.js", array('jquery',"gform_masked_input"),time()); | |
| 136 | - wp_localize_script("gf_repeater","yeeaddons_gf_repeater_data",array("input_mask"=>($input_mask))); | |
| 137 | - } | |
| 138 | - public function styles() { | |
| 139 | - $styles = array( | |
| 140 | - array( | |
| 141 | - 'handle' => 'repeater_icon', | |
| 142 | - 'src' => SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/css/repeatericons.css", | |
| 143 | - 'version' => time(), | |
| 144 | - 'enqueue' => array( | |
| 145 | - array( 'field_types' => array( 'repeater_end' ) ) | |
| 146 | - ) | |
| 147 | - ), | |
| 148 | - array( | |
| 149 | - 'handle' => 'gf_repeater', | |
| 150 | - 'src' => SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/wp_repeater.css", | |
| 151 | - 'version' => time(), | |
| 152 | - 'enqueue' => array( | |
| 153 | - array( 'field_types' => array( 'repeater_end' ) ) | |
| 154 | - ) | |
| 155 | - ), | |
| 156 | - ); | |
| 157 | - return array_merge( parent::styles(), $styles ); | |
| 158 | - } | |
| 159 | -} | |