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