Advertisement
Guest User

Untitled

a guest
Jun 5th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  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( $image ) ) {
  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.    
  19.         // --- StartHack ---------------------------------------------
  20.         if( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ) {
  21.             $imageurl = str_replace('http://', 'https://', $imageurl);
  22.         } else {
  23.             $imageurl = str_replace('https://', 'http://', $imageurl);
  24.         }
  25.         // --- EndHack ---------------------------------------------
  26.  
  27.         echo '<img src="'.esc_url($imageurl).'" style="';
  28.         if ( !empty( $width ) && is_numeric( $width ) ) {
  29.             echo "max-width: {$width}px;";
  30.         }
  31.         if ( !empty( $height ) && is_numeric( $height ) ) {
  32.             echo "max-height: {$height}px;";
  33.         }
  34.         echo "\"";
  35.         if ( !empty( $align ) && $align != 'none' ) {
  36.             $align = esc_attr($align);
  37.             echo " class=\"align{$align}\"";
  38.         }
  39.         if ( !empty( $alt ) ) {
  40.             $alt = esc_attr($alt);
  41.             echo " alt=\"{$alt}\"";
  42.         } else {
  43.             $title = esc_attr($title);
  44.             echo " alt=\"{$title}\"";                  
  45.         }
  46.         echo " />";
  47.     }
  48.  
  49.     if ( $link ) { echo '</a>'; }
  50. }
  51. if ( !empty( $description ) ) {
  52.     $text = apply_filters( 'widget_text', $description, $args, $instance );
  53.     echo '<div class="'.$this->widget_options['classname'].'-description" >';
  54.     echo wpautop( $text );         
  55.     echo "</div>";
  56. }
  57. echo $after_widget;
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement