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.Image.class.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Register, display and save an image field setting in the admin menu |
| 5 | * |
| 6 | * @since 1.0 |
| 7 | * @package Simple Admin Pages |
| 8 | */ |
| 9 | |
| 10 | class sapAdminPageSettingImage_2_6_1 extends sapAdminPageSetting_2_6_1 { |
| 11 | |
| 12 | public $sanitize_callback = 'absint'; |
| 13 | |
| 14 | /** |
| 15 | * Scripts that must be loaded for this component |
| 16 | * @since 2.1.0 |
| 17 | */ |
| 18 | public $scripts = array( |
| 19 | 'sap-image' => array( |
| 20 | 'path' => 'js/image.js', |
| 21 | 'dependencies' => array( 'jquery' ), |
| 22 | 'version' => SAP_VERSION, |
| 23 | 'footer' => true, |
| 24 | ), |
| 25 | ); |
| 26 | |
| 27 | /** |
| 28 | * Translateable strings required for this component |
| 29 | * @since 2.1.0 |
| 30 | */ |
| 31 | public $strings = array( |
| 32 | 'add_image' => null, // __( 'Add Image', 'textdomain' ), |
| 33 | 'change_image' => null, // __( 'Change Image', 'textdomain' ), |
| 34 | 'remove_image' => null, // __( 'Remove Image', 'textdomain' ), |
| 35 | ); |
| 36 | |
| 37 | /** |
| 38 | * Display this setting |
| 39 | * @since 1.0 |
| 40 | */ |
| 41 | public function display_setting() { |
| 42 | $image_url = $this->value ? wp_get_attachment_url( $this->value ) : ''; |
| 43 | ?> |
| 44 | |
| 45 | <fieldset <?php $this->print_conditional_data(); ?>> |
| 46 | <div class="sap-image-wrapper <?php echo $this->value ? 'sap-image-wrapper-has-image' : 'sap-image-wrapper-no-image'; ?>" data-id="sap-<?php echo $this->id; ?>"> |
| 47 | <input name="<?php echo $this->get_input_name(); ?>" type="hidden" id="sap-<?php echo $this->id; ?>" value="<?php echo $this->value; ?>"> |
| 48 | <img src="<?php echo esc_attr( $image_url ); ?>"> |
| 49 | <button class="button sap-image-btn-add" id="sap-<?php echo $this->id; ?>-add"><?php echo esc_html( $this->strings['add_image'] ); ?></button> |
| 50 | <button class="button sap-image-btn-change" id="sap-<?php echo $this->id; ?>-change"><?php echo esc_html( $this->strings['change_image'] ); ?></button> |
| 51 | <button class="button sap-image-btn-remove" id="sap-<?php echo $this->id; ?>-remove"><?php echo esc_html( $this->strings['remove_image'] ); ?></button> |
| 52 | </div> |
| 53 | </fieldset> |
| 54 | |
| 55 | <?php |
| 56 | |
| 57 | // global $wp_scripts; |
| 58 | // print_r( $wp_scripts ); |
| 59 | |
| 60 | $this->display_description(); |
| 61 | |
| 62 | } |
| 63 | |
| 64 | } |
| 65 |