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.SelectPost.class.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Register, display and save a selection with a drop-down list of any post type |
| 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 | * 'args' => array(); // Arguments to pass to WordPress's get_post() function |
| 14 | * ); |
| 15 | * |
| 16 | * @since 1.0 |
| 17 | * @package Simple Admin Pages |
| 18 | */ |
| 19 | |
| 20 | class sapAdminPageSettingSelectPost_2_6_1 extends sapAdminPageSetting_2_6_1 { |
| 21 | |
| 22 | public $sanitize_callback = 'intval'; |
| 23 | |
| 24 | // Whether or not to display a blank option |
| 25 | public $blank_option = true; |
| 26 | |
| 27 | /** |
| 28 | * An array of arguments accepted by get_posts(). |
| 29 | * See: http://codex.wordpress.org/Template_Tags/get_posts |
| 30 | */ |
| 31 | public $args = array(); |
| 32 | |
| 33 | /** |
| 34 | * Display this setting |
| 35 | * @since 1.0 |
| 36 | */ |
| 37 | public function display_setting() { |
| 38 | |
| 39 | $posts = new WP_Query( $this->args ); |
| 40 | |
| 41 | ?> |
| 42 | |
| 43 | <fieldset <?php $this->print_conditional_data(); ?>> |
| 44 | |
| 45 | <select name="<?php echo $this->get_input_name(); ?>" id="<?php echo $this->get_input_name(); ?>" <?php echo ( $this->disabled ? 'disabled' : ''); ?>> |
| 46 | |
| 47 | <?php if ( $this->blank_option === true ) : ?> |
| 48 | <option></option> |
| 49 | <?php endif; ?> |
| 50 | |
| 51 | <?php while( $posts->have_posts() ) : $posts->next_post(); ?> |
| 52 | <option value="<?php echo absint( $posts->post->ID ); ?>" <?php selected( $this->value, $posts->post->ID ); ?>><?php echo esc_attr( $posts->post->post_title ); ?></option> |
| 53 | <?php endwhile; ?> |
| 54 | |
| 55 | </select> |
| 56 | |
| 57 | <?php $this->display_disabled(); ?> |
| 58 | |
| 59 | </fieldset> |
| 60 | |
| 61 | <?php |
| 62 | |
| 63 | wp_reset_postdata(); |
| 64 | |
| 65 | $this->display_description(); |
| 66 | |
| 67 | } |
| 68 | |
| 69 | } |
| 70 |