Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit; # Exit if accessed directly
- }
- # Upcoming Events
- add_shortcode( 'educon_events', function($atts, $content = null){
- extract(shortcode_atts(array(
- 'layout' => 'layout1',
- 'title' => '',
- 'count' => '3',
- 'event_cat' => 'themeumall',
- 'order' => 'DESC',
- 'class' => '',
- ), $atts));
- global $post;
- $output = '';
- if ( $layout == 'layout1' || $layout == 'layout2' ) {
- if( ( $event_cat == '' ) || ( $event_cat == 'themeumall' ) ){
- $args = array(
- 'post_type' => 'event',
- 'showposts' => $count,
- 'meta_type' => 'DATETIME',
- 'orderby' => 'meta_value',
- 'order' => $order,
- 'meta_key' => 'themeum_start_datetime',
- 'meta_value' => date('Y-m-d h:i'),
- 'meta_compare' => '>=',
- 'paged' => get_query_var('paged')
- );
- } else{
- $args = array(
- 'post_type' => 'event',
- 'showposts' => $count,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'event-category',
- 'field' => 'slug',
- 'terms' => $event_cat,
- ),
- ),
- 'meta_key' => 'themeum_start_datetime',
- 'meta_type' => 'DATETIME',
- 'orderby' => 'meta_value',
- 'order' => $order,
- 'paged' => get_query_var('paged')
- );
- }
- }
- if($layout == 'layout3'){
- if( ( $event_cat == '' ) || ( $event_cat == 'themeumall' ) ){
- $args = array(
- 'post_type' => 'event',
- 'showposts' => $count,
- 'meta_key' => 'themeum_start_datetime',
- 'meta_value' => date('Y-m-d h:i'),
- 'meta_compare' => '<',
- 'orderby' => 'meta_value',
- 'order' => $order
- );
- }else{
- $args = array(
- 'post_type' => 'event',
- 'showposts' => $count,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'event-category',
- 'field' => 'slug',
- 'terms' => $event_cat,
- ),
- ),
- 'meta_key' => 'themeum_start_datetime',
- 'meta_value' => date('Y-m-d h:i'),
- 'meta_compare' => '<',
- 'orderby' => 'meta_value',
- 'order' => $order
- );
- }
- }
- $query = new WP_Query($args);
- if( $layout == 'layout1' ){
- $output .= '<div class="shortcode-upcoming-event">';
- if ( $query->have_posts() ) :
- while ( $query->have_posts() ) : $query->the_post();
- $event_start_datetime = get_post_meta(get_the_ID(),'themeum_start_datetime', true );
- $event_end_datetime = get_post_meta(get_the_ID(),'themeum_end_datetime', true );
- $themeum_venue = get_post_meta(get_the_ID(),'themeum_venue', true );
- $media_url ='';
- if( has_post_thumbnail( get_the_ID() ) ){
- $thumb_src = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'wpeducon-medium' );
- $media_url = $thumb_src[0];
- }
- $style = '';
- $style .= (!empty($media_url)) ? 'background-image: url('.$media_url.');' : '';
- $output .= '<div class="upcoming-event-content full-width-events clearfix">';
- $output .= '<div class="row">';
- $output .= '<div class="col-md-3 col-sm-3 col-xs-3" style="'.esc_html($style).'">';
- $output .= '<div class="entry-date-overlayer"></div>';
- $output .= '<div class="entry-date">';
- $output .= '<span class="entry-date-day">'.date_i18n( "d", strtotime($event_start_datetime)).'</span>';
- $output .= '<span class="entry-date-month">'.date_i18n( "M,Y", strtotime($event_start_datetime)).'</span>';
- $output .= '</div>';
- $output .= '</div>';
- $output .= '<div class="col-md-9 col-sm-9 col-xs-9">';
- $output .= '<h3><a href="'.get_permalink().'">'.get_the_title().'</a></h3>';
- $output .= '<span class="entry-date-time"><i class="fa fa-clock-o" aria-hidden="true"></i> '.date_i18n( "h:i A", strtotime($event_start_datetime)).' - '.date_i18n("h:i A", strtotime($event_end_datetime)) .'</span>';
- $output .= '<span class="entry-date-time"><i class="fa fa-map-signs" aria-hidden="true"></i> '.esc_html($themeum_venue).'</span>';
- $output .= '</div>';
- $output .= '</div>';
- $output .= '</div>';
- endwhile;
- endif;
- $output .= '</div>';
- }
- if( $layout == 'layout2' ){
- $output = '<div class="event-countdown-wrapper-content ' . esc_attr($class) .'">';
- $count = 1;
- $x = 1;
- if ( $query->have_posts() ) :
- while ( $query->have_posts() ) : $query->the_post();
- $datetime = get_post_meta(get_the_ID(), 'themeum_start_datetime', true); ?>
- <script type="text/javascript">
- jQuery(function($) {
- $('#countdown-timer'+ <?php echo $count; ?> +'').countdown("<?php echo str_replace('-', '/', $datetime); ?>", function(event) {
- $(this).html(event.strftime('<div class="event-countdown-section"><span class="countdown-date">%-D </span><span class="countdown-period">%!D: .<?php echo esc_html__("DAY", "string"); ?>,<?php echo esc_html__("DAYS", "string"); ?>;</span></div><div class="event-countdown-section"><span class="countdown-date">%-H </span><span class="countdown-period">%!H:<?php echo esc_html__("HOUR", "string"); ?>,<?php echo esc_html__("HOURS", "string"); ?>;</span></div><div class="event-countdown-section"><span class="countdown-date">%-M </span><span class="countdown-period">%!M:<?php echo esc_html__("MINUTE", "string"); ?>,<?php echo esc_html__("MINUTES", "string"); ?>;</span></div><div class="event-countdown-section"><span class="countdown-date">%-S </span><span class="countdown-period">%!S:<?php echo esc_html__("SECOND", "string"); ?>,<?php echo esc_html__("SECONDS", "string"); ?>;</span></div>'));
- });
- });
- </script>
- <?php
- if( $x == 1 ){ $output .= '<div class="row">'; }
- $output .= '<div class="col-xs-12 col-sm-6 col-md-4">';
- $output .= '<div class="single-event-content">';
- $output .= '<div class="event-single-img">';
- if (has_post_thumbnail( $post->ID ) ):
- $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'wpeducon-medium' );
- $output .= '<img class="img-responsive" src="'.esc_url( $image[0] ).'" alt="'.get_the_title().'">';
- endif;
- $output .= '</div>'; #event-single-img
- $output .= '<div class="event-content-wrapper">';
- $output .= '<h3 class="countdown-timer-title"><i class="fa fa-clock-o" aria-hidden="true"></i> '.date_i18n("F j, Y", strtotime($datetime)).'</h3>';
- $output .= '<h3 class="countdown-timer-subtitle"><a href="'.get_permalink().'">'.get_the_title().'</a></h3>';
- $output .= '<div id="countdown-timer'.$count.'" class="stringscountdown"></div>';
- $output .= '</div>'; #event-img
- $output .= '</div>'; # single-event-content
- $output .= '</div>'; # col-xs-12
- if( $x == 3 ){
- $output .= '</div>'; # row
- $x = 1;
- }else{
- $x++;
- }
- $count++;
- endwhile;
- endif;
- $output .= '</div>'; // event-countdown-wrapper-content
- }
- if( $layout == 'layout3' ){
- $output = '<div class="event-countdown-wrapper-content ' . esc_attr($class) .'">';
- $count = 1;
- $x = 1;
- if ( $query->have_posts() ) :
- while ( $query->have_posts() ) : $query->the_post();
- $datetime = get_post_meta(get_the_ID(), 'themeum_start_datetime', true); ?>
- <?php
- if( $x == 1 ){ $output .= '<div class="row">'; }
- $output .= '<div class="col-xs-12 col-sm-6 col-md-4">';
- $output .= '<div class="single-event-content">';
- $output .= '<div class="event-single-img">';
- if (has_post_thumbnail( $post->ID ) ):
- $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'wpeducon-medium' );
- $output .= '<img class="img-responsive" src="'.esc_url( $image[0] ).'" alt="'.get_the_title().'">';
- endif;
- $output .= '</div>'; #event-single-img
- $output .= '<div class="event-content-wrapper without-event">';
- $output .= '<h3 class="countdown-timer-title"><i class="fa fa-clock-o" aria-hidden="true"></i> '.date_i18n("F j, Y", strtotime($datetime)).'</h3>';
- $output .= '<h3 class="countdown-timer-subtitle"><a href="'.get_permalink().'">'.get_the_title().'</a></h3>';
- $output .= '</div>'; #event-img
- $output .= '</div>'; # single-event-content
- $output .= '</div>'; # col-xs-12
- if( $x == 3 ){
- $output .= '</div>'; # row
- $x = 1;
- }else{
- $x++;
- }
- $count++;
- endwhile;
- endif;
- $output .= '</div>'; // event-countdown-wrapper-content
- }
- $page_numb = max( 1, get_query_var('paged') );
- $max_page = $query->max_num_pages;
- ob_start();
- wpeducon_pagination( $page_numb, $max_page );
- $output .= ob_get_contents();
- ob_clean();
- wp_reset_postdata();
- return $output;
- });
- # Visual Composer
- if (class_exists('WPBakeryVisualComposerAbstract')) {
- vc_map(array(
- "name" => esc_html__("Educon Events", 'themeum-core'),
- "base" => "educon_events",
- 'icon' => 'icon-thm-title',
- "class" => "",
- "description" => esc_html__("Widget Title Heading", 'themeum-core'),
- "category" => esc_html__('Educon', 'themeum-core'),
- "params" => array(
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Title Heading", 'themeum-core'),
- "param_name" => "layout",
- "value" => array(
- 'Select' =>'',
- 'Upcoming Event Style1' =>'layout1',
- 'Upcoming Event Style2' =>'layout2',
- 'Past Events' =>'layout3'
- ),
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Select The Performer Category:","themeum-core"),
- "param_name" => "event_cat",
- "value" => themeum_cat_list( 'event-category' )
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Order", 'themeum-core'),
- "param_name" => "order",
- "value" => array('DESC'=>'DESC','ASC'=>'ASC'),
- ),
- array(
- "type" => "textfield",
- "heading" => __("Title", "themeum-core"),
- "param_name" => "title",
- "value" => "",
- "admin_label" =>true,
- ),
- array(
- "type" => "textfield",
- "heading" => __("Maximum Number of Event:", "themeum-core"),
- "param_name" => "count",
- "value" => "",
- ),
- array(
- "type" => "textfield",
- "heading" => __("Extra CSS Class", "themeum-core"),
- "param_name" => "class",
- "value" => "",
- ),
- )
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement