Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: noname
- Plugin URI: http://inmaremma.net
- Description: today
- Author: Adi Cumpanasu / Adrian Cumpanasu
- Version: 1
- Author URI: http://www.codeclubber.com
- */
- /* WIDGET SKELETON COPIED FROM SOME WEBSITE ----------------------------------- */
- class RandomPostWidget extends WP_Widget
- {
- function RandomPostWidget()
- {
- $widget_ops = array('classname' => 'RandomPostWidget', 'description' => 'Displays a random post with thumbnail' );
- $this->WP_Widget('RandomPostWidget', 'eventi Oggi', $widget_ops);
- }
- function form($instance)
- {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
- $title = $instance['title'];
- ?>
- <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>
- <?php
- }
- function update($new_instance, $old_instance)
- {
- $instance = $old_instance;
- $instance['title'] = $new_instance['title'];
- return $instance;
- }
- function widget($args, $instance)
- {
- extract($args, EXTR_SKIP);
- echo $before_widget;
- $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
- if (!empty($title))
- echo $before_title . $title . $after_title;
- //* END WIDGET SKELETON COPIED FROM SOME WEBSITE FIRST PART ----------------------------------- */
- ?>
- <?php wp_reset_query(); ?>
- <?php
- global $post;
- $CurrentDate = date('Y-m-d');
- $events_today = tribe_get_events(
- array(
- 'start_date'=>$CurrentDate,
- 'end_date'=>$CurrentDate
- )
- );
- ?>
- <?php if(! empty($events_today) ) { // CHECK IF EVENTS
- ?>
- <ul class="wpp-list nav nav-pills nav-stacked">
- <?php
- foreach($events_today as $post) {
- setup_postdata($post);
- ?>
- <?php // if ( has_post_thumbnail() ) { ?>
- <li>
- <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
- <?php the_post_thumbnail('thumbnail', array('class' => 'wpp-thumbnail wpp_cached_thumb wpp_featured')); ?>
- </a>
- <div class="descwpp">
- <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="wpp-post-title">
- <span class="start-event-inm">da <?php echo tribe_get_start_date( $post->ID, false, 'd M - G:i ' ); ?></span>
- <span class="end-event-inm">a <?php echo tribe_get_end_date( $post->ID, false, 'd M - G:i ' ); ?></span>
- <br>
- <?php the_title(); ?>
- </a>
- <span class="wpp-excerpt">
- <?php the_excerpt(); ?>
- </span>
- </div>
- </li>
- <?php // } // END IF HAS THUMBNAIL
- ?>
- <?php } //endforeach ?>
- </ul>
- <?php } else { // END CHECK IF EVENTS
- echo '<span class="no-events-inm">Ci dispiace, nessun evento oggi!</span>';
- }
- ?>
- <?php wp_reset_query(); ?>
- <?php
- //* WIDGET SKELETON COPIED FROM SOME WEBSITE SECOND PART ----------------------------------- */
- echo $after_widget;
- }
- }
- add_action( 'widgets_init', create_function('', 'return register_widget("RandomPostWidget");') );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement