Skip to content

Commit 10a7156

Browse files
Merge pull request #3 from mavinothkumar/1.1
Bug fixes and refactored
2 parents ee77b64 + 27693bf commit 10a7156

File tree

24 files changed

+414
-274
lines changed

24 files changed

+414
-274
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ Then Please go to Frontend Dashboard | Frontend Dashboard | Login (Tab) | Settin
7777
6. [fed_user role=user_role] to generate the role based user page
7878

7979
### Changelog
80+
81+
**v1.1 [11-August-2017]**
82+
* Added more filter and action hooks for developers
83+
* Minor: Bug fixed
84+
85+
8086
**v1.0 [04-August-2017]**
8187
- Public release
8288

admin/assets/fed_admin_script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ jQuery(document).ready(function ($) {
250250

251251

252252
}
253-
e.preventDefault;
253+
e.preventDefault();
254254
});
255255

256256
$('.fed_add_edit_input_container .fed_button.active').trigger('click');

admin/assets/fed_admin_style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ Loader
528528
border: 1px solid #e0e0e0;
529529
cursor: pointer;
530530
}
531+
.bc_fed.fed_plugins .thumbnail > img, .bc_fed.fed_plugins .thumbnail a > img {
532+
width: 100% !important;
533+
}
534+
.bc_fed.fed_plugins .thumbnail {
535+
padding:0 !important;
536+
}
531537
.bc_fed .fed_buttons_container .fed_button.active {
532538
background-color: #00B5AD;
533539
color: white;

admin/function-admin.php

Lines changed: 61 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -124,131 +124,108 @@ function fed_profile_enable_disable( $condition = '', $type = '' ) {
124124
* @return string
125125
*/
126126
function 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
*/
14711449
function 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

admin/layout/add_edit_profile.php

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ class="close"
8787
}
8888
$row = fed_process_user_profile( $rows, $action );
8989
$selected = $row['input_type'];
90-
}
91-
else {
90+
} else {
9291
$row = fed_get_empty_value_for_user_profile( $action );
9392
}
9493
}
@@ -173,8 +172,10 @@ function fed_get_admin_up_role_based( $row, $action ) {
173172
<div class="col-md-12">
174173
<label><?php _e( 'Select user role to show this input field', 'fed' ) ?></label>
175174
</div>
176-
<?php foreach ( $all_roles as $key => $role ) {
177-
$c_value = in_array( $key, $row['user_role'] ) ? 'Enable' : 'Disable';
175+
<?php
176+
177+
foreach ( $all_roles as $key => $role ) {
178+
$c_value = in_array( $key, $row['user_role'],false ) ? 'Enable' : 'Disable';
178179
?>
179180
<div class="col-md-2">
180181
<?php echo fed_input_box( 'user_role', array(
@@ -192,7 +193,7 @@ function fed_get_admin_up_role_based( $row, $action ) {
192193
<label><?php _e( 'Menu Location', 'fed' ) ?></label>
193194
<?php echo fed_input_box( 'menu', array(
194195
'default_value' => 'Enable',
195-
'label' => __('Menu Location','fed'),
196+
'label' => __( 'Menu Location', 'fed' ),
196197
'value' => $row['menu'],
197198
'options' => $options
198199
), 'select' ); ?>
@@ -202,7 +203,7 @@ function fed_get_admin_up_role_based( $row, $action ) {
202203
<div class="form-group col-md-4 fed_show_user_profile">
203204
<?php echo fed_input_box( 'show_user_profile', array(
204205
'default_value' => 'Disable',
205-
'label' => __('Disable in User Profile?','fed'),
206+
'label' => __( 'Disable in User Profile?', 'fed' ),
206207
'value' => $row['show_user_profile'],
207208
), 'checkbox' ); ?>
208209
</div>
@@ -224,8 +225,8 @@ function fed_get_admin_up_display_permission( $row, $action, $type = '' ) {
224225
?>
225226
<div class="row fed_admin_up_display_permission">
226227
<?php
227-
if ( $action == 'profile' ) {
228-
if ( $type == 'file' ) {
228+
if ( $action === 'profile' ) {
229+
if ( $type === 'file' ) {
229230
$value = 'Disable';
230231
$others = 'disabled';
231232
$notification = '<i class="fa fa-info bg-info-font" data-toggle="popover" data-trigger="hover" title=" Status" data-content="Only registered user can upload the files."></i>';
@@ -236,11 +237,11 @@ function fed_get_admin_up_display_permission( $row, $action, $type = '' ) {
236237
} ?>
237238
<div class="form-group col-md-4">
238239
<?php echo fed_input_box( 'show_register', array(
239-
'default_value' => 'Enable',
240-
'label' => __('Show this field on Register Form','fed').$notification,
241-
'value' => $value,
242-
'disabled' => $others
243-
), 'checkbox' );
240+
'default_value' => 'Enable',
241+
'label' => __( 'Show this field on Register Form', 'fed' ) .' ' .$notification,
242+
'value' => $value,
243+
'disabled' => $others
244+
), 'checkbox' );
244245

245246
?>
246247

@@ -295,7 +296,7 @@ function fed_get_admin_up_label_input_order( $row ) {
295296
<?php echo fed_input_box( 'label_name', array(
296297
'class' => 'form-control ' . $change . ' ',
297298
'value' => $row['label_name']
298-
), 'text' ); ?>
299+
), 'single_line' ); ?>
299300
</div>
300301

301302
<div class="form-group col-md-6">
@@ -342,9 +343,10 @@ function fed_get_admin_up_input_meta( $row ) {
342343
<?php
343344
if ( fed_check_field_is_belongs_to_extra( $row['input_meta'] ) ) {
344345
echo fed_input_box( 'input_meta', array(
345-
'class' => 'fed_admin_input_meta form-control',
346-
'value' => $row['input_meta'],
347-
), 'readonly' );
346+
'class' => 'fed_admin_input_meta form-control',
347+
'value' => $row['input_meta'],
348+
'readonly' => true,
349+
), 'single_line' );
348350

349351
echo fed_input_box( 'fed_extra', array(
350352
'value' => $row['input_meta'],
@@ -353,7 +355,7 @@ function fed_get_admin_up_input_meta( $row ) {
353355
echo fed_input_box( 'input_meta', array(
354356
'class' => 'fed_admin_input_meta form-control',
355357
'value' => $row['input_meta']
356-
), 'text' );
358+
), 'single_line' );
357359
}
358360
?>
359361
</div>

admin/layout/input_fields/common.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
function fed_get_placeholder_field( array $row ) {
88
?>
99
<label for=""><?php _e( 'Placeholder Text', 'fed' ) ?></label>
10-
<?php echo fed_input_box( 'placeholder', array( 'value' => $row['placeholder'] ), 'text' ); ?>
10+
<?php echo fed_input_box( 'placeholder', array( 'value' => $row['placeholder'] ), 'single_line' ); ?>
1111
<?php
1212
}
1313

1414
function fed_get_class_field( array $row ) {
1515
?>
1616
<label for=""><?php _e( 'Class Name', 'fed' ) ?></label>
17-
<?php echo fed_input_box( 'class_name', array( 'value' => $row['class_name'] ), 'text' ); ?>
17+
<?php echo fed_input_box( 'class_name', array( 'value' => $row['class_name'] ), 'single_line' ); ?>
1818
<?php
1919
}
2020

2121
function fed_get_id_field( array $row ) {
2222
?>
2323
<label for=""><?php _e( 'ID Name', 'fed' ) ?></label>
24-
<?php echo fed_input_box( 'id_name', array( 'value' => $row['id_name'] ), 'text' ); ?>
24+
<?php echo fed_input_box( 'id_name', array( 'value' => $row['id_name'] ), 'single_line' ); ?>
2525
<?php
2626
}

admin/layout/input_fields/radio.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class="fed_admin_menu fed_ajax"
4545
'placeholder' => __('Please enter the value by key,value','fed'),
4646
'rows' => 10,
4747
'value' => $row['input_value']
48-
), 'textarea' ); ?>
48+
), 'multi_line' ); ?>
4949
</div>
5050
<div class="col-md-7">
5151
<div class="row fed_key_value_eg_container">

0 commit comments

Comments
 (0)