field-controls.php
1 year ago
field-header.php
1 year ago
field-label.php
1 week ago
field-name.php
1 year ago
field-text.php
1 year ago
field-type.php
1 year ago
field-type.php
77 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Field Type |
| 4 | * |
| 5 | * If disabled, create <select> with single option and add hidden input with current value. |
| 6 | */ |
| 7 | ?> |
| 8 | <tr> |
| 9 | <th><?php echo esc_html_x( 'Type', 'noun', 'strong-testimonials' ); ?></th> |
| 10 | <td> |
| 11 | <?php |
| 12 | if ( $adding ) : |
| 13 | ?> |
| 14 | <select class="first-field field-type new" name="fields[<?php echo esc_attr( $key ); ?>][input_type]"> |
| 15 | |
| 16 | <?php /* Start with a blank option with event trigger to update optgroups */ ?> |
| 17 | <option class="no-selection" value="none" name="none">—</option> |
| 18 | |
| 19 | <?php /* Post fields */ ?> |
| 20 | <optgroup class="post" label="<?php esc_html_e( 'Post Fields', 'strong-testimonials' ); ?>"> |
| 21 | <?php foreach ( $field_types['post'] as $field_key => $field_parts ) : ?> |
| 22 | <option value="<?php echo esc_attr( $field_key ); ?>"><?php echo esc_html( $field_parts['option_label'] ); ?></option> |
| 23 | <?php endforeach; ?> |
| 24 | </optgroup> |
| 25 | |
| 26 | <?php /* Custom fields */ ?> |
| 27 | <optgroup class="custom" label="<?php esc_html_e( 'Custom Fields', 'strong-testimonials' ); ?>"> |
| 28 | <?php foreach ( $field_types['custom'] as $field_key => $field_parts ) : ?> |
| 29 | <option value="<?php echo esc_attr( $field_key ); ?>"><?php echo esc_html( $field_parts['option_label'] ); ?></option> |
| 30 | <?php endforeach; ?> |
| 31 | </optgroup> |
| 32 | |
| 33 | <?php /* Special fields */ ?> |
| 34 | <optgroup class="optional" label="<?php esc_html_e( 'Special Fields', 'strong-testimonials' ); ?>"> |
| 35 | <?php foreach ( $field_types['optional'] as $field_key => $field_parts ) : ?> |
| 36 | <?php $data = ( $field_parts['name'] ) ? ' data-force-name="' . $field_parts['name'] . '"' : ''; ?> |
| 37 | <option value="<?php echo esc_attr( $field_key ); ?>"<?php echo esc_attr( $data ); ?>><?php echo esc_html( $field_parts['option_label'] ); ?></option> |
| 38 | <?php endforeach; ?> |
| 39 | </optgroup> |
| 40 | |
| 41 | </select> |
| 42 | |
| 43 | <span class="help form-error-text" style="display: none;"><?php esc_html_e( 'Select a field type or delete this field.', 'strong-testimonials' ); ?></span> |
| 44 | |
| 45 | <?php do_action( 'wpmtst_after_form_type_selection' ); ?> |
| 46 | |
| 47 | <?php else : ?> |
| 48 | |
| 49 | <?php |
| 50 | if ( 'post' === $field['record_type'] ) { |
| 51 | foreach ( $field_types['post'] as $field_key => $field_parts ) { |
| 52 | // compare field *name* |
| 53 | if ( $field['name'] === $field_key ) { |
| 54 | echo esc_html( $field_parts['option_label'] ); |
| 55 | } |
| 56 | } |
| 57 | } elseif ( 'custom' === $field['record_type'] ) { |
| 58 | foreach ( $field_types['custom'] as $field_key => $field_parts ) { |
| 59 | // compare field *type* |
| 60 | if ( $field['input_type'] === $field_key ) { |
| 61 | echo esc_html( $field_parts['option_label'] ); |
| 62 | } |
| 63 | } |
| 64 | } elseif ( 'optional' === $field['record_type'] ) { |
| 65 | foreach ( $field_types['optional'] as $field_key => $field_parts ) { |
| 66 | // compare field *type* |
| 67 | if ( $field['input_type'] === $field_key ) { |
| 68 | echo esc_html( $field_parts['option_label'] ); |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | endif; // editing |
| 74 | ?> |
| 75 | </td> |
| 76 | </tr> |
| 77 |