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.Checkbox.class.php
68 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Register, display and save an option with multiple checkboxes. |
| 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 | * 'options' => array( |
| 13 | * 'value' => 'Name' |
| 14 | * ), // The checkbox values and text |
| 15 | * ); |
| 16 | * ); |
| 17 | * |
| 18 | * @since 2.0 |
| 19 | * @package Simple Admin Pages |
| 20 | */ |
| 21 | |
| 22 | class sapAdminPageSettingCheckbox_2_6_1 extends sapAdminPageSetting_2_6_1 { |
| 23 | |
| 24 | //public $sanitize_callback = 'sanitize_text_field'; |
| 25 | |
| 26 | /** |
| 27 | * Display this setting |
| 28 | * @since 2.0 |
| 29 | */ |
| 30 | public function display_setting() { |
| 31 | |
| 32 | $input_name = $this->get_input_name(); |
| 33 | $values = ( is_array( $this->value ) ? $this->value : array() ); |
| 34 | |
| 35 | ?> |
| 36 | <fieldset <?php echo ( isset( $this->columns ) ? 'class="sap-setting-columns-' . $this->columns . '"' : '' ); ?> <?php $this->print_conditional_data(); ?>> |
| 37 | <?php foreach ( $this->options as $id => $title ) : ?> |
| 38 | <label title="<?php echo ( strpos( $title, '<' ) === false ? $title : ''); ?>" class="sap-admin-input-container"> |
| 39 | <input type="checkbox" name="<?php echo $input_name; ?>[]" id="<?php echo $input_name . "-" . $id; ?>" value="<?php echo $id; ?>" <?php echo ( in_array($id, $values) ? 'checked="checked"' : '' ) ?> <?php echo ( $this->disabled ? 'disabled' : ''); ?> /> |
| 40 | <span class='sap-admin-checkbox'></span> <span><?php echo $title; ?></span> |
| 41 | </label> |
| 42 | <?php endforeach; ?> |
| 43 | <?php $this->display_disabled(); ?> |
| 44 | </fieldset> |
| 45 | <?php |
| 46 | |
| 47 | $this->display_description(); |
| 48 | |
| 49 | } |
| 50 | |
| 51 | public function sanitize_callback_wrapper( $values ) { |
| 52 | |
| 53 | return is_array( $values ) ? array_map( $this->sanitize_callback, $values ) : array(); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Escape the value to display it safely HTML textarea fields |
| 58 | */ |
| 59 | public function esc_value( $values ) { |
| 60 | |
| 61 | $return = is_array( $values ) ? array_map( 'esc_attr', $values ) : $values; |
| 62 | $return = is_string( $return ) ? esc_attr( $return ) : $return; |
| 63 | |
| 64 | return $return; |
| 65 | } |
| 66 | |
| 67 | } |
| 68 |