Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.55 KB | None | 0 0
  1. /**
  2.  * Banner 200x200
  3.  */
  4. class Ad200x200 extends WP_Widget {
  5.     /** constructor */
  6.     function Ad200x200() {
  7.         parent::WP_Widget(false, $name = 'Banner 200x200');
  8.     }
  9.  
  10.     /** @see WP_Widget::widget */
  11.     function widget($args, $instance) {    
  12.         extract( $args );
  13.         $title = apply_filters('widget_title', $instance['title']);
  14.         ?>
  15.               <?php echo $before_widget; ?>
  16.              
  17.                 <?php if ( $title )
  18.                    echo $before_title . $title . $after_title; ?>
  19.                        
  20.                 <?php
  21.                 // unset our variables
  22.                 global $pods_cache; $pods_cache->enabled = false;
  23.                
  24.                 $anuncio = new Pod('anuncio_b');
  25.                 $anuncio->findRecords('rand()', 1);
  26.                 $total_anuncios = $anuncio->getTotalRows();
  27.                
  28.                 if( $total_anuncios > 0 ) :
  29.                
  30.                 while ( $anuncio->fetchRecord() ) :
  31.  
  32.                    
  33.                     // set our variables
  34.                     $anuncio_anunciante = $anuncio->get_field('name');
  35.                     $anuncio_banner_imagem =  $anuncio->get_field('banner_imagem.guid');
  36.                     $anuncio_banner_flash =  $anuncio->get_field('banner_flash.guid');
  37.                    
  38.                     if ( $anuncio_banner_flash != "" ) { ?>
  39.                        
  40.                         <object width="200" height="200">
  41.                         <param name="movie" value="<?php echo $anuncio_banner_flash; ?>">
  42.                         <embed src="<?php echo $anuncio_banner_flash; ?>" width="200" height="200">
  43.                         </embed>
  44.                        
  45.                     <?php }
  46.                    
  47.                     else { ?>
  48.  
  49.                         <img src="<?php echo $anuncio_banner_imagem; ?>" />
  50.                    
  51.                     <?php } ?>     
  52.                        
  53.                 <?php endwhile ?>
  54.  
  55.                 <?php endif ?>
  56.                
  57.                 <?php global $pods_cache; $pods_cache->enabled = true; ?>
  58.  
  59.               <?php echo $after_widget; ?>
  60.         <?php
  61.     }
  62.  
  63.     /** @see WP_Widget::update */
  64.     function update($new_instance, $old_instance) {            
  65.     $instance = $old_instance;
  66.     $instance['title'] = strip_tags($new_instance['title']);
  67.         return $instance;
  68.     }
  69.  
  70.     /** @see WP_Widget::form */
  71.     function form($instance) {             
  72.         $title = esc_attr($instance['title']);
  73.         ?>
  74.             <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
  75.         <?php
  76.     }
  77.  
  78. } // class Ad200x200
  79.  
  80. // register Ad200x200 widget
  81. add_action('widgets_init', create_function('', 'return register_widget("Ad200x200");'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement