Sindbad~EG File Manager

Current Path : /home/copmadinaarea/www/wp-content__80fcb17/plugins/adorechurch-core/widgets/
Upload File :
Current File : /home/copmadinaarea/www/wp-content__80fcb17/plugins/adorechurch-core/widgets/upcoming_events.php

<?php
/*** Widget code for Upcoming Events ***/
class adore_core_upcoming_events extends WP_Widget {
	// constructor
	public function __construct() {
		 $widget_ops = array('description' => __( "Display Upcoming Events.", 'adorechurch-core') );
         parent::__construct(false, $name = __('(N) Upcoming Events','adorechurch-core'), $widget_ops);
	}
	// widget form creation
	public function form($instance) {
	    // Check values
                if( $instance) {
			 $title = esc_attr($instance['title']);
			 $number = esc_attr($instance['number']);
			 $category = esc_attr($instance['category']);
			 $status = esc_attr($instance['status']);
		} else {
			 $title = '';
			 $number = '';
           $category='';
		   $status = '';
		}
	?>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title', 'adorechurch-core'); ?></label>
            <input class="spTitle_<?php echo esc_attr($title); ?>" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
        </p>
        
        <p>
	            <label for="<?php echo esc_attr($this->get_field_id('number')); ?>"><?php _e('Number of events to show', 'adorechurch-core'); ?></label>
	            <input class="spNumber_<?php echo esc_attr($number); ?>" id="<?php echo esc_attr($this->get_field_id('number')); ?>" name="<?php echo esc_attr($this->get_field_name('number')); ?>" type="text" value="<?php echo esc_attr($number); ?>" />
        </p>
       
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('category')); ?>"><?php _e('Select Category', 'adorechurch-core'); ?></label>
            <select class="spType_event_cat" id="<?php echo esc_attr($this->get_field_id('category')); ?>" name="<?php echo esc_attr($this->get_field_name('category')); ?>">
            <option value=""><?php _e('All','adorechurch-core'); ?></option>
                <?php
                $post_terms = get_terms('event-category');
                if(!empty($post_terms)){
                      foreach ($post_terms as $term) {
                         
                        $term_name = $term->name;
                        $term_id = $term->slug;
                        $activePost = ($term_id == $category)? 'selected' : '';
                        echo '<option value="'. $term_id .'" '.$activePost.'>' . $term_name . '</p>';
                    }
                }
                ?>
            </select> 
        </p> 
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('status')); ?>"><?php _e('Select Event Type', 'adorechurch-core'); ?></label>
            <select class="spType_event_cat" id="<?php echo esc_attr($this->get_field_id('status')); ?>" name="<?php echo esc_attr($this->get_field_name('status')); ?>">
            <option value="future" <?php echo esc_attr(($status=='future')?'selected':''); ?>><?php _e('Future','adorechurch-core'); ?></option>
            <option value="past" <?php echo esc_attr(($status=='past')?'selected':''); ?>><?php _e('Past','adorechurch-core'); ?></option>
            </select> 
        </p> 
	<?php
	}
	// update widget
	public function update($new_instance, $old_instance) {
		  $instance = $old_instance;
                // Fields
		  $instance['title'] = strip_tags($new_instance['title']);
		  $instance['number'] = strip_tags($new_instance['number']);
		  $instance['category'] = strip_tags($new_instance['category']);
		  $instance['status'] = strip_tags($new_instance['status']);
		  return $instance;
	}
	// display widget
	public function widget($args, $instance) {
           $cache = array();
		if ( ! $this->is_preview() ) {
			$cache = wp_cache_get( 'upcoming_events', 'widget' );
		}
		if ( ! is_array( $cache ) ) {
			$cache = array();
		}
		if ( ! isset( $args['widget_id'] ) ) {
			$args['widget_id'] = $this->id;
		}
		if ( isset( $cache[ $args['widget_id'] ] ) ) {
			echo ''.$cache[ $args['widget_id'] ];
			return;
		}
		ob_start();
	   extract( $args );
           
	   // these are the widget options
	   $post_title = apply_filters('widget_title', $instance['title']);
	   $post_title = ($post_title=='')?__('Upcoming Events','adorechurch-core'):$post_title;
	   $number = apply_filters('widget_number', $instance['number']);
       $category = apply_filters('widget-category', empty($instance['category']) ?'': $instance['category'], $instance, $this->id_base);
	   $numberEvent = (!empty($number))? $number : 4 ;
	   $EventHeading = $post_title;
	   $status = apply_filters('widget_status', $instance['status']);
	   echo ''.$args['before_widget'];
		if( !empty($instance['title']) ){
			echo ''.$args['before_title'];
			echo apply_filters('widget_title',$EventHeading, $instance, $this->id_base);
			echo ''.$args['after_title'];
		}
		wp_reset_postdata();
		$imic_options = get_option('imic_options');
		$event_view = $imic_options['event_time_view'];
		$event_counter_view = $imic_options['event_countdown_position'];
		$events = imic_recur_events($status,'nos',$category);
		if($status=='future') { ksort($events); } else { krsort($events); }
		if(!empty($events)) { $total = 1;
			echo '<div class="events-listing-content smaller-cont">'; 
			foreach($events as $key=>$value) {
				$style = '';
				$date_converted=adorechurch_date_localization('Y-m-d',$key );
                $custom_event_url= imic_query_arg($date_converted,$value);
				$start_time = '23:59';
				$start_time_meta = get_post_meta($value,'imic_event_start_dt',true);
				if($start_time_meta!='') {
				$start_time_meta = strtotime($start_time_meta);
				$start_time = adorechurch_date_localization('G:i',$start_time_meta); }
				$st_time = '';
				$st_time = adorechurch_date_localization('Y-m-d',$key);
				$st_time = strtotime($st_time.' '.$start_time);
				if($event_counter_view==0) 
				{
					$end_date_event = $key; 
				} 
				else 
				{ 
					$end_time_meta = get_post_meta($value,'imic_event_end_dt',true);
					$end_date_event = '';
					if($end_time_meta!='') 
					{
						$end_time_meta = strtotime($end_time_meta);
						$end_time = adorechurch_date_localization('G:i',$end_time_meta); 
					}
					$en_time = '';
					$en_time = adorechurch_date_localization('Y-m-d',$key);
					$end_date_event = strtotime($en_time.' '.$end_time);
				}
				echo '<div class="event-list-item">
                                	<div class="event-list-item-date">
                                    	<span class="event-date">
                                        	<span class="event-day">'.adorechurch_date_localization('d', $key).'</span>
                                        	<span class="event-month">'.adorechurch_date_localization('M, ', $key).adorechurch_date_localization('Y', $key).'</span>
                                        </span>
                                    </div>
                                    <div class="event-list-item-info">
                                    	<div class="lined-info">
                                        	<h4><a href="'.$custom_event_url.'">'.get_the_title($value).'</a></h4>
                                        </div>';
										if($event_view==0) { 
                                        echo '<span class="meta-data"><i class="fa fa-clock-o"></i> '.adorechurch_date_localization('l, ', $key); echo adorechurch_date_localization(get_option('time_format'), $st_time); if($end_date_event!='') { echo ' - '.adorechurch_date_localization(get_option('time_format'), $end_date_event); } echo '</span> '; }
										else {
										echo '<span class="meta-data"><i class="fa fa-clock-o"></i> '.adorechurch_date_localization('l, ', $key); echo adorechurch_date_localization(get_option('time_format'), $st_time); echo '</span> '; }
										 if($key<adorechurch_date_localization('U')) { echo '<span class="label label-default">'.__('Passed','adorechurch-core').'</span>'; } elseif(adorechurch_date_localization('U')>$st_time&&adorechurch_date_localization('U')<$key) { echo '<span class="label label-success">'.__('Going On','adorechurch-core').'</span>'; } else { echo '<span class="label label-primary">'.__('Upcoming','adorechurch-core').'</span>'; } echo '</span>';
										$address = get_post_meta($value,'imic_event_address2',true); if($address!='') {
                                        echo '<span class="meta-data"><i class="fa fa-map-marker"></i> '.$address.'</span>'; }
                                    echo '</div>
                                </div>';
								if (++$total > $numberEvent) { break; }
			} 
		}else{
			echo '<div class="event-list-item">
			<div class="event-list-item-info">
			<div class="lined-info event-title"><h4>'.
			__('No Upcoming Events Found','adorechurch-core').
			'</h4></div></div></div>';		
		} echo '</div>';
	   echo ''.$args['after_widget'];
	   
	   if ( ! $this->is_preview() ) {
			$cache[ $args['widget_id'] ] = ob_get_flush();
			wp_cache_set( 'adore_core_upcoming_events', $cache, 'widget' );
		} else {
			ob_end_flush();
		}
	}
}
// register widget
add_action( 'widgets_init', function(){
	register_widget( 'adore_core_upcoming_events' );
});
?>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists