| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) { |
| 7 |
echo FrmProPost::get_category_dropdown( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 8 |
$field, |
| 9 |
array( |
| 10 |
'location' => 'front', |
| 11 |
'name' => $field_name, |
| 12 |
'id' => $html_id, |
| 13 |
) |
| 14 |
); |
| 15 |
} else { |
| 16 |
if ( $read_only ) { |
| 17 |
?> |
| 18 |
<select <?php do_action( 'frm_field_input_html', $field ); ?>> |
| 19 |
<?php } else { ?> |
| 20 |
<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $html_id ); ?>" <?php do_action( 'frm_field_input_html', $field ); ?>> |
| 21 |
<?php |
| 22 |
} |
| 23 |
|
| 24 |
$placeholder = FrmFieldsController::add_placeholder_to_select( $field ); |
| 25 |
|
| 26 |
$skipped = false; |
| 27 |
$other_opt = false; |
| 28 |
$other_checked = false; |
| 29 |
|
| 30 |
if ( empty( $field['options'] ) ) { |
| 31 |
$field['options'] = array(); |
| 32 |
} |
| 33 |
|
| 34 |
foreach ( $field['options'] as $opt_key => $opt ) { |
| 35 |
$field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field ); |
| 36 |
$opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field ); |
| 37 |
$selected = FrmAppHelper::check_selected( $field['value'], $field_val ); |
| 38 |
if ( $other_opt === false ) { |
| 39 |
$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $selected ); |
| 40 |
if ( FrmFieldsHelper::is_other_opt( $opt_key ) && $selected ) { |
| 41 |
$other_checked = true; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
if ( $placeholder && $opt == '' && ! $skipped ) { |
| 46 |
$skipped = true; |
| 47 |
continue; |
| 48 |
} |
| 49 |
|
| 50 |
$option_params = array( |
| 51 |
'value' => $field_val, |
| 52 |
); |
| 53 |
if ( $selected ) { |
| 54 |
$option_params['selected'] = 'selected'; |
| 55 |
} |
| 56 |
if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 57 |
$option_params['class'] = 'frm_other_trigger'; |
| 58 |
} |
| 59 |
?> |
| 60 |
<option <?php FrmAppHelper::array_to_html_params( $option_params, true ); ?>> |
| 61 |
<?php echo esc_html( $opt == '' ? ' ' : $opt ); ?> |
| 62 |
</option> |
| 63 |
<?php |
| 64 |
unset( $option_params ); |
| 65 |
} |
| 66 |
?> |
| 67 |
</select> |
| 68 |
<?php |
| 69 |
|
| 70 |
if ( isset( $other_args ) ) { |
| 71 |
FrmFieldsHelper::include_other_input( |
| 72 |
array( |
| 73 |
'other_opt' => $other_opt, |
| 74 |
'read_only' => $read_only, |
| 75 |
'checked' => $other_checked, |
| 76 |
'name' => $other_args['name'], |
| 77 |
'value' => $other_args['value'], |
| 78 |
'field' => $field, |
| 79 |
'html_id' => $html_id, |
| 80 |
'opt_key' => false, |
| 81 |
) |
| 82 |
); |
| 83 |
} |
| 84 |
} |
| 85 |
|