| 1 |
<?php |
| 2 |
/** |
| 3 |
* The form builder functionality of the plugin. |
| 4 |
* |
| 5 |
* @link http://wpgeodirectory.com |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package userswp |
| 9 |
* @subpackage userswp/admin/settings |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* The form builder functionality of the plugin. |
| 14 |
* |
| 15 |
* @package userswp |
| 16 |
* @subpackage userswp/admin/settings |
| 17 |
* @author GeoDirectory Team <info@wpgeodirectory.com> |
| 18 |
*/ |
| 19 |
class UsersWP_Form_Builder { |
| 20 |
|
| 21 |
public static function output( $tab = '' ) { |
| 22 |
|
| 23 |
global $current_tab; |
| 24 |
|
| 25 |
do_action( 'uwp_form_builder_start' ); |
| 26 |
|
| 27 |
// Get current tab/section |
| 28 |
if ( $tab ) { |
| 29 |
$current_tab = sanitize_title( $tab ); |
| 30 |
} else { |
| 31 |
$current_tab = empty( $_GET['tab'] ) ? 'account' : sanitize_title( $_GET['tab'] ); |
| 32 |
} |
| 33 |
|
| 34 |
$form = ''; |
| 35 |
if(isset($_GET['form']) && !empty($_GET['form'])){ |
| 36 |
$form = '&form='.(int) $_GET['form']; |
| 37 |
} |
| 38 |
|
| 39 |
// Get tabs for the form builder page |
| 40 |
$tabs = apply_filters( 'uwp_form_builder_tabs_array', array( |
| 41 |
'account' => __( 'Account', 'userswp' ), |
| 42 |
'register' => __( 'Register', 'userswp' ), |
| 43 |
) ); |
| 44 |
|
| 45 |
?> |
| 46 |
<div class="wrap"> |
| 47 |
<nav class="nav-tab-wrapper uwp-nav-tab-wrapper"> |
| 48 |
<?php |
| 49 |
foreach ( $tabs as $name => $label ) { |
| 50 |
echo '<a href="' . esc_url( admin_url( 'admin.php?page=uwp_form_builder&tab=' . $name . $form ) ) . '" id="uwp-form-builder-' . esc_attr( $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
| 51 |
} |
| 52 |
do_action( 'uwp_form_builder_tabs' ); |
| 53 |
?> |
| 54 |
</nav> |
| 55 |
<h1 class="screen-reader-text"><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1> |
| 56 |
<?php |
| 57 |
do_action( 'uwp_form_builder_tabs_content', $current_tab, $tabs ); |
| 58 |
do_action( 'uwp_form_builder_tabs_' . $current_tab, $tabs ); |
| 59 |
do_action( 'uwp_extra_form_builder_content', $current_tab, $tabs ); |
| 60 |
?> |
| 61 |
</div> |
| 62 |
<?php |
| 63 |
} |
| 64 |
|
| 65 |
public function uwp_form_builder( $default_tab = 'account' ) { |
| 66 |
ob_start(); |
| 67 |
$form_type = ( isset( $_GET['tab'] ) && $_GET['tab'] != '' ) ? sanitize_text_field( $_GET['tab'] ) : $default_tab; |
| 68 |
?> |
| 69 |
<div class="uwp-panel-heading"> |
| 70 |
<h3><?php echo apply_filters( 'uwp_form_builder_panel_head', '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></h3> |
| 71 |
</div> |
| 72 |
|
| 73 |
<div class="uwp-before-form-builder-container"> |
| 74 |
<?php do_action( 'uwp_before_form_builder_content', $default_tab ); ?> |
| 75 |
</div> |
| 76 |
|
| 77 |
<div id="uwp_form_builder_container" class="clearfix"> |
| 78 |
<div class="uwp-form-builder-frame"> |
| 79 |
|
| 80 |
<div class="uwp-side-sortables" id="uwp-available-fields"> |
| 81 |
<h3> |
| 82 |
<span><?php echo apply_filters( 'uwp_form_builder_available_fields_head', __( 'Add new form field', 'userswp' ), $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span> |
| 83 |
</h3> |
| 84 |
|
| 85 |
<p> |
| 86 |
<?php |
| 87 |
$note = sprintf( __( 'Click on any box below to add a field of that type on %s form. You must use a fieldset to group your fields.', 'userswp' ), $form_type ); |
| 88 |
echo apply_filters( 'uwp_form_builder_available_fields_note', $note, $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 89 |
?> |
| 90 |
</p> |
| 91 |
|
| 92 |
<?php do_action( 'uwp_before_available_fields', $default_tab ); ?> |
| 93 |
|
| 94 |
<h3> |
| 95 |
<?php esc_html_e( 'Standard Fields', 'userswp' ); ?> |
| 96 |
</h3> |
| 97 |
|
| 98 |
<div class="inside"> |
| 99 |
<div id="uwp-form-builder-tab" class="uwp-tabs-panel"> |
| 100 |
<?php do_action( 'uwp_manage_available_fields', $form_type ); ?> |
| 101 |
</div> |
| 102 |
</div> |
| 103 |
<?php |
| 104 |
|
| 105 |
$predefined_fields = apply_filters( 'uwp_predefined_fields_tabs', array( |
| 106 |
'account', |
| 107 |
'profile-tabs' |
| 108 |
) ); |
| 109 |
if ( in_array( $form_type, $predefined_fields ) ) { |
| 110 |
?> |
| 111 |
<h3> |
| 112 |
<?php esc_html_e( 'Predefined Fields', 'userswp' ); ?> |
| 113 |
</h3> |
| 114 |
|
| 115 |
<div class="inside"> |
| 116 |
<div id="uwp-form-builder-tab-predefined" class="uwp-tabs-panel"> |
| 117 |
<?php do_action( 'uwp_manage_available_fields_predefined', $form_type ); ?> |
| 118 |
</div> |
| 119 |
</div> |
| 120 |
<?php } |
| 121 |
|
| 122 |
$custom_fields = apply_filters( 'uwp_custom_fields_tabs', array( 'account', 'profile-tabs' ) ); |
| 123 |
if ( in_array( $form_type, $custom_fields ) ) { ?> |
| 124 |
<h3> |
| 125 |
<?php esc_html_e( 'Custom Fields', 'userswp' ); ?> |
| 126 |
</h3> |
| 127 |
|
| 128 |
<div class="inside"> |
| 129 |
<div id="uwp-form-builder-tab-custom" class="uwp-tabs-panel"> |
| 130 |
<?php do_action( 'uwp_manage_available_fields_custom', $form_type ); ?> |
| 131 |
</div> |
| 132 |
</div> |
| 133 |
<?php } |
| 134 |
do_action( 'uwp_after_available_fields', $default_tab ); |
| 135 |
?> |
| 136 |
</div> |
| 137 |
|
| 138 |
|
| 139 |
<div class="uwp-side-sortables" id="uwp-selected-fields"> |
| 140 |
|
| 141 |
<h3> |
| 142 |
<span> |
| 143 |
<?php |
| 144 |
$title = __( 'List of fields that will appear in the account form.', 'userswp' ); |
| 145 |
echo apply_filters( 'uwp_form_builder_selected_fields_head', $title, $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 146 |
</span> |
| 147 |
</h3> |
| 148 |
|
| 149 |
<p> |
| 150 |
<?php |
| 151 |
$note = sprintf( __( 'Click to expand and view field related settings. You may drag and drop to arrange fields order on %s form too.', 'userswp' ), $form_type ); |
| 152 |
echo apply_filters( 'uwp_form_builder_selected_fields_note', $note, $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 153 |
</p> |
| 154 |
|
| 155 |
<div class="inside"> |
| 156 |
<div id="uwp-form-builder-tab-selected" class="uwp-tabs-panel"> |
| 157 |
<div class="field_row_main"> |
| 158 |
<?php do_action( 'uwp_manage_selected_fields', $form_type ); ?> |
| 159 |
</div> |
| 160 |
</div> |
| 161 |
</div> |
| 162 |
|
| 163 |
</div> |
| 164 |
|
| 165 |
</div> |
| 166 |
</div> |
| 167 |
|
| 168 |
<?php |
| 169 |
echo ob_get_clean(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 170 |
} |
| 171 |
|
| 172 |
public function display_before_available_fields( $tab = '' ) { |
| 173 |
global $wpdb; |
| 174 |
|
| 175 |
if ( empty( $tab ) || $tab == 'account' ) { |
| 176 |
$form_type = 'account'; |
| 177 |
$type = 'predefined'; |
| 178 |
?> |
| 179 |
<h3> |
| 180 |
<span> |
| 181 |
<?php echo apply_filters( 'uwp_form_builder_available_fields_head', __( 'Existing Fields', 'userswp' ), $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 182 |
</span> |
| 183 |
</h3> |
| 184 |
|
| 185 |
<p> |
| 186 |
<?php |
| 187 |
$note = sprintf( __( 'Click on field to add it to the form. Existing fields are most used fields in all other forms.', 'userswp' ), $form_type ); |
| 188 |
echo apply_filters( 'uwp_form_builder_existing_fields_note', $note, $form_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 189 |
?> |
| 190 |
</p> |
| 191 |
|
| 192 |
<div class="inside"> |
| 193 |
<div id="uwp-form-builder-tab-existing" class="uwp-tabs-panel"> |
| 194 |
<input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr($form_type); ?>"/> |
| 195 |
<input type="hidden" name="manage_field_type" class="manage_field_type" value="custom_fields"> |
| 196 |
<ul class="core uwp-tabs-selected uwp_form_extras"> |
| 197 |
<?php |
| 198 |
$form_id = ! empty( $_GET['form'] ) ? absint($_GET['form']) : 1; |
| 199 |
$table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 200 |
$existing_fields = $wpdb->get_results( "select htmlvar_name from " . $table_name . " where form_type ='" . $form_type . "' AND form_id = " . $form_id ); |
| 201 |
|
| 202 |
$existing_field_ids = array(); |
| 203 |
if ( ! empty( $existing_fields ) ) { |
| 204 |
foreach ( $existing_fields as $existing_field ) { |
| 205 |
$existing_field_ids[] = $existing_field->htmlvar_name; |
| 206 |
} |
| 207 |
} |
| 208 |
|
| 209 |
$fields = $this->get_form_existing_fields( $form_type, 'array' ); |
| 210 |
|
| 211 |
if ( ! empty( $fields ) ) { |
| 212 |
foreach ( $fields as $id => $field ) { |
| 213 |
$display = ''; |
| 214 |
if ( in_array( $field['htmlvar_name'], $existing_field_ids ) ) { |
| 215 |
$display = 'display:none;'; |
| 216 |
} |
| 217 |
|
| 218 |
$style = 'style="' . $display . '"'; |
| 219 |
?> |
| 220 |
<li class="uwp-tooltip-wrap" <?php echo esc_attr($style); ?>> |
| 221 |
<a id="uwp-<?php echo esc_attr($field['htmlvar_name']); ?>" |
| 222 |
data-field-custom-type="<?php echo esc_attr($type); ?>" |
| 223 |
data-field-type-key="<?php echo esc_attr($field['htmlvar_name']); ?>" |
| 224 |
data-field-type="<?php echo esc_attr($field['field_type']); ?>" |
| 225 |
class="uwp-draggable-form-items" |
| 226 |
href="javascript:void(0);"> |
| 227 |
|
| 228 |
<?php if ( isset( $field['field_icon'] ) && strpos( $field['field_icon'], ' fa-' ) !== false ) { |
| 229 |
echo '<i class="' . esc_attr($field['field_icon']) . '" aria-hidden="true"></i>'; |
| 230 |
} elseif ( isset( $field['field_icon'] ) && $field['field_icon'] ) { |
| 231 |
echo '<b style="background-image: url("' . esc_url($field['field_icon']) . '")"></b>'; |
| 232 |
} else { |
| 233 |
echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
| 234 |
} |
| 235 |
|
| 236 |
echo ' ' . esc_attr($field['site_title']); |
| 237 |
|
| 238 |
if ( isset( $field['help_text'] ) && $field['help_text'] ) { |
| 239 |
echo uwp_help_tip( $field['help_text'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 240 |
} ?> |
| 241 |
</a> |
| 242 |
</li> |
| 243 |
<?php |
| 244 |
} |
| 245 |
} |
| 246 |
?> |
| 247 |
</ul> |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
<?php |
| 251 |
} |
| 252 |
} |
| 253 |
|
| 254 |
public function get_form_existing_fields( $type = '', $output = '' ) { |
| 255 |
|
| 256 |
global $wpdb; |
| 257 |
$custom_fields = array(); |
| 258 |
$table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 259 |
$register_forms = uwp_get_option( 'multiple_registration_forms' ); |
| 260 |
if ( 'array' == $output ) { |
| 261 |
$output = ARRAY_A; |
| 262 |
} else { |
| 263 |
$output = OBJECT; |
| 264 |
} |
| 265 |
if ( ! empty( $register_forms ) && is_array( $register_forms ) ) { |
| 266 |
foreach ( $register_forms as $key => $register_form ) { |
| 267 |
$form_ids[] = (int) $register_form['id']; |
| 268 |
} |
| 269 |
|
| 270 |
if ( isset( $form_ids ) && count( $form_ids ) > 0 ) { |
| 271 |
$form_ids_placeholder = array_fill( 0, count( $form_ids ), '%s' ); |
| 272 |
$form_ids_placeholder = implode( ', ', $form_ids_placeholder ); |
| 273 |
$query = "SELECT * FROM " . $table_name . " WHERE form_type = 'account' AND form_id IN (" . $form_ids_placeholder . ") ORDER BY sort_order ASC"; |
| 274 |
$custom_fields = $wpdb->get_results( $wpdb->prepare( $query, $form_ids ), $output ); |
| 275 |
} |
| 276 |
} |
| 277 |
|
| 278 |
$custom_fields = uwp_get_unique_custom_fields( $custom_fields ); |
| 279 |
|
| 280 |
return apply_filters( 'uwp_form_existing_fields', $custom_fields, $type ); |
| 281 |
} |
| 282 |
|
| 283 |
public function multiple_registration_form( $tab = '' ) { |
| 284 |
|
| 285 |
if ( empty( $tab ) || $tab == 'account' ) { |
| 286 |
$current_form = ! empty( $_GET['form'] ) ? (int) $_GET['form'] : 1; |
| 287 |
$register_tab = admin_url( 'admin.php?page=uwp_form_builder&tab=account' ); |
| 288 |
$register_forms = uwp_get_option( 'multiple_registration_forms' ); |
| 289 |
$user_roles = uwp_get_user_roles(); |
| 290 |
$current_role = get_option( 'default_role' ); |
| 291 |
$actions = uwp_get_registration_form_actions(); |
| 292 |
$current_action = uwp_get_option( 'uwp_registration_action', false ); |
| 293 |
$current_title = __( 'Form', 'userswp' ); |
| 294 |
$current_redirect_to = $current_custom_url = ''; |
| 295 |
$current_gdpr_page = $current_tos_page = - 1; |
| 296 |
if ( ! empty( $_GET['form_type'] ) && $_GET['form_type'] === 'new' ) { |
| 297 |
$new_added = ! empty( $register_forms ) ? end( $register_forms ) : array(); |
| 298 |
$current_form = ! empty( $new_added['id'] ) ? $new_added['id'] : 1; |
| 299 |
} |
| 300 |
?> |
| 301 |
<div class="multiple-registration-form"> |
| 302 |
<form class="uwp_user_type_form" id="uwp_user_type_form" method="POST"> |
| 303 |
<input type="hidden" name="manage_field_form_id" class="manage_field_form_id" |
| 304 |
id="manage_field_form_id" |
| 305 |
value="<?php echo esc_attr( $current_form ); ?>"> |
| 306 |
<?php do_action( 'uwp_user_type_form_before', $current_form, $tab ); ?> |
| 307 |
<?php |
| 308 |
if ( ! empty( $register_forms ) && is_array( $register_forms ) ) { ?> |
| 309 |
<table class="form-table bsui userswp" id="uwp-forms-main"> |
| 310 |
<tr> |
| 311 |
<th><?php esc_html_e( 'Select Form:', 'userswp' ); ?></th> |
| 312 |
<td> |
| 313 |
<div class="d-inline-block align-top"> |
| 314 |
<select onChange="window.location.replace(jQuery(this).val());" |
| 315 |
name="form_select" id="multiple_registration_select" |
| 316 |
class="small-text aui-select2"> |
| 317 |
<?php |
| 318 |
foreach ( $register_forms as $key => $forms ) { |
| 319 |
$form_id = ! empty( $forms['id'] ) ? $forms['id'] : ''; |
| 320 |
$form_title = ! empty( $forms['title'] ) ? sanitize_title_with_dashes($forms['title']) : ''; |
| 321 |
$user_role = ! empty( $forms['user_role'] ) ? $forms['user_role'] : ''; |
| 322 |
$action = ! empty( $forms['reg_action'] ) ? $forms['reg_action'] : $current_action; |
| 323 |
$redirect_to = isset( $forms['redirect_to'] ) ? $forms['redirect_to'] : ''; |
| 324 |
$custom_url = ! empty( $forms['custom_url'] ) ? $forms['custom_url'] : ''; |
| 325 |
$gdpr_page = ! empty( $forms['gdpr_page'] ) ? (int) $forms['gdpr_page'] : - 1; |
| 326 |
$tos_page = ! empty( $forms['tos_page'] ) ? (int) $forms['tos_page'] : - 1; |
| 327 |
if ( $current_form == $form_id ) { |
| 328 |
$current_title = $form_title; |
| 329 |
$current_action = $action; |
| 330 |
$current_redirect_to = $redirect_to; |
| 331 |
$current_custom_url = $custom_url; |
| 332 |
$current_gdpr_page = $gdpr_page; |
| 333 |
$current_tos_page = $tos_page; |
| 334 |
if ( ! empty( $user_role ) && in_array( $user_role, array_keys( $user_roles ) ) ) { |
| 335 |
$current_role = $user_role; |
| 336 |
} |
| 337 |
} |
| 338 |
?> |
| 339 |
<option <?php selected( $current_form, $form_id ); ?> |
| 340 |
value="<?php echo esc_attr( $register_tab . '&form=' . $form_id ); ?>"><?php echo esc_html( wp_sprintf( __( '%s - #%s', 'userswp' ), $form_title, $form_id ) ); ?></option> |
| 341 |
<?php } |
| 342 |
?> |
| 343 |
</select> |
| 344 |
</div> |
| 345 |
<div class="d-inline-block align-top"> |
| 346 |
<button class="btn btn-sm btn-info register-show-options" type="button" |
| 347 |
id="show_options"><?php esc_html_e( 'Form Options', 'userswp' ); ?></button> |
| 348 |
<?php if ( ! empty( $current_form ) && $current_form > 1 ) { ?> |
| 349 |
<button data-id="<?php echo esc_attr($current_form); ?>" |
| 350 |
data-nonce="<?php echo esc_attr( wp_create_nonce( 'uwp-delete-register-form-nonce' ) ); ?>" |
| 351 |
class="btn btn-sm btn-danger register-form-remove" type="button" |
| 352 |
name="form_remove"><?php esc_html_e( 'Delete Form', 'userswp' ); ?></button> |
| 353 |
<?php } ?> |
| 354 |
<button data-nonce="<?php echo esc_attr( wp_create_nonce( 'uwp-create-register-form-nonce' ) ); ?>" |
| 355 |
class="btn btn-sm btn-primary register-form-create" type="button" |
| 356 |
name="register_form_create" |
| 357 |
id="form_create"><?php esc_html_e( 'Create Form', 'userswp' ); ?></button> |
| 358 |
</div> |
| 359 |
</td> |
| 360 |
</tr> |
| 361 |
</table> |
| 362 |
<?php } ?> |
| 363 |
|
| 364 |
<table class="form-table bsui userswp" id="uwp-form-more-options" style="display:none;"> |
| 365 |
<tr> |
| 366 |
<th><?php esc_html_e( 'Title:', 'userswp' ); echo uwp_help_tip(__('Title of the form', 'userswp')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th> |
| 367 |
<td> |
| 368 |
<input type="text" name="form_title" value="<?php echo esc_attr($current_title); ?>" |
| 369 |
class="regular-text"> |
| 370 |
</td> |
| 371 |
<?php if ( ! empty( $user_roles ) && is_array( $user_roles ) ) { ?> |
| 372 |
<th><?php esc_html_e( 'User Role to Assign:', 'userswp' ); echo uwp_help_tip(__('Role to assign when user register via this form.', 'userswp')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th> |
| 373 |
<td> |
| 374 |
<select name="user_role" id="multiple_registration_user_role" |
| 375 |
class="small-text aui-select2"> |
| 376 |
<?php |
| 377 |
foreach ( $user_roles as $key => $user_role ) { |
| 378 |
?> |
| 379 |
<option <?php selected( $current_role, $key ); ?> |
| 380 |
value="<?php echo esc_attr($key); ?>"><?php echo esc_html( wp_sprintf( __( '%s', 'userswp' ), $user_role ) ); ?></option> |
| 381 |
<?php } |
| 382 |
?> |
| 383 |
</select> |
| 384 |
</td> |
| 385 |
<?php } ?> |
| 386 |
</tr> |
| 387 |
<tr> |
| 388 |
<th><?php esc_html_e( 'Registration Action:', 'userswp' ); echo uwp_help_tip(__('Select how registration should be handled.', 'userswp')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th> |
| 389 |
<td> |
| 390 |
<select name="reg_action" id="uwp_registration_action" |
| 391 |
class="small-text aui-select2"> |
| 392 |
<?php |
| 393 |
foreach ( $actions as $key => $action ) { |
| 394 |
?> |
| 395 |
<option <?php selected( $current_action, $key ); ?> |
| 396 |
value="<?php echo esc_attr($key); ?>"><?php echo esc_html( wp_sprintf( __( '%s', 'userswp' ), $action ) ); ?></option> |
| 397 |
<?php } ?> |
| 398 |
</select> |
| 399 |
</td> |
| 400 |
</tr> |
| 401 |
<tr style="display:none;"> |
| 402 |
<th><?php esc_html_e( 'Redirect Page:', 'userswp' ); echo uwp_help_tip(__('Set the page to redirect the user to after signing up.', 'userswp')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th> |
| 403 |
<td> |
| 404 |
<select name="redirect_to" id="register_redirect_to" |
| 405 |
class="small-text aui-select2"> |
| 406 |
<?php |
| 407 |
$pages = get_pages(); |
| 408 |
$pages_options = array( |
| 409 |
'-1' => __( 'Last User Page', 'userswp' ), |
| 410 |
'0' => __( 'Default Redirect', 'userswp' ), |
| 411 |
'-2' => __( 'Custom Redirect', 'userswp' ), |
| 412 |
); |
| 413 |
if ( $pages ) { |
| 414 |
foreach ( $pages as $page ) { |
| 415 |
$pages_options[ $page->ID ] = $page->post_title; |
| 416 |
} |
| 417 |
} |
| 418 |
foreach ( $pages_options as $key => $option ) { |
| 419 |
?> |
| 420 |
<option <?php selected( $current_redirect_to, $key ); ?> |
| 421 |
value="<?php echo esc_attr($key); ?>"><?php echo esc_html( wp_sprintf( __( '%s', 'userswp' ), $option ) ); ?></option> |
| 422 |
<?php } ?> |
| 423 |
</select> |
| 424 |
</td> |
| 425 |
<th><?php esc_html_e( 'Custom Redirect URL:', 'userswp' ); echo uwp_help_tip(__( 'Set the page to redirect the user to after signing up. If default redirect has been set then WordPress default will be used.', 'userswp' )); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th> |
| 426 |
<td> |
| 427 |
<input type="text" name="custom_url" id="register_redirect_custom_url" |
| 428 |
class="regular-text" value="<?php echo esc_attr($current_custom_url); ?>"> |
| 429 |
</td> |
| 430 |
</tr> |
| 431 |
<tr> |
| 432 |
<th><?php esc_html_e( 'GDPR Policy Page:', 'userswp' ); echo uwp_help_tip(__('Page to link when GDPR policy page custom field added to form. If not set then default setting will be used.', 'userswp')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th> |
| 433 |
<td> |
| 434 |
<?php |
| 435 |
$args = array( |
| 436 |
'name' => 'gdpr_page', |
| 437 |
'id' => 'multiple_registration_gdpr_page', |
| 438 |
'sort_column' => 'menu_order', |
| 439 |
'sort_order' => 'ASC', |
| 440 |
'show_option_none' => ' ', |
| 441 |
'class' => ' regular-text aui-select2 ', |
| 442 |
'echo' => false, |
| 443 |
'selected' => (int) $current_gdpr_page > 0 ? (int) $current_gdpr_page : - 1, |
| 444 |
); |
| 445 |
echo str_replace( ' id=', " data-placeholder='" . esc_attr__( 'Select a page…', 'userswp' ) . "' id=", wp_dropdown_pages( $args ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 446 |
?> |
| 447 |
</td> |
| 448 |
<th><?php esc_html_e( 'TOS Page:', 'userswp' ); echo uwp_help_tip(__('Page to link when Terms and Conditions custom field added to form. If not set then default setting will be used.', 'userswp')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped?></th> |
| 449 |
<td> |
| 450 |
<?php |
| 451 |
$args = array( |
| 452 |
'name' => 'tos_page', |
| 453 |
'id' => 'multiple_registration_tos_page', |
| 454 |
'sort_column' => 'menu_order', |
| 455 |
'sort_order' => 'ASC', |
| 456 |
'show_option_none' => ' ', |
| 457 |
'class' => ' regular-text aui-select2 ', |
| 458 |
'echo' => false, |
| 459 |
'selected' => (int) $current_tos_page > 0 ? (int) $current_tos_page : - 1, |
| 460 |
); |
| 461 |
echo str_replace( ' id=', " data-placeholder='" . esc_attr__( 'Select a page…', 'userswp' ) . "' id=", wp_dropdown_pages( $args ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 462 |
?> |
| 463 |
</td> |
| 464 |
</tr> |
| 465 |
<?php do_action( 'uwp_user_type_form_before_submit', $current_form, $tab ); ?> |
| 466 |
<tr> |
| 467 |
<td></td> |
| 468 |
<td> |
| 469 |
<button class="btn btn-sm btn-secondary" id="form_update" type="submit" |
| 470 |
name="form_update"><?php esc_html_e( 'Update', 'userswp' ); ?></button> |
| 471 |
</td> |
| 472 |
</tr> |
| 473 |
</table> |
| 474 |
<input type="hidden" name="uwp_update_register_form_nonce" value="<?php echo esc_attr( wp_create_nonce( 'uwp-update-register-form-nonce' ) ); ?>" /> |
| 475 |
<?php do_action( 'uwp_user_type_form_after', $current_form, $tab ); ?> |
| 476 |
</form> |
| 477 |
</div> |
| 478 |
<?php |
| 479 |
} |
| 480 |
|
| 481 |
if ( ! empty( $tab ) && $tab == 'register' ) { |
| 482 |
$current_form = ! empty( $_GET['form'] ) ? absint($_GET['form']) : 1; |
| 483 |
|
| 484 |
$register_tab = admin_url( 'admin.php?page=uwp_form_builder&tab=register' ); |
| 485 |
$register_forms = uwp_get_option( 'multiple_registration_forms' ); |
| 486 |
?> |
| 487 |
<div class="multiple-registration-form"> |
| 488 |
<input type="hidden" name="manage_field_form_id" class="manage_field_form_id" id="manage_field_form_id" |
| 489 |
value="<?php echo esc_attr( $current_form ); ?>"> |
| 490 |
<table class="form-table bsui userswp"> |
| 491 |
<?php |
| 492 |
if ( ! empty( $register_forms ) && is_array( $register_forms ) ) { ?> |
| 493 |
<tr> |
| 494 |
<th><?php esc_html_e( 'Select Form:', 'userswp' ); ?></th> |
| 495 |
<td> |
| 496 |
<div class="d-inline-block align-top"> |
| 497 |
<select onChange="window.location.replace(jQuery(this).val());" |
| 498 |
name="multiple-registration-select" id="multiple_registration_select" |
| 499 |
class="small-text aui-select2"> |
| 500 |
<?php |
| 501 |
foreach ( $register_forms as $key => $forms ) { |
| 502 |
$form_id = ! empty( $forms['id'] ) ? $forms['id'] : ''; |
| 503 |
$form_title = ! empty( $forms['title'] ) ? sanitize_title_with_dashes($forms['title']) : ''; |
| 504 |
?> |
| 505 |
<option <?php selected( $current_form, $form_id ); ?> |
| 506 |
value="<?php echo esc_attr( $register_tab . '&form=' . $form_id ); ?>"><?php echo esc_html( wp_sprintf( __( '%s - #%s', 'userswp' ), $form_title, $form_id ) ); ?></option> |
| 507 |
<?php } ?> |
| 508 |
</select> |
| 509 |
</div> |
| 510 |
</td> |
| 511 |
</tr> |
| 512 |
<?php } |
| 513 |
if ( ! empty( $current_form ) && $current_form > 0 ) { ?> |
| 514 |
<tr> |
| 515 |
<th><?php esc_html_e( 'Register Form Shortcode:', 'userswp' ); ?></th> |
| 516 |
<td> |
| 517 |
<span class="uwp-custom-desc"><code><strong>[uwp_register id="<?php echo esc_attr( $current_form ); ?>" title="<?php echo esc_attr( uwp_get_register_form_by( $current_form ) ); ?>"]</strong></code></span> |
| 518 |
</td> |
| 519 |
</tr> |
| 520 |
<?php } ?> |
| 521 |
</table> |
| 522 |
</div> |
| 523 |
<?php |
| 524 |
} |
| 525 |
|
| 526 |
if ( ! empty( $tab ) && $tab == 'profile-tabs' ) { |
| 527 |
$current_form = ! empty( $_GET['form'] ) ? absint($_GET['form']) : 1; |
| 528 |
|
| 529 |
$register_tab = admin_url( 'admin.php?page=uwp_form_builder&tab=profile-tabs' ); |
| 530 |
$register_forms = uwp_get_option( 'multiple_registration_forms' ); |
| 531 |
?> |
| 532 |
<div class="multiple-registration-form"> |
| 533 |
<input type="hidden" name="manage_field_form_id" class="manage_field_form_id" id="manage_field_form_id" |
| 534 |
value="<?php echo esc_attr( $current_form ); ?>"> |
| 535 |
<table class="form-table bsui userswp"> |
| 536 |
<?php |
| 537 |
if ( ! empty( $register_forms ) && is_array( $register_forms ) ) { ?> |
| 538 |
<tr> |
| 539 |
<th><?php esc_html_e( 'Select Form:', 'userswp' ); ?></th> |
| 540 |
<td> |
| 541 |
<div class="d-inline-block align-top"> |
| 542 |
<select onChange="window.location.replace(jQuery(this).val());" |
| 543 |
name="multiple-registration-select" id="multiple_registration_select" |
| 544 |
class="small-text aui-select2"> |
| 545 |
<?php |
| 546 |
foreach ( $register_forms as $key => $forms ) { |
| 547 |
$form_id = ! empty( $forms['id'] ) ? $forms['id'] : ''; |
| 548 |
$form_title = ! empty( $forms['title'] ) ? $forms['title'] : ''; |
| 549 |
?> |
| 550 |
<option <?php selected( $current_form, $form_id ); ?> |
| 551 |
value="<?php echo esc_attr( $register_tab . '&form=' . $form_id ); ?>"><?php echo esc_html( wp_sprintf( __( '%s - #%s', 'userswp' ), $form_title, $form_id ) ); ?></option> |
| 552 |
<?php } ?> |
| 553 |
</select> |
| 554 |
</div> |
| 555 |
</td> |
| 556 |
</tr> |
| 557 |
<?php } ?> |
| 558 |
</table> |
| 559 |
</div> |
| 560 |
<?php |
| 561 |
} |
| 562 |
} |
| 563 |
|
| 564 |
public function manage_available_fields_predefined( $form_type ) { |
| 565 |
switch ( $form_type ) { |
| 566 |
case 'account': |
| 567 |
$this->custom_available_fields( 'predefined', $form_type ); |
| 568 |
break; |
| 569 |
} |
| 570 |
} |
| 571 |
|
| 572 |
public function custom_available_fields( $type, $form_type ) { |
| 573 |
?> |
| 574 |
<input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr($form_type); ?>"/> |
| 575 |
<input type="hidden" name="manage_field_type" class="manage_field_type" value="custom_fields"> |
| 576 |
<?php |
| 577 |
if ( $type == 'predefined' ) { |
| 578 |
$fields = $this->form_fields_predefined( $form_type ); |
| 579 |
} elseif ( $type == 'custom' ) { |
| 580 |
$fields = $this->form_fields_custom( $form_type ); |
| 581 |
} else { |
| 582 |
$fields = $this->form_fields( $form_type ); |
| 583 |
?> |
| 584 |
<ul class="full"> |
| 585 |
<li class="uwp-tooltip-wrap"> |
| 586 |
<a id="uwp-fieldset" |
| 587 |
class="uwp-draggable-form-items uwp-fieldset" |
| 588 |
href="javascript:void(0);" |
| 589 |
data-field-custom-type="" |
| 590 |
data-field-type="fieldset" |
| 591 |
data-field-type-key="fieldset"> |
| 592 |
<i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i> |
| 593 |
<i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i> |
| 594 |
<?php esc_html_e( 'Fieldset (section separator)', 'userswp' ); |
| 595 |
echo uwp_help_tip( __( 'This adds a section separator with a title.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 596 |
?> |
| 597 |
</a> |
| 598 |
</li> |
| 599 |
</ul> |
| 600 |
|
| 601 |
<?php |
| 602 |
} |
| 603 |
|
| 604 |
if ( ! empty( $fields ) ) { |
| 605 |
?> |
| 606 |
<ul> |
| 607 |
<?php |
| 608 |
foreach ( $fields as $id => $field ) { |
| 609 |
?> |
| 610 |
<li class="uwp-tooltip-wrap"> |
| 611 |
<a id="uwp-<?php echo esc_attr( $id ); ?>" |
| 612 |
data-field-custom-type="<?php echo esc_attr($type); ?>" |
| 613 |
data-field-type-key="<?php echo esc_attr($id); ?>" |
| 614 |
data-field-type="<?php echo esc_attr($field['field_type']); ?>" |
| 615 |
class="uwp-draggable-form-items" |
| 616 |
href="javascript:void(0);"> |
| 617 |
|
| 618 |
<?php if ( isset( $field['field_icon'] ) && strpos( $field['field_icon'], ' fa-' ) !== false ) { |
| 619 |
echo '<i class="' . esc_attr($field['field_icon']) . '" aria-hidden="true"></i>'; |
| 620 |
} elseif ( isset( $field['field_icon'] ) && $field['field_icon'] ) { |
| 621 |
echo '<b style="background-image: url("' . esc_url($field['field_icon']) . '")"></b>'; |
| 622 |
} else { |
| 623 |
echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
| 624 |
} |
| 625 |
|
| 626 |
echo ' ' . esc_attr($field['site_title']); |
| 627 |
|
| 628 |
if ( isset( $field['help_text'] ) && $field['help_text'] ) { |
| 629 |
echo uwp_help_tip( $field['help_text'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 630 |
} ?> |
| 631 |
</a> |
| 632 |
</li> |
| 633 |
<?php |
| 634 |
} |
| 635 |
} else { |
| 636 |
esc_html_e( 'There are no custom fields here yet.', 'userswp' ); |
| 637 |
} |
| 638 |
?> |
| 639 |
</ul> |
| 640 |
|
| 641 |
<?php |
| 642 |
|
| 643 |
} |
| 644 |
|
| 645 |
public function form_fields_predefined( $type = '' ) { |
| 646 |
$custom_fields = array(); |
| 647 |
|
| 648 |
// Country |
| 649 |
$custom_fields['uwp_country'] = array( |
| 650 |
'field_type' => 'select', |
| 651 |
'class' => 'uwp-country', |
| 652 |
'field_icon' => 'fas fa-map-marker-alt', |
| 653 |
'site_title' => __( 'Country', 'userswp' ), |
| 654 |
'help_text' => __( 'Adds a input for Country field.', 'userswp' ), |
| 655 |
'defaults' => array( |
| 656 |
'admin_title' => 'Country', |
| 657 |
'site_title' => 'Country', |
| 658 |
'htmlvar_name' => 'uwp_country', |
| 659 |
'is_active' => 1, |
| 660 |
'default_value' => '', |
| 661 |
'is_required' => 0, |
| 662 |
'option_values' => '', |
| 663 |
'required_msg' => '', |
| 664 |
'field_icon' => 'fas fa-map-marker-alt', |
| 665 |
'css_class' => '' |
| 666 |
) |
| 667 |
); |
| 668 |
|
| 669 |
// Gender |
| 670 |
$custom_fields['gender'] = array( |
| 671 |
'field_type' => 'select', |
| 672 |
'class' => 'uwp-gender', |
| 673 |
'field_icon' => 'fas fa-user', |
| 674 |
'site_title' => __( 'Gender', 'userswp' ), |
| 675 |
'help_text' => __( 'Adds a input for Gender field.', 'userswp' ), |
| 676 |
'defaults' => array( |
| 677 |
'admin_title' => 'Gender', |
| 678 |
'site_title' => 'Gender', |
| 679 |
'htmlvar_name' => 'gender', |
| 680 |
'is_active' => 1, |
| 681 |
'default_value' => '', |
| 682 |
'is_required' => 0, |
| 683 |
'option_values' => __( 'Male,Female,Other', 'userswp' ), |
| 684 |
'required_msg' => '', |
| 685 |
'field_icon' => 'fas fa-user', |
| 686 |
'css_class' => '' |
| 687 |
) |
| 688 |
); |
| 689 |
|
| 690 |
$custom_fields['dob'] = array( |
| 691 |
'field_type' => 'datepicker', |
| 692 |
'class' => 'uwp-dob', |
| 693 |
'field_icon' => 'fas fa-birthday-cake', |
| 694 |
'site_title' => __( 'Date of birth', 'userswp' ), |
| 695 |
'help_text' => __( 'Adds a date input for users to enter their date of birth.', 'userswp' ), |
| 696 |
'defaults' => array( |
| 697 |
'data_type' => 'DATE', |
| 698 |
'admin_title' => __( 'Date of birth', 'userswp' ), |
| 699 |
'site_title' => __( 'Date of birth', 'userswp' ), |
| 700 |
'form_label' => __( 'Enter your date of birth.', 'userswp' ), |
| 701 |
'htmlvar_name' => 'dob', |
| 702 |
'is_active' => true, |
| 703 |
'for_admin_use' => false, |
| 704 |
'default_value' => '', |
| 705 |
'is_required' => false, |
| 706 |
'validation_pattern' => '', |
| 707 |
'validation_msg' => '', |
| 708 |
'required_msg' => '', |
| 709 |
'field_icon' => 'fas fa-birthday-cake', |
| 710 |
'css_class' => '', |
| 711 |
'extra_fields' => array( |
| 712 |
'date_range' => 'c-100:c+0' |
| 713 |
) |
| 714 |
) |
| 715 |
); |
| 716 |
|
| 717 |
// Mobile |
| 718 |
$custom_fields['mobile'] = array( |
| 719 |
'field_type' => 'phone', |
| 720 |
'class' => 'uwp-mobile', |
| 721 |
'field_icon' => 'fas fa-mobile-alt', |
| 722 |
'site_title' => __( 'Mobile', 'userswp' ), |
| 723 |
'help_text' => __( 'Adds a input for Mobile field.', 'userswp' ), |
| 724 |
'defaults' => array( |
| 725 |
'admin_title' => 'Mobile', |
| 726 |
'site_title' => 'Mobile', |
| 727 |
'htmlvar_name' => 'mobile', |
| 728 |
'is_active' => 1, |
| 729 |
'default_value' => '', |
| 730 |
'is_required' => 0, |
| 731 |
'required_msg' => '', |
| 732 |
'field_icon' => 'fas fa-mobile-alt', |
| 733 |
'css_class' => '' |
| 734 |
) |
| 735 |
); |
| 736 |
|
| 737 |
$custom_fields['register_gdpr'] = array( |
| 738 |
'field_type' => 'checkbox', |
| 739 |
'class' => 'uwp-register-gdpr', |
| 740 |
'field_icon' => 'fas fa-file', |
| 741 |
'site_title' => __( 'GDPR Policy Page', 'userswp' ), |
| 742 |
'help_text' => __( 'Adds Register GDPR page.', 'userswp' ), |
| 743 |
'defaults' => array( |
| 744 |
'admin_title' => 'GDPR Policy', |
| 745 |
'site_title' => 'GDPR Policy', |
| 746 |
'form_label' => __( 'GDPR Policy', 'userswp' ), |
| 747 |
'htmlvar_name' => 'register_gdpr', |
| 748 |
'is_active' => 1, |
| 749 |
'default_value' => '', |
| 750 |
'is_required' => 1, |
| 751 |
'required_msg' => '', |
| 752 |
'field_icon' => 'fas fa-file', |
| 753 |
'css_class' => 'btn-register-gdpr' |
| 754 |
) |
| 755 |
); |
| 756 |
|
| 757 |
$custom_fields['register_tos'] = array( |
| 758 |
'field_type' => 'checkbox', |
| 759 |
'class' => 'uwp-register-tos', |
| 760 |
'field_icon' => 'fas fa-file', |
| 761 |
'site_title' => __( 'Terms & Conditions', 'userswp' ), |
| 762 |
'help_text' => __( 'Adds Register TOS page.', 'userswp' ), |
| 763 |
'help_text_tip' => __( 'This will show next to the checkbox, to add a link to the TOS page, use format: %%link_start%% View TOS %%link_end%%', 'userswp' ), |
| 764 |
'defaults' => array( |
| 765 |
'admin_title' => 'Terms & Conditions', |
| 766 |
'site_title' => 'Terms & Conditions', |
| 767 |
'form_label' => __( 'Terms & Conditions', 'userswp' ), |
| 768 |
'htmlvar_name' => 'register_tos', |
| 769 |
'is_active' => 1, |
| 770 |
'default_value' => '', |
| 771 |
'is_required' => 1, |
| 772 |
'required_msg' => '', |
| 773 |
'field_icon' => 'fas fa-file', |
| 774 |
'css_class' => 'btn-register-tos', |
| 775 |
) |
| 776 |
); |
| 777 |
|
| 778 |
// Website |
| 779 |
$custom_fields['user_url'] = array( |
| 780 |
'field_type' => 'url', |
| 781 |
'class' => 'uwp-website', |
| 782 |
'field_icon' => 'fas fa-link', |
| 783 |
'site_title' => __( 'Website', 'userswp' ), |
| 784 |
'help_text' => __( 'Let users enter their website url.', 'userswp' ), |
| 785 |
'defaults' => array( |
| 786 |
'admin_title' => 'Website', |
| 787 |
'site_title' => 'Website', |
| 788 |
'form_label' => __( 'Website', 'userswp' ), |
| 789 |
'htmlvar_name' => 'user_url', |
| 790 |
'is_active' => 1, |
| 791 |
'default_value' => '', |
| 792 |
'is_required' => 0, |
| 793 |
'required_msg' => '', |
| 794 |
'field_icon' => 'fas fa-link', |
| 795 |
'css_class' => 'btn-website' |
| 796 |
) |
| 797 |
); |
| 798 |
|
| 799 |
// Facebook |
| 800 |
$custom_fields['facebook'] = array( |
| 801 |
'field_type' => 'url', |
| 802 |
'class' => 'uwp-facebook', |
| 803 |
'field_icon' => 'fab fa-facebook-square', |
| 804 |
'site_title' => __( 'Facebook', 'userswp' ), |
| 805 |
'help_text' => __( 'Let users enter their facebook url.', 'userswp' ), |
| 806 |
'defaults' => array( |
| 807 |
'admin_title' => 'Facebook', |
| 808 |
'site_title' => 'Facebook', |
| 809 |
'form_label' => __( 'Facebook url', 'userswp' ), |
| 810 |
'htmlvar_name' => 'facebook', |
| 811 |
'is_active' => 1, |
| 812 |
'default_value' => '', |
| 813 |
'is_required' => 0, |
| 814 |
'required_msg' => '', |
| 815 |
'field_icon' => 'fab fa-facebook-f', |
| 816 |
'css_class' => 'btn-facebook' |
| 817 |
) |
| 818 |
); |
| 819 |
|
| 820 |
// Twitter |
| 821 |
$custom_fields['twitter'] = array( |
| 822 |
'field_type' => 'url', |
| 823 |
'class' => 'uwp-twitter', |
| 824 |
'field_icon' => 'fab fa-twitter-square', |
| 825 |
'site_title' => __( 'Twitter', 'userswp' ), |
| 826 |
'help_text' => __( 'Let users enter their twitter url.', 'userswp' ), |
| 827 |
'defaults' => array( |
| 828 |
'admin_title' => 'Twitter', |
| 829 |
'site_title' => 'Twitter', |
| 830 |
'form_label' => __( 'Twitter url', 'userswp' ), |
| 831 |
'htmlvar_name' => 'twitter', |
| 832 |
'is_active' => 1, |
| 833 |
'default_value' => '', |
| 834 |
'is_required' => 0, |
| 835 |
'required_msg' => '', |
| 836 |
'field_icon' => 'fab fa-twitter', |
| 837 |
'css_class' => 'btn-twitter' |
| 838 |
) |
| 839 |
); |
| 840 |
|
| 841 |
// Instagram |
| 842 |
$custom_fields['instagram'] = array( |
| 843 |
'field_type' => 'url', |
| 844 |
'class' => 'uwp-instagram', |
| 845 |
'field_icon' => 'fab fa-instagram', |
| 846 |
'site_title' => __( 'Instagram', 'userswp' ), |
| 847 |
'help_text' => __( 'Let users enter their instagram url.', 'userswp' ), |
| 848 |
'defaults' => array( |
| 849 |
'admin_title' => 'Instagram', |
| 850 |
'site_title' => 'Instagram', |
| 851 |
'form_label' => __( 'Instagram url', 'userswp' ), |
| 852 |
'htmlvar_name' => 'instagram', |
| 853 |
'is_active' => 1, |
| 854 |
'default_value' => '', |
| 855 |
'is_required' => 0, |
| 856 |
'required_msg' => '', |
| 857 |
'field_icon' => 'fab fa-instagram', |
| 858 |
'css_class' => 'btn-instagram' |
| 859 |
) |
| 860 |
); |
| 861 |
|
| 862 |
// Linkedin |
| 863 |
$custom_fields['linkedin'] = array( |
| 864 |
'field_type' => 'url', |
| 865 |
'class' => 'uwp-linkedin', |
| 866 |
'field_icon' => 'fab fa-linkedin', |
| 867 |
'site_title' => __( 'Linkedin', 'userswp' ), |
| 868 |
'help_text' => __( 'Let users enter their linkedin url.', 'userswp' ), |
| 869 |
'defaults' => array( |
| 870 |
'admin_title' => 'Linkedin', |
| 871 |
'site_title' => 'Linkedin', |
| 872 |
'form_label' => __( 'Linkedin url', 'userswp' ), |
| 873 |
'htmlvar_name' => 'linkedin', |
| 874 |
'is_active' => 1, |
| 875 |
'default_value' => '', |
| 876 |
'is_required' => 0, |
| 877 |
'required_msg' => '', |
| 878 |
'field_icon' => 'fab fa-linkedin-in', |
| 879 |
'css_class' => 'btn-linkedin' |
| 880 |
) |
| 881 |
); |
| 882 |
|
| 883 |
|
| 884 |
// Flickr |
| 885 |
$custom_fields['flickr'] = array( |
| 886 |
'field_type' => 'url', |
| 887 |
'class' => 'uwp-flickr', |
| 888 |
'field_icon' => 'fab fa-flickr', |
| 889 |
'site_title' => __( 'Flickr', 'userswp' ), |
| 890 |
'help_text' => __( 'Let users enter their Flickr url.', 'userswp' ), |
| 891 |
'defaults' => array( |
| 892 |
'admin_title' => 'Flickr', |
| 893 |
'site_title' => 'Flickr', |
| 894 |
'form_label' => __( 'Flickr url', 'userswp' ), |
| 895 |
'htmlvar_name' => 'flickr', |
| 896 |
'is_active' => 1, |
| 897 |
'default_value' => '', |
| 898 |
'is_required' => 0, |
| 899 |
'required_msg' => '', |
| 900 |
'field_icon' => 'fab fa-flickr', |
| 901 |
'css_class' => 'btn-flickr' |
| 902 |
) |
| 903 |
); |
| 904 |
|
| 905 |
// GitHub |
| 906 |
$custom_fields['github'] = array( |
| 907 |
'field_type' => 'url', |
| 908 |
'class' => 'uwp-github', |
| 909 |
'field_icon' => 'fab fa-github-square', |
| 910 |
'site_title' => __( 'GitHub', 'userswp' ), |
| 911 |
'help_text' => __( 'Let users enter their GitHub url.', 'userswp' ), |
| 912 |
'defaults' => array( |
| 913 |
'admin_title' => 'GitHub', |
| 914 |
'site_title' => 'GitHub', |
| 915 |
'form_label' => __( 'GitHub url', 'userswp' ), |
| 916 |
'htmlvar_name' => 'github', |
| 917 |
'is_active' => 1, |
| 918 |
'default_value' => '', |
| 919 |
'is_required' => 0, |
| 920 |
'required_msg' => '', |
| 921 |
'field_icon' => 'fab fa-github-alt', |
| 922 |
'css_class' => 'btn-github' |
| 923 |
) |
| 924 |
); |
| 925 |
|
| 926 |
// YouTube |
| 927 |
$custom_fields['youtube'] = array( |
| 928 |
'field_type' => 'url', |
| 929 |
'class' => 'uwp-youtube', |
| 930 |
'field_icon' => 'fab fa-youtube-square', |
| 931 |
'site_title' => __( 'YouTube', 'userswp' ), |
| 932 |
'help_text' => __( 'Let users enter their YouTube url.', 'userswp' ), |
| 933 |
'defaults' => array( |
| 934 |
'admin_title' => 'YouTube', |
| 935 |
'site_title' => 'YouTube', |
| 936 |
'form_label' => __( 'YouTube url', 'userswp' ), |
| 937 |
'htmlvar_name' => 'youtube', |
| 938 |
'is_active' => 1, |
| 939 |
'default_value' => '', |
| 940 |
'is_required' => 0, |
| 941 |
'required_msg' => '', |
| 942 |
'field_icon' => 'fab fa-youtube', |
| 943 |
'css_class' => 'btn-youtube' |
| 944 |
) |
| 945 |
); |
| 946 |
|
| 947 |
// WordPress |
| 948 |
$custom_fields['wordpress'] = array( |
| 949 |
'field_type' => 'url', |
| 950 |
'class' => 'uwp-wordpress', |
| 951 |
'field_icon' => 'fab fa-wordpress-simple', |
| 952 |
'site_title' => __( 'WordPress', 'userswp' ), |
| 953 |
'help_text' => __( 'Let users enter their WordPress profile url.', 'userswp' ), |
| 954 |
'defaults' => array( |
| 955 |
'admin_title' => 'WordPress', |
| 956 |
'site_title' => 'WordPress', |
| 957 |
'form_label' => __( 'WordPress url', 'userswp' ), |
| 958 |
'htmlvar_name' => 'wordpress', |
| 959 |
'is_active' => 1, |
| 960 |
'default_value' => '', |
| 961 |
'is_required' => 0, |
| 962 |
'required_msg' => '', |
| 963 |
'field_icon' => 'fab fa-wordpress-simple', |
| 964 |
'css_class' => 'btn-wordpress' |
| 965 |
) |
| 966 |
); |
| 967 |
|
| 968 |
// Language |
| 969 |
$custom_fields['uwp_language'] = array( |
| 970 |
'field_type' => 'select', |
| 971 |
'class' => 'uwp-language', |
| 972 |
'field_icon' => 'fas fa-language', |
| 973 |
'site_title' => __( 'Select Language', 'userswp' ), |
| 974 |
'help_text' => __( 'Adds a input for user language selection.', 'userswp' ), |
| 975 |
'defaults' => array( |
| 976 |
'admin_title' => 'Select Language', |
| 977 |
'site_title' => 'Select Language', |
| 978 |
'form_label' => __( 'Site Language', 'userswp' ), |
| 979 |
'htmlvar_name' => 'uwp_language', |
| 980 |
'is_active' => 1, |
| 981 |
'default_value' => 'site-default', |
| 982 |
'is_required' => 0, |
| 983 |
'option_values' => '', |
| 984 |
'required_msg' => '', |
| 985 |
'field_icon' => 'fas fa-language', |
| 986 |
'css_class' => '' |
| 987 |
) |
| 988 |
); |
| 989 |
|
| 990 |
|
| 991 |
return apply_filters( 'uwp_form_fields_predefined', $custom_fields, $type ); |
| 992 |
} |
| 993 |
|
| 994 |
public function form_fields_custom( $type = '' ) { |
| 995 |
$custom_fields = array(); |
| 996 |
|
| 997 |
return apply_filters( 'uwp_form_fields_custom', $custom_fields, $type ); |
| 998 |
} |
| 999 |
|
| 1000 |
public function form_fields( $type = '' ) { |
| 1001 |
|
| 1002 |
$custom_fields = array( |
| 1003 |
'text' => array( |
| 1004 |
'field_type' => 'text', |
| 1005 |
'class' => 'uwp-text', |
| 1006 |
'field_icon' => 'fas fa-minus', |
| 1007 |
'site_title' => __( 'Text', 'userswp' ), |
| 1008 |
'help_text' => __( 'Add any sort of text field, text or numbers', 'userswp' ) |
| 1009 |
), |
| 1010 |
'datepicker' => array( |
| 1011 |
'field_type' => 'datepicker', |
| 1012 |
'class' => 'uwp-datepicker', |
| 1013 |
'field_icon' => 'fas fa-calendar-alt', |
| 1014 |
'site_title' => __( 'Date', 'userswp' ), |
| 1015 |
'help_text' => __( 'Adds a date picker.', 'userswp' ) |
| 1016 |
), |
| 1017 |
'textarea' => array( |
| 1018 |
'field_type' => 'textarea', |
| 1019 |
'class' => 'uwp-textarea', |
| 1020 |
'field_icon' => 'fas fa-bars', |
| 1021 |
'site_title' => __( 'Textarea', 'userswp' ), |
| 1022 |
'help_text' => __( 'Adds a textarea', 'userswp' ) |
| 1023 |
), |
| 1024 |
'time' => array( |
| 1025 |
'field_type' => 'time', |
| 1026 |
'class' => 'uwp-time', |
| 1027 |
'field_icon' => 'far fa-clock', |
| 1028 |
'site_title' => __( 'Time', 'userswp' ), |
| 1029 |
'help_text' => __( 'Adds a time picker', 'userswp' ) |
| 1030 |
), |
| 1031 |
'checkbox' => array( |
| 1032 |
'field_type' => 'checkbox', |
| 1033 |
'class' => 'uwp-checkbox', |
| 1034 |
'field_icon' => 'far fa-check-square', |
| 1035 |
'site_title' => __( 'Checkbox', 'userswp' ), |
| 1036 |
'help_text' => __( 'Adds a checkbox', 'userswp' ) |
| 1037 |
), |
| 1038 |
'phone' => array( |
| 1039 |
'field_type' => 'phone', |
| 1040 |
'class' => 'uwp-phone', |
| 1041 |
'field_icon' => 'fas fa-phone', |
| 1042 |
'site_title' => __( 'Phone', 'userswp' ), |
| 1043 |
'help_text' => __( 'Adds a phone input', 'userswp' ) |
| 1044 |
), |
| 1045 |
'radio' => array( |
| 1046 |
'field_type' => 'radio', |
| 1047 |
'class' => 'uwp-radio', |
| 1048 |
'field_icon' => 'far fa-dot-circle', |
| 1049 |
'site_title' => __( 'Radio', 'userswp' ), |
| 1050 |
'help_text' => __( 'Adds a radio input', 'userswp' ) |
| 1051 |
), |
| 1052 |
'email' => array( |
| 1053 |
'field_type' => 'email', |
| 1054 |
'class' => 'uwp-email', |
| 1055 |
'field_icon' => 'far fa-envelope', |
| 1056 |
'site_title' => __( 'Email', 'userswp' ), |
| 1057 |
'help_text' => __( 'Adds a email input', 'userswp' ) |
| 1058 |
), |
| 1059 |
'select' => array( |
| 1060 |
'field_type' => 'select', |
| 1061 |
'field_icon' => 'far fa-caret-square-down', |
| 1062 |
'site_title' => __( 'Select', 'userswp' ), |
| 1063 |
'help_text' => __( 'Adds a select input', 'userswp' ) |
| 1064 |
), |
| 1065 |
'multiselect' => array( |
| 1066 |
'field_type' => 'multiselect', |
| 1067 |
'class' => 'uwp-multiselect', |
| 1068 |
'field_icon' => 'far fa-caret-square-down', |
| 1069 |
'site_title' => __( 'Multi Select', 'userswp' ), |
| 1070 |
'help_text' => __( 'Adds a multiselect input', 'userswp' ) |
| 1071 |
), |
| 1072 |
'url' => array( |
| 1073 |
'field_type' => 'url', |
| 1074 |
'class' => 'uwp-url', |
| 1075 |
'field_icon' => 'fas fa-link', |
| 1076 |
'site_title' => __( 'URL', 'userswp' ), |
| 1077 |
'help_text' => __( 'Adds a url input', 'userswp' ) |
| 1078 |
), |
| 1079 |
'editor' => array( |
| 1080 |
'field_type' => 'editor', |
| 1081 |
'class' => 'uwp-html', |
| 1082 |
'field_icon' => 'fas fa-code', |
| 1083 |
'site_title' => __( 'HTML', 'userswp' ), |
| 1084 |
'help_text' => __( 'Adds a wysiwyg editor input', 'userswp' ) |
| 1085 |
), |
| 1086 |
'file' => array( |
| 1087 |
'field_type' => 'file', |
| 1088 |
'class' => 'uwp-file', |
| 1089 |
'field_icon' => 'fas fa-file', |
| 1090 |
'site_title' => __( 'File Upload', 'userswp' ), |
| 1091 |
'help_text' => __( 'Adds a file input', 'userswp' ) |
| 1092 |
) |
| 1093 |
); |
| 1094 |
|
| 1095 |
return apply_filters( 'uwp_form_fields', $custom_fields, $type ); |
| 1096 |
} |
| 1097 |
|
| 1098 |
public function manage_available_fields_custom( $form_type ) { |
| 1099 |
switch ( $form_type ) { |
| 1100 |
case 'account': |
| 1101 |
$this->custom_available_fields( 'custom', $form_type ); |
| 1102 |
break; |
| 1103 |
} |
| 1104 |
} |
| 1105 |
|
| 1106 |
public function manage_available_fields( $form_type ) { |
| 1107 |
switch ( $form_type ) { |
| 1108 |
case 'account': |
| 1109 |
$this->custom_available_fields( '', $form_type ); |
| 1110 |
break; |
| 1111 |
case 'register': |
| 1112 |
$this->register_available_fields( $form_type ); |
| 1113 |
break; |
| 1114 |
} |
| 1115 |
} |
| 1116 |
|
| 1117 |
public function register_available_fields( $form_type ) { |
| 1118 |
global $wpdb; |
| 1119 |
|
| 1120 |
$form_id = ! empty( $_GET['form'] ) ? absint($_GET['form']) : 1; |
| 1121 |
|
| 1122 |
$extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
| 1123 |
|
| 1124 |
$existing_fields = $wpdb->get_results( "select site_htmlvar_name from " . $extras_table_name . " where form_type ='" . $form_type . "' AND form_id = " . $form_id ); |
| 1125 |
|
| 1126 |
$existing_field_ids = array(); |
| 1127 |
if ( ! empty( $existing_fields ) ) { |
| 1128 |
foreach ( $existing_fields as $existing_field ) { |
| 1129 |
$existing_field_ids[] = $existing_field->site_htmlvar_name; |
| 1130 |
} |
| 1131 |
} |
| 1132 |
?> |
| 1133 |
<input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr($form_type); ?>"/> |
| 1134 |
<input type="hidden" name="manage_field_type" class="manage_field_type" value="register"> |
| 1135 |
<ul> |
| 1136 |
<?php |
| 1137 |
|
| 1138 |
$fields = $this->register_fields( $form_type, $form_id ); |
| 1139 |
|
| 1140 |
if ( ! empty( $fields ) ) { |
| 1141 |
foreach ( $fields as $field ) { |
| 1142 |
$field = stripslashes_deep( $field ); // strip slashes |
| 1143 |
|
| 1144 |
|
| 1145 |
$fieldset_width = ''; |
| 1146 |
if ( $field['field_type'] == 'fieldset' ) { |
| 1147 |
$fieldset_width = 'width:100%;'; |
| 1148 |
} |
| 1149 |
|
| 1150 |
$display = ''; |
| 1151 |
if ( in_array( $field['htmlvar_name'], $existing_field_ids ) ) { |
| 1152 |
$display = 'display:none;'; |
| 1153 |
} |
| 1154 |
|
| 1155 |
$style = 'style="' . $display . $fieldset_width . '"'; |
| 1156 |
?> |
| 1157 |
<li <?php echo $style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> > |
| 1158 |
|
| 1159 |
<a id="uwp-<?php echo esc_attr($field['htmlvar_name']); ?>" |
| 1160 |
class="uwp-draggable-form-items uwp-<?php echo esc_attr($field['field_type']); ?>" |
| 1161 |
href="javascript:void(0);" data-field-type="<?php echo esc_attr($field['field_type']); ?>"> |
| 1162 |
|
| 1163 |
<?php if ( $icon = uwp_get_field_icon( $field['field_icon'] ) ) { |
| 1164 |
echo $icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1165 |
} else { |
| 1166 |
echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
| 1167 |
} ?> |
| 1168 |
|
| 1169 |
<?php echo esc_attr($field['site_title']); ?> |
| 1170 |
|
| 1171 |
</a> |
| 1172 |
</li> |
| 1173 |
|
| 1174 |
|
| 1175 |
<?php |
| 1176 |
} |
| 1177 |
} |
| 1178 |
?> |
| 1179 |
</ul> |
| 1180 |
<?php |
| 1181 |
} |
| 1182 |
|
| 1183 |
public function register_fields( $form_type, $form_id = 1 ) { |
| 1184 |
|
| 1185 |
global $wpdb; |
| 1186 |
|
| 1187 |
$table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 1188 |
$fields = $wpdb->get_results( $wpdb->prepare( "select field_type, site_title, htmlvar_name, field_icon from " . $table_name . " where form_type = %s and is_register_field = %s and form_id = %d order by sort_order asc", array( |
| 1189 |
'account', |
| 1190 |
'1', |
| 1191 |
$form_id |
| 1192 |
) ), ARRAY_A ); |
| 1193 |
|
| 1194 |
return apply_filters( 'uwp_register_fields', $fields, $form_type ); |
| 1195 |
} |
| 1196 |
|
| 1197 |
public function manage_selected_fields( $form_type ) { |
| 1198 |
switch ( $form_type ) { |
| 1199 |
case 'account': |
| 1200 |
$this->custom_selected_fields( $form_type ); |
| 1201 |
break; |
| 1202 |
case 'register': |
| 1203 |
$this->register_selected_fields( $form_type ); |
| 1204 |
break; |
| 1205 |
} |
| 1206 |
} |
| 1207 |
|
| 1208 |
public function custom_selected_fields( $form_type ) { |
| 1209 |
|
| 1210 |
global $wpdb; |
| 1211 |
$table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 1212 |
$form_id = ! empty( $_GET['form'] ) ? absint($_GET['form']) : 1; |
| 1213 |
?> |
| 1214 |
<input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr($form_type); ?>"/> |
| 1215 |
<input type="hidden" name="manage_field_type" class="manage_field_type" value="custom_fields"> |
| 1216 |
<ul class="core uwp-tabs-selected uwp_form_extras"> |
| 1217 |
<?php |
| 1218 |
$fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND form_id = %s ORDER BY sort_order ASC", array( |
| 1219 |
$form_type, |
| 1220 |
$form_id |
| 1221 |
) ) ); |
| 1222 |
|
| 1223 |
if ( ! empty( $fields ) ) { |
| 1224 |
foreach ( $fields as $field ) { |
| 1225 |
$result_str = $field; |
| 1226 |
$field_type = $field->field_type; |
| 1227 |
$field_type_key = $field->field_type_key; |
| 1228 |
$field_ins_upd = 'display'; |
| 1229 |
|
| 1230 |
$this->form_field_adminhtml( $field_type, $result_str, $field_ins_upd, $field_type_key ); |
| 1231 |
} |
| 1232 |
} |
| 1233 |
?></ul> |
| 1234 |
<?php |
| 1235 |
|
| 1236 |
} |
| 1237 |
|
| 1238 |
public function form_field_adminhtml( $field_type, $result_str, $field_ins_upd = '', $field_type_key = '', $form_type = false ) { |
| 1239 |
global $wpdb; |
| 1240 |
$table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 1241 |
$cf = $result_str; |
| 1242 |
$cf_arr = $this->get_form_existing_fields( $form_type ); |
| 1243 |
|
| 1244 |
if ( ! is_object( $cf ) ) { |
| 1245 |
|
| 1246 |
$field_info = $wpdb->get_row( $wpdb->prepare( "select * from " . $table_name . " where id= %d", array( $cf ) ) ); |
| 1247 |
|
| 1248 |
} else { |
| 1249 |
$field_info = $cf; |
| 1250 |
$result_str = $cf->id; |
| 1251 |
} |
| 1252 |
|
| 1253 |
if ( ! $field_info ) { |
| 1254 |
$field_info = ( isset( $cf_arr[ $field_type_key ] ) ) ? $cf_arr[ $field_type_key ] : null; |
| 1255 |
} |
| 1256 |
|
| 1257 |
$this->admin_form_field_html( $field_info, $field_type, $field_type_key, $field_ins_upd, $result_str, $form_type ); |
| 1258 |
|
| 1259 |
} |
| 1260 |
|
| 1261 |
/** |
| 1262 |
* @param $field_info |
| 1263 |
* @param $field_type |
| 1264 |
* @param string $field_type_key |
| 1265 |
* @param string $field_ins_upd |
| 1266 |
* @param $result_str |
| 1267 |
* @param bool $form_type |
| 1268 |
*/ |
| 1269 |
public function admin_form_field_html( $field_info, $field_type, $field_type_key, $field_ins_upd, $result_str, $form_type = false ) { |
| 1270 |
|
| 1271 |
if ( ! $form_type ) { |
| 1272 |
if ( ! isset( $field_info->form_type ) ) { |
| 1273 |
$form_type = sanitize_text_field( $_REQUEST['tab'] ); |
| 1274 |
} else { |
| 1275 |
$form_type = $field_info->form_type; |
| 1276 |
} |
| 1277 |
} |
| 1278 |
|
| 1279 |
$cf_arr1 = $this->form_fields( $form_type ); |
| 1280 |
$cf_arr2 = $this->form_fields_predefined( $form_type ); |
| 1281 |
$cf_arr3 = $this->form_fields_custom( $form_type ); |
| 1282 |
|
| 1283 |
$cf_arr = $cf_arr1 + $cf_arr2 + $cf_arr3; // this way defaults can't be overwritten |
| 1284 |
|
| 1285 |
$cf = ( isset( $cf_arr[ $field_type_key ] ) ) ? $cf_arr[ $field_type_key ] : ''; |
| 1286 |
|
| 1287 |
$field_info = stripslashes_deep( $field_info ); // strip slashes from labels |
| 1288 |
|
| 1289 |
$field_site_title = ''; |
| 1290 |
if ( isset( $field_info->site_title ) ) { |
| 1291 |
$field_site_title = $field_info->site_title; |
| 1292 |
} |
| 1293 |
|
| 1294 |
$field_display = $field_type == 'address' && $field_info->htmlvar_name == 'post' ? 'style="display:none"' : ''; |
| 1295 |
|
| 1296 |
if ( isset( $cf['field_icon'] ) && strpos( $cf['field_icon'], ' fa-' ) !== false ) { |
| 1297 |
$field_icon = '<i class="' . esc_attr($cf['field_icon']) . '" aria-hidden="true"></i>'; |
| 1298 |
} elseif ( isset( $cf['field_icon'] ) && $cf['field_icon'] ) { |
| 1299 |
$field_icon = '<b style="background-image: url("' . esc_url($cf['field_icon']) . '")"></b>'; |
| 1300 |
} else { |
| 1301 |
$field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>'; |
| 1302 |
} |
| 1303 |
|
| 1304 |
if ( isset( $cf['site_title'] ) && $cf['site_title'] ) { |
| 1305 |
$field_type_name = $cf['site_title']; |
| 1306 |
} else { |
| 1307 |
$field_type_name = $field_type; |
| 1308 |
} |
| 1309 |
|
| 1310 |
$htmlvar_name = isset($field_info->htmlvar_name) ? sanitize_text_field($field_info->htmlvar_name) : ''; |
| 1311 |
|
| 1312 |
?> |
| 1313 |
<li class="text li-settings" id="licontainer_<?php echo esc_attr( $result_str ); ?>"> |
| 1314 |
<i class="fas fa-caret-down toggle-arrow" aria-hidden="true" onclick="uwp_show_hide(this);"></i> |
| 1315 |
<div class="title title<?php echo esc_attr( $result_str ); ?> uwp-fieldset"> |
| 1316 |
<?php |
| 1317 |
$nonce = wp_create_nonce( 'custom_fields_' . $result_str ); |
| 1318 |
if ( $field_type == 'fieldset' ) { |
| 1319 |
?> |
| 1320 |
<i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i> |
| 1321 |
<i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i> |
| 1322 |
<b><?php echo esc_html( uwp_ucwords( __( 'Fieldset:', 'userswp' ) ) ); ?></b> |
| 1323 |
<span class="field-type"><?php echo ' (' . esc_html( uwp_ucwords( $field_site_title ) ) . ')'; ?></span> |
| 1324 |
<?php |
| 1325 |
} else { |
| 1326 |
echo $field_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1327 |
?> |
| 1328 |
<b><?php echo esc_html( uwp_ucwords( ' ' . $field_site_title ) ); ?></b> |
| 1329 |
<span class="field-type"><?php echo ' (' . esc_html( uwp_ucwords( $field_type_name ) ) . ')'; ?></span> |
| 1330 |
<?php |
| 1331 |
} |
| 1332 |
?> |
| 1333 |
</div> |
| 1334 |
|
| 1335 |
<form> |
| 1336 |
<div id="field_frm<?php echo esc_attr( $result_str ); ?>" class="field_frm" |
| 1337 |
style="display:<?php if ( $field_ins_upd == 'submit' ) { |
| 1338 |
echo 'block;'; |
| 1339 |
} else { |
| 1340 |
echo 'none;'; |
| 1341 |
} ?>"> |
| 1342 |
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $nonce ); ?>"/> |
| 1343 |
<input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr($form_type); ?>"/> |
| 1344 |
<input type="hidden" name="field_type" id="field_type" value="<?php echo esc_attr($field_type); ?>"/> |
| 1345 |
<input type="hidden" name="field_type_key" id="field_type_key" |
| 1346 |
value="<?php echo esc_attr($field_type_key); ?>"/> |
| 1347 |
<input type="hidden" name="field_id" id="field_id" value="<?php echo esc_attr( $result_str ); ?>"/> |
| 1348 |
<input type="hidden" name="is_active" id="is_active" value="1"/> |
| 1349 |
|
| 1350 |
<input type="hidden" name="is_default" |
| 1351 |
value="<?php echo isset( $field_info->is_default ) ? esc_attr($field_info->is_default) : ''; ?>"/><?php // show in sidebar value?> |
| 1352 |
|
| 1353 |
<ul class="widefat post fixed" style="width:100%;"> |
| 1354 |
|
| 1355 |
<?php |
| 1356 |
// data_type |
| 1357 |
if ( has_filter( "uwp_builder_data_type_{$field_type}" ) ) { |
| 1358 |
|
| 1359 |
echo apply_filters( "uwp_builder_data_type_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1360 |
|
| 1361 |
} else { |
| 1362 |
$value = ''; |
| 1363 |
if ( isset( $field_info->data_type ) ) { |
| 1364 |
$value = esc_attr( $field_info->data_type ); |
| 1365 |
} elseif ( isset( $cf['defaults']['data_type'] ) && $cf['defaults']['data_type'] ) { |
| 1366 |
$value = $cf['defaults']['data_type']; |
| 1367 |
} |
| 1368 |
?> |
| 1369 |
<input type="hidden" name="data_type" id="data_type" value="<?php echo esc_attr($value); ?>"/> |
| 1370 |
<?php |
| 1371 |
} |
| 1372 |
|
| 1373 |
// site_title |
| 1374 |
if ( has_filter( "uwp_builder_site_title_{$field_type}" ) ) { |
| 1375 |
|
| 1376 |
echo apply_filters( "uwp_builder_site_title_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1377 |
|
| 1378 |
} else { |
| 1379 |
$value = ''; |
| 1380 |
if ( isset( $field_info->site_title ) ) { |
| 1381 |
$value = esc_attr( $field_info->site_title ); |
| 1382 |
} elseif ( isset( $cf['defaults']['site_title'] ) && $cf['defaults']['site_title'] ) { |
| 1383 |
$value = $cf['defaults']['site_title']; |
| 1384 |
} |
| 1385 |
?> |
| 1386 |
<li class="uwp-setting-name"> |
| 1387 |
<label for="site_title" class="uwp-tooltip-wrap"> |
| 1388 |
<?php |
| 1389 |
echo uwp_help_tip( __( 'This will be the label for the field.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1390 |
esc_html_e( 'Field Label:', 'userswp' ); ?> |
| 1391 |
</label> |
| 1392 |
<div class="uwp-input-wrap"> |
| 1393 |
<input type="text" name="site_title" id="site_title" |
| 1394 |
value="<?php echo esc_attr($value); ?>"/> |
| 1395 |
</div> |
| 1396 |
</li> |
| 1397 |
<?php |
| 1398 |
} |
| 1399 |
|
| 1400 |
// Input Label |
| 1401 |
if ( has_filter( "uwp_builder_form_label_{$field_type}" ) ) { |
| 1402 |
|
| 1403 |
echo apply_filters( "uwp_builder_form_label_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1404 |
|
| 1405 |
} else { |
| 1406 |
$value = ''; |
| 1407 |
if ( isset( $field_info->form_label ) ) { |
| 1408 |
$value = esc_attr( $field_info->form_label ); |
| 1409 |
} elseif ( isset( $cf['defaults']['form_label'] ) && $cf['defaults']['form_label'] ) { |
| 1410 |
$value = $cf['defaults']['form_label']; |
| 1411 |
} |
| 1412 |
?> |
| 1413 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 1414 |
<label for="form_label" class="uwp-tooltip-wrap"> |
| 1415 |
<?php |
| 1416 |
echo uwp_help_tip( __( 'If your form label is different, then you can fill this field. Ex: You would like to display "What is your age?" in Form Field but would like to display "DOB" in site. In such cases "What is your age?" should be entered here and "DOB" should be entered in previous field. Note: If this field not filled, then the previous field will be used in Form.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1417 |
esc_html_e( 'Form Label: (Optional)', 'userswp' ); ?> |
| 1418 |
</label> |
| 1419 |
<div class="uwp-input-wrap"> |
| 1420 |
<input type="text" name="form_label" id="form_label" |
| 1421 |
value="<?php echo esc_attr($value); ?>"/> |
| 1422 |
</div> |
| 1423 |
</li> |
| 1424 |
<?php |
| 1425 |
} |
| 1426 |
|
| 1427 |
// Input Description |
| 1428 |
if ( has_filter( "uwp_builder_field_description_{$field_type}" ) ) { |
| 1429 |
|
| 1430 |
echo apply_filters( "uwp_builder_field_description_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1431 |
|
| 1432 |
} else { |
| 1433 |
$value = ''; |
| 1434 |
if ( isset( $field_info->help_text ) ) { |
| 1435 |
$value = esc_attr( $field_info->help_text ); |
| 1436 |
} elseif ( isset( $cf['defaults']['help_text'] ) && $cf['defaults']['help_text'] ) { |
| 1437 |
$value = $cf['defaults']['help_text']; |
| 1438 |
} |
| 1439 |
?> |
| 1440 |
<li class="uwp-setting-name"> |
| 1441 |
<label for="help_text" class="uwp-tooltip-wrap"> |
| 1442 |
<?php |
| 1443 |
$tip_text = !empty($cf['help_text_tip']) ? esc_attr($cf['help_text_tip']) : __( 'This will be displayed below the field in the form.', 'userswp' ); |
| 1444 |
echo uwp_help_tip( $tip_text ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1445 |
esc_html_e( 'Field Description:', 'userswp' ); ?> |
| 1446 |
</label> |
| 1447 |
<div class="uwp-input-wrap"> |
| 1448 |
<input type="text" name="help_text" id="help_text" |
| 1449 |
value="<?php echo esc_attr($value); ?>"/> |
| 1450 |
</div> |
| 1451 |
</li> |
| 1452 |
<?php |
| 1453 |
} |
| 1454 |
|
| 1455 |
|
| 1456 |
// htmlvar_name |
| 1457 |
if ( has_filter( "uwp_builder_htmlvar_name_{$field_type}" ) ) { |
| 1458 |
|
| 1459 |
echo apply_filters( "uwp_builder_htmlvar_name_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1460 |
|
| 1461 |
} else { |
| 1462 |
$value = ''; |
| 1463 |
if ( isset( $field_info->htmlvar_name ) ) { |
| 1464 |
$value = esc_attr( $field_info->htmlvar_name ); |
| 1465 |
} elseif ( isset( $cf['defaults']['htmlvar_name'] ) && $cf['defaults']['htmlvar_name'] ) { |
| 1466 |
$value = $cf['defaults']['htmlvar_name']; |
| 1467 |
} |
| 1468 |
?> |
| 1469 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 1470 |
<label for="htmlvar_name" class="uwp-tooltip-wrap"> |
| 1471 |
<?php |
| 1472 |
echo uwp_help_tip( __( 'This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1473 |
esc_html_e( 'Field Key :', 'userswp' ); ?> |
| 1474 |
</label> |
| 1475 |
<div class="uwp-input-wrap"> |
| 1476 |
<input type="text" name="htmlvar_name" id="htmlvar_name" pattern="[a-zA-Z0-9]+" |
| 1477 |
title="<?php esc_attr_e( 'Must not contain spaces or special characters', 'userswp' ); ?>" |
| 1478 |
value="<?php if ( $value ) { |
| 1479 |
echo esc_attr( preg_replace( '/uwp_' . $form_type . '_/', '', $value, 1 ) ); |
| 1480 |
} ?>" <?php if ( ! empty( $value ) && $value != '' ) { |
| 1481 |
echo 'readonly="readonly"'; |
| 1482 |
} ?> /> |
| 1483 |
</div> |
| 1484 |
</li> |
| 1485 |
<?php |
| 1486 |
} |
| 1487 |
|
| 1488 |
// Placeholder text |
| 1489 |
if ( has_filter( "uwp_builder_placeholder_value_{$field_type}" ) ) { |
| 1490 |
|
| 1491 |
echo apply_filters( "uwp_builder_placeholder_value_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1492 |
|
| 1493 |
} else { |
| 1494 |
$value = ''; |
| 1495 |
if ( isset( $field_info->placeholder_value ) ) { |
| 1496 |
$value = esc_attr( $field_info->placeholder_value ); |
| 1497 |
} elseif ( isset( $cf['defaults']['placeholder_value'] ) && $cf['defaults']['placeholder_value'] ) { |
| 1498 |
$value = $cf['defaults']['placeholder_value']; |
| 1499 |
} |
| 1500 |
?> |
| 1501 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 1502 |
<label for="placeholder_value" class="uwp-tooltip-wrap"> |
| 1503 |
<?php |
| 1504 |
echo uwp_help_tip( __( 'Display placeholder text for this field.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1505 |
esc_html_e( 'Placeholder :', 'userswp' ); ?> |
| 1506 |
</label> |
| 1507 |
<div class="uwp-input-wrap"> |
| 1508 |
<input type="text" name="placeholder_value" |
| 1509 |
id="placeholder_value_<?php echo esc_attr($result_str); ?>" |
| 1510 |
title="<?php esc_attr_e( 'Enter placeholder text for this field.', 'userswp' ); ?>" |
| 1511 |
value="<?php echo esc_attr($value); ?>"/> |
| 1512 |
</div> |
| 1513 |
</li> |
| 1514 |
<?php |
| 1515 |
} |
| 1516 |
|
| 1517 |
// is_active |
| 1518 |
if ( has_filter( "uwp_builder_is_active_{$field_type}" ) ) { |
| 1519 |
|
| 1520 |
echo apply_filters( "uwp_builder_is_active_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1521 |
|
| 1522 |
} else { |
| 1523 |
$value = ''; |
| 1524 |
if ( isset( $field_info->is_active ) ) { |
| 1525 |
$value = esc_attr( $field_info->is_active ); |
| 1526 |
} elseif ( isset( $cf['defaults']['is_active'] ) && $cf['defaults']['is_active'] ) { |
| 1527 |
$value = $cf['defaults']['is_active']; |
| 1528 |
} |
| 1529 |
?> |
| 1530 |
<li <?php echo esc_attr($field_display); ?> class="uwp-setting-name"> |
| 1531 |
<label for="is_active" class="uwp-tooltip-wrap"> |
| 1532 |
<?php |
| 1533 |
echo uwp_help_tip( __( 'If no is selected then the field will not be displayed anywhere.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1534 |
esc_html_e( 'Is active :', 'userswp' ); ?> |
| 1535 |
</label> |
| 1536 |
<div class="uwp-input-wrap"> |
| 1537 |
<input type="hidden" name="is_active" value="0"/> |
| 1538 |
<input type="checkbox" name="is_active" |
| 1539 |
value="1" <?php checked( $value, 1, true ); ?> /> |
| 1540 |
</div> |
| 1541 |
</li> |
| 1542 |
<?php |
| 1543 |
} |
| 1544 |
|
| 1545 |
// for_admin_use |
| 1546 |
if ( has_filter( "uwp_builder_for_admin_use_{$field_type}" ) ) { |
| 1547 |
|
| 1548 |
echo apply_filters( "uwp_builder_for_admin_use_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1549 |
|
| 1550 |
} else { |
| 1551 |
$value = ''; |
| 1552 |
if ( isset( $field_info->for_admin_use ) ) { |
| 1553 |
$value = esc_attr( $field_info->for_admin_use ); |
| 1554 |
} elseif ( isset( $cf['defaults']['for_admin_use'] ) && $cf['defaults']['for_admin_use'] ) { |
| 1555 |
$value = $cf['defaults']['for_admin_use']; |
| 1556 |
} |
| 1557 |
?> |
| 1558 |
<li <?php echo esc_attr($field_display); ?> class="uwp-setting-name uwp-advanced-setting"> |
| 1559 |
<label for="for_admin_use" class="uwp-tooltip-wrap"> |
| 1560 |
<?php |
| 1561 |
echo uwp_help_tip( __( 'If yes is selected then only site admin can see and edit this field.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1562 |
esc_html_e( 'For admin use only? :', 'userswp' ); ?> |
| 1563 |
</label> |
| 1564 |
<div class="uwp-input-wrap"> |
| 1565 |
<input type="hidden" name="for_admin_use" value="0"/> |
| 1566 |
<input type="checkbox" name="for_admin_use" |
| 1567 |
value="1" <?php checked( $value, 1, true ); ?> /> |
| 1568 |
</div> |
| 1569 |
</li> |
| 1570 |
<?php |
| 1571 |
} |
| 1572 |
|
| 1573 |
// is_public |
| 1574 |
if ( has_filter( "uwp_builder_is_public_{$field_type}" ) ) { |
| 1575 |
|
| 1576 |
echo apply_filters( "uwp_builder_is_public_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1577 |
|
| 1578 |
} else { |
| 1579 |
$value = ''; |
| 1580 |
if ( isset( $field_info->is_public ) ) { |
| 1581 |
$value = esc_attr( $field_info->is_public ); |
| 1582 |
} elseif ( isset( $cf['defaults']['is_public'] ) && $cf['defaults']['is_public'] ) { |
| 1583 |
$value = $cf['defaults']['is_public']; |
| 1584 |
} |
| 1585 |
?> |
| 1586 |
<li <?php echo esc_attr($field_display); ?> class="uwp-setting-name uwp-advanced-setting"> |
| 1587 |
<label for="is_public" class="uwp-tooltip-wrap"> |
| 1588 |
<?php |
| 1589 |
echo uwp_help_tip( __( 'If no is selected then the field will not be visible to other users.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1590 |
esc_html_e( 'Is Public :', 'userswp' ); ?> |
| 1591 |
</label> |
| 1592 |
<div class="uwp-input-wrap"> |
| 1593 |
<?php |
| 1594 |
if ( ! isset($value) ) { |
| 1595 |
$value = "1"; |
| 1596 |
} |
| 1597 |
?> |
| 1598 |
<select name="is_public" class="aui-select2"> |
| 1599 |
<option value="1" <?php selected( $value, "1" ); ?>><?php echo esc_html__( "Yes", "userswp" ) ?></option> |
| 1600 |
<option value="0" <?php selected( $value, "0" ); ?>><?php echo esc_html__( "No", "userswp" ) ?></option> |
| 1601 |
<option value="2" <?php selected( $value, "2" ); ?>><?php echo esc_html__( "Let User Decide", "userswp" ) ?></option> |
| 1602 |
</select> |
| 1603 |
|
| 1604 |
</div> |
| 1605 |
</li> |
| 1606 |
<?php |
| 1607 |
} |
| 1608 |
|
| 1609 |
// default_value |
| 1610 |
if ( has_filter( "uwp_builder_default_value_{$field_type}" ) ) { |
| 1611 |
|
| 1612 |
echo apply_filters( "uwp_builder_default_value_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1613 |
|
| 1614 |
} else { |
| 1615 |
$value = ''; |
| 1616 |
if ( isset( $field_info->default_value ) ) { |
| 1617 |
$value = esc_attr( $field_info->default_value ); |
| 1618 |
} elseif ( isset( $cf['defaults']['default_value'] ) && $cf['defaults']['default_value'] ) { |
| 1619 |
$value = $cf['defaults']['default_value']; |
| 1620 |
} |
| 1621 |
?> |
| 1622 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 1623 |
<label for="default_value" class="uwp-tooltip-wrap"> |
| 1624 |
<?php |
| 1625 |
if ( $field_type == 'checkbox' ) { |
| 1626 |
$tip = __( 'Should the checkbox be checked by default?', 'userswp' ); |
| 1627 |
} else if ( $field_type == 'email' ) { |
| 1628 |
$tip = __( 'A default value for the field, usually blank. Ex: info@mysite.com', 'userswp' ); |
| 1629 |
} else { |
| 1630 |
$tip = __( 'A default value for the field, usually blank. (for links this will be used as the link text)', 'userswp' ); |
| 1631 |
} |
| 1632 |
?> |
| 1633 |
<?php |
| 1634 |
echo uwp_help_tip( $tip ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1635 |
esc_html_e( 'Default value :', 'userswp' ); ?> |
| 1636 |
</label> |
| 1637 |
<div class="uwp-input-wrap"> |
| 1638 |
<?php if ( $field_type == 'checkbox' ) { ?> |
| 1639 |
<select name="default_value" id="default_value" class="aui-select2"> |
| 1640 |
<option value=""><?php esc_html_e( 'Unchecked', 'userswp' ); ?></option> |
| 1641 |
<option value="1" <?php selected( true, (int) $value === 1 ); ?>><?php esc_html_e( 'Checked', 'userswp' ); ?></option> |
| 1642 |
</select> |
| 1643 |
<?php } else if ( $field_type == 'email' ) { ?> |
| 1644 |
<input type="email" name="default_value" |
| 1645 |
placeholder="<?php esc_attr_e( 'info@mysite.com', 'userswp' ); ?>" |
| 1646 |
id="default_value" value="<?php echo esc_attr( $value ); ?>"/><br/> |
| 1647 |
<?php } else { ?> |
| 1648 |
<input type="text" name="default_value" id="default_value" |
| 1649 |
value="<?php echo esc_attr( $value ); ?>"/><br/> |
| 1650 |
<?php } ?> |
| 1651 |
</div> |
| 1652 |
</li> |
| 1653 |
<?php |
| 1654 |
} |
| 1655 |
|
| 1656 |
// advanced_editor |
| 1657 |
if ( has_filter( "uwp_builder_advanced_editor_{$field_type}" ) ) { |
| 1658 |
|
| 1659 |
echo apply_filters( "uwp_builder_advanced_editor_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1660 |
|
| 1661 |
} |
| 1662 |
?> |
| 1663 |
<input type="hidden" readonly="readonly" name="sort_order" id="sort_order" |
| 1664 |
value="<?php if ( isset( $field_info->sort_order ) ) { |
| 1665 |
echo esc_attr( $field_info->sort_order ); |
| 1666 |
} ?>"/> |
| 1667 |
<?php |
| 1668 |
|
| 1669 |
// is_required |
| 1670 |
if ( has_filter( "uwp_builder_is_required_{$field_type}" ) ) { |
| 1671 |
|
| 1672 |
echo apply_filters( "uwp_builder_is_required_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1673 |
|
| 1674 |
} else { |
| 1675 |
$value = ''; |
| 1676 |
if ( isset( $field_info->is_required ) ) { |
| 1677 |
$value = esc_attr( $field_info->is_required ); |
| 1678 |
} elseif ( isset( $cf['defaults']['is_required'] ) && $cf['defaults']['is_required'] ) { |
| 1679 |
$value = $cf['defaults']['is_required']; |
| 1680 |
} |
| 1681 |
?> |
| 1682 |
<li class="uwp-setting-name"> |
| 1683 |
<label for="is_required" class="uwp-tooltip-wrap"> |
| 1684 |
<?php |
| 1685 |
echo uwp_help_tip( __( 'Select yes to set field as required', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1686 |
esc_html_e( 'Is required :', 'userswp' ); ?> |
| 1687 |
</label> |
| 1688 |
|
| 1689 |
<div class="uwp-input-wrap"> |
| 1690 |
<input type="hidden" name="is_required" value="0"/> |
| 1691 |
<input type="checkbox" name="is_required" |
| 1692 |
value="1" <?php checked( $value, 1, true ); ?> /> |
| 1693 |
</div> |
| 1694 |
|
| 1695 |
</li> |
| 1696 |
|
| 1697 |
<?php |
| 1698 |
} |
| 1699 |
|
| 1700 |
// required_msg |
| 1701 |
if ( has_filter( "uwp_builder_required_msg_{$field_type}" ) ) { |
| 1702 |
|
| 1703 |
echo apply_filters( "uwp_builder_required_msg_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1704 |
|
| 1705 |
} else { |
| 1706 |
$value = ''; |
| 1707 |
if ( isset( $field_info->required_msg ) ) { |
| 1708 |
$value = esc_attr( $field_info->required_msg ); |
| 1709 |
} elseif ( isset( $cf['defaults']['required_msg'] ) && $cf['defaults']['required_msg'] ) { |
| 1710 |
$value = $cf['defaults']['required_msg']; |
| 1711 |
} |
| 1712 |
?> |
| 1713 |
<li class="cf-is-required-msg uwp-setting-name uwp-advanced-setting" <?php if ( ( isset( $field_info->is_required ) && $field_info->is_required == '0' ) || ! isset( $field_info->is_required ) ) { |
| 1714 |
echo "style='display:none;'"; |
| 1715 |
} ?>> |
| 1716 |
<label for="required_msg" class="uwp-tooltip-wrap"> |
| 1717 |
<?php |
| 1718 |
echo uwp_help_tip( __( 'Enter text for the error message if the field is required and has not fulfilled the requirements.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1719 |
esc_html_e( 'Required message:', 'userswp' ); ?> |
| 1720 |
</label> |
| 1721 |
<div class="uwp-input-wrap"> |
| 1722 |
<input type="text" name="required_msg" id="required_msg" |
| 1723 |
value="<?php echo esc_attr( $value ); ?>"/> |
| 1724 |
</div> |
| 1725 |
</li> |
| 1726 |
<?php |
| 1727 |
} |
| 1728 |
|
| 1729 |
// validation pattern |
| 1730 |
if ( has_filter( "uwp_builder_validation_pattern_{$field_type}" ) ) { |
| 1731 |
|
| 1732 |
echo apply_filters( "uwp_builder_validation_pattern_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1733 |
|
| 1734 |
} |
| 1735 |
|
| 1736 |
// extra_fields |
| 1737 |
if ( has_filter( "uwp_builder_extra_fields_{$field_type}" ) ) { |
| 1738 |
|
| 1739 |
echo apply_filters( "uwp_builder_extra_fields_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1740 |
|
| 1741 |
} |
| 1742 |
|
| 1743 |
// field_icon |
| 1744 |
if ( has_filter( "uwp_builder_field_icon_{$field_type}" ) ) { |
| 1745 |
|
| 1746 |
echo apply_filters( "uwp_builder_field_icon_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1747 |
|
| 1748 |
} else { |
| 1749 |
$value = ''; |
| 1750 |
if ( isset( $field_info->field_icon ) ) { |
| 1751 |
$value = esc_attr( $field_info->field_icon ); |
| 1752 |
} elseif ( isset( $cf['defaults']['field_icon'] ) && $cf['defaults']['field_icon'] ) { |
| 1753 |
$value = $cf['defaults']['field_icon']; |
| 1754 |
} |
| 1755 |
?> |
| 1756 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 1757 |
|
| 1758 |
<label for="field_icon" class="uwp-tooltip-wrap"> |
| 1759 |
<?php |
| 1760 |
echo uwp_help_tip( sprintf( __( 'Upload icon using media and enter its url path, or enter %sfont awesome%s class eg:"fas fa-home"', 'userswp' ), '<a href="http://fortawesome.github.io/Font-Awesome/icons/" target="_blank" >', '</a>' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1761 |
esc_html_e( 'Upload icon :', 'userswp' ); ?> |
| 1762 |
</label> |
| 1763 |
<div class="uwp-input-wrap"> |
| 1764 |
<input type="text" name="field_icon" id="field_icon" |
| 1765 |
value="<?php echo esc_attr($value); ?>"/> |
| 1766 |
</div> |
| 1767 |
|
| 1768 |
</li> |
| 1769 |
<?php |
| 1770 |
} |
| 1771 |
|
| 1772 |
// css_class |
| 1773 |
if ( has_filter( "uwp_builder_css_class_{$field_type}" ) ) { |
| 1774 |
|
| 1775 |
echo apply_filters( "uwp_builder_css_class_{$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1776 |
|
| 1777 |
} else { |
| 1778 |
?> |
| 1779 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 1780 |
|
| 1781 |
<?php |
| 1782 |
$value = ''; |
| 1783 |
if ( isset( $field_info->css_class ) ) { |
| 1784 |
$value = esc_attr( $field_info->css_class ); |
| 1785 |
} elseif ( isset( $cf['defaults']['css_class'] ) && $cf['defaults']['css_class'] ) { |
| 1786 |
$value = $cf['defaults']['css_class']; |
| 1787 |
} |
| 1788 |
$tip = __( 'Enter custom css class for field custom style.', 'userswp' ); |
| 1789 |
if ( $field_type == 'multiselect' ) { |
| 1790 |
$tip .= __( '(Enter class `uwp-comma-list` to show list as comma separated)', 'userswp' ); |
| 1791 |
} |
| 1792 |
?> |
| 1793 |
|
| 1794 |
<label for="css_class" class="uwp-tooltip-wrap"> |
| 1795 |
<?php |
| 1796 |
echo uwp_help_tip( $tip ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1797 |
esc_html_e( 'CSS class :', 'userswp' ); ?> |
| 1798 |
</label> |
| 1799 |
<div class="uwp-input-wrap"> |
| 1800 |
<input type="text" name="css_class" id="css_class" |
| 1801 |
value="<?php echo esc_attr($value); ?>"/> |
| 1802 |
</div> |
| 1803 |
|
| 1804 |
</li> |
| 1805 |
<?php |
| 1806 |
} |
| 1807 |
|
| 1808 |
// show_in |
| 1809 |
if ( has_filter( "uwp_builder_show_in_{$field_type}" ) ) { |
| 1810 |
|
| 1811 |
echo apply_filters( "uwp_builder_show_in_$field_type}", '', $result_str, $cf, $field_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1812 |
|
| 1813 |
} else { |
| 1814 |
$value = ''; |
| 1815 |
if ( isset( $field_info->show_in ) ) { |
| 1816 |
$value = esc_attr( $field_info->show_in ); |
| 1817 |
} elseif ( isset( $cf['defaults']['show_in'] ) && $cf['defaults']['show_in'] ) { |
| 1818 |
$value = esc_attr( $cf['defaults']['show_in'] ); |
| 1819 |
} |
| 1820 |
?> |
| 1821 |
<li class="uwp-setting-name"> |
| 1822 |
<label for="show_in" class="uwp-tooltip-wrap"> |
| 1823 |
<?php |
| 1824 |
echo uwp_help_tip( __( 'Select in what locations you want to display this field.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1825 |
esc_html_e( 'Show in what locations?:', 'userswp' ); ?> |
| 1826 |
</label> |
| 1827 |
<div class="uwp-input-wrap"> |
| 1828 |
|
| 1829 |
<?php |
| 1830 |
|
| 1831 |
$show_in_locations = uwp_get_show_in_locations(); |
| 1832 |
|
| 1833 |
if ( $field_type == 'fieldset' ) { |
| 1834 |
unset( $show_in_locations['[fieldset]'] ); |
| 1835 |
} |
| 1836 |
|
| 1837 |
if ( ! in_array( $field_type, array( |
| 1838 |
'text', |
| 1839 |
'datepicker', |
| 1840 |
'textarea', |
| 1841 |
'time', |
| 1842 |
'phone', |
| 1843 |
'email', |
| 1844 |
'select', |
| 1845 |
'multiselect', |
| 1846 |
'url', |
| 1847 |
'html', |
| 1848 |
'fieldset', |
| 1849 |
'radio', |
| 1850 |
'checkbox', |
| 1851 |
'file' |
| 1852 |
) ) ) { |
| 1853 |
unset( $show_in_locations['[own_tab]'] ); |
| 1854 |
} |
| 1855 |
?> |
| 1856 |
|
| 1857 |
<select multiple="multiple" name="show_in[]" |
| 1858 |
style="min-width:300px;" |
| 1859 |
class="aui-select2 form-control" |
| 1860 |
data-placeholder="<?php esc_attr_e( 'Select locations', 'userswp' ); ?>"> |
| 1861 |
<?php |
| 1862 |
|
| 1863 |
$show_in_values = explode( ',', $value ); |
| 1864 |
|
| 1865 |
foreach ( $show_in_locations as $key => $val ) { |
| 1866 |
$selected = false; |
| 1867 |
|
| 1868 |
if ( is_array( $show_in_values ) && in_array( $key, $show_in_values ) ) { |
| 1869 |
$selected = true; |
| 1870 |
} |
| 1871 |
|
| 1872 |
?> |
| 1873 |
<option value="<?php echo esc_attr($key); ?>" <?php selected( $selected, true ); ?>><?php echo esc_html( $val ); ?></option> |
| 1874 |
<?php |
| 1875 |
} |
| 1876 |
?> |
| 1877 |
</select> |
| 1878 |
</div> |
| 1879 |
</li> |
| 1880 |
<?php |
| 1881 |
} |
| 1882 |
|
| 1883 |
do_action( 'uwp_admin_extra_custom_fields', $field_info, $cf ); ?> |
| 1884 |
|
| 1885 |
<li> |
| 1886 |
<label for="save" class="uwp-tooltip-wrap"> |
| 1887 |
</label> |
| 1888 |
<div class="uwp-input-wrap uwp-tab-actions" data-setting="save_button"> |
| 1889 |
<input type="button" class="button button-primary" name="save" id="save" |
| 1890 |
value="<?php echo esc_attr( __( 'Save', 'userswp' ) ); ?>" |
| 1891 |
onclick="save_field('<?php echo esc_attr( $result_str ); ?>')"/> |
| 1892 |
<?php |
| 1893 |
$can_delete = apply_filters( 'uwp_cfa_can_delete_field', true, $field_info, $form_type ); |
| 1894 |
if ( $can_delete ){ ?> |
| 1895 |
<a class="item-delete submitdelete deletion" id="delete-16" |
| 1896 |
href="javascript:void(0);" |
| 1897 |
onclick="delete_field('<?php echo esc_attr( $result_str ); ?>', '<?php echo esc_attr( wp_create_nonce( 'custom_fields_delete_' . $result_str ) ); ?>', '<?php echo esc_attr($htmlvar_name); ?>')"><?php esc_html_e( "Remove", "userswp" ); ?></a> |
| 1898 |
<?php } ?> |
| 1899 |
<?php UsersWP_Settings_Page::toggle_advanced_button(); ?> |
| 1900 |
</div> |
| 1901 |
</li> |
| 1902 |
</ul> |
| 1903 |
</div> |
| 1904 |
</form> |
| 1905 |
</li> |
| 1906 |
<?php |
| 1907 |
} |
| 1908 |
|
| 1909 |
/** |
| 1910 |
* Add HTML5 validation pattern fields. |
| 1911 |
* |
| 1912 |
* @since 1.2.2.17 |
| 1913 |
* |
| 1914 |
* @param string $output Html output. |
| 1915 |
* @param string $result_str Result string. |
| 1916 |
* @param array $cf Custom fields values. |
| 1917 |
* @param object $field_info Extra fields information. |
| 1918 |
* @return string $output. |
| 1919 |
*/ |
| 1920 |
public static function validation_pattern( $output, $result_str, $cf, $field_info ) { |
| 1921 |
ob_start(); |
| 1922 |
|
| 1923 |
$value = ''; |
| 1924 |
if ( isset( $field_info->validation_pattern ) ) { |
| 1925 |
$value = esc_attr( $field_info->validation_pattern ); |
| 1926 |
} elseif ( isset( $cf['defaults']['validation_pattern'] ) && $cf['defaults']['validation_pattern'] ) { |
| 1927 |
$value = $cf['defaults']['validation_pattern']; |
| 1928 |
} |
| 1929 |
?> |
| 1930 |
<li class="cf-is-validation-pattern uwp-setting-name uwp-advanced-setting"> |
| 1931 |
<label for="validation_pattern" class="uwp-tooltip-wrap"> |
| 1932 |
<?php |
| 1933 |
echo uwp_help_tip( __( 'Enter regex expression for HTML5 pattern validation.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1934 |
esc_html_e( 'Validation pattern:', 'userswp' ); ?> |
| 1935 |
</label> |
| 1936 |
<div class="uwp-input-wrap"> |
| 1937 |
<input type="text" name="validation_pattern" id="validation_pattern" |
| 1938 |
value="<?php echo esc_attr( $value ); ?>"/> |
| 1939 |
</div> |
| 1940 |
</li> |
| 1941 |
|
| 1942 |
<?php |
| 1943 |
$value = ''; |
| 1944 |
if ( isset( $field_info->validation_msg ) ) { |
| 1945 |
$value = esc_attr( $field_info->validation_msg ); |
| 1946 |
} elseif ( isset( $cf['defaults']['validation_msg'] ) && $cf['defaults']['validation_msg'] ) { |
| 1947 |
$value = $cf['defaults']['validation_msg']; |
| 1948 |
} |
| 1949 |
?> |
| 1950 |
<li class="cf-is-validation-msg uwp-setting-name uwp-advanced-setting"> |
| 1951 |
<label for="validation_msg" class="uwp-tooltip-wrap"> |
| 1952 |
<?php |
| 1953 |
echo uwp_help_tip( __( 'Enter a extra validation message to show to the user if validation fails.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1954 |
esc_html_e( 'Validation message:', 'userswp' ); ?> |
| 1955 |
</label> |
| 1956 |
<div class="uwp-input-wrap"> |
| 1957 |
<input type="text" name="validation_msg" id="required_msg" |
| 1958 |
value="<?php echo esc_attr( $value ); ?>"/> |
| 1959 |
</div> |
| 1960 |
</li> |
| 1961 |
<?php |
| 1962 |
|
| 1963 |
$output = ob_get_clean(); |
| 1964 |
|
| 1965 |
return $output; |
| 1966 |
} |
| 1967 |
|
| 1968 |
public function register_selected_fields( $form_type ) { |
| 1969 |
global $wpdb; |
| 1970 |
$extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
| 1971 |
$form_id = ! empty( $_GET['form'] ) ? absint($_GET['form']) : 1; |
| 1972 |
?> |
| 1973 |
<input type="hidden" name="manage_field_type" class="manage_field_type" value="register"> |
| 1974 |
<ul class="core uwp_form_extras uwp-tabs-selected"><?php |
| 1975 |
|
| 1976 |
$fields = $wpdb->get_results( |
| 1977 |
$wpdb->prepare( |
| 1978 |
"select * from " . $extras_table_name . " where form_type = %s AND form_id = %d order by sort_order asc", |
| 1979 |
array( $form_type, $form_id ) |
| 1980 |
) |
| 1981 |
); |
| 1982 |
|
| 1983 |
if ( ! empty( $fields ) ) { |
| 1984 |
foreach ( $fields as $field ) { |
| 1985 |
$result_str = $field; |
| 1986 |
$field_ins_upd = 'display'; |
| 1987 |
$this->register_field_adminhtml( $result_str, $field_ins_upd, false ); |
| 1988 |
} |
| 1989 |
} ?> |
| 1990 |
</ul> |
| 1991 |
<?php |
| 1992 |
} |
| 1993 |
|
| 1994 |
public function register_field_adminhtml( $result_str, $field_ins_upd = '', $default = false, $request = array() ) { |
| 1995 |
global $wpdb; |
| 1996 |
|
| 1997 |
$table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 1998 |
$extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
| 1999 |
|
| 2000 |
$cf = $result_str; |
| 2001 |
if ( ! is_object( $cf ) && ( is_int( $cf ) || ctype_digit( $cf ) ) ) { |
| 2002 |
$field_info = $wpdb->get_row( $wpdb->prepare( "select * from " . $extras_table_name . " where id= %d", array( $cf ) ) ); |
| 2003 |
} elseif ( is_object( $cf ) ) { |
| 2004 |
$result_str = $cf->id; |
| 2005 |
$field_info = $wpdb->get_row( $wpdb->prepare( "select * from " . $extras_table_name . " where id= %d", array( (int) $cf->id ) ) ); |
| 2006 |
} else { |
| 2007 |
$field_info = false; |
| 2008 |
} |
| 2009 |
|
| 2010 |
if ( isset( $request['field_type'] ) && $request['field_type'] != '' ) { |
| 2011 |
$field_type = esc_attr( $request['field_type'] ); |
| 2012 |
} else { |
| 2013 |
$field_type = $field_info->field_type; |
| 2014 |
} |
| 2015 |
|
| 2016 |
|
| 2017 |
$field_site_name = ''; |
| 2018 |
if ( isset( $request['site_title'] ) ) { |
| 2019 |
$field_site_name = $request['site_title']; |
| 2020 |
} |
| 2021 |
|
| 2022 |
if ( $field_info ) { |
| 2023 |
$account_field_info = uwp_get_custom_field_info( $field_info->site_htmlvar_name ); |
| 2024 |
if ( isset( $account_field_info->site_title ) ) { |
| 2025 |
if ( $account_field_info->field_type == 'fieldset' ) { |
| 2026 |
$field_site_name = __( 'Fieldset:', 'userswp' ) . ' ' . $account_field_info->site_title; |
| 2027 |
} else { |
| 2028 |
$field_site_name = $account_field_info->site_title; |
| 2029 |
} |
| 2030 |
} |
| 2031 |
$field_info = stripslashes_deep( $field_info ); // strip slashes |
| 2032 |
} |
| 2033 |
$field_site_name = sanitize_title( $field_site_name ); |
| 2034 |
|
| 2035 |
if ( isset( $request['form_type'] ) ) { |
| 2036 |
$form_type = esc_attr( $request['form_type'] ); |
| 2037 |
} else { |
| 2038 |
$form_type = $field_info->form_type; |
| 2039 |
} |
| 2040 |
|
| 2041 |
if ( isset( $request['htmlvar_name'] ) && $request['htmlvar_name'] != '' ) { |
| 2042 |
$htmlvar_name = esc_attr( $request['htmlvar_name'] ); |
| 2043 |
} else { |
| 2044 |
$htmlvar_name = $field_info->site_htmlvar_name; |
| 2045 |
} |
| 2046 |
|
| 2047 |
if ( isset( $htmlvar_name ) ) { |
| 2048 |
if ( ! is_object( $field_info ) ) { |
| 2049 |
$field_info = new stdClass(); |
| 2050 |
} |
| 2051 |
$field_info->field_icon = $wpdb->get_var( |
| 2052 |
$wpdb->prepare( "SELECT field_icon FROM " . $table_name . " WHERE htmlvar_name = %s", array( $htmlvar_name ) ) |
| 2053 |
); |
| 2054 |
} |
| 2055 |
|
| 2056 |
$icon = isset( $field_info->field_icon ) ? $field_info->field_icon : ''; |
| 2057 |
if ( uwp_is_fa_icon( $icon ) ) { |
| 2058 |
$field_icon = '<i class="' . esc_attr( $icon ) . '" aria-hidden="true"></i>'; |
| 2059 |
} elseif ( uwp_is_icon_url( $icon ) ) { |
| 2060 |
$field_icon = '<b style="background-image: url("' . esc_url($icon) . '")"></b>'; |
| 2061 |
} elseif ( isset( $field_info->field_type ) && $field_info->field_type == 'fieldset' ) { |
| 2062 |
$field_icon = '<i class="fas fa-arrows-alt-h" aria-hidden="true"></i>'; |
| 2063 |
} else { |
| 2064 |
$field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>'; |
| 2065 |
} |
| 2066 |
?> |
| 2067 |
<li class="text li-settings" id="licontainer_<?php echo esc_attr( $result_str ); ?>"> |
| 2068 |
<i class="fas fa-caret-down toggle-arrow" aria-hidden="true" onclick="uwp_show_hide(this);"></i> |
| 2069 |
<form> |
| 2070 |
<div class="title title<?php echo esc_attr( $result_str ); ?> uwp-fieldset"> |
| 2071 |
<?php |
| 2072 |
$nonce = wp_create_nonce( 'uwp_form_extras_nonce' . $result_str ); |
| 2073 |
echo $field_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2074 |
?> |
| 2075 |
<b><?php echo esc_html( uwp_ucwords( ' ' . $field_site_name ) ); ?></b> |
| 2076 |
|
| 2077 |
</div> |
| 2078 |
|
| 2079 |
<div id="field_frm<?php echo esc_attr( $result_str ); ?>" class="field_frm" |
| 2080 |
style="display:<?php if ( $field_ins_upd == 'submit' ) { |
| 2081 |
echo 'block;'; |
| 2082 |
} else { |
| 2083 |
echo 'none;'; |
| 2084 |
} ?>"> |
| 2085 |
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $nonce ); ?>"/> |
| 2086 |
<input type="hidden" name="field_id" id="field_id" value="<?php echo esc_attr( $result_str ); ?>"/> |
| 2087 |
<input type="hidden" name="form_type" id="form_type" value="<?php echo esc_attr($form_type); ?>"/> |
| 2088 |
<input type="hidden" name="field_type" id="field_type" value="<?php echo esc_attr($field_type); ?>"/> |
| 2089 |
<input type="hidden" name="is_active" id="is_active" value="1"/> |
| 2090 |
<ul class="widefat post fixed" style="width:100%;"> |
| 2091 |
|
| 2092 |
<input type="hidden" name="site_htmlvar_name" value="<?php echo esc_attr($htmlvar_name) ?>"/> |
| 2093 |
|
| 2094 |
<li> |
| 2095 |
<div class="uwp-input-wrap"> |
| 2096 |
<p><?php esc_html_e( 'No options available', 'userswp' ); ?></p> |
| 2097 |
</div> |
| 2098 |
</li> |
| 2099 |
|
| 2100 |
<li> |
| 2101 |
<div class="uwp-input-wrap"> |
| 2102 |
<?php |
| 2103 |
$no_actions = array( 'username', 'email' ); |
| 2104 |
$no_actions = apply_filters( 'uwp_register_fields_without_actions', $no_actions ); |
| 2105 |
if ( isset($htmlvar_name) && ! in_array( $htmlvar_name, $no_actions ) ) { ?> |
| 2106 |
<input type="button" class="button button-primary" name="save" id="save" |
| 2107 |
value="<?php esc_attr_e( 'Save', 'userswp' ); ?>" |
| 2108 |
onclick="save_field('<?php echo esc_js( $result_str ); ?>', 'register')" |
| 2109 |
style="display: none;"/> |
| 2110 |
<input type="button" name="delete" |
| 2111 |
value="<?php esc_attr_e( 'Delete', 'userswp' ); ?>" |
| 2112 |
onclick="delete_field('<?php echo esc_js( $result_str ); ?>', '<?php echo esc_js( $nonce ); ?>','<?php echo esc_js( $htmlvar_name ); ?>', 'register')" |
| 2113 |
class="button"/> |
| 2114 |
<?php } ?> |
| 2115 |
|
| 2116 |
</div> |
| 2117 |
</li> |
| 2118 |
</ul> |
| 2119 |
|
| 2120 |
</div> |
| 2121 |
</form> |
| 2122 |
</li> |
| 2123 |
<?php |
| 2124 |
} |
| 2125 |
|
| 2126 |
public function builder_extra_fields_smr( $output, $result_str, $cf, $field_info ) { |
| 2127 |
|
| 2128 |
ob_start(); |
| 2129 |
|
| 2130 |
$value = ''; |
| 2131 |
if ( isset( $field_info->option_values ) ) { |
| 2132 |
$value = esc_attr( $field_info->option_values ); |
| 2133 |
} elseif ( isset( $cf['defaults']['option_values'] ) && $cf['defaults']['option_values'] ) { |
| 2134 |
$value = esc_attr( $cf['defaults']['option_values'] ); |
| 2135 |
} |
| 2136 |
|
| 2137 |
$field_type = isset( $field_info->field_type ) ? $field_info->field_type : $cf['field_type']; |
| 2138 |
$field_type_key = isset( $field_info->field_type_key ) ? $field_info->field_type_key : ''; |
| 2139 |
if ( ! $field_type_key ) { |
| 2140 |
$field_type_key = isset( $_REQUEST['field_type_key'] ) ? esc_html( $_REQUEST['field_type_key'] ) : ''; |
| 2141 |
} |
| 2142 |
?> |
| 2143 |
<li class="uwp-setting-name"> |
| 2144 |
<label for="option_values" class="uwp-tooltip-wrap"> |
| 2145 |
<?php |
| 2146 |
$tip = __( 'Option Values should be separated by comma.', 'userswp' ); |
| 2147 |
if ( $field_type != 'multiselect' ) { |
| 2148 |
$tip .= '<br/><small>' . __( 'If using for a tick filter place a / and then either a 1 for true or 0 for false', 'userswp' ); |
| 2149 |
$tip .= '<br/>' . __( 'eg: No Dogs Allowed/0,Dogs Allowed/1', 'userswp' ) . '</small>'; |
| 2150 |
} |
| 2151 |
if ( $field_type == 'multiselect' || $field_type == 'select' ) { |
| 2152 |
$tip .= '<br/><small>' . __( 'Like: Apple,Bannana,Pear,Peach', 'userswp' ); |
| 2153 |
$tip .= '<br/>' . __( 'Or you can show Selection/Value shown: Pets Allowed/Yes,Pets not Allowed/No', 'userswp' ); |
| 2154 |
$tip .= '<br/>' . __( '- If using OPTGROUP tag to grouping options, use {optgroup}OPTGROUP-LABEL|OPTION-1,OPTION-2{/optgroup}', 'userswp' ); |
| 2155 |
$tip .= '<br/>' . __( 'eg: {optgroup}Pets Allowed|No Dogs Allowed/0,Dogs Allowed/1{/optgroup},{optgroup}Sports|Cricket/Cricket,Football/Football,Hockey{/optgroup}', 'userswp' ) . '</small>'; |
| 2156 |
} |
| 2157 |
?> |
| 2158 |
<?php |
| 2159 |
echo uwp_help_tip( $tip ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2160 |
esc_html_e( 'Option Values :', 'userswp' ); ?> |
| 2161 |
</label> |
| 2162 |
<div class="uwp-input-wrap"> |
| 2163 |
|
| 2164 |
<?php if ( isset( $field_type_key ) && $field_type_key == 'uwp_country' ) { |
| 2165 |
|
| 2166 |
// @todo here we should show a multiselect to either include or exclude countries |
| 2167 |
esc_html_e( 'A full country list will be shown', 'userswp' ); |
| 2168 |
} elseif ( isset( $field_type_key ) && $field_type_key == 'uwp_language' ) { |
| 2169 |
esc_html_e( 'Available translation languages list will be shown', 'userswp' ); |
| 2170 |
} else { ?> |
| 2171 |
<input type="text" name="option_values" id="option_values" value="<?php echo esc_attr($value); ?>"/> |
| 2172 |
<?php } ?> |
| 2173 |
|
| 2174 |
<br/> |
| 2175 |
|
| 2176 |
</div> |
| 2177 |
</li> |
| 2178 |
<?php |
| 2179 |
|
| 2180 |
$html = ob_get_clean(); |
| 2181 |
|
| 2182 |
return $output . $html; |
| 2183 |
} |
| 2184 |
|
| 2185 |
public function builder_extra_fields_datepicker( $output, $result_str, $cf, $field_info ) { |
| 2186 |
ob_start(); |
| 2187 |
$extra = array(); |
| 2188 |
if ( isset( $field_info->extra_fields ) && $field_info->extra_fields != '' ) { |
| 2189 |
$extra = unserialize( $field_info->extra_fields ); |
| 2190 |
} |
| 2191 |
?> |
| 2192 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 2193 |
<label for="date_format" class="uwp-tooltip-wrap"> |
| 2194 |
<?php |
| 2195 |
echo uwp_help_tip( __( 'Select the date format.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2196 |
esc_html_e( 'Date Format :', 'userswp' ); ?> |
| 2197 |
</label> |
| 2198 |
<div class="uwp-input-wrap" style="overflow:inherit;"> |
| 2199 |
<?php |
| 2200 |
$date_formats = array( |
| 2201 |
'm/d/Y', |
| 2202 |
'd/m/Y', |
| 2203 |
'Y/m/d', |
| 2204 |
'm-d-Y', |
| 2205 |
'd-m-Y', |
| 2206 |
'Y-m-d', |
| 2207 |
'F j, Y', |
| 2208 |
); |
| 2209 |
|
| 2210 |
$date_formats = apply_filters( 'uwp_date_formats', $date_formats ); |
| 2211 |
?> |
| 2212 |
<select name="extra[date_format]" id="date_format" class="aui-select2"> |
| 2213 |
<?php |
| 2214 |
foreach ( $date_formats as $format ) { |
| 2215 |
$selected = false; |
| 2216 |
if ( ! empty( $extra ) && esc_attr( $extra['date_format'] ) == $format ) { |
| 2217 |
$selected = true; |
| 2218 |
} |
| 2219 |
echo "<option " . selected( $selected, true, false ) . " value='" . esc_attr( $format ) . "'>" . esc_html( $format . " (" . date_i18n( $format, time() ) . ")" ) . "</option>"; |
| 2220 |
} |
| 2221 |
?> |
| 2222 |
</select> |
| 2223 |
|
| 2224 |
</div> |
| 2225 |
</li> |
| 2226 |
<?php |
| 2227 |
|
| 2228 |
$html = ob_get_clean(); |
| 2229 |
|
| 2230 |
return $output . $html; |
| 2231 |
} |
| 2232 |
|
| 2233 |
public function builder_extra_fields_password( $output, $result_str, $cf, $field_info ) { |
| 2234 |
ob_start(); |
| 2235 |
|
| 2236 |
//confirm password field |
| 2237 |
$extra = array(); |
| 2238 |
if ( isset( $field_info->extra_fields ) && $field_info->extra_fields != '' ) { |
| 2239 |
$extra = unserialize( $field_info->extra_fields ); |
| 2240 |
} |
| 2241 |
$value = isset( $extra['confirm_password'] ) ? $extra['confirm_password'] : '1'; |
| 2242 |
if ( isset( $field_info->htmlvar_name ) && $field_info->htmlvar_name == 'password' ) { |
| 2243 |
?> |
| 2244 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 2245 |
<label for="extra[confirm_password]" class="uwp-tooltip-wrap"> |
| 2246 |
<?php |
| 2247 |
echo uwp_help_tip( __( 'Lets you display confirm password form field.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2248 |
esc_html_e( 'Display confirm password field?:', 'userswp' ); ?> |
| 2249 |
</label> |
| 2250 |
|
| 2251 |
<div class="uwp-input-wrap"> |
| 2252 |
<input type="hidden" name="extra[confirm_password]" value="0"/> |
| 2253 |
<input type="checkbox" name="extra[confirm_password]" value="1" <?php checked( $value, 1, true ); ?> |
| 2254 |
onclick=""/> |
| 2255 |
</div> |
| 2256 |
</li> |
| 2257 |
<?php |
| 2258 |
} |
| 2259 |
$html = ob_get_clean(); |
| 2260 |
|
| 2261 |
return $output . $html; |
| 2262 |
} |
| 2263 |
|
| 2264 |
public function builder_extra_fields_email( $output, $result_str, $cf, $field_info ) { |
| 2265 |
ob_start(); |
| 2266 |
//confirm email field |
| 2267 |
$extra = array(); |
| 2268 |
if ( isset( $field_info->extra_fields ) && $field_info->extra_fields != '' ) { |
| 2269 |
$extra = unserialize( $field_info->extra_fields ); |
| 2270 |
} |
| 2271 |
$value = isset( $extra['confirm_email'] ) ? $extra['confirm_email'] : '0'; |
| 2272 |
|
| 2273 |
if ( isset( $field_info->htmlvar_name ) && $field_info->htmlvar_name == 'email' ) { |
| 2274 |
?> |
| 2275 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 2276 |
<label for="extra[confirm_email]" class="uwp-tooltip-wrap"> |
| 2277 |
<?php |
| 2278 |
echo uwp_help_tip( __( 'Lets you display confirm email form field.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2279 |
esc_html_e( 'Display confirm email field?:', 'userswp' ); ?> |
| 2280 |
</label> |
| 2281 |
|
| 2282 |
<div class="uwp-input-wrap"> |
| 2283 |
<input type="hidden" name="extra[confirm_email]" value="0"/> |
| 2284 |
<input type="checkbox" name="extra[confirm_email]" value="1" <?php checked( $value, 1, true ); ?> |
| 2285 |
onclick=""/> |
| 2286 |
</div> |
| 2287 |
</li> |
| 2288 |
<?php |
| 2289 |
} |
| 2290 |
$html = ob_get_clean(); |
| 2291 |
|
| 2292 |
return $output . $html; |
| 2293 |
} |
| 2294 |
|
| 2295 |
public function builder_extra_fields_file( $output, $result_str, $cf, $field_info ) { |
| 2296 |
ob_start(); |
| 2297 |
|
| 2298 |
$file_obj = new UsersWP_Files(); |
| 2299 |
$allowed_file_types = $file_obj->allowed_mime_types(); |
| 2300 |
|
| 2301 |
$extra_fields = isset( $field_info->extra_fields ) && $field_info->extra_fields != '' ? maybe_unserialize( $field_info->extra_fields ) : ''; |
| 2302 |
$uwp_file_types = ! empty( $extra_fields ) && ! empty( $extra_fields['uwp_file_types'] ) ? $extra_fields['uwp_file_types'] : array( '*' ); |
| 2303 |
?> |
| 2304 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 2305 |
<label for="uwp_file_types" class="uwp-tooltip-wrap"> |
| 2306 |
<?php |
| 2307 |
echo uwp_help_tip( __( 'Select file types to allowed for file uploading. (Select multiple file types by holding down "Ctrl" key.)', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2308 |
esc_html_e( 'Allowed file types :', 'userswp' ); ?> |
| 2309 |
</label> |
| 2310 |
<div class="uwp-input-wrap"> |
| 2311 |
<select name="extra[uwp_file_types][]" id="uwp_file_types" multiple="multiple" class="aui-select2" |
| 2312 |
style="height:100px;width:90%;"> |
| 2313 |
<option value="*" <?php selected( true, in_array( '*', $uwp_file_types ) ); ?>><?php esc_html_e( 'All types', 'userswp' ); ?></option> |
| 2314 |
<?php foreach ( $allowed_file_types as $format => $types ) { ?> |
| 2315 |
<optgroup |
| 2316 |
label="<?php echo esc_attr( wp_sprintf( __( '%s formats', 'userswp' ), __( $format, 'userswp' ) ) ); ?>"> |
| 2317 |
<?php foreach ( $types as $ext => $type ) { ?> |
| 2318 |
<option value="<?php echo esc_attr( $ext ); ?>" <?php selected( true, in_array( $ext, $uwp_file_types ) ); ?>><?php echo '.' . esc_html( $ext ); ?></option> |
| 2319 |
<?php } ?> |
| 2320 |
</optgroup> |
| 2321 |
<?php } ?> |
| 2322 |
</select> |
| 2323 |
</div> |
| 2324 |
</li> |
| 2325 |
<?php |
| 2326 |
|
| 2327 |
$html = ob_get_clean(); |
| 2328 |
|
| 2329 |
return $output . $html; |
| 2330 |
} |
| 2331 |
|
| 2332 |
public function builder_data_type_text( $output, $result_str, $cf, $field_info ) { |
| 2333 |
ob_start(); |
| 2334 |
|
| 2335 |
$dt_value = ''; |
| 2336 |
if ( isset( $field_info->data_type ) ) { |
| 2337 |
$dt_value = esc_attr( $field_info->data_type ); |
| 2338 |
} elseif ( isset( $cf['defaults']['data_type'] ) && $cf['defaults']['data_type'] ) { |
| 2339 |
$dt_value = $cf['defaults']['data_type']; |
| 2340 |
} |
| 2341 |
?> |
| 2342 |
<li class="uwp-setting-name uwp-advanced-setting"> |
| 2343 |
<label for="data_type" class="uwp-tooltip-wrap"> |
| 2344 |
<?php |
| 2345 |
echo uwp_help_tip( __( 'Select Custom Field type', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2346 |
esc_html_e( 'Field Data Type:', 'userswp' ); ?> |
| 2347 |
</label> |
| 2348 |
<div class="uwp-input-wrap"> |
| 2349 |
|
| 2350 |
<select name="data_type" id="data_type" class="aui-select2" |
| 2351 |
onchange="uwp_data_type_changed(this, '<?php echo esc_js( $result_str ); ?>');"> |
| 2352 |
<option |
| 2353 |
value="XVARCHAR" <?php if ( $dt_value == 'VARCHAR' ) { |
| 2354 |
echo 'selected="selected"'; |
| 2355 |
} ?>><?php esc_html_e( 'Text Field', 'userswp' ); ?></option> |
| 2356 |
<option |
| 2357 |
value="INT" <?php if ( $dt_value == 'INT' ) { |
| 2358 |
echo 'selected="selected"'; |
| 2359 |
} ?>><?php esc_html_e( 'Number Field', 'userswp' ); ?></option> |
| 2360 |
<option |
| 2361 |
value="FLOAT" <?php if ( $dt_value == 'FLOAT' ) { |
| 2362 |
echo 'selected="selected"'; |
| 2363 |
} ?>><?php esc_html_e( 'Decimal Field', 'userswp' ); ?></option> |
| 2364 |
</select> |
| 2365 |
|
| 2366 |
</div> |
| 2367 |
</li> |
| 2368 |
|
| 2369 |
<?php |
| 2370 |
$value = ''; |
| 2371 |
if ( isset( $field_info->decimal_point ) ) { |
| 2372 |
$value = esc_attr( $field_info->decimal_point ); |
| 2373 |
} elseif ( isset( $cf['defaults']['decimal_point'] ) && $cf['defaults']['decimal_point'] ) { |
| 2374 |
$value = $cf['defaults']['decimal_point']; |
| 2375 |
} |
| 2376 |
?> |
| 2377 |
|
| 2378 |
<li class="decimal-point-wrapper uwp-setting-name uwp-advanced-setting" |
| 2379 |
style="<?php echo ( $dt_value == 'FLOAT' ) ? '' : 'display:none' ?>"> |
| 2380 |
<label for="decimal_point" class="uwp-tooltip-wrap"> |
| 2381 |
<?php |
| 2382 |
echo uwp_help_tip( __( 'Decimal places to display after point', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2383 |
esc_html_e( 'Select decimal precision:', 'userswp' ); ?> |
| 2384 |
</label> |
| 2385 |
<div class="uwp-input-wrap"> |
| 2386 |
<select name="decimal_point" id="decimal_point" class="aui-select2"> |
| 2387 |
<option value=""><?php esc_html_e( 'Select', 'userswp' ); ?></option> |
| 2388 |
<?php for ( $i = 1; $i <= 10; $i ++ ) { ?> |
| 2389 |
<option value="<?php echo (int) $i; ?>" <?php selected( $i, (int) $value ); ?>><?php echo (int) $i; ?></option> |
| 2390 |
<?php } ?> |
| 2391 |
</select> |
| 2392 |
</div> |
| 2393 |
</li> |
| 2394 |
<?php |
| 2395 |
|
| 2396 |
$output = ob_get_clean(); |
| 2397 |
|
| 2398 |
return $output; |
| 2399 |
} |
| 2400 |
|
| 2401 |
public function advance_admin_custom_fields( $field_info, $cf ) { |
| 2402 |
$hide_register_field = ( isset( $cf['defaults']['is_register_field'] ) && $cf['defaults']['is_register_field'] === false ) ? "style='display:none;'" : ''; |
| 2403 |
$hide_register_field = ( isset( $field_info->for_admin_use ) && $field_info->for_admin_use == '1' ) ? "style='display:none;'" : $hide_register_field; |
| 2404 |
$hide_user_sort = ( isset( $cf['defaults']['user_sort'] ) && $cf['defaults']['user_sort'] === false ) ? "style='display:none;'" : ''; |
| 2405 |
|
| 2406 |
$value = 0; |
| 2407 |
if ( isset( $field_info->is_register_field ) ) { |
| 2408 |
$value = (int) $field_info->is_register_field; |
| 2409 |
} else if ( isset( $cf['defaults']['is_register_field'] ) && $cf['defaults']['is_register_field'] ) { |
| 2410 |
$value = ( $cf['defaults']['is_register_field'] ) ? 1 : 0; |
| 2411 |
} |
| 2412 |
|
| 2413 |
if ( isset( $field_info->htmlvar_name ) ) { |
| 2414 |
$htmlvar_name = $field_info->htmlvar_name; |
| 2415 |
} else if ( isset( $cf['defaults']['htmlvar_name'] ) && $cf['defaults']['htmlvar_name'] ) { |
| 2416 |
$htmlvar_name = ( $cf['defaults']['htmlvar_name'] ) ? $cf['defaults']['htmlvar_name'] : ''; |
| 2417 |
} |
| 2418 |
|
| 2419 |
//register only field |
| 2420 |
$hide_register_only_field = ( isset( $cf['defaults']['is_register_only_field'] ) && $cf['defaults']['is_register_only_field'] === false ) ? "style='display:none;'" : ''; |
| 2421 |
$hide_register_only_field = ( isset( $field_info->for_admin_use ) && $field_info->for_admin_use == '1' ) ? "style='display:none;'" : $hide_register_only_field; |
| 2422 |
$register_only_value = 0; |
| 2423 |
if ( isset( $field_info->is_register_only_field ) ) { |
| 2424 |
$register_only_value = (int) $field_info->is_register_only_field; |
| 2425 |
} else if ( isset( $cf['defaults']['is_register_only_field'] ) && $cf['defaults']['is_register_only_field'] ) { |
| 2426 |
$register_only_value = ( $cf['defaults']['is_register_only_field'] ) ? 1 : 0; |
| 2427 |
} |
| 2428 |
|
| 2429 |
$user_sort_value = 0; |
| 2430 |
if ( isset( $field_info->user_sort ) ) { |
| 2431 |
$user_sort_value = (int) $field_info->user_sort; |
| 2432 |
} else if ( isset( $cf['defaults']['user_sort'] ) && $cf['defaults']['user_sort'] ) { |
| 2433 |
$user_sort_value = ( $cf['defaults']['user_sort'] ) ? 1 : 0; |
| 2434 |
} |
| 2435 |
|
| 2436 |
?> |
| 2437 |
<li <?php echo $hide_register_field; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> class="cf-incin-reg-form uwp-setting-name"> |
| 2438 |
<label for="is_register_field" class="uwp-tooltip-wrap"> |
| 2439 |
<?php |
| 2440 |
echo uwp_help_tip( __( 'Lets you use this field as register form field, set from register tab above.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2441 |
esc_html_e( 'Include this field in register form:', 'userswp' ); ?> |
| 2442 |
</label> |
| 2443 |
|
| 2444 |
<?php |
| 2445 |
$reg_only_fields = uwp_get_register_only_fields(); |
| 2446 |
if ( isset( $htmlvar_name ) && in_array( $htmlvar_name, $reg_only_fields ) ) { |
| 2447 |
?> |
| 2448 |
<div> |
| 2449 |
<input type="hidden" name="is_register_field" value="1"/> |
| 2450 |
<p><?php esc_html_e( 'This is mandatory register form field.', 'userswp' ); ?></p> |
| 2451 |
</div> |
| 2452 |
<?php |
| 2453 |
} else { |
| 2454 |
?> |
| 2455 |
<div class="uwp-input-wrap"> |
| 2456 |
<input type="hidden" name="is_register_field" value="0"/> |
| 2457 |
<input type="checkbox" name="is_register_field" value="1" <?php checked( $value, 1, true ); ?> /> |
| 2458 |
</div> |
| 2459 |
<?php } ?> |
| 2460 |
</li> |
| 2461 |
|
| 2462 |
<li <?php echo $hide_register_only_field; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>class="cf-inconlyin-reg-form uwp-setting-name uwp-advanced-setting"> |
| 2463 |
<label for="is_register_only_field" class="uwp-tooltip-wrap"> |
| 2464 |
<?php |
| 2465 |
echo uwp_help_tip( __( 'Lets you use this field as register ONLY form field.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2466 |
esc_html_e( 'Include this field ONLY in register form:', 'userswp' ); ?> |
| 2467 |
</label> |
| 2468 |
|
| 2469 |
<?php |
| 2470 |
if ( isset( $htmlvar_name ) && in_array( $htmlvar_name, $reg_only_fields ) ) { |
| 2471 |
?> |
| 2472 |
<div> |
| 2473 |
<input type="hidden" name="is_register_only_field" value="1"/> |
| 2474 |
<p><?php esc_html_e( 'This field is applicable only for register form.', 'userswp' ); ?></p> |
| 2475 |
</div> |
| 2476 |
<?php |
| 2477 |
} else { |
| 2478 |
?> |
| 2479 |
<div class="uwp-input-wrap"> |
| 2480 |
<input type="hidden" name="is_register_only_field" value="0"/> |
| 2481 |
<input type="checkbox" name="is_register_only_field" |
| 2482 |
value="1" <?php checked( $register_only_value, 1, true ); ?> /> |
| 2483 |
</div> |
| 2484 |
<?php } ?> |
| 2485 |
</li> |
| 2486 |
|
| 2487 |
<li <?php echo $hide_user_sort; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> class="cf-incin-reg-form uwp-setting-name uwp-advanced-setting"> |
| 2488 |
<label for="user_sort" class="uwp-tooltip-wrap"> |
| 2489 |
<?php |
| 2490 |
echo uwp_help_tip( __( 'Lets you use this field as sorting in the users listing page, set from user sorting tab above.', 'userswp' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2491 |
esc_html_e( 'Include this field in sorting options:', 'userswp' ); ?> |
| 2492 |
</label> |
| 2493 |
<input type="hidden" name="user_sort" value="0"/> |
| 2494 |
<input type="checkbox" name="user_sort" value="1" <?php checked( $user_sort_value, 1, true ); ?> /> |
| 2495 |
</li> |
| 2496 |
|
| 2497 |
<?php |
| 2498 |
} |
| 2499 |
|
| 2500 |
public function return_empty_string() { |
| 2501 |
return ""; |
| 2502 |
} |
| 2503 |
|
| 2504 |
public function register_available_fields_head( $heading, $form_type ) { |
| 2505 |
switch ( $form_type ) { |
| 2506 |
case 'register': |
| 2507 |
$heading = __( 'Available register form fields.', 'userswp' ); |
| 2508 |
break; |
| 2509 |
} |
| 2510 |
|
| 2511 |
return $heading; |
| 2512 |
} |
| 2513 |
|
| 2514 |
public function register_available_fields_note( $note, $form_type ) { |
| 2515 |
switch ( $form_type ) { |
| 2516 |
case 'register': |
| 2517 |
$note = __( "Click on any box below to make it appear in register form. To make a field available here, go to account tab and expand any field from selected fields panel and tick the checkbox saying 'Include this field in register form'.", 'userswp' ); |
| 2518 |
break; |
| 2519 |
} |
| 2520 |
|
| 2521 |
return $note; |
| 2522 |
} |
| 2523 |
|
| 2524 |
public function register_selected_fields_head( $heading, $form_type ) { |
| 2525 |
switch ( $form_type ) { |
| 2526 |
case 'register': |
| 2527 |
$heading = __( 'List of fields that will appear in the register form.', 'userswp' ); |
| 2528 |
break; |
| 2529 |
|
| 2530 |
} |
| 2531 |
|
| 2532 |
return $heading; |
| 2533 |
} |
| 2534 |
|
| 2535 |
public function register_selected_fields_note( $note, $form_type ) { |
| 2536 |
switch ( $form_type ) { |
| 2537 |
case 'register': |
| 2538 |
$note = __( 'Click to expand and view field related settings. You may drag and drop to arrange fields order in register form.', 'userswp' ); |
| 2539 |
break; |
| 2540 |
|
| 2541 |
} |
| 2542 |
|
| 2543 |
return $note; |
| 2544 |
} |
| 2545 |
|
| 2546 |
/** |
| 2547 |
* Handles the create custom field ajax request. |
| 2548 |
* |
| 2549 |
* @since 1.0.0 |
| 2550 |
* @package userswp |
| 2551 |
* @return void |
| 2552 |
*/ |
| 2553 |
public function create_field() { |
| 2554 |
|
| 2555 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 2556 |
wp_die( -1 ); |
| 2557 |
} |
| 2558 |
|
| 2559 |
$form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : ''; |
| 2560 |
$field_type = isset( $_REQUEST['field_type'] ) ? sanitize_text_field( $_REQUEST['field_type'] ) : ''; |
| 2561 |
$field_type_key = isset( $_REQUEST['field_type_key'] ) ? sanitize_text_field( $_REQUEST['field_type_key'] ) : ''; |
| 2562 |
$field_action = isset( $_REQUEST['field_ins_upd'] ) ? sanitize_text_field( $_REQUEST['field_ins_upd'] ) : ''; |
| 2563 |
$field_id = isset( $_REQUEST['field_id'] ) ? sanitize_text_field( $_REQUEST['field_id'] ) : ''; |
| 2564 |
$form_id = isset( $_REQUEST['form_id'] ) ? absint($_REQUEST['form_id']) : 1; |
| 2565 |
|
| 2566 |
$field_id = $field_id != '' ? trim( $field_id, '_' ) : $field_id; |
| 2567 |
|
| 2568 |
$field_ids = array(); |
| 2569 |
if ( ! empty( $_REQUEST['licontainer'] ) && is_array( $_REQUEST['licontainer'] ) ) { |
| 2570 |
foreach ( $_REQUEST['licontainer'] as $lic_id ) { |
| 2571 |
$field_ids[] = sanitize_text_field( $lic_id ); |
| 2572 |
} |
| 2573 |
} |
| 2574 |
|
| 2575 |
/* ------- check nonce field ------- */ |
| 2576 |
if ( isset( $_REQUEST['update'] ) && $_REQUEST['update'] == "update" && isset( $_REQUEST['create_field'] ) && isset( $_REQUEST['manage_field_type'] ) && $_REQUEST['manage_field_type'] == 'custom_fields' ) { |
| 2577 |
echo $this->set_field_order( $field_ids, $form_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2578 |
} |
| 2579 |
|
| 2580 |
/* ---- Show field form in admin ---- */ |
| 2581 |
if ( $field_type != '' && $field_id != '' && $field_action == 'new' && isset( $_REQUEST['create_field'] ) && isset( $_REQUEST['manage_field_type'] ) && $_REQUEST['manage_field_type'] == 'custom_fields' ) { |
| 2582 |
$this->form_field_adminhtml( $field_type, $field_id, $field_action, $field_type_key, $form_type ); |
| 2583 |
} |
| 2584 |
|
| 2585 |
|
| 2586 |
/* ---- Delete field ---- */ |
| 2587 |
if ( $field_id != '' && $field_action == 'delete' && isset( $_REQUEST['_wpnonce'] ) && isset( $_REQUEST['create_field'] ) && isset( $_REQUEST['manage_field_type'] ) && $_REQUEST['manage_field_type'] == 'custom_fields' ) { |
| 2588 |
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom_fields_delete_' . $field_id ) ) { |
| 2589 |
return; |
| 2590 |
} |
| 2591 |
|
| 2592 |
echo $this->admin_form_field_delete( $field_id, true, $form_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2593 |
} |
| 2594 |
|
| 2595 |
/* ---- Save field ---- */ |
| 2596 |
if ( $field_id != '' && $field_action == 'submit' && isset( $_REQUEST['_wpnonce'] ) && isset( $_REQUEST['create_field'] ) && isset( $_REQUEST['manage_field_type'] ) && $_REQUEST['manage_field_type'] == 'custom_fields' ) { |
| 2597 |
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom_fields_' . $field_id ) ) { |
| 2598 |
return; |
| 2599 |
} |
| 2600 |
|
| 2601 |
foreach ( $_REQUEST as $pkey => $pval ) { |
| 2602 |
if ( isset( $_REQUEST[ $pkey ] ) && is_array( $_REQUEST[ $pkey ] ) ) { |
| 2603 |
$tags = 'skip_field'; |
| 2604 |
} else { |
| 2605 |
$tags = ''; |
| 2606 |
} |
| 2607 |
|
| 2608 |
if ( $tags != 'skip_field' ) { |
| 2609 |
$_REQUEST[ $pkey ] = strip_tags( $_REQUEST[ $pkey ], $tags ); |
| 2610 |
} |
| 2611 |
} |
| 2612 |
|
| 2613 |
$return = $this->admin_form_field_save( $_REQUEST ); |
| 2614 |
|
| 2615 |
if ( is_int( $return ) ) { |
| 2616 |
$lastid = $return; |
| 2617 |
$this->form_field_adminhtml( $field_type, $lastid, 'submit', $field_type_key, $form_type ); |
| 2618 |
} else { |
| 2619 |
echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2620 |
} |
| 2621 |
} |
| 2622 |
|
| 2623 |
wp_die(); |
| 2624 |
|
| 2625 |
} |
| 2626 |
|
| 2627 |
public function set_field_order( $field_ids = array(), $form_id = 1 ) { |
| 2628 |
|
| 2629 |
global $wpdb; |
| 2630 |
|
| 2631 |
$table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 2632 |
|
| 2633 |
$count = 0; |
| 2634 |
if ( ! empty( $field_ids ) ): |
| 2635 |
$user_meta_info = false; |
| 2636 |
foreach ( $field_ids as $id ) { |
| 2637 |
|
| 2638 |
$cf = trim( $id, '_' ); |
| 2639 |
|
| 2640 |
$user_meta_info = $wpdb->query( |
| 2641 |
$wpdb->prepare( |
| 2642 |
"update " . $table_name . " set |
| 2643 |
sort_order=%d |
| 2644 |
where id= %d and form_id = %d", |
| 2645 |
array( $count, $cf, $form_id ) |
| 2646 |
) |
| 2647 |
); |
| 2648 |
$count ++; |
| 2649 |
} |
| 2650 |
|
| 2651 |
return $user_meta_info; |
| 2652 |
else: |
| 2653 |
return false; |
| 2654 |
endif; |
| 2655 |
} |
| 2656 |
|
| 2657 |
public function admin_form_field_delete( $field_id = '', $delete_meta = true, $form_id = 1 ) { |
| 2658 |
|
| 2659 |
global $wpdb; |
| 2660 |
|
| 2661 |
$table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 2662 |
$extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
| 2663 |
$meta_table = get_usermeta_table_prefix() . 'uwp_usermeta'; |
| 2664 |
|
| 2665 |
if ( $field_id != '' ) { |
| 2666 |
$cf = trim( $field_id, '_' ); |
| 2667 |
|
| 2668 |
if ( $field = $wpdb->get_row( $wpdb->prepare( "select id, htmlvar_name from " . $table_name . " where id= %d AND form_id = %d", array( $cf, $form_id ) ) ) ) { |
| 2669 |
|
| 2670 |
$excluded_delete = array('username', 'email'); |
| 2671 |
if(isset($field->htmlvar_name) && in_array($field->htmlvar_name, $excluded_delete)){ |
| 2672 |
return $field_id; |
| 2673 |
} |
| 2674 |
|
| 2675 |
$wpdb->query( $wpdb->prepare( "delete from " . $table_name . " where id= %d AND form_id = %d", array( $cf, $form_id ) ) ); |
| 2676 |
|
| 2677 |
// Also delete register form field |
| 2678 |
$wpdb->query( $wpdb->prepare( "delete from " . $extras_table_name . " where site_htmlvar_name= %s AND form_id = %d ", array( $field->htmlvar_name, $form_id ) ) ); |
| 2679 |
|
| 2680 |
// delete the meta column |
| 2681 |
if ( isset($field->htmlvar_name) && $delete_meta ) { |
| 2682 |
$register_forms = uwp_get_option( 'multiple_registration_forms' ); |
| 2683 |
$custom_fields = array(); |
| 2684 |
|
| 2685 |
if ( ! empty( $register_forms ) && is_array( $register_forms ) ) { |
| 2686 |
foreach ( $register_forms as $key => $register_form ) { |
| 2687 |
$form_ids[] = (int) $register_form['id']; |
| 2688 |
} |
| 2689 |
|
| 2690 |
if ( isset( $form_ids ) && count( $form_ids ) > 0 ) { |
| 2691 |
$form_ids_placeholder = array_fill( 0, count( $form_ids ), '%d' ); |
| 2692 |
$form_ids_placeholder = implode( ', ', $form_ids_placeholder ); |
| 2693 |
$query = $wpdb->prepare("SELECT id FROM " . $table_name . " WHERE form_type = 'account' AND htmlvar_name = '".$field->htmlvar_name."' AND form_id IN (" . $form_ids_placeholder . ") ORDER BY sort_order ASC", $form_ids); |
| 2694 |
$custom_fields = $wpdb->get_results( $query); |
| 2695 |
} |
| 2696 |
} |
| 2697 |
|
| 2698 |
if(isset($custom_fields) && !empty($custom_fields) && count($custom_fields) > 0){ |
| 2699 |
// Do not delete user meta column if field used in more than one form. |
| 2700 |
} else { |
| 2701 |
$col_name = sanitize_sql_orderby( $field->htmlvar_name ); |
| 2702 |
$wpdb->query( "ALTER TABLE `{$meta_table}` DROP COLUMN $col_name" ); |
| 2703 |
} |
| 2704 |
} |
| 2705 |
|
| 2706 |
do_action( 'uwp_after_custom_field_deleted', $cf, $field ); |
| 2707 |
|
| 2708 |
return $field_id; |
| 2709 |
} else { |
| 2710 |
return 0; |
| 2711 |
} |
| 2712 |
} else { |
| 2713 |
return 0; |
| 2714 |
} |
| 2715 |
} |
| 2716 |
|
| 2717 |
public function admin_form_field_save( $request_field = array() ) { |
| 2718 |
|
| 2719 |
global $wpdb;$wpdb->show_errors(); |
| 2720 |
|
| 2721 |
$table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 2722 |
|
| 2723 |
$meta_table = get_usermeta_table_prefix() . 'uwp_usermeta'; |
| 2724 |
|
| 2725 |
$old_html_variable = ''; |
| 2726 |
|
| 2727 |
$result_str = isset( $request_field['field_id'] ) ? trim( $request_field['field_id'] ) : ''; |
| 2728 |
$form_id = isset( $request_field['form_id'] ) ? (int) $request_field['form_id'] : 1; |
| 2729 |
|
| 2730 |
$user_meta_info = null; |
| 2731 |
|
| 2732 |
// some servers fail if a POST value is VARCHAR so we change it. |
| 2733 |
if ( isset( $request_field['data_type'] ) && $request_field['data_type'] == 'XVARCHAR' ) { |
| 2734 |
$request_field['data_type'] = 'VARCHAR'; |
| 2735 |
} |
| 2736 |
|
| 2737 |
$cf = trim( $result_str, '_' ); |
| 2738 |
|
| 2739 |
$cehhtmlvar_name = isset( $request_field['htmlvar_name'] ) ? $request_field['htmlvar_name'] : ''; |
| 2740 |
$form_type = $request_field['form_type']; |
| 2741 |
|
| 2742 |
$old_html_variable_name = 'uwp_account_' . $cehhtmlvar_name; |
| 2743 |
$check_old_html_variable = $wpdb->get_var( |
| 2744 |
$wpdb->prepare( |
| 2745 |
"select htmlvar_name from " . $table_name . " where id <> %d and htmlvar_name = %s and form_type = %s and form_id = %d", |
| 2746 |
array( $cf, $old_html_variable_name, $form_type, $form_id ) |
| 2747 |
) |
| 2748 |
); |
| 2749 |
|
| 2750 |
$check_html_variable = $wpdb->get_var( |
| 2751 |
$wpdb->prepare( |
| 2752 |
"select htmlvar_name from " . $table_name . " where id <> %d and htmlvar_name = %s and form_type = %s and form_id = %d", |
| 2753 |
array( $cf, $cehhtmlvar_name, $form_type, $form_id ) |
| 2754 |
) |
| 2755 |
); |
| 2756 |
|
| 2757 |
|
| 2758 |
if ( ( ! $check_old_html_variable && ! $check_html_variable ) || $request_field['field_type'] == 'fieldset' ) { |
| 2759 |
|
| 2760 |
if ( $cf != '' ) { |
| 2761 |
|
| 2762 |
$user_meta_info = $wpdb->get_row( |
| 2763 |
$wpdb->prepare( |
| 2764 |
"select * from " . $table_name . " where id = %d", |
| 2765 |
array( $cf ) |
| 2766 |
) |
| 2767 |
); |
| 2768 |
|
| 2769 |
} |
| 2770 |
|
| 2771 |
if ( ! empty( $user_meta_info ) ) { |
| 2772 |
$old_html_variable = $user_meta_info->htmlvar_name; |
| 2773 |
|
| 2774 |
} |
| 2775 |
|
| 2776 |
$site_title = sanitize_text_field( $request_field['site_title'] ); |
| 2777 |
$form_label = isset( $request_field['form_label'] ) ? sanitize_text_field( $request_field['form_label'] ) : ''; |
| 2778 |
$help_text = isset( $request_field['help_text'] ) ? sanitize_text_field( $request_field['help_text'] ) : ''; |
| 2779 |
$field_type = sanitize_text_field( $request_field['field_type'] ); |
| 2780 |
$data_type = sanitize_text_field( $request_field['data_type'] ); |
| 2781 |
$field_type_key = isset( $request_field['field_type_key'] ) ? sanitize_text_field( $request_field['field_type_key'] ) : $field_type; |
| 2782 |
$htmlvar_name = isset( $request_field['htmlvar_name'] ) ? str_replace( array( |
| 2783 |
'-', |
| 2784 |
' ', |
| 2785 |
'"', |
| 2786 |
"'" |
| 2787 |
), array( '_', '', '', '' ), sanitize_title_with_dashes( $request_field['htmlvar_name'] ) ) : null; |
| 2788 |
$default_value = isset( $request_field['default_value'] ) ? sanitize_text_field( $request_field['default_value'] ) : ''; |
| 2789 |
$sort_order = isset( $request_field['sort_order'] ) ? absint( $request_field['sort_order'] ) : ''; |
| 2790 |
$is_active = isset( $request_field['is_active'] ) ? absint( $request_field['is_active'] ) : 1; |
| 2791 |
$placeholder_value = isset( $request_field['placeholder_value'] ) ? $request_field['placeholder_value'] : ''; |
| 2792 |
$for_admin_use = isset( $request_field['for_admin_use'] ) ? absint( $request_field['for_admin_use'] ) : 0; |
| 2793 |
$is_required = isset( $request_field['is_required'] ) ? absint( $request_field['is_required'] ) : 0; |
| 2794 |
$is_dummy = isset( $request_field['is_dummy'] ) ? absint( $request_field['is_dummy'] ) : 0; |
| 2795 |
$is_public = isset( $request_field['is_public'] ) ? absint( $request_field['is_public'] ) : 0; |
| 2796 |
$is_default = isset( $request_field['is_default'] ) ? absint( $request_field['is_default'] ) : 0; |
| 2797 |
$is_register_field = isset( $request_field['is_register_field'] ) ? absint( $request_field['is_register_field'] ) : 0; |
| 2798 |
$is_search_field = isset( $request_field['is_search_field'] ) ? absint( $request_field['is_search_field'] ) : 0; |
| 2799 |
$is_register_only_field = isset( $request_field['is_register_only_field'] ) ? absint( $request_field['is_register_only_field'] ) : 0; |
| 2800 |
$required_msg = isset( $request_field['required_msg'] ) ? sanitize_text_field( $request_field['required_msg'] ) : ''; |
| 2801 |
$css_class = isset( $request_field['css_class'] ) ? sanitize_text_field( $request_field['css_class'] ) : ''; |
| 2802 |
$field_icon = isset( $request_field['field_icon'] ) ? sanitize_text_field( $request_field['field_icon'] ) : ''; |
| 2803 |
$show_in = isset( $request_field['show_in'] ) ? $request_field['show_in'] : ''; |
| 2804 |
$user_roles = isset( $request_field['user_roles'] ) ? $request_field['user_roles'] : ''; |
| 2805 |
$decimal_point = isset( $request_field['decimal_point'] ) ? absint( $request_field['decimal_point'] ) : ''; // decimal point for DECIMAL data type |
| 2806 |
$decimal_point = $decimal_point > 0 ? ( $decimal_point > 10 ? 10 : $decimal_point ) : ''; |
| 2807 |
$validation_pattern = isset( $request_field['validation_pattern'] ) ? sanitize_text_field( $request_field['validation_pattern'] ) : ''; |
| 2808 |
$validation_msg = isset( $request_field['validation_msg'] ) ? sanitize_text_field( $request_field['validation_msg'] ) : ''; |
| 2809 |
$user_sort = isset( $request_field['user_sort'] ) ? absint( $request_field['user_sort'] ) : 0; |
| 2810 |
|
| 2811 |
if ( empty( $htmlvar_name ) ) { |
| 2812 |
$htmlvar_name = sanitize_key( str_replace( array( '-', ' ', '"', "'" ), array( |
| 2813 |
'_', |
| 2814 |
'_', |
| 2815 |
'', |
| 2816 |
'' |
| 2817 |
), $request_field['site_title'] ) ); |
| 2818 |
if ( str_replace( '_', '', $htmlvar_name ) != '' ) { |
| 2819 |
$htmlvar_name = substr( $htmlvar_name, 0, 50 ); |
| 2820 |
} else { |
| 2821 |
$htmlvar_name = time(); |
| 2822 |
} |
| 2823 |
} |
| 2824 |
|
| 2825 |
if ( is_array( $show_in ) ) { |
| 2826 |
$show_in = implode( ",", $request_field['show_in'] ); |
| 2827 |
$show_in = sanitize_text_field( $show_in ); |
| 2828 |
} |
| 2829 |
|
| 2830 |
if ( is_array( $user_roles ) ) { |
| 2831 |
$user_roles = implode( ",", $request_field['user_roles'] ); |
| 2832 |
$user_roles = sanitize_text_field( $user_roles ); |
| 2833 |
} |
| 2834 |
|
| 2835 |
$option_values = ''; |
| 2836 |
if ( isset( $request_field['option_values'] ) ) { |
| 2837 |
$option_values = $request_field['option_values']; |
| 2838 |
} |
| 2839 |
|
| 2840 |
if ( isset( $request_field['extra'] ) && ! empty( $request_field['extra'] ) ) { |
| 2841 |
$extra_fields = $request_field['extra']; |
| 2842 |
} |
| 2843 |
|
| 2844 |
if ( $sort_order == '' ) { |
| 2845 |
|
| 2846 |
$last_order = $wpdb->get_var( "SELECT MAX(sort_order) as last_order FROM " . $table_name ); |
| 2847 |
|
| 2848 |
$sort_order = (int) $last_order + 1; |
| 2849 |
} |
| 2850 |
|
| 2851 |
if ( ! empty( $user_meta_info ) ) { |
| 2852 |
|
| 2853 |
$excluded = uwp_get_excluded_fields(); |
| 2854 |
|
| 2855 |
if ( ! in_array( $htmlvar_name, $excluded ) ) { |
| 2856 |
// Create custom columns |
| 2857 |
switch ( $field_type ): |
| 2858 |
|
| 2859 |
case 'checkbox': |
| 2860 |
case 'multiselect': |
| 2861 |
case 'select': |
| 2862 |
|
| 2863 |
$op_size = '500'; |
| 2864 |
|
| 2865 |
// only make the field as big as it needs to be. |
| 2866 |
if ( isset( $option_values ) && $option_values && $field_type == 'select' ) { |
| 2867 |
$option_values_arr = explode( ',', $option_values ); |
| 2868 |
if ( isset( $option_values_arr ) && is_array( $option_values_arr ) ) { |
| 2869 |
$op_max = 0; |
| 2870 |
foreach ( $option_values_arr as $op_val ) { |
| 2871 |
if ( strlen( $op_val ) && strlen( $op_val ) > $op_max ) { |
| 2872 |
$op_max = strlen( $op_val ); |
| 2873 |
} |
| 2874 |
} |
| 2875 |
if ( $op_max ) { |
| 2876 |
$op_size = $op_max; |
| 2877 |
} |
| 2878 |
} |
| 2879 |
} elseif ( isset( $option_values ) && $option_values && $field_type == 'multiselect' ) { |
| 2880 |
if ( strlen( $option_values ) ) { |
| 2881 |
$op_size = strlen( $option_values ); |
| 2882 |
} |
| 2883 |
} |
| 2884 |
|
| 2885 |
$meta_field_add = "ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; |
| 2886 |
|
| 2887 |
if ( $default_value != '' ) { |
| 2888 |
$meta_field_add .= " DEFAULT '" . $default_value . "'"; |
| 2889 |
} |
| 2890 |
|
| 2891 |
$alter_result = $wpdb->query( $meta_field_add ); |
| 2892 |
if ( $alter_result === false ) { |
| 2893 |
return __( 'Column change failed, you may have too many columns.', 'userswp' ); |
| 2894 |
} |
| 2895 |
|
| 2896 |
if ( isset( $request_field['cat_display_type'] ) ) { |
| 2897 |
$extra_fields = $request_field['cat_display_type']; |
| 2898 |
} |
| 2899 |
|
| 2900 |
if ( isset( $request_field['multi_display_type'] ) ) { |
| 2901 |
$extra_fields = $request_field['multi_display_type']; |
| 2902 |
} |
| 2903 |
|
| 2904 |
|
| 2905 |
break; |
| 2906 |
|
| 2907 |
case 'textarea': |
| 2908 |
case 'editor': |
| 2909 |
case 'url': |
| 2910 |
case 'file': |
| 2911 |
|
| 2912 |
$alter_result = $wpdb->query( "ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL" ); |
| 2913 |
if ( $alter_result === false ) { |
| 2914 |
return __( 'Column change failed, you may have too many columns.', 'userswp' ); |
| 2915 |
} |
| 2916 |
if ( isset( $request_field['advanced_editor'] ) ) { |
| 2917 |
$extra_fields = $request_field['advanced_editor']; |
| 2918 |
} |
| 2919 |
|
| 2920 |
break; |
| 2921 |
|
| 2922 |
case 'fieldset': |
| 2923 |
// Nothing happened for fieldset |
| 2924 |
break; |
| 2925 |
|
| 2926 |
default: |
| 2927 |
if ( $data_type != 'VARCHAR' && $data_type != '' ) { |
| 2928 |
if ( $data_type == 'FLOAT' && $decimal_point > 0 ) { |
| 2929 |
$default_value_add = "ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int) $decimal_point . ") NULL"; |
| 2930 |
} else { |
| 2931 |
$default_value_add = "ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; |
| 2932 |
} |
| 2933 |
|
| 2934 |
if ( is_numeric( $default_value ) && $default_value != '' ) { |
| 2935 |
$default_value_add .= " DEFAULT '" . $default_value . "'"; |
| 2936 |
} |
| 2937 |
} else { |
| 2938 |
$default_value_add = "ALTER TABLE " . $meta_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; |
| 2939 |
if ( $default_value != '' ) { |
| 2940 |
$default_value_add .= " DEFAULT '" . $default_value . "'"; |
| 2941 |
} |
| 2942 |
} |
| 2943 |
|
| 2944 |
$alter_result = $wpdb->query( $default_value_add ); |
| 2945 |
if ( $alter_result === false ) { |
| 2946 |
return __( 'Column change failed, you may have too many columns.', 'userswp' ); |
| 2947 |
} |
| 2948 |
break; |
| 2949 |
endswitch; |
| 2950 |
} |
| 2951 |
|
| 2952 |
$extra_field_query = ''; |
| 2953 |
if ( ! empty( $extra_fields ) ) { |
| 2954 |
$extra_field_query = serialize( $extra_fields ); |
| 2955 |
} |
| 2956 |
|
| 2957 |
$wpdb->query( |
| 2958 |
|
| 2959 |
$wpdb->prepare( |
| 2960 |
|
| 2961 |
"update " . $table_name . " set |
| 2962 |
form_type = %s, |
| 2963 |
site_title = %s, |
| 2964 |
form_label = %s, |
| 2965 |
help_text = %s, |
| 2966 |
field_type = %s, |
| 2967 |
data_type = %s, |
| 2968 |
decimal_point = %s, |
| 2969 |
field_type_key = %s, |
| 2970 |
htmlvar_name = %s, |
| 2971 |
default_value = %s, |
| 2972 |
sort_order = %s, |
| 2973 |
is_active = %s, |
| 2974 |
placeholder_value = %s, |
| 2975 |
for_admin_use = %s, |
| 2976 |
is_default = %s, |
| 2977 |
is_required = %s, |
| 2978 |
is_dummy = %s, |
| 2979 |
is_public = %s, |
| 2980 |
is_register_field = %s, |
| 2981 |
is_search_field = %s, |
| 2982 |
is_register_only_field = %s, |
| 2983 |
required_msg = %s, |
| 2984 |
css_class = %s, |
| 2985 |
field_icon = %s, |
| 2986 |
show_in = %s, |
| 2987 |
user_roles = %s, |
| 2988 |
option_values = %s, |
| 2989 |
extra_fields = %s, |
| 2990 |
validation_pattern = %s, |
| 2991 |
validation_msg = %s, |
| 2992 |
form_id = %d, |
| 2993 |
user_sort = %s |
| 2994 |
where id = %d", |
| 2995 |
|
| 2996 |
array( |
| 2997 |
$form_type, |
| 2998 |
$site_title, |
| 2999 |
$form_label, |
| 3000 |
$help_text, |
| 3001 |
$field_type, |
| 3002 |
$data_type, |
| 3003 |
$decimal_point, |
| 3004 |
$field_type_key, |
| 3005 |
$htmlvar_name, |
| 3006 |
$default_value, |
| 3007 |
$sort_order, |
| 3008 |
$is_active, |
| 3009 |
$placeholder_value, |
| 3010 |
$for_admin_use, |
| 3011 |
$is_default, |
| 3012 |
$is_required, |
| 3013 |
$is_dummy, |
| 3014 |
$is_public, |
| 3015 |
$is_register_field, |
| 3016 |
$is_search_field, |
| 3017 |
$is_register_only_field, |
| 3018 |
$required_msg, |
| 3019 |
$css_class, |
| 3020 |
$field_icon, |
| 3021 |
$show_in, |
| 3022 |
$user_roles, |
| 3023 |
$option_values, |
| 3024 |
$extra_field_query, |
| 3025 |
$validation_pattern, |
| 3026 |
$validation_msg, |
| 3027 |
$form_id, |
| 3028 |
$user_sort, |
| 3029 |
$cf |
| 3030 |
) |
| 3031 |
) |
| 3032 |
|
| 3033 |
); |
| 3034 |
|
| 3035 |
$lastid = trim( $cf ); |
| 3036 |
|
| 3037 |
do_action( 'uwp_after_custom_fields_updated', $lastid ); |
| 3038 |
|
| 3039 |
} else { |
| 3040 |
|
| 3041 |
switch ( $field_type ): |
| 3042 |
|
| 3043 |
case 'checkbox': |
| 3044 |
$data_type = 'TINYINT'; |
| 3045 |
|
| 3046 |
$meta_field_add = $data_type . "( 1 ) NOT NULL "; |
| 3047 |
if ( (int) $default_value === 1 ) { |
| 3048 |
$meta_field_add .= " DEFAULT '1'"; |
| 3049 |
} |
| 3050 |
|
| 3051 |
$add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
| 3052 |
if ( $add_result === false ) { |
| 3053 |
return __( 'Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp' ); |
| 3054 |
} |
| 3055 |
break; |
| 3056 |
case 'multiselect': |
| 3057 |
case 'select': |
| 3058 |
$data_type = 'VARCHAR'; |
| 3059 |
$op_size = '500'; |
| 3060 |
|
| 3061 |
// only make the field as big as it needs to be. |
| 3062 |
if ( isset( $option_values ) && $option_values && $field_type == 'select' ) { |
| 3063 |
$option_values_arr = explode( ',', $option_values ); |
| 3064 |
|
| 3065 |
if ( isset( $option_values_arr ) && is_array( $option_values_arr ) ) { |
| 3066 |
$op_max = 0; |
| 3067 |
|
| 3068 |
foreach ( $option_values_arr as $op_val ) { |
| 3069 |
if ( strlen( $op_val ) && strlen( $op_val ) > $op_max ) { |
| 3070 |
$op_max = strlen( $op_val ); |
| 3071 |
} |
| 3072 |
} |
| 3073 |
|
| 3074 |
if ( $op_max ) { |
| 3075 |
$op_size = $op_max; |
| 3076 |
} |
| 3077 |
} |
| 3078 |
} elseif ( isset( $option_values ) && $option_values && $field_type == 'multiselect' ) { |
| 3079 |
if ( strlen( $option_values ) ) { |
| 3080 |
$op_size = strlen( $option_values ); |
| 3081 |
} |
| 3082 |
|
| 3083 |
if ( isset( $request_field['multi_display_type'] ) ) { |
| 3084 |
$extra_fields = $request_field['multi_display_type']; |
| 3085 |
} |
| 3086 |
} |
| 3087 |
|
| 3088 |
$meta_field_add = $data_type . "( $op_size ) NULL "; |
| 3089 |
if ( $default_value != '' ) { |
| 3090 |
$meta_field_add .= " DEFAULT '" . $default_value . "'"; |
| 3091 |
} |
| 3092 |
|
| 3093 |
$add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
| 3094 |
if ( $add_result === false ) { |
| 3095 |
return __( 'Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp' ); |
| 3096 |
} |
| 3097 |
break; |
| 3098 |
case 'textarea': |
| 3099 |
case 'editor': |
| 3100 |
case 'url': |
| 3101 |
case 'file': |
| 3102 |
|
| 3103 |
$data_type = 'TEXT'; |
| 3104 |
|
| 3105 |
$meta_field_add = $data_type . " NULL "; |
| 3106 |
|
| 3107 |
$add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
| 3108 |
if ( $add_result === false ) { |
| 3109 |
return __( 'Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp' ); |
| 3110 |
} |
| 3111 |
|
| 3112 |
break; |
| 3113 |
|
| 3114 |
case 'datepicker': |
| 3115 |
|
| 3116 |
$data_type = 'DATE'; |
| 3117 |
|
| 3118 |
$meta_field_add = $data_type . " NULL "; |
| 3119 |
|
| 3120 |
$add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
| 3121 |
if ( $add_result === false ) { |
| 3122 |
return __( 'Column creation failed, you may have too many columns or the default value must have in valid date format.', 'userswp' ); |
| 3123 |
} |
| 3124 |
|
| 3125 |
break; |
| 3126 |
|
| 3127 |
case 'time': |
| 3128 |
|
| 3129 |
$data_type = 'TIME'; |
| 3130 |
|
| 3131 |
$meta_field_add = $data_type . " NULL "; |
| 3132 |
|
| 3133 |
$add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
| 3134 |
if ( $add_result === false ) { |
| 3135 |
return __( 'Column creation failed, you may have too many columns or the default value must have in valid time format.', 'userswp' ); |
| 3136 |
} |
| 3137 |
|
| 3138 |
break; |
| 3139 |
|
| 3140 |
default: |
| 3141 |
|
| 3142 |
if ( $data_type != 'VARCHAR' && $data_type != '' ) { |
| 3143 |
$meta_field_add = $data_type . " NULL "; |
| 3144 |
|
| 3145 |
if ( $data_type == 'FLOAT' && $decimal_point > 0 ) { |
| 3146 |
$meta_field_add = "DECIMAL(11, " . (int) $decimal_point . ") NULL "; |
| 3147 |
} |
| 3148 |
|
| 3149 |
if ( is_numeric( $default_value ) && $default_value != '' ) { |
| 3150 |
$meta_field_add .= " DEFAULT '" . $default_value . "'"; |
| 3151 |
} |
| 3152 |
} else { |
| 3153 |
$meta_field_add = " VARCHAR( 254 ) NULL "; |
| 3154 |
|
| 3155 |
if ( $default_value != '' ) { |
| 3156 |
$meta_field_add .= " DEFAULT '" . $default_value . "'"; |
| 3157 |
} |
| 3158 |
} |
| 3159 |
|
| 3160 |
$add_result = uwp_add_column_if_not_exist( $meta_table, $htmlvar_name, $meta_field_add ); |
| 3161 |
if ( $add_result === false ) { |
| 3162 |
return __( 'Column creation failed, you may have too many columns or the default value does not match with field data type.', 'userswp' ); |
| 3163 |
} |
| 3164 |
break; |
| 3165 |
endswitch; |
| 3166 |
|
| 3167 |
$extra_field_query = ''; |
| 3168 |
if ( ! empty( $extra_fields ) ) { |
| 3169 |
$extra_field_query = serialize( $extra_fields ); |
| 3170 |
} |
| 3171 |
|
| 3172 |
$wpdb->query( |
| 3173 |
|
| 3174 |
$wpdb->prepare( |
| 3175 |
|
| 3176 |
"insert into " . $table_name . " set |
| 3177 |
form_type = %s, |
| 3178 |
site_title = %s, |
| 3179 |
form_label = %s, |
| 3180 |
help_text = %s, |
| 3181 |
field_type = %s, |
| 3182 |
data_type = %s, |
| 3183 |
decimal_point = %s, |
| 3184 |
field_type_key = %s, |
| 3185 |
htmlvar_name = %s, |
| 3186 |
default_value = %s, |
| 3187 |
sort_order = %d, |
| 3188 |
is_active = %s, |
| 3189 |
placeholder_value = %s, |
| 3190 |
for_admin_use = %s, |
| 3191 |
is_default = %s, |
| 3192 |
is_required = %s, |
| 3193 |
is_dummy = %s, |
| 3194 |
is_public = %s, |
| 3195 |
is_register_field = %s, |
| 3196 |
is_search_field = %s, |
| 3197 |
is_register_only_field = %s, |
| 3198 |
required_msg = %s, |
| 3199 |
css_class = %s, |
| 3200 |
field_icon = %s, |
| 3201 |
show_in = %s, |
| 3202 |
user_roles = %s, |
| 3203 |
option_values = %s, |
| 3204 |
extra_fields = %s, |
| 3205 |
validation_pattern = %s, |
| 3206 |
validation_msg = %s, |
| 3207 |
form_id = %d, |
| 3208 |
user_sort = %s ", |
| 3209 |
|
| 3210 |
array( |
| 3211 |
$form_type, |
| 3212 |
$site_title, |
| 3213 |
$form_label, |
| 3214 |
$help_text, |
| 3215 |
$field_type, |
| 3216 |
$data_type, |
| 3217 |
$decimal_point, |
| 3218 |
$field_type_key, |
| 3219 |
$htmlvar_name, |
| 3220 |
$default_value, |
| 3221 |
$sort_order, |
| 3222 |
$is_active, |
| 3223 |
$placeholder_value, |
| 3224 |
$for_admin_use, |
| 3225 |
$is_default, |
| 3226 |
$is_required, |
| 3227 |
$is_dummy, |
| 3228 |
$is_public, |
| 3229 |
$is_register_field, |
| 3230 |
$is_search_field, |
| 3231 |
$is_register_only_field, |
| 3232 |
$required_msg, |
| 3233 |
$css_class, |
| 3234 |
$field_icon, |
| 3235 |
$show_in, |
| 3236 |
$user_roles, |
| 3237 |
$option_values, |
| 3238 |
$extra_field_query, |
| 3239 |
$validation_pattern, |
| 3240 |
$validation_msg, |
| 3241 |
$form_id, |
| 3242 |
$user_sort |
| 3243 |
) |
| 3244 |
|
| 3245 |
) |
| 3246 |
|
| 3247 |
); |
| 3248 |
|
| 3249 |
$lastid = $wpdb->insert_id; |
| 3250 |
|
| 3251 |
$lastid = trim( $lastid ); |
| 3252 |
|
| 3253 |
} |
| 3254 |
|
| 3255 |
return (int) $lastid; |
| 3256 |
|
| 3257 |
|
| 3258 |
} else { |
| 3259 |
return 'invalid_key'; |
| 3260 |
} |
| 3261 |
|
| 3262 |
} |
| 3263 |
|
| 3264 |
public function register_ajax_handler() { |
| 3265 |
if ( isset( $_REQUEST['create_field'] ) ) { |
| 3266 |
|
| 3267 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 3268 |
wp_die( -1 ); |
| 3269 |
} |
| 3270 |
|
| 3271 |
$form_id = isset( $_REQUEST['form_id'] ) ? sanitize_text_field( $_REQUEST['form_id'] ) : 1; |
| 3272 |
$field_id = isset( $_REQUEST['field_id'] ) ? trim( sanitize_text_field( $_REQUEST['field_id'] ), '_' ) : ''; |
| 3273 |
$field_action = isset( $_REQUEST['field_ins_upd'] ) ? sanitize_text_field( $_REQUEST['field_ins_upd'] ) : ''; |
| 3274 |
|
| 3275 |
/* ------- check nonce field ------- */ |
| 3276 |
if ( isset( $_REQUEST['update'] ) && $_REQUEST['update'] == 'update' ) { |
| 3277 |
$field_ids = array(); |
| 3278 |
if ( ! empty( $_REQUEST['licontainer'] ) && is_array( $_REQUEST['licontainer'] ) ) { |
| 3279 |
foreach ( $_REQUEST['licontainer'] as $lic_id ) { |
| 3280 |
$field_ids[] = sanitize_text_field( $lic_id ); |
| 3281 |
} |
| 3282 |
} |
| 3283 |
|
| 3284 |
$return = uwp_form_extras_field_order( $field_ids, "register", $form_id ); |
| 3285 |
|
| 3286 |
if ( is_array( $return ) ) { |
| 3287 |
$return = json_encode( $return ); |
| 3288 |
} |
| 3289 |
|
| 3290 |
echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 3291 |
} |
| 3292 |
|
| 3293 |
/* ---- Show field form in admin ---- */ |
| 3294 |
if ( $field_action == 'new' ) { |
| 3295 |
$form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : ''; |
| 3296 |
$fields = $this->register_fields( $form_type, $form_id ); |
| 3297 |
|
| 3298 |
|
| 3299 |
$_REQUEST['site_field_id'] = isset( $_REQUEST['field_id'] ) ? sanitize_text_field( $_REQUEST['field_id'] ) : ''; |
| 3300 |
$_REQUEST['is_default'] = '0'; |
| 3301 |
|
| 3302 |
if ( ! empty( $fields ) ) { |
| 3303 |
foreach ( $fields as $val ) { |
| 3304 |
$val = stripslashes_deep( $val ); |
| 3305 |
|
| 3306 |
if ( $val['htmlvar_name'] == $_REQUEST['htmlvar_name'] ) { |
| 3307 |
$_REQUEST['field_type'] = $val['field_type']; |
| 3308 |
$_REQUEST['site_title'] = $val['site_title']; |
| 3309 |
} |
| 3310 |
} |
| 3311 |
} |
| 3312 |
|
| 3313 |
|
| 3314 |
$htmlvar_name = isset( $_REQUEST['htmlvar_name'] ) ? sanitize_text_field( $_REQUEST['htmlvar_name'] ) : ''; |
| 3315 |
|
| 3316 |
$this->register_field_adminhtml( $htmlvar_name, $field_action, false, $_REQUEST ); |
| 3317 |
} |
| 3318 |
|
| 3319 |
/* ---- Delete field ---- */ |
| 3320 |
if ( $field_id != '' && $field_action == 'delete' && isset( $_REQUEST['_wpnonce'] ) ) { |
| 3321 |
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'uwp_form_extras_nonce' . $field_id ) ) { |
| 3322 |
return; |
| 3323 |
} |
| 3324 |
|
| 3325 |
echo $this->register_field_delete( $field_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 3326 |
} |
| 3327 |
|
| 3328 |
/* ---- Save field ---- */ |
| 3329 |
if ( $field_id != '' && $field_action == 'submit' && isset( $_REQUEST['_wpnonce'] ) ) { |
| 3330 |
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'uwp_form_extras_nonce' . $field_id ) ) { |
| 3331 |
return; |
| 3332 |
} |
| 3333 |
|
| 3334 |
foreach ( $_REQUEST as $pkey => $pval ) { |
| 3335 |
$tags = is_array( $_REQUEST[ $pkey ] ) ? 'skip_field' : ''; |
| 3336 |
|
| 3337 |
if ( $tags != 'skip_field' ) { |
| 3338 |
$_REQUEST[ $pkey ] = strip_tags( sanitize_text_field( $_REQUEST[ $pkey ] ), $tags ); |
| 3339 |
} |
| 3340 |
} |
| 3341 |
|
| 3342 |
|
| 3343 |
$return = $this->register_field_save( $_REQUEST ); |
| 3344 |
|
| 3345 |
if ( is_int( $return ) ) { |
| 3346 |
$lastid = $return; |
| 3347 |
|
| 3348 |
$this->register_field_adminhtml( $lastid, 'submit' ); |
| 3349 |
} else { |
| 3350 |
echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 3351 |
} |
| 3352 |
} |
| 3353 |
} |
| 3354 |
die(); |
| 3355 |
} |
| 3356 |
|
| 3357 |
public function register_field_delete( $field_id = '' ) { |
| 3358 |
|
| 3359 |
global $wpdb; |
| 3360 |
$extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
| 3361 |
|
| 3362 |
if ( $field_id != '' ) { |
| 3363 |
$cf = trim( $field_id, '_' ); |
| 3364 |
|
| 3365 |
$wpdb->query( $wpdb->prepare( "delete from " . $extras_table_name . " where id= %d ", array( $cf ) ) ); |
| 3366 |
|
| 3367 |
return $field_id; |
| 3368 |
|
| 3369 |
} else { |
| 3370 |
return 0; |
| 3371 |
} |
| 3372 |
} |
| 3373 |
|
| 3374 |
public function register_field_save( $request_field = array() ) { |
| 3375 |
|
| 3376 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 3377 |
wp_die( -1 ); |
| 3378 |
} |
| 3379 |
|
| 3380 |
global $wpdb; |
| 3381 |
$extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
| 3382 |
|
| 3383 |
$form_id = isset( $request_field['form_id'] ) ? (int) $request_field['form_id'] : ''; |
| 3384 |
$result_str = isset( $request_field['field_id'] ) ? trim( $request_field['field_id'] ) : ''; |
| 3385 |
|
| 3386 |
$cf = trim( $result_str, '_' ); |
| 3387 |
|
| 3388 |
/*-------- check duplicate validation --------*/ |
| 3389 |
|
| 3390 |
$site_htmlvar_name = isset( $request_field['site_htmlvar_name'] ) ? sanitize_text_field($request_field['site_htmlvar_name']) : sanitize_text_field($request_field['htmlvar_name']); |
| 3391 |
$form_type = $request_field['form_type']; |
| 3392 |
$field_type = $request_field['field_type']; |
| 3393 |
|
| 3394 |
$check_html_variable = $wpdb->get_var( $wpdb->prepare( "select site_htmlvar_name from " . $extras_table_name . " where id <> %d and site_htmlvar_name = %s and form_type = %s and form_id=%d", |
| 3395 |
array( $cf, $site_htmlvar_name, $form_type, $form_id ) ) ); |
| 3396 |
|
| 3397 |
|
| 3398 |
if ( ! $check_html_variable ) { |
| 3399 |
|
| 3400 |
if ( $cf != '' ) { |
| 3401 |
|
| 3402 |
$user_meta_info = $wpdb->get_row( |
| 3403 |
$wpdb->prepare( |
| 3404 |
"select * from " . $extras_table_name . " where id = %d", |
| 3405 |
array( $cf ) |
| 3406 |
) |
| 3407 |
); |
| 3408 |
|
| 3409 |
} |
| 3410 |
|
| 3411 |
if ( $form_type == '' ) { |
| 3412 |
$form_type = 'register'; |
| 3413 |
} |
| 3414 |
|
| 3415 |
$site_htmlvar_name = sanitize_text_field($request_field['site_htmlvar_name']); |
| 3416 |
$field_id = ( isset( $request_field['field_id'] ) && $request_field['field_id'] ) ? str_replace( 'new', '', $request_field['field_id'] ) : ''; |
| 3417 |
|
| 3418 |
if ( ! empty( $user_meta_info ) ) { |
| 3419 |
|
| 3420 |
$wpdb->query( |
| 3421 |
$wpdb->prepare( |
| 3422 |
"update " . $extras_table_name . " set |
| 3423 |
form_type = %s, |
| 3424 |
field_type = %s, |
| 3425 |
site_htmlvar_name = %s, |
| 3426 |
sort_order = %s, |
| 3427 |
form_id = %d |
| 3428 |
where id = %d", |
| 3429 |
array( |
| 3430 |
$form_type, |
| 3431 |
$field_type, |
| 3432 |
$site_htmlvar_name, |
| 3433 |
$field_id, |
| 3434 |
$form_id, |
| 3435 |
$cf |
| 3436 |
) |
| 3437 |
|
| 3438 |
) |
| 3439 |
|
| 3440 |
); |
| 3441 |
|
| 3442 |
$lastid = trim( $cf ); |
| 3443 |
|
| 3444 |
|
| 3445 |
} else { |
| 3446 |
|
| 3447 |
|
| 3448 |
$wpdb->query( |
| 3449 |
$wpdb->prepare( |
| 3450 |
|
| 3451 |
"insert into " . $extras_table_name . " set |
| 3452 |
form_type = %s, |
| 3453 |
field_type = %s, |
| 3454 |
site_htmlvar_name = %s, |
| 3455 |
sort_order = %s, |
| 3456 |
form_id = %s", |
| 3457 |
array( |
| 3458 |
$form_type, |
| 3459 |
$field_type, |
| 3460 |
$site_htmlvar_name, |
| 3461 |
$field_id, |
| 3462 |
$form_id |
| 3463 |
) |
| 3464 |
) |
| 3465 |
); |
| 3466 |
$lastid = $wpdb->insert_id; |
| 3467 |
$lastid = trim( $lastid ); |
| 3468 |
} |
| 3469 |
|
| 3470 |
return (int) $lastid; |
| 3471 |
|
| 3472 |
|
| 3473 |
} else { |
| 3474 |
return 'invalid_key'; |
| 3475 |
} |
| 3476 |
} |
| 3477 |
|
| 3478 |
} |