widget-admin.php
65 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Widget admin template |
| 4 | */ |
| 5 | |
| 6 | // Block direct requests |
| 7 | if ( !defined('ABSPATH') ) |
| 8 | die('-1'); |
| 9 | ?> |
| 10 | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'image_widget'); ?></label> |
| 11 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" /></p> |
| 12 | |
| 13 | <p><label for="<?php echo $this->get_field_id('image'); ?>"><?php _e('Image:', 'image_widget'); ?></label> |
| 14 | <?php |
| 15 | $media_upload_iframe_src = "media-upload.php?type=image&post_id=0&widget_id=".$this->id; //NOTE #1: the widget id is added here to allow uploader to only return array if this is used with image widget so that all other uploads are not harmed. |
| 16 | $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src"); |
| 17 | $image_title = __(($instance['image'] ? 'Change Image' : 'Add Image'), 'image_widget'); |
| 18 | ?><br /> |
| 19 | <a href="<?php echo $image_upload_iframe_src; ?>&TB_iframe=true" id="add_image-<?php echo $this->get_field_id('image'); ?>" class="thickbox-image-widget" title='<?php echo $image_title; ?>' onClick="imageWidget.setActiveWidget('<?php echo $this->id; ?>');return false;" style="text-decoration:none"><img src='images/media-button-image.gif' alt='<?php echo $image_title; ?>' align="absmiddle" /> <?php echo $image_title; ?></a> |
| 20 | <div id="display-<?php echo $this->get_field_id('image'); ?>"><?php |
| 21 | if ($instance['imageurl']) { |
| 22 | echo "<img src=\"{$instance['imageurl']}\" alt=\"{$instance['title']}\" style=\""; |
| 23 | if ($instance['width'] && is_numeric($instance['width'])) { |
| 24 | echo "max-width: {$instance['width']}px;"; |
| 25 | } |
| 26 | if ($instance['height'] && is_numeric($instance['height'])) { |
| 27 | echo "max-height: {$instance['height']}px;"; |
| 28 | } |
| 29 | echo "\""; |
| 30 | if (!empty($instance['align']) && $instance['align'] != 'none') { |
| 31 | echo " class=\"align{$instance['align']}\""; |
| 32 | } |
| 33 | echo " />"; |
| 34 | } |
| 35 | ?></div> |
| 36 | <br clear="all" /> |
| 37 | <input id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="hidden" value="<?php echo $instance['image']; ?>" /> |
| 38 | </p> |
| 39 | |
| 40 | <p><label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Caption:', 'image_widget'); ?></label> |
| 41 | <textarea rows="8" class="widefat" id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>"><?php echo format_to_edit($instance['description']); ?></textarea></p> |
| 42 | |
| 43 | <p><label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link:', 'image_widget'); ?></label> |
| 44 | <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['link'])); ?>" /><br /> |
| 45 | <select name="<?php echo $this->get_field_name('linktarget'); ?>" id="<?php echo $this->get_field_id('linktarget'); ?>"> |
| 46 | <option value="_self"<?php selected( $instance['linktarget'], '_self' ); ?>><?php _e('Stay in Window', 'image_widget'); ?></option> |
| 47 | <option value="_blank"<?php selected( $instance['linktarget'], '_blank' ); ?>><?php _e('Open New Window', 'image_widget'); ?></option> |
| 48 | </select></p> |
| 49 | |
| 50 | <p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width:', 'image_widget'); ?></label> |
| 51 | <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['width'])); ?>" onchange="imageWidget.changeImgWidth('<?php echo $this->id; ?>')" /></p> |
| 52 | |
| 53 | <p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height:', 'image_widget'); ?></label> |
| 54 | <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['height'])); ?>" onchange="imageWidget.changeImgHeight('<?php echo $this->id; ?>')" /></p> |
| 55 | |
| 56 | <p><label for="<?php echo $this->get_field_id('align'); ?>"><?php _e('Align:', 'image_widget'); ?></label> |
| 57 | <select name="<?php echo $this->get_field_name('align'); ?>" id="<?php echo $this->get_field_id('align'); ?>" onchange="imageWidget.changeImgAlign('<?php echo $this->id; ?>')"> |
| 58 | <option value="none"<?php selected( $instance['align'], 'none' ); ?>><?php _e('none', 'image_widget'); ?></option> |
| 59 | <option value="left"<?php selected( $instance['align'], 'left' ); ?>><?php _e('left', 'image_widget'); ?></option> |
| 60 | <option value="center"<?php selected( $instance['align'], 'center' ); ?>><?php _e('center', 'image_widget'); ?></option> |
| 61 | <option value="right"<?php selected( $instance['align'], 'right' ); ?>><?php _e('right', 'image_widget'); ?></option> |
| 62 | </select></p> |
| 63 | |
| 64 | <p><label for="<?php echo $this->get_field_id('alt'); ?>"><?php _e('Alternate Text:', 'image_widget'); ?></label> |
| 65 | <input id="<?php echo $this->get_field_id('alt'); ?>" name="<?php echo $this->get_field_name('alt'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['alt'])); ?>" /></p> |