function st_upcomming_events_func($atts, $content = '') { extract(shortcode_atts(array('title' => '', 'numpost' => 5, 'more_text' => '', 'more_url' => '#'), $atts)); if (intval($numpost) <= 0) { $numpost = (int) get_option('posts_per_page', 10); } else { $numpost = intval($numpost); } $myposts = st_get_upcomming_events($numpost); $e = ''; foreach ($myposts as $post) { $start_date = get_post_meta($post->ID, '_st_event_start_date', true); if ($start_date != '') { $start_date = strtotime($start_date); } $end_date = get_post_meta($post->ID, '_st_event_end_date', true); if ($end_date != '') { $end_date = strtotime($end_date); } $link = get_permalink($post->ID); $e .= '<li> <p class="small-event-data"> <strong>' . date_i18n('d', $start_date) . '</strong><a href="' . $link . '"></a><span>' . date_i18n('M', $start_date) . '</span> </p> <a class="event-title" href="' . $link . '">' . apply_filters('the_title', $post->post_title) . '</a> <span>' . __('at', 'smooththemes') . ' ' . date_i18n('H:iA, l d F Y', $start_date) . '</span> <span><strong>' . get_post_meta($post->ID, '_st_event_meta_price', true) . '</strong></span> </li>'; } wp_reset_query(); $link_more = ''; if ($more_text != '') { $link_more = ' <a class="view-all" href="' . $more_url . '">' . esc_html($more_text) . '</a>'; } $html = '<div class="builder-item-wrapper builder-editor"> <div class="builder-title-wrapper clearfix"> <h3 class="builder-item-title">' . esc_html($title) . '</h3> ' . $link_more . ' </div> <div class="builder-item-content row"> <div class="twelve columns b0"> <ul class="upcoming-events"> ' . $e . ' </ul> </div> </div> </div>'; return $html; }
public function widget($args, $instance) { // outputs the content of the widget global $wpdb, $post; extract($args); $title = apply_filters('widget_title', $instance['title']); $number = intval($instance['number']); if ($number <= 0) { $number = 3; // default = 3; } echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $myposts = st_get_upcomming_events($number); $e = ''; foreach ($myposts as $post) { $start_date = get_post_meta($post->ID, '_st_event_start_date', true); if ($start_date != '') { $start_date = strtotime($start_date); } $end_date = get_post_meta($post->ID, '_st_event_end_date', true); if ($end_date != '') { $end_date = strtotime($end_date); } $link = get_permalink($post->ID); $e .= '<li> <p class="small-event-data"> <strong>' . date_i18n('d', $start_date) . '</strong><a href="' . $link . '"></a><span>' . date_i18n('M', $start_date) . '</span> </p> <a class="event-title" href="' . $link . '">' . apply_filters('the_title', $post->post_title) . '</a> <span>' . __('at', 'smooththemes') . ' ' . date_i18n('H:iA, l d F Y', $start_date) . '</span> <span><strong>' . get_post_meta($post->ID, '_st_event_meta_price', true) . '</strong></span> </li>'; } wp_reset_query(); if ($e) { ?> <ul class="upcoming-events"> <?php echo $e; ?> </ul> <?php } wp_reset_query(); echo $after_widget; }