コード例 #1
0
 static function handle_calendar_shortcode($atts = array())
 {
     /* Shortcodes don't accept hyphens, so convert taxonomy names */
     $taxs = array('category', 'tag', 'venue');
     foreach ($taxs as $tax) {
         if (isset($atts['event_' . $tax])) {
             $atts['event-' . $tax] = $atts['event_' . $tax];
             unset($atts['event_' . $tax]);
         }
     }
     if (isset($atts['show_long'])) {
         $atts['show-long'] = $atts['show_long'];
         unset($atts['show_long']);
     }
     if (isset($atts['link_to_single'])) {
         $atts['link-to-single'] = $atts['link_to_single'];
         unset($atts['link_to_single']);
     }
     /* Parse defaults */
     $atts = wp_parse_args($atts, array('showpastevents' => 1, 'show-long' => 0, 'link-to-single' => 0));
     self::$add_script = true;
     $id = count(self::$widget_calendars);
     $cal_id = 'eo_shortcode_calendar_' . $id;
     self::$widget_calendars[$cal_id] = $atts;
     $tz = eo_get_blog_timezone();
     $date = isset($_GET['eo_month']) ? $_GET['eo_month'] . '-01' : 'now';
     $month = new DateTime($date, $tz);
     $month = date_create($month->format('Y-m-1'), $tz);
     $html = '<div class="widget_calendar eo-calendar eo-calendar-shortcode eo_widget_calendar" id="' . $cal_id . '">';
     $html .= '<div id="' . $cal_id . '_content" class="eo-widget-cal-wrap" data-eo-widget-cal-id="' . $cal_id . '">';
     $html .= EO_Calendar_Widget::generate_output($month, $atts);
     $html .= '</div>';
     $html .= '</div>';
     return $html;
 }
コード例 #2
0
 public function testCatAttributesShortcode()
 {
     do_shortcode('[eo_fullcalendar event_category="foo,bar"]');
     $args = array_pop(EventOrganiser_Shortcodes::$calendars);
     $this->assertEquals('foo,bar', $args['event_category']);
     //Reset
     EventOrganiser_Shortcodes::$calendars = array();
 }
コード例 #3
0
/**
 * Returns the mark-up for a Google map of the venue (and enqueues scripts).
 * Accepts an arguments array corresponding to the attributes supported by the shortcode.
 * 
 * ### Examples
 * <code>
 *   // Display map of two venues 
 *   <?php echo eo_get_venue_map(array('london-eye','edinburgh-castle')); ?>
 * </code>
 * @since 1.6
 * @link http://wp-event-organiser.com/blog/tutorial/changing-the-venue-map-icon/ Changing the venue map icon
 * @link http://www.stephenharris.info/2012/event-organiser-1-6-whats-new/ Examples of using eo_get_venue_map()
 * @param mixed $venue_slug_or_id The venue ID as an integer. Or Slug as string. Uses venue of current event if empty.
 * @return string The markup of the map. False is no venue found.
 */
function eo_get_venue_map($venue_slug_or_id = '', $args = array())
{
    //Cast as array to allow multi venue support
    if ($venue_slug_or_id == '%all%' || is_array($venue_slug_or_id) && in_array('%all%', $venue_slug_or_id)) {
        $all_venues = eo_get_venues();
        if ($all_venues) {
            $venue_slug_or_id = array_map('intval', wp_list_pluck($all_venues, 'term_id'));
        }
    }
    if (!is_array($venue_slug_or_id)) {
        $venue_slug_or_id = array($venue_slug_or_id);
    }
    $venue_ids = array_map('eo_get_venue_id_by_slugorid', $venue_slug_or_id);
    //Map properties
    $args = shortcode_atts(array('zoom' => 15, 'scrollwheel' => true, 'zoomcontrol' => true, 'rotatecontrol' => true, 'pancontrol' => true, 'overviewmapcontrol' => true, 'streetviewcontrol' => true, 'maptypecontrol' => true, 'draggable' => true, 'maptypeid' => 'ROADMAP', 'width' => '100%', 'height' => '200px', 'class' => '', 'tooltip' => true, 'styles' => array()), $args);
    //Cast zoom as integer
    $args['zoom'] = (int) $args['zoom'];
    //Escape attributes
    $width = esc_attr($args['width']);
    $height = esc_attr($args['height']);
    $class = esc_attr($args['class']);
    $args['maptypeid'] = strtoupper($args['maptypeid']);
    //If class is selected use that style, otherwise use specified height and width
    if (!empty($class)) {
        $class .= " eo-venue-map googlemap";
        $style = "";
    } else {
        $class = "eo-venue-map googlemap";
        $style = "style='height:" . $height . ";width:" . $width . ";' ";
    }
    $venue_ids = array_filter($venue_ids);
    if (empty($venue_ids)) {
        return false;
    }
    //Set up venue locations for map
    foreach ($venue_ids as $venue_id) {
        //Venue lat/lng array
        $latlng = eo_get_venue_latlng($venue_id);
        //Venue tooltip description
        $tooltip_content = '<strong>' . eo_get_venue_name($venue_id) . '</strong>';
        $address = array_filter(eo_get_venue_address($venue_id));
        if (!empty($address)) {
            $tooltip_content .= '<br />' . implode(', ', $address);
        }
        /**
         * Filters the tooltip content for a venue.
         * 
         * ### Example
         * 
         *    //Adds a link to the venue page to the tooltip
         *    add_filter( 'eventorganiser_venue_tooltip', 'my_venue_tooltip_content_link_to_venue', 10, 2 );
         *    function my_venue_tooltip_content_link_to_venue( $description, $venue_id ){
         *        $description .= sprintf('<p><a href="%s"> Visit the venue page! </a> </p>', eo_get_venue_link($venue_id));
         *        return $description;
         *    }
         * 
         * @link https://gist.github.com/stephenharris/4988307 Add upcoming events to the the tooltip 
         * @param string $tooltip_content The HTML content for the venue tooltip.
         * @param int $venue_id The ID of the venue.
         * @param array $args An array of map options. See documentation for `eo_get_venue_map()`.
         */
        $tooltip_content = apply_filters('eventorganiser_venue_tooltip', $tooltip_content, $venue_id, $args);
        /**
         * Filters the url of the venue map marker. Set to `null` for default.
         *
         * @link http://wp-event-organiser.com/extensions/event-organiser-venue-markers Custom venue markers
         * @param string|null $icon Url to the icon image. Null to use default.
         * @param int $venue_id The ID of the venue.
         * @param array $args An array of map options. See documentation for `eo_get_venue_map()`.
         */
        $icon = apply_filters('eventorganiser_venue_marker', null, $venue_id, $args);
        $locations[] = array('venue_id' => $venue_id, 'lat' => $latlng['lat'], 'lng' => $latlng['lng'], 'tooltipContent' => $tooltip_content, 'icon' => $icon);
    }
    $map = array_merge($args, array('locations' => $locations));
    /**
     * Filters the tooltip content for a venue.
     * 
     * ### Example
     * 
     *    //Styles your google map
     *    add_filter( 'eventorganiser_venue_map_options', 'style_my_google_map', 10 );
     *    function style_my_google_map( $map_args ){
     *        $map_args['styles'] = {set styles};;
     *        return $map_args;
     *    }
     *    
     * @link https://developers.google.com/maps/documentation/javascript/styling#styling_the_default_map
     * @param array $map Array of map properties, including the key 'location' (array of locations) 
     *                   height, width, zoom and styles.
     */
    $map = apply_filters('eventorganiser_venue_map_options', $map);
    //This could be improved
    EventOrganiser_Shortcodes::$map[] = $map;
    EventOrganiser_Shortcodes::$add_script = true;
    $id = count(EventOrganiser_Shortcodes::$map);
    return "<div class='" . $class . "' id='eo_venue_map-{$id}' " . $style . "></div>";
}
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $template = $instance['template'];
     $no_events = isset($instance['no_events']) ? $instance['no_events'] : '';
     unset($instance['template']);
     unset($instance['no_events']);
     $events = eo_get_events($instance);
     echo $before_widget;
     echo $before_title;
     echo esc_html($instance['title']);
     echo $after_title;
     global $post;
     $tmp_post = $post;
     echo '<ul class="eo-events eo-events-widget">';
     if ($events) {
         foreach ($events as $post) {
             setup_postdata($post);
             if (empty($template)) {
                 //Use default template
                 //Check if all day, set format accordingly
                 if ($post->event_allday) {
                     $format = get_option('date_format');
                 } else {
                     $format = get_option('date_format') . '  ' . get_option('time_format');
                 }
                 echo '<li><a title="' . the_title_attribute(array('echo' => false)) . '" href="' . get_permalink() . '">' . esc_html(get_the_title()) . '</a> ' . __('on', 'eventorganiser') . ' ' . eo_format_date($post->StartDate . ' ' . $post->StartTime, $format) . '</li>';
             } else {
                 echo '<li>' . EventOrganiser_Shortcodes::read_template($template) . '</li>';
             }
         }
         $post = $tmp_post;
         wp_reset_postdata();
     } else {
         echo $no_events;
     }
     echo '</ul>';
     echo $after_widget;
 }
コード例 #5
0
function eventorganiser_list_events($query, $args = array(), $echo = 1)
{
    $args = array_merge(array('id' => '', 'class' => 'eo-event-list', 'type' => 'shortcode', 'no_events' => ''), $args);
    /* Pass these defaults - backwards compat with using eo_get_events()*/
    $query = wp_parse_args($query, array('posts_per_page' => -1, 'post_type' => 'event', 'suppress_filters' => false, 'orderby' => 'eventstart', 'order' => 'ASC', 'showrepeats' => 1, 'group_events_by' => '', 'showpastevents' => true));
    //Make sure false and 'False' etc actually get parsed as 0/false (input from shortcodes, for instance, can be varied).
    //This maybe moved to the shortcode handler if this function is made public.
    if (strtolower($query['showpastevents']) === 'false') {
        $query['showpastevents'] = 0;
    }
    if (!empty($query['numberposts'])) {
        $query['posts_per_page'] = (int) $query['numberposts'];
    }
    $template = isset($args['template']) ? $args['template'] : '';
    global $eo_event_loop, $eo_event_loop_args;
    $eo_event_loop_args = $args;
    $eo_event_loop = new WP_Query($query);
    /**
     * @ignore
     * Try to find template - backwards compat. Don't use this filter. Will be removed!
     */
    $template_file = apply_filters('eventorganiser_event_list_loop', false);
    $template_file = locate_template($template_file);
    if ($template_file || empty($template)) {
        ob_start();
        if (empty($template_file)) {
            $template_file = eo_locate_template(array($eo_event_loop_args['type'] . '-event-list.php', 'event-list.php'), true, false);
        } else {
            require $template_file;
        }
        $html = ob_get_contents();
        ob_end_clean();
    } else {
        //Using the 'placeholder' template
        $no_events = isset($args['no_events']) ? $args['no_events'] : '';
        $line_wrap = '<li class="%2$s">%1$s</li>';
        $id = !empty($args['id']) ? 'id="' . esc_attr($args['id']) . '"' : '';
        $container = '<ul ' . $id . ' class="%2$s">%1$s</ul>';
        $html = '';
        if ($eo_event_loop->have_posts()) {
            while ($eo_event_loop->have_posts()) {
                $eo_event_loop->the_post();
                $event_classes = eo_get_event_classes();
                $html .= sprintf($line_wrap, EventOrganiser_Shortcodes::read_template($template), esc_attr(implode(' ', $event_classes)));
            }
        } elseif ($no_events) {
            $html .= sprintf($line_wrap, $no_events, 'eo-no-events');
        }
        $html = sprintf($container, $html, esc_attr($args['class']));
    }
    wp_reset_postdata();
    if ($echo) {
        echo $html;
    }
    return $html;
}
コード例 #6
0
/**
 * Returns the mark-up for a Google map of the venue (and enqueues scripts).
 * Accepts an arguments array corresponding to the attributes supported by the shortcode.
 * 
 * ### Examples
 * <code>
 *   // Display map of two venues 
 *   <?php echo eo_get_venue_map(array('london-eye','edinburgh-castle')); ?>
 * </code>
 * @since 1.6
 * @link http://wp-event-organiser.com/blog/tutorial/changing-the-venue-map-icon/ Changing the venue map icon
 * @link http://www.stephenharris.info/2012/event-organiser-1-6-whats-new/ Examples of using eo_get_venue_map()
 * @param mixed $venue_slug_or_id The venue ID as an integer. Or Slug as string. Uses venue of current event if empty.
 * @return string The markup of the map. False is no venue found.
 */
function eo_get_venue_map($venue_slug_or_id = '', $args = array())
{
    //Cast as array to allow multi venue support
    if ($venue_slug_or_id == '%all%' || is_array($venue_slug_or_id) && in_array('%all%', $venue_slug_or_id)) {
        $all_venues = eo_get_venues();
        if ($all_venues) {
            $venue_slug_or_id = array_map('intval', wp_list_pluck($all_venues, 'term_id'));
        }
    }
    if (!is_array($venue_slug_or_id)) {
        $venue_slug_or_id = array($venue_slug_or_id);
    }
    $venue_ids = array_map('eo_get_venue_id_by_slugorid', $venue_slug_or_id);
    //Map properties
    $args = shortcode_atts(array('zoom' => 15, 'scrollwheel' => true, 'zoomcontrol' => true, 'rotatecontrol' => true, 'pancontrol' => true, 'overviewmapcontrol' => true, 'streetviewcontrol' => true, 'maptypecontrol' => true, 'draggable' => true, 'maptypeid' => 'ROADMAP', 'width' => '100%', 'height' => '200px', 'class' => '', 'tooltip' => true), $args);
    //Cast zoom as integer
    $args['zoom'] = (int) $args['zoom'];
    //Escape attributes
    $width = esc_attr($args['width']);
    $height = esc_attr($args['height']);
    $class = esc_attr($args['class']);
    $args['maptypeid'] = strtoupper($args['maptypeid']);
    //If class is selected use that style, otherwise use specified height and width
    if (!empty($class)) {
        $class .= " eo-venue-map googlemap";
        $style = "";
    } else {
        $class = "eo-venue-map googlemap";
        $style = "style='height:" . $height . ";width:" . $width . ";' ";
    }
    $venue_ids = array_filter($venue_ids);
    if (empty($venue_ids)) {
        return false;
    }
    //Set up venue locations for map
    foreach ($venue_ids as $venue_id) {
        //Venue lat/lng array
        $latlng = eo_get_venue_latlng($venue_id);
        //Venue tooltip description
        $tooltip_content = '<strong>' . eo_get_venue_name($venue_id) . '</strong>';
        $address = array_filter(eo_get_venue_address($venue_id));
        if (!empty($address)) {
            $tooltip_content .= '<br />' . implode(', ', $address);
        }
        $tooltip_content = apply_filters('eventorganiser_venue_tooltip', $tooltip_content, $venue_id, $args);
        $icon = apply_filters('eventorganiser_venue_marker', null, $venue_id, $args);
        $locations[] = array('venue_id' => $venue_id, 'lat' => $latlng['lat'], 'lng' => $latlng['lng'], 'tooltipContent' => $tooltip_content, 'icon' => $icon);
    }
    //This could be improved
    EventOrganiser_Shortcodes::$map[] = array_merge($args, array('locations' => $locations));
    EventOrganiser_Shortcodes::$add_script = true;
    $id = count(EventOrganiser_Shortcodes::$map);
    return "<div class='" . $class . "' id='eo_venue_map-{$id}' " . $style . "></div>";
}
コード例 #7
0
/**
 * Returns HTML mark-up for the fullCalendar
 *
 * It also (indirectly) triggers the enquing of the necessary scripts and styles. The `$args` array
 * accepts exactly the same arguments as the shortcode, they are
 *
 * * **headerleft** (string) What appears on the left of the calendar header. Default 'title'.
 * * **headercenter** (string) What appears on the left of the calendar header. Default ''.
 * * **headerright** (string) What appears on the left of the calendar header. Default 'prev next today'.
 * * **defaultview** (string) The view the calendar loads on. Default 'month',
 * * **event-category** (string|array) Restrict calendar to specified category(ues) (by slug). Default all categories.
 * * **event-venue** (string|array) Restrict calendar to specified venue(s) (by slug). Default all venues.
 * * **timeformat** (string) Time format for calendar. Default 'G:i'.
 * * **axisformat** (string) Axis time format (for day/week views). WP's time format option.
 * * **key** (bool) Whether to show a category key. Default false.
 * * **tooltip** (bool) Whether to show a tooltips. Default true. Content is filtered by [`eventorganiser_event_tooltip`](http://codex.wp-event-organiser.com/hook-eventorganiser_event_tooltip.html)
 * * **users_events** - (bool) True to show only eents for which the current user is attending
 * * **weekends** (bool) Whether to include weekends in the calendar. Default true.
 * * **mintime** (string) Earliest time to show on week/day views. Default '0',
 * * **maxtime** (string) Latest time to show on week/day views. Default '24',
 * * **alldayslot** (bool) Whether to include an all day slot (week / day views) in the calendar. Default true.
 * * **alldaytext** (string) Text to display in all day slot. Default 'All Day'.
 * * **titleformatmonth** (string) Date format (PHP) for title for month view. Default 'l, M j, Y'
 * * **titleformatweek** (string) Date format (PHP) for title for week view. Default 'M j[ Y]{ '&#8212;'[ M] j Y}.
 * * **titleformatday** (string) Date format (PHP) for title for day view. Default 'F Y'
 * * **columnformatmonth** (string) Dateformat for month columns. Default 'D'.
 * * **columnformatweek** (string) Dateformat for month columns. Default 'D n/j'.
 * * **columnformatday** (string) Dateformat for month columns. Default 'l n/j',
 * * **year** The year the calendar should start on (e.g. 2013)
 * * **month** The month the calendar should start on (1=Jan, 12=Dec)
 * * **date** The calendar the date should start on
 *
 * @link http://arshaw.com/fullcalendar/ The fullCalendar (jQuery plug-in)
 * @link http://arshaw.com/fullcalendar/docs/utilities/formatDates/ (Range formats).
 * @link https://github.com/stephenharris/fullcalendar Event Organiser version of fullCalendar
 * @since 1.7
 * @param array $args An array of attributes for the calendar 
 * @return string HTML mark-up.
*/
function eo_get_event_fullcalendar($args = array())
{
    global $wp_locale;
    $defaults = array('headerleft' => 'title', 'headercenter' => '', 'headerright' => 'prev next today', 'defaultview' => 'month', 'event-category' => '', 'event_category' => '', 'event-venue' => '', 'event_venue' => '', 'event-tag' => '', 'author' => false, 'author_name' => false, 'timeformat' => get_option('time_format'), 'axisformat' => get_option('time_format'), 'key' => false, 'tooltip' => true, 'weekends' => true, 'mintime' => '0', 'maxtime' => '24', 'alldayslot' => true, 'alldaytext' => __('All Day', 'eventorganiser'), 'columnformatmonth' => 'D', 'columnformatweek' => 'D n/j', 'columnformatday' => 'l n/j', 'titleformatmonth' => 'F Y', 'titleformatweek' => "M j[ Y]{ '&#8212;'[ M] j, Y}", 'titleformatday' => 'l, M j, Y', 'year' => false, 'month' => false, 'date' => false, 'users_events' => false, 'event_occurrence__in' => array(), 'theme' => true, 'isrtl' => $wp_locale->is_rtl());
    $args = shortcode_atts($defaults, $args, 'eo_fullcalendar');
    $key = $args['key'];
    unset($args['key']);
    //Support 'event-category' and 'event-venue'. Backwards compat with 'event_category'/'event_venue'
    $args['event-category'] = empty($args['event_category']) ? $args['event-category'] : $args['event_category'];
    $args['event-venue'] = empty($args['event_venue']) ? $args['event-venue'] : $args['event_venue'];
    //Convert event_category / event_venue to comma-delimitered strings
    $args['event_category'] = is_array($args['event-category']) ? implode(',', $args['event-category']) : $args['event-category'];
    $args['event_venue'] = is_array($args['event-venue']) ? implode(',', $args['event-venue']) : $args['event-venue'];
    $args['event_tag'] = is_array($args['event-tag']) ? implode(',', $args['event-tag']) : $args['event-tag'];
    //Get author ID from author/author_name
    $args['event_organiser'] = $args['author'] ? (int) $args['author'] : eo_get_user_id_by('slug', $args['author_name']);
    //Convert php time format into xDate time format
    $date_attributes = array('timeformat', 'axisformat', 'columnformatday', 'columnformatweek', 'columnformatmonth', 'titleformatmonth', 'titleformatday', 'titleformatweek');
    $args['timeformatphp'] = $args['timeformat'];
    foreach ($date_attributes as $date_attribute) {
        $args[$date_attribute] = str_replace('((', '[', $args[$date_attribute]);
        $args[$date_attribute] = str_replace('))', ']', $args[$date_attribute]);
        $args[$date_attribute . 'php'] = $args[$date_attribute];
        $args[$date_attribute] = eventorganiser_php2xdate($args[$date_attribute]);
    }
    //Month expects 0-11, we ask for 1-12.
    $args['month'] = $args['month'] ? $args['month'] - 1 : false;
    EventOrganiser_Shortcodes::$calendars[] = array_merge($args);
    EventOrganiser_Shortcodes::$add_script = true;
    $id = count(EventOrganiser_Shortcodes::$calendars);
    $html = '<div id="eo_fullcalendar_' . $id . '_loading" style="background:white;position:absolute;z-index:5" >';
    $html .= sprintf('<img src="%1$s" style="vertical-align:middle; padding: 0px 5px 5px 0px;" alt="%2$s" /> %2$s', esc_url(EVENT_ORGANISER_URL . 'css/images/loading-image.gif'), esc_html__('Loading&#8230;', 'eventorganiser'));
    $html .= '</div>';
    $html .= '<div class="eo-fullcalendar eo-fullcalendar-shortcode" id="eo_fullcalendar_' . $id . '"></div>';
    if ($key) {
        $args = array('orderby' => 'name', 'show_count' => 0, 'hide_empty' => 0);
        $html .= eventorganiser_category_key($args, $id);
    }
    return $html;
}
 function get_venue_map($venue_id, $args)
 {
     self::$add_script = true;
     extract(shortcode_atts(array('zoom' => 15, 'width' => '100%', 'height' => '200px', 'class' => ''), $args));
     //Set zoom
     $zoom = (int) $zoom;
     //Set the attributes
     $width = esc_attr($width);
     $height = esc_attr($height);
     //If class is selected use that style, otherwise use specified height and width
     if (!empty($class)) {
         $class = esc_attr($class) . " eo-venue-map googlemap";
         $style = "";
     } else {
         $class = "eo-venue-map googlemap";
         $style = "style='height:" . $height . ";width:" . $width . ";' ";
     }
     //Get latlng value by slug
     $latlng = eo_get_venue_latlng($venue_id);
     self::$map[] = array('lat' => $latlng['lat'], 'lng' => $latlng['lng'], 'zoom' => $zoom);
     $id = count(self::$map);
     $return = "<div class='" . $class . "' id='eo_venue_map-{$id}' " . $style . "></div>";
     return $return;
 }
function eo_get_venue_map($venue_slug_or_id = '', $args = array())
{
    $venue_id = eo_get_venue_id_by_slugorid($venue_slug_or_id);
    return EventOrganiser_Shortcodes::get_venue_map($venue_id, $args = array());
}