コード例 #1
0
    /**
     * Outputs the content of the widget
     *
     * @param array $args
     * @param array $instance
     */
    public function widget($args, $instance)
    {
        echo $args['before_widget'];
        echo $args['before_title'] . 'Upcoming Events' . $args['after_title'];
        // Get the upcoming events
        $upcoming_events = tribe_get_events(array('eventDisplay' => 'list', 'posts_per_page' => 2));
        if (!$upcoming_events) {
            ?>
<p><em>There are no upcoming events.</em></p><?php 
        } else {
            ?>
<ul class="webtide-upcoming-events no-list-style"><?php 
            foreach ($upcoming_events as $event) {
                // Get event permalink
                $event_permalink = get_permalink($event->ID);
                // Get the speaker info
                $speaker_name = get_post_meta($event->ID, 'speaker_name', true);
                $speaker_from = get_post_meta($event->ID, 'speaker_from', true);
                ?>
<li class="event">
							<h4 class="meeting-title"><a href="<?php 
                echo $event_permalink;
                ?>
"><?php 
                echo get_the_title($event->ID);
                ?>
</a></h4>
							<p><?php 
                // Print speaker name and from
                if ($speaker_name) {
                    ?>
<span class="meeting-speaker"><?php 
                    echo $speaker_name . ($speaker_from ? ", <em>{$speaker_from}</em>" : NULL);
                    ?>
</span><?php 
                }
                // True = abbreviate stuff
                if ($event_dt_string = ua_webtide_get_date_time_string($event, true)) {
                    ?>
<span class="meeting-date-time"><?php 
                    echo $event_dt_string;
                    ?>
</span><?php 
                }
                // Get the venue
                if ($event_venue = tribe_get_venue()) {
                    ?>
<span class="meeting-location"><?php 
                    echo $event_venue;
                    ?>
</span><?php 
                }
                ?>
<a class="meeting-view-details" href="<?php 
                echo $event_permalink;
                ?>
">View details</a>
							</p>
						</li><?php 
            }
            ?>
</ul><?php 
        }
        echo $args['after_widget'];
    }
コード例 #2
0
ファイル: events.php プロジェクト: bamawebtide/webtide-plugin
function ua_webtide_get_next_monthly_meeting_html($args = array())
{
    // Parse the args
    $defaults = array('event_title_element' => 'h3', 'abbreviate_dt' => false, 'include_excerpt' => false, 'view_details' => true, 'include_button' => false);
    $args = wp_parse_args($args, $defaults);
    // Build the next meeting
    $next_meeting_html = NULL;
    // Get the next meeting
    if ($next_meeting = ua_webtide_get_next_monthly_meeting()) {
        // Get the permalink
        $next_meeting_permalink = get_permalink($next_meeting->ID);
        // Print the event title
        $next_meeting_html .= '<' . $args['event_title_element'] . ' class="meeting-title"><a href="' . $next_meeting_permalink . '">' . get_the_title($next_meeting->ID) . '</a></' . $args['event_title_element'] . '>';
        // Print the details
        $next_meeting_html .= '<p class="meeting-details">';
        // Add members only message
        if (!IS_WEBTIDE_MEMBER) {
            $next_meeting_html .= '<span class="members-only">Monthly meetings are for WebTide members only.</span>';
        } else {
            if ($speakers = get_field('speakers', $next_meeting->ID)) {
                // Add each speaker
                foreach ($speakers as $speaker) {
                    // Make sure we have a name
                    if (isset($speaker['speaker_name']) && !empty($speaker['speaker_name'])) {
                        $next_meeting_html .= '<span class="meeting-speaker">';
                        // Print the speaker
                        $next_meeting_html .= $speaker['speaker_name'];
                        // If we have a "from"
                        if (isset($speaker['speaker_from']) && !empty($speaker['speaker_from'])) {
                            $next_meeting_html .= ", <em>{$speaker['speaker_from']}</em>";
                        }
                        $next_meeting_html .= '</span>';
                    }
                }
            }
            // False = do not abbreviate stuff
            if ($dt_string = ua_webtide_get_date_time_string($next_meeting, false)) {
                $next_meeting_html .= '<span class="meeting-date-time">' . $dt_string . '</span>';
            }
            // Get the venue
            if ($venue = tribe_get_venue()) {
                $next_meeting_html .= '<span class="meeting-location">' . $venue . '</span>';
            }
            // Will lunch be served?
            if (($will_lunch_be_served = get_post_meta($next_meeting->ID, 'will_lunch_be_served', true)) && strcasecmp('yes', $will_lunch_be_served) == 0) {
                $next_meeting_html .= '<span class="lunch-will-be-served">Lunch will be served!</span>';
            }
        }
        $next_meeting_html .= '</p>';
        // If we're including the excerpt
        if ($args['include_excerpt']) {
            // Setup the text
            $raw_excerpt = $text = $next_meeting->post_excerpt;
            // If we have no excerpt...
            if ('' == $text && !empty($next_meeting->post_content)) {
                // Use content and strip shortcodes
                $text = strip_shortcodes($next_meeting->post_content);
            }
            // Take care of the text
            $text = apply_filters('the_content', $text);
            $text = str_replace(']]>', ']]&gt;', $text);
            // Get excerpt length
            $excerpt_length = 12;
            //apply_filters( 'excerpt_length', 10 );
            // Filter the string in the "more" link displayed after a trimmed excerpt.
            $excerpt_more = apply_filters('excerpt_more', '...');
            // Trim the text
            $text = wp_trim_words($text, $excerpt_length, $excerpt_more);
            // Filter the trimmed excerpt string.
            $text = apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
            // Add to HTML
            if ($text) {
                $next_meeting_html .= wpautop($text);
            }
        }
        // Show view details link?
        if ($args['view_details']) {
            $next_meeting_html .= '<a class="meeting-view-details" href="' . $next_meeting_permalink . '">View details</a>';
        }
        // Show button?
        if ($args['include_button']) {
            $next_meeting_html .= '<a class="button expand" href="' . $next_meeting_permalink . '">Learn more about the meeting</a>';
        }
    }
    return $next_meeting_html;
}