@@ -124,131 +124,108 @@ function fed_profile_enable_disable( $condition = '', $type = '' ) {
124124 * @return string
125125 */
126126function fed_get_input_details ( $ attr ) {
127-
128- $ placeholder = isset ( $ attr ['placeholder ' ] ) && $ attr ['placeholder ' ] != '' ? esc_attr ( $ attr ['placeholder ' ] ) : '' ;
129- $ class = isset ( $ attr ['class_name ' ] ) && $ attr ['class_name ' ] != '' ? 'form-control ' . esc_attr ( $ attr ['class_name ' ] ) : 'form-control ' ;
130- $ name = isset ( $ attr ['input_meta ' ] ) && $ attr ['input_meta ' ] != '' ? esc_attr ( $ attr ['input_meta ' ] ) : $ attr ['input_meta ' ];
131- $ value = isset ( $ attr ['user_value ' ] ) && $ attr ['user_value ' ] != '' ? $ attr ['user_value ' ] : '' ;
132- $ required = isset ( $ attr ['is_required ' ] ) && $ attr ['is_required ' ] == 'true ' ? 'required="required" ' : '' ;
133- // $required = isset( $attr['is_required'] ) && $attr['is_required'] == 'true' ? '' : '';
134- $ id = isset ( $ attr ['id_name ' ] ) && $ attr ['id_name ' ] != '' ? $ attr ['id_name ' ] : '' ;
135- $ input = '' ;
136- $ readonly = isset ( $ attr ['readonly ' ] ) && $ attr ['readonly ' ] != '' ? esc_attr ( $ attr ['readonly ' ] ) : '' ;
137-
138- $ attr ['extended ' ] = isset ( $ attr ['extended ' ] ) ? ( is_string ( $ attr ['extended ' ] ) ? unserialize ( $ attr ['extended ' ] ) : $ attr ['extended ' ] ) : array ();
139-
140- $ altFormat = isset ( $ attr ['extended ' ]['date_format ' ] ) && $ attr ['extended ' ]['date_format ' ] != '' ? esc_attr ( $ attr ['extended ' ]['date_format ' ] ) : 'm-d-Y ' ;
141-
142- $ dateFormat = isset ( $ attr ['extended ' ]['date_format ' ] ) && $ attr ['extended ' ]['date_format ' ] != '' ? esc_attr ( $ attr ['extended ' ]['date_format ' ] ) : 'm-d-Y ' ;
143-
144- $ mode = isset ( $ attr ['extended ' ]['date_mode ' ] ) && $ attr ['extended ' ]['date_mode ' ] != '' ? esc_attr ( $ attr ['extended ' ]['date_mode ' ] ) : 'single ' ;
145-
146- $ enableTime = isset ( $ attr ['extended ' ]['enable_time ' ] ) && $ attr ['extended ' ]['enable_time ' ] != '' ? esc_attr ( $ attr ['extended ' ]['enable_time ' ] ) : false ;
147-
148- $ time_24hr = isset ( $ attr ['extended ' ]['time_24hr ' ] ) && $ attr ['extended ' ]['time_24hr ' ] != '' ? esc_attr ( $ attr ['extended ' ]['time_24hr ' ] ) : false ;
149-
150- switch ( $ attr ['input_type ' ] ) {
127+ $ values = array ();
128+ $ values ['placeholder ' ] = isset ( $ attr ['placeholder ' ] ) && $ attr ['placeholder ' ] != '' ? esc_attr ( $ attr ['placeholder ' ] ) : '' ;
129+ $ values ['input_type ' ] = isset ( $ attr ['input_type ' ] ) && $ attr ['input_type ' ] != '' ? esc_attr ( $ attr ['input_type ' ] ) : 'text ' ;
130+ $ values ['class ' ] = isset ( $ attr ['class_name ' ] ) && $ attr ['class_name ' ] != '' ? 'form-control ' . esc_attr ( $ attr ['class_name ' ] ) : 'form-control ' ;
131+ $ values ['name ' ] = isset ( $ attr ['input_meta ' ] ) && $ attr ['input_meta ' ] != '' ? esc_attr ( $ attr ['input_meta ' ] ) : 'BUG ' ;
132+ $ values ['value ' ] = isset ( $ attr ['user_value ' ] ) && $ attr ['user_value ' ] != '' ? $ attr ['user_value ' ] : '' ;
133+ $ values ['required ' ] = isset ( $ attr ['is_required ' ] ) && $ attr ['is_required ' ] == 'true ' ? 'required="required" ' : '' ;
134+ $ values ['id ' ] = isset ( $ attr ['id_name ' ] ) && $ attr ['id_name ' ] != '' ? $ attr ['id_name ' ] : '' ;
135+ $ values ['default_value ' ] = isset ( $ attr ['default_value ' ] ) && $ attr ['default_value ' ] != '' ? $ attr ['default_value ' ] : 'yes ' ;
136+ $ input = '' ;
137+ $ values ['readonly ' ] = isset ( $ attr ['readonly ' ] ) && $ attr ['readonly ' ] === true ? 'readonly=readonly ' : '' ;
138+ $ values ['disabled ' ] = isset ( $ attr ['disabled ' ] ) && $ attr ['disabled ' ] === true ? 'disabled=disabled ' : '' ;
139+
140+ $ label = isset ( $ attr ['label ' ] ) ? $ attr ['label ' ] : '' ;
141+ $ values ['extended ' ] = isset ( $ attr ['extended ' ] ) ? ( is_string ( $ attr ['extended ' ] ) ? unserialize ( $ attr ['extended ' ] ) : $ attr ['extended ' ] ) : array ();
142+
143+ $ values ['extra ' ] = isset ( $ attr ['extra ' ] ) ? $ attr ['extra ' ] : '' ;
144+
145+ switch ( $ values ['input_type ' ] ) {
151146 case 'single_line ' :
152- $ input .= '<input ' . $ readonly . ' ' . $ required . ' type="text" name=" ' . $ name . '" value=" ' . esc_attr ( $ value ) . '" class=" ' . $ class . '" placeholder=" ' . $ placeholder . '" id=" ' . $ id . '"> ' ;
147+ $ input .= '<input ' . $ values [ ' disabled ' ] . $ values [ ' extra ' ] . $ values [ ' readonly ' ] . ' ' . $ values [ ' required ' ] . ' type="text" name=" ' . $ values [ ' name ' ] . '" value=" ' . esc_attr ( $ values [ ' value ' ] ) . '" class=" ' . $ values [ ' class ' ] . '" placeholder=" ' . $ values [ ' placeholder ' ] . '" id=" ' . $ values [ ' id ' ] . '"> ' ;
153148 break ;
149+
154150 case 'hidden ' :
155- $ input .= '<input ' . $ readonly . ' ' . $ required . ' type="hidden" name=" ' . $ name . '" value=" ' . esc_attr ( $ value ) . '" class=" ' . $ class . '" placeholder=" ' . $ placeholder . '" id=" ' . $ id . '"> ' ;
151+ $ input .= '<input ' . $ values [ ' disabled ' ] . $ values [ ' extra ' ] . $ values [ ' readonly ' ] . ' ' . $ values [ ' required ' ] . ' type="hidden" name=" ' . $ values [ ' name ' ] . '" value=" ' . esc_attr ( $ values [ ' value ' ] ) . '" class=" ' . $ values [ ' class ' ] . '" placeholder=" ' . $ values [ ' placeholder ' ] . '" id=" ' . $ values [ ' id ' ] . '"> ' ;
156152 break ;
153+
157154 case 'email ' :
158- $ input .= '<input ' . $ readonly . ' ' . $ required . ' type="email" name=" ' . $ name . '" value=" ' . esc_attr ( $ value ) . '" class=" ' . $ class . '" placeholder=" ' . $ placeholder . '" id=" ' . $ id . '"> ' ;
159- break ;
160- case 'password ' :
161- $ input .= '<input ' . $ required . ' type="password" name=" ' . $ name . '" class=" ' . $ class . '" placeholder=" ' . $ placeholder . '" id=" ' . $ id . '"> ' ;
162- break ;
163- case 'date ' :
164- $ input .= '<input type="text" ' . $ required . ' data-date-format="F j, Y h:i K" data-alt-format=" ' . $ dateFormat . '" data-alt-input="true" data-mode=" ' . $ mode . '" placeholder=" ' . $ altFormat . '" data-enable-time=" ' . $ enableTime . '" data-time_24hr=" ' . $ time_24hr . '" type="text" name=" ' . $ name . '" class="flatpickr ' . $ class . '" id=" ' . $ id . '" value=" ' . $ value . '" > ' ;
155+ $ input .= '<input ' . $ values ['disabled ' ] . $ values ['extra ' ] . $ values ['readonly ' ] . ' ' . $ values ['required ' ] . ' type="email" name=" ' . $ values ['name ' ] . '" value=" ' . esc_attr ( $ values ['value ' ] ) . '" class=" ' . $ values ['class ' ] . '" placeholder=" ' . $ values ['placeholder ' ] . '" id=" ' . $ values ['id ' ] . '"> ' ;
165156 break ;
166157
167- case 'url ' :
168- $ input .= '<input ' . $ required . ' type="url" placeholder=" ' . $ placeholder . '" name=" ' . $ name . '" class=" ' . $ class . '" id =" ' . $ id . '" value =" ' . esc_attr ( $ value ) . '" > ' ;
158+ case 'password ' :
159+ $ input .= '<input ' . $ values [ ' disabled ' ] . $ values [ ' extra ' ] . $ values [ ' required ' ] . ' type="password" name=" ' . $ values [ ' name ' ] . '" class=" ' . $ values [ ' class ' ] . '" placeholder =" ' . $ values [ ' placeholder ' ] . '" id =" ' . $ values [ ' id ' ] . '"> ' ;
169160 break ;
170161
171- case 'color ' :
172- if ( $ value == '' ) {
173- $ value = '#000000 ' ;
174- }
175- $ input .= '<input ' . $ required . ' type="text" name=" ' . $ name . '" class="jscolor {hash:true} ' . $ class . '" id=" ' . $ id . '" value=" ' . esc_attr ( $ value ) . '" > ' ;
176- break ;
177162
178- case 'file ' :
179- if ( $ value != '' ) {
180- $ value = (int ) $ value ;
181- $ img = wp_get_attachment_image ( $ value , array ( 100 , 100 ) );
182- if ( $ img == '' ) {
183- $ img = '<span class="fed_upload_icon fa fa-2x fa fa fa-upload"></span> ' ;
184- }
185- } else {
186- $ value = '' ;
187- $ img = '<span class="fed_upload_icon fa fa-2x fa fa fa-upload"></span> ' ;
188- }
189- $ input .= '<div class="fed_upload_container text-center ' . $ class . '" id=" ' . $ id . '">
190- <div class="fed_upload_image_container"> ' . $ img . '</div>
191- <input type="hidden" name=" ' . $ name . '" class="fed_upload_input" value=" ' . $ value . '" />
192- </div> ' ;
163+ case 'url ' :
164+ $ input .= '<input ' . $ values ['disabled ' ] . $ values ['extra ' ] . $ values ['required ' ] . ' type="url" placeholder=" ' . $ values ['placeholder ' ] . '" name=" ' . $ values ['name ' ] . '" class=" ' . $ values ['class ' ] . '" id=" ' . $ values ['id ' ] . '" value=" ' . esc_attr ( $ values ['value ' ] ) . '" > ' ;
193165 break ;
194166
195167 case 'multi_line ' :
196168 $ rows = isset ( $ attr ['rows ' ] ) ? absint ( $ attr ['rows ' ] ) : 4 ;
197169
198- $ input .= '<textarea name=" ' . $ name . '" rows=" ' . $ rows . '"
199- class=" ' . $ class . '" placeholder=" ' . $ placeholder . '" id=" ' . $ id . '"> ' . esc_textarea ( $ value ) . '</textarea> ' ;
170+ $ input .= '<textarea ' . $ values [ ' disabled ' ] . $ values [ ' extra ' ] . ' name=" ' . $ values [ ' name ' ] . '" rows=" ' . $ rows . '"
171+ class=" ' . $ values [ ' class ' ] . '" placeholder=" ' . $ values [ ' placeholder ' ] . '" id=" ' . $ values [ ' id ' ] . '"> ' . esc_textarea ( $ values [ ' value ' ] ) . '</textarea> ' ;
200172 break ;
201173
202174 case 'checkbox ' :
203- $ label = isset ( $ attr ['label ' ] ) ? $ attr ['label ' ] : '' ;
204- $ class = $ class == 'form-control ' ? '' : $ class ;
205- $ input .= '<label class=" ' . $ class . '" for=" ' . $ name . '">
206- <input ' . $ required . ' name=" ' . $ name . '" value="yes"
207- type="checkbox" id=" ' . $ id . '" ' . checked ( $ value , 'yes ' , false ) . '>
208- ' . $ label . '</label> ' ;
175+ $ values ['class ' ] = $ values ['class ' ] == 'form-control ' ? '' : $ values ['class ' ];
176+ $ input .= '<label class=" ' . $ values ['class ' ] . '">
177+ <input ' . $ values ['disabled ' ] . $ values ['extra ' ] . $ values ['required ' ] . ' name=" ' . $ values ['name ' ] . '" value=" ' .$ values ['default_value ' ].'" type="checkbox" id=" ' . $ values ['id ' ] . '" ' . checked ( $ values ['value ' ], $ values ['default_value ' ], false ) . '> ' . $ label . '</label> ' ;
209178
210179 break ;
211180
212181 case 'select ' :
213- //$options = is_array( $attr['input_value'] ) ? $attr['input_value'] : array();
214- $ options = strlen ( $ attr ['input_value ' ] ) > 0 ? fed_convert_comma_separated_key_value ( $ attr ['input_value ' ] ) : array ();
215- $ input .= '<select name=" ' . $ name . '" class=" ' . $ class . '" id=" ' . $ id . '"> ' ;
182+ $ options = fed_get_select_option_value ( $ attr ['input_value ' ] );
183+ $ input .= '<select ' . $ values ['disabled ' ] . $ values ['extra ' ] . ' name=" ' . $ values ['name ' ] . '" class=" ' . $ values ['class ' ] . '" id=" ' . $ values ['id ' ] . '"> ' ;
216184 foreach ( $ options as $ key => $ label ) {
217185 $ input .= '<option
218- value=" ' . esc_attr ( $ key ) . '" ' . selected ( $ value , $ key , false ) . '> ' . $ label . '</option> ' ;
186+ value=" ' . esc_attr ( $ key ) . '" ' . selected ( $ values [ ' value ' ] , $ key , false ) . '> ' . $ label . '</option> ' ;
219187 }
220188 $ input .= '</select> ' ;
221189 break ;
222190
223191 case 'number ' :
224192 $ min = isset ( $ attr ['input_min ' ] ) ? $ attr ['input_min ' ] : 0 ;
225- $ max = isset ( $ attr ['input_max ' ] ) ? $ attr ['input_max ' ] : 0 ;
193+ $ max = isset ( $ attr ['input_max ' ] ) ? $ attr ['input_max ' ] : 999999 ;
226194 $ step = isset ( $ attr ['input_step ' ] ) ? $ attr ['input_step ' ] : 'any ' ;
227195
228- $ input .= '<input ' . $ required . ' type="number" name=" ' . $ name . '"
229- value=" ' . esc_attr ( $ value ) . '" class=" ' . $ class . '"
230- placeholder=" ' . $ placeholder . '"
196+ $ input .= '<input ' . $ values [ ' disabled ' ] . $ values [ ' extra ' ] . $ values [ ' required ' ] . ' type="number" name=" ' . $ values [ ' name ' ] . '"
197+ value=" ' . esc_attr ( $ values [ ' value ' ] ) . '" class=" ' . $ values [ ' class ' ] . '"
198+ placeholder=" ' . $ values [ ' placeholder ' ] . '"
231199 min=" ' . esc_attr ( $ min ) . '"
232200 max=" ' . esc_attr ( $ max ) . '"
233- step=" ' . esc_attr ( $ step ) . '" id=" ' . $ id . '"> ' ;
201+ step=" ' . esc_attr ( $ step ) . '" id=" ' . $ values [ ' id ' ] . '"> ' ;
234202 break ;
235203
236204 case 'radio ' :
237- // $options = is_array( $attr['options'] ) ? $attr['options'] : array();
238- $ class = $ class == 'form-control ' ? '' : $ class ;
239- $ options = strlen ( $ attr ['input_value ' ] ) > 0 ? fed_convert_comma_separated_key_value ( $ attr ['input_value ' ] ) : array ();
205+ $ values ['class ' ] = $ values ['class ' ] == 'form-control ' ? '' : $ values ['class ' ];
206+ $ options = strlen ( $ attr ['input_value ' ] ) > 0 ? fed_convert_comma_separated_key_value ( $ attr ['input_value ' ] ) : array ();
240207 foreach ( $ options as $ key => $ label ) {
241- $ input .= '<label class=" ' . $ class . '" for=" ' . $ key . '">
242- <input name=" ' . $ name . '" value=" ' . $ key . '"
243- type="radio" ' . checked ( $ value , $ key , false ) . $ required . '>
208+ $ input .= '<label class=" ' . $ values [ ' class ' ] . '" for=" ' . $ key . '">
209+ <input ' . $ values [ ' disabled ' ] . $ values [ ' extra ' ] . ' name=" ' . $ values [ ' name ' ] . '" value=" ' . $ key . '"
210+ type="radio" ' . checked ( $ values [ ' value ' ] , $ key , false ) . $ values [ ' required ' ] . '>
244211 ' . $ label . '
245212 </label> ' ;
246213 }
247214 break ;
248215
249216 }
250217
251- return apply_filters ( 'fed_custom_input_fields ' , $ input , $ attr );
218+ return apply_filters ( 'fed_custom_input_fields ' , $ input , $ values , $ attr );
219+ }
220+
221+ function fed_get_select_option_value ( $ input_value ) {
222+ if ( is_string ( $ input_value ) ) {
223+ return strlen ( $ input_value ) > 0 ? fed_convert_comma_separated_key_value ( $ input_value ) : array ();
224+ }
225+ if ( is_array ( $ input_value ) ) {
226+ return count ( $ input_value ) > 0 ? $ input_value : array ();
227+ }
228+
252229}
253230
254231/**
@@ -1290,6 +1267,7 @@ function fed_get_script_loading_pages() {
12901267 'fed_orders ' ,
12911268 'fed_help ' ,
12921269 'fed_status ' ,
1270+ 'fed_plugin_pages '
12931271 ) );
12941272}
12951273
@@ -1469,7 +1447,7 @@ function fed_currency_type() {
14691447 * @return array
14701448 */
14711449function fed_get_country_code () {
1472- return apply_filters ('fed_extend_country_code ' ,array (
1450+ return apply_filters ( 'fed_extend_country_code ' , array (
14731451 'empty ' => 'Select Country ' ,
14741452 'AF ' => 'AFGHANISTAN ' ,
14751453 'AX ' => 'ÅLAND ISLANDS ' ,
@@ -1714,7 +1692,7 @@ function fed_get_country_code() {
17141692 'YE ' => 'YEMEN ' ,
17151693 'ZM ' => 'ZAMBIA ' ,
17161694 'ZW ' => 'ZIMBABWE ' ,
1717- ));
1695+ ) );
17181696}
17191697
17201698/**
@@ -2010,7 +1988,7 @@ function fed_show_help_message( array $message ) {
20101988 $ content = isset ( $ message ['content ' ] ) ? $ message ['content ' ] : '' ;
20111989
20121990 return '
2013- <span class=" ' . $ icon . '" data-toggle="popover" data-trigger="hover" title=" ' . $ title . '" data-content=" ' . $ content . '" data-original-title=" ' . $ title. '"></span>
1991+ <span class=" ' . $ icon . '" data-toggle="popover" data-trigger="hover" title=" ' . $ title . '" data-content=" ' . $ content . '" data-original-title=" ' . $ title . '"></span>
20141992 ' ;
20151993}
20161994
0 commit comments