main.php
110 lines
| 1 | <?php |
| 2 | |
| 3 | $settings = EEB()->settings->get_setting(); |
| 4 | $advanced_settings = (bool) EEB()->settings->get_setting( 'advanced_settings', true ); |
| 5 | |
| 6 | ?> |
| 7 | <div id="post-body-content"> |
| 8 | <div class="postbox"> |
| 9 | <div class="inside"> |
| 10 | <fieldset> |
| 11 | <table class="form-table"> |
| 12 | <?php foreach( $settings as $setting_name => $setting ) : |
| 13 | $hide_main_layer = ''; |
| 14 | |
| 15 | if( ! $advanced_settings && isset( $setting['advanced'] ) && $setting['advanced'] === true ){ |
| 16 | $hide_main_layer = 'style="display:none !important;"'; |
| 17 | } |
| 18 | |
| 19 | //Hide foggy email integration |
| 20 | if( $setting['title'] === 'Foggy Email API Key' && ! isset( $_GET['displayfoggy'] ) ){ |
| 21 | continue; |
| 22 | } |
| 23 | |
| 24 | //Validate settings value |
| 25 | $main_settings_value = ''; |
| 26 | if( isset( $setting['value'] ) ){ |
| 27 | $main_settings_value = $setting['value']; |
| 28 | } |
| 29 | |
| 30 | $is_checked = ( $setting['type'] == 'checkbox' && ( $main_settings_value === 1 || $main_settings_value === '1' ) ) ? 'checked' : ''; |
| 31 | $value = ( $setting['type'] != 'checkbox' && $setting['type'] != 'multi-input' ) ? $main_settings_value : '1'; |
| 32 | |
| 33 | ?> |
| 34 | <tr valign="top" <?php echo $hide_main_layer; ?>> |
| 35 | <th scope="row"> |
| 36 | <?php echo $setting['title']; ?> |
| 37 | </th> |
| 38 | <td scope="row" valign="top"> |
| 39 | <p> |
| 40 | <?php if( $setting['type'] === 'multi-input' ) : ?> |
| 41 | <?php foreach( $setting['inputs'] as $si_key => $data ) : |
| 42 | $hide_sub_layer = ''; |
| 43 | |
| 44 | if( ! $advanced_settings && isset( $data['advanced'] ) && $data['advanced'] === true ){ |
| 45 | $hide_sub_layer = 'style="display:none !important;"'; |
| 46 | } |
| 47 | |
| 48 | //Always set the radio value of single inputs to their key |
| 49 | if( $setting['input-type'] === 'radio' ){ |
| 50 | $data['value'] = $si_key; |
| 51 | } |
| 52 | |
| 53 | $mi_is_checked = ( $setting['input-type'] == 'checkbox' && ( isset( $data['value'] ) && ( $data['value'] === 1 || $data['value'] === '1' ) ) ) ? 'checked' : ''; |
| 54 | $mi_value = ( $setting['input-type'] != 'checkbox' ) ? $data['value'] : '1'; |
| 55 | $si_name = $si_key; |
| 56 | |
| 57 | //Re-validate for radio inputs |
| 58 | if( $setting['input-type'] == 'radio' ){ |
| 59 | $si_name = $setting_name; |
| 60 | |
| 61 | //Check radio button |
| 62 | if( (string) $main_settings_value === (string) $data['value'] ){ |
| 63 | $mi_is_checked = 'checked'; |
| 64 | } |
| 65 | } |
| 66 | ?> |
| 67 | <p <?php echo $hide_sub_layer; ?>> |
| 68 | <input id="<?php echo $si_name . '_' . $si_key; ?>" name="<?php echo $this->settings_key; ?>[<?php echo $si_name; ?>]" type="<?php echo $setting['input-type']; ?>" class="regular-text" value="<?php echo $mi_value; ?>" <?php echo $mi_is_checked; ?> /> |
| 69 | <label for="<?php echo $si_name . '_' . $si_key; ?>"> |
| 70 | <?php echo $data['label']; ?> |
| 71 | </label> |
| 72 | </p> |
| 73 | <?php if( isset( $data['description'] ) ) : ?> |
| 74 | <p class="description" <?php echo $hide_sub_layer; ?>> |
| 75 | <?php if( in_array( $setting['input-type'], array( 'checkbox', 'radio' ) ) ) : ?> |
| 76 | <input name="email-encoder-bundle-hidden-margin" type="radio" class="regular-text" value="" style="visibility:hidden !important;pointer-events:none !important;"/> |
| 77 | <?php endif; ?> |
| 78 | <?php echo $data['description']; ?> |
| 79 | </p> |
| 80 | <?php endif; ?> |
| 81 | <?php endforeach; ?> |
| 82 | <?php else : ?> |
| 83 | <input id="<?php echo $setting['id']; ?>" name="<?php echo $this->settings_key; ?>[<?php echo $setting_name; ?>]" type="<?php echo $setting['type']; ?>" class="regular-text" value="<?php echo $value; ?>" <?php echo $is_checked; ?> /> |
| 84 | <?php if( isset( $setting['label'] ) ) : ?> |
| 85 | <label for="<?php echo $setting_name; ?>"> |
| 86 | <?php echo $setting['label']; ?> |
| 87 | </label> |
| 88 | <?php endif; ?> |
| 89 | <?php endif; ?> |
| 90 | </p> |
| 91 | <?php if( isset( $setting['description'] ) ) : ?> |
| 92 | <p class="description"> |
| 93 | <?php echo $setting['description']; ?> |
| 94 | </p> |
| 95 | <?php endif; ?> |
| 96 | </td> |
| 97 | <td> |
| 98 | |
| 99 | </td> |
| 100 | </tr> |
| 101 | <?php endforeach; ?> |
| 102 | </table> |
| 103 | </fieldset> |
| 104 | |
| 105 | <p> |
| 106 | <?php submit_button( __( 'Save all', 'email-encoder-bundle' ) ); ?> |
| 107 | </p> |
| 108 | </div> |
| 109 | </div> |
| 110 | </div> |