| @@ -1,166 +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="1" 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 | - | |
| 90 | - | |
| 91 | - <li class="field_field_repeater_end_text_setting field_setting"> | |
| 92 | - <label class="section_label"> | |
| 93 | - <?php esc_html_e('Text button', 'gravityforms-repeater'); ?> | |
| 94 | - </label> | |
| 95 | - <input type="text" id="field_repeater_end_text" placeholder="Add more" value="" onchange="SetFieldProperty('field_repeater_end_text', this.value);"> | |
| 96 | - <?php esc_html_e("add button text",'gravityforms-repeater') ?> | |
| 97 | - </li> | |
| 98 | - <?php | |
| 99 | - } | |
| 100 | - } | |
| 101 | - function editor_script(){ | |
| 102 | - ?> | |
| 103 | - <script type='text/javascript'> | |
| 104 | - ( function( $ ) { | |
| 105 | - "use strict"; | |
| 106 | - jQuery(document).ready(function($) { | |
| 107 | - jQuery(document).on('gform_load_field_settings', function(event, field, form){ | |
| 108 | - jQuery('#repeater_title').val( field.repeater_title); | |
| 109 | - jQuery('#repeater_initial_rows').val( field.repeater_initial_rows); | |
| 110 | - jQuery('#repeater_max').val( field.repeater_max); | |
| 111 | - jQuery('#repeater_initial_rows_map').val( field.repeater_initial_rows_map); | |
| 112 | - jQuery('#field_repeater_end_text').val( field.field_repeater_end_text); | |
| 113 | - }); | |
| 114 | - }); | |
| 115 | - } )( jQuery ); | |
| 116 | - </script> | |
| 117 | - <?php | |
| 118 | - } | |
| 119 | - public function pre_init() { | |
| 120 | - parent::pre_init(); | |
| 121 | - add_action( 'gform_field_standard_settings', array($this,'type'), 10, 2 ); | |
| 122 | - add_action( 'gform_editor_js', array($this,'editor_script') ); | |
| 123 | - include SUPERADDONS_GF_REPEATER_PLUGIN_PATH."fields/repeater_field.php"; | |
| 124 | - include SUPERADDONS_GF_REPEATER_PLUGIN_PATH."fields/repeater_start_field.php"; | |
| 125 | - add_filter( 'gform_pre_validation', array( "Superaddons_GFRepeater_Field", 'remove_validation' ) ); | |
| 126 | - } | |
| 127 | - public function scripts() { | |
| 128 | - if(!is_admin()){ | |
| 129 | - $scripts = array( | |
| 130 | - array( | |
| 131 | - 'handle' => 'gf_repeater', | |
| 132 | - 'src' => SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/wp_repeater.js", | |
| 133 | - 'version' => time(), | |
| 134 | - 'deps' => array( 'jquery'), | |
| 135 | - 'enqueue' => array( | |
| 136 | - array( 'field_types' => array( 'repeater_end' ) ), | |
| 137 | - ), | |
| 138 | - ), | |
| 139 | - ); | |
| 140 | - return array_merge( parent::scripts(), $scripts ); | |
| 141 | - }else{ | |
| 142 | - return parent::scripts(); | |
| 143 | - } | |
| 144 | - } | |
| 145 | - public function styles() { | |
| 146 | - $styles = array( | |
| 147 | - array( | |
| 148 | - 'handle' => 'repeater_icon', | |
| 149 | - 'src' => SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/css/repeatericons.css", | |
| 150 | - 'version' => time(), | |
| 151 | - 'enqueue' => array( | |
| 152 | - array( 'field_types' => array( 'repeater_end' ) ) | |
| 153 | - ) | |
| 154 | - ), | |
| 155 | - array( | |
| 156 | - 'handle' => 'gf_repeater', | |
| 157 | - 'src' => SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/wp_repeater.css", | |
| 158 | - 'version' => time(), | |
| 159 | - 'enqueue' => array( | |
| 160 | - array( 'field_types' => array( 'repeater_end' ) ) | |
| 161 | - ) | |
| 162 | - ), | |
| 163 | - ); | |
| 164 | - return array_merge( parent::styles(), $styles ); | |
| 165 | - } | |
| 166 | -} | |