widget.php
49 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Widget template. This template can be overriden using the "sp_template_image-widget_widget.php" filter. |
| 4 | * See the readme.txt file for more info. |
| 5 | */ |
| 6 | |
| 7 | // Block direct requests |
| 8 | if ( !defined('ABSPATH') ) |
| 9 | die('-1'); |
| 10 | |
| 11 | echo $before_widget; |
| 12 | if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } |
| 13 | if ( !empty( $imageurl ) ) { |
| 14 | if ( $link ) { |
| 15 | echo '<a class="'.$this->widget_options['classname'].'-image-link" href="'.esc_url($link).'" target="'.esc_attr($linktarget).'">'; |
| 16 | } |
| 17 | if ( $imageurl ) { |
| 18 | echo '<img src="'.esc_url($imageurl).'" style="'; |
| 19 | if ( !empty( $width ) && is_numeric( $width ) ) { |
| 20 | echo "max-width: {$width}px;"; |
| 21 | } |
| 22 | if ( !empty( $height ) && is_numeric( $height ) ) { |
| 23 | echo "max-height: {$height}px;"; |
| 24 | } |
| 25 | echo "\""; |
| 26 | if ( !empty( $align ) && $align != 'none' ) { |
| 27 | $align = esc_attr($align); |
| 28 | echo " class=\"align{$align}\""; |
| 29 | } |
| 30 | if ( !empty( $alt ) ) { |
| 31 | $alt = esc_attr($alt); |
| 32 | echo " alt=\"{$alt}\""; |
| 33 | } else { |
| 34 | $title = esc_attr($title); |
| 35 | echo " alt=\"{$title}\""; |
| 36 | } |
| 37 | echo " />"; |
| 38 | } |
| 39 | |
| 40 | if ( $link ) { echo '</a>'; } |
| 41 | } |
| 42 | if ( !empty( $description ) ) { |
| 43 | $text = apply_filters( 'widget_text', $description, $args, $instance ); |
| 44 | echo '<div class="'.$this->widget_options['classname'].'-description" >'; |
| 45 | echo wpautop( $text ); |
| 46 | echo "</div>"; |
| 47 | } |
| 48 | echo $after_widget; |
| 49 | ?> |