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.Ordering.class.php
95 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Register and display a table for saving the order of a list of items. |
| 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 | * 'items' => array( |
| 13 | * 'item' => 'Label' // The items to be re-ordered |
| 14 | * ) |
| 15 | * ); |
| 16 | * |
| 17 | * @since 2.5 |
| 18 | * @package Simple Admin Pages |
| 19 | */ |
| 20 | |
| 21 | class sapAdminPageSettingOrdering_2_6_1 extends sapAdminPageSetting_2_6_1 { |
| 22 | |
| 23 | public $sanitize_callback = 'sanitize_text_field'; |
| 24 | |
| 25 | /** |
| 26 | * Add in the JS requried for the values to be stored |
| 27 | * @since 2.5 |
| 28 | */ |
| 29 | public $scripts = array( |
| 30 | 'sap-ordering-table' => array( |
| 31 | 'path' => 'js/ordering.js', |
| 32 | 'dependencies' => array( 'jquery' ), |
| 33 | 'version' => SAP_VERSION, |
| 34 | 'footer' => true, |
| 35 | ), |
| 36 | ); |
| 37 | |
| 38 | /** |
| 39 | * Add in the CSS requried for rows to be displayed correctly |
| 40 | * @since 2.5 |
| 41 | */ |
| 42 | public $styles = array( |
| 43 | 'sap-ordering-table' => array( |
| 44 | 'path' => 'css/ordering.css', |
| 45 | 'dependencies' => array( ), |
| 46 | 'version' => SAP_VERSION, |
| 47 | 'media' => 'all', |
| 48 | ), |
| 49 | ); |
| 50 | |
| 51 | /** |
| 52 | * Display this setting |
| 53 | * @since 2.0 |
| 54 | */ |
| 55 | public function display_setting() { |
| 56 | |
| 57 | $input_name = $this->get_input_name(); |
| 58 | $values = is_array( $this->value ) ? $this->value : json_decode( html_entity_decode( $this->value ), true ); |
| 59 | |
| 60 | if ( ! is_array( $values ) ) |
| 61 | $values = array(); |
| 62 | |
| 63 | if ( empty( $values ) and is_string( $this->items ) ) |
| 64 | $values = array_merge( $values, json_decode( $this->items, true ) ); |
| 65 | |
| 66 | ?> |
| 67 | |
| 68 | <fieldset <?php $this->print_conditional_data(); ?>> |
| 69 | <div class='sap-ordering-table <?php echo ( $this->disabled ? 'disabled' : ''); ?>'> |
| 70 | <input type='hidden' id="sap-ordering-table-main-input" name='<?php echo $input_name; ?>' value='<?php echo esc_attr( json_encode( $values ) ); ?>' /> |
| 71 | <table> |
| 72 | <tbody> |
| 73 | <?php foreach ( $values as $value => $label ) { ?> |
| 74 | <tr class='sap-ordering-table-row'> |
| 75 | <td> |
| 76 | <input type='hidden' value='<?php echo esc_attr( $value ); ?>' /> |
| 77 | <span><?php echo esc_html( $label ); ?></span> |
| 78 | </td> |
| 79 | </tr> |
| 80 | <?php } ?> |
| 81 | </tbody> |
| 82 | </table> |
| 83 | </div> |
| 84 | |
| 85 | <?php $this->display_disabled(); ?> |
| 86 | </fieldset> |
| 87 | |
| 88 | <?php |
| 89 | |
| 90 | $this->display_description(); |
| 91 | |
| 92 | } |
| 93 | |
| 94 | } |
| 95 |