AdminPage.Menu.class.php
4 years ago
AdminPage.Submenu.class.php
4 years ago
AdminPage.Themes.class.php
4 years ago
AdminPage.class.php
4 years ago
AdminPageSection.class.php
4 years ago
AdminPageSetting.Address.class.php
4 years ago
AdminPageSetting.Checkbox.class.php
4 years ago
AdminPageSetting.ColorPicker.class.php
4 years ago
AdminPageSetting.Count.class.php
4 years ago
AdminPageSetting.Editor.class.php
4 years ago
AdminPageSetting.FileUpload.class.php
4 years ago
AdminPageSetting.HTML.class.php
4 years ago
AdminPageSetting.Image.class.php
4 years ago
AdminPageSetting.InfiniteTable.class.php
4 years ago
AdminPageSetting.McApiKey.class.php
4 years ago
AdminPageSetting.McListMerge.class.php
4 years ago
AdminPageSetting.Number.class.php
4 years ago
AdminPageSetting.OpeningHours.class.php
4 years ago
AdminPageSetting.Ordering.class.php
4 years ago
AdminPageSetting.Radio.class.php
4 years ago
AdminPageSetting.Scheduler.class.php
4 years ago
AdminPageSetting.Select.class.php
4 years ago
AdminPageSetting.SelectMenu.class.php
4 years ago
AdminPageSetting.SelectPost.class.php
4 years ago
AdminPageSetting.SelectTaxonomy.class.php
4 years ago
AdminPageSetting.Text.class.php
4 years ago
AdminPageSetting.Textarea.class.php
4 years ago
AdminPageSetting.Time.class.php
4 years ago
AdminPageSetting.Toggle.class.php
4 years ago
AdminPageSetting.WarningTip.class.php
4 years ago
AdminPageSetting.class.php
4 years ago
Library.class.php
4 years ago
AdminPageSetting.Select.class.php
66 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Register, display and save a selection option with a drop-down menu. |
| 5 | * |
| 6 | * This setting accepts the following arguments in its constructor function. |
| 7 | * |
| 8 | * $args = array( |
| 9 | * 'id' => 'setting_id', // Unique id |
| 10 | * 'title' => 'My Setting', // Title or label for the setting |
| 11 | * 'description' => 'Description', // Help text description |
| 12 | * 'blank_option' => true, // Whether or not to show a blank option |
| 13 | * 'options' => array( // An array of key/value pairs which |
| 14 | * 'option1' => 'Option 1', // define the options. |
| 15 | * 'option2' => 'Option 2', |
| 16 | * ... |
| 17 | * ); |
| 18 | * ); |
| 19 | * |
| 20 | * @since 1.0 |
| 21 | * @package Simple Admin Pages |
| 22 | */ |
| 23 | |
| 24 | class sapAdminPageSettingSelect_2_6_1 extends sapAdminPageSetting_2_6_1 { |
| 25 | |
| 26 | public $sanitize_callback = 'sanitize_text_field'; |
| 27 | |
| 28 | // Whether or not to display a blank option |
| 29 | public $blank_option = true; |
| 30 | |
| 31 | // An array of options for this select field, accepted as a key/value pair. |
| 32 | public $options = array(); |
| 33 | |
| 34 | /** |
| 35 | * Display this setting |
| 36 | * @since 1.0 |
| 37 | */ |
| 38 | public function display_setting() { |
| 39 | |
| 40 | ?> |
| 41 | |
| 42 | <fieldset <?php $this->print_conditional_data(); ?>> |
| 43 | |
| 44 | <select name="<?php echo $this->get_input_name(); ?>" id="<?php echo $this->id; ?>" <?php echo ( $this->disabled ? 'disabled' : ''); ?>> |
| 45 | |
| 46 | <?php if ( $this->blank_option === true ) : ?> |
| 47 | <option></option> |
| 48 | <?php endif; ?> |
| 49 | |
| 50 | <?php foreach ( $this->options as $id => $title ) : ?> |
| 51 | <option value="<?php echo esc_attr( $id ); ?>"<?php if( $this->value == $id ) : ?> selected="selected"<?php endif; ?>><?php echo esc_html( $title ); ?></option> |
| 52 | <?php endforeach; ?> |
| 53 | |
| 54 | </select> |
| 55 | <?php $this->display_disabled(); ?> |
| 56 | |
| 57 | </fieldset> |
| 58 | |
| 59 | <?php |
| 60 | |
| 61 | $this->display_description(); |
| 62 | |
| 63 | } |
| 64 | |
| 65 | } |
| 66 |