Advertisement
Guest User

EVENTI OGGI

a guest
Apr 15th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.06 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: noname
  4. Plugin URI: http://inmaremma.net
  5. Description: today
  6. Author: Adi Cumpanasu / Adrian Cumpanasu
  7. Version: 1
  8. Author URI: http://www.codeclubber.com
  9. */
  10.  
  11.  
  12.  
  13. /* WIDGET SKELETON COPIED FROM SOME WEBSITE -----------------------------------  */
  14.  
  15. class RandomPostWidget extends WP_Widget
  16. {
  17.   function RandomPostWidget()
  18.   {
  19.     $widget_ops = array('classname' => 'RandomPostWidget', 'description' => 'Displays a random post with thumbnail' );
  20.     $this->WP_Widget('RandomPostWidget', 'eventi Oggi', $widget_ops);
  21.   }
  22.  
  23.   function form($instance)
  24.   {
  25.     $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
  26.     $title = $instance['title'];
  27. ?>
  28.   <p><label for="<?php echo $this->get_field_id('title'); ?>">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 attribute_escape($title); ?>" /></label></p>
  29. <?php
  30.   }
  31.  
  32.   function update($new_instance, $old_instance)
  33.   {
  34.     $instance = $old_instance;
  35.     $instance['title'] = $new_instance['title'];
  36.     return $instance;
  37.   }
  38.  
  39.   function widget($args, $instance)
  40.   {
  41.     extract($args, EXTR_SKIP);
  42.  
  43.     echo $before_widget;
  44.     $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
  45.  
  46.     if (!empty($title))
  47.       echo $before_title . $title . $after_title;
  48.  
  49.     //* END WIDGET SKELETON COPIED FROM SOME WEBSITE FIRST PART -----------------------------------  */
  50.     ?>
  51.        
  52. <?php wp_reset_query(); ?>
  53.  
  54. <?php
  55. global $post;
  56. $CurrentDate = date('Y-m-d');
  57. $events_today = tribe_get_events(
  58. array(
  59. 'start_date'=>$CurrentDate,
  60. 'end_date'=>$CurrentDate
  61. )
  62. );
  63.  
  64. ?>
  65.  
  66.  
  67.  
  68. <?php  if(! empty($events_today) ) {    // CHECK IF EVENTS
  69. ?>
  70. <ul class="wpp-list nav nav-pills nav-stacked">
  71. <?php
  72. foreach($events_today as $post) {
  73.     setup_postdata($post);
  74.     ?>
  75.    
  76.     <?php // if ( has_post_thumbnail() ) { ?>
  77.     <li>
  78.     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
  79.         <?php the_post_thumbnail('thumbnail', array('class' => 'wpp-thumbnail wpp_cached_thumb wpp_featured')); ?>
  80.     </a>
  81.     <div class="descwpp">
  82.         <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="wpp-post-title">
  83.             <span class="start-event-inm">da <?php echo tribe_get_start_date( $post->ID, false, 'd M - G:i ' ); ?></span>
  84.             <span class="end-event-inm">a <?php echo tribe_get_end_date( $post->ID, false, 'd M - G:i ' ); ?></span>
  85.             <br>
  86.             <?php the_title(); ?>
  87.         </a>
  88.         <span class="wpp-excerpt">
  89.             <?php the_excerpt(); ?>
  90.         </span>
  91.     </div>
  92.     </li>
  93.  
  94.     <?php // }  // END IF HAS THUMBNAIL
  95.     ?>
  96.    
  97. <?php } //endforeach ?>
  98. </ul>
  99. <?php  } else {  // END CHECK IF EVENTS
  100. echo '<span class="no-events-inm">Ci dispiace, nessun evento oggi!</span>';
  101. }
  102. ?>
  103.  
  104. <?php wp_reset_query(); ?>
  105.    <?php
  106.     //* WIDGET SKELETON COPIED FROM SOME WEBSITE SECOND PART -----------------------------------  */
  107.     echo $after_widget;
  108.   }
  109.  
  110. }
  111. add_action( 'widgets_init', create_function('', 'return register_widget("RandomPostWidget");') );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement