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;
 }
 function handle_calendar_shortcode($atts)
 {
     global $post;
     self::$add_script = true;
     self::$widget_calendars[] = true;
     $id = count(self::$calendars);
     $tz = eo_get_blog_timezone();
     $month = new DateTime('now', $tz);
     $month = date_create($month->format('Y-m-1'), $tz);
     $html = '<div class="widget_calendar eo-calendar eo-calendar-shortcode eo_widget_calendar" id="eo_shortcode_calendar_' . $id . '">';
     $html .= '<div id="eo_shortcode_calendar_' . $id . '_content">' . EO_Calendar_Widget::generate_output($month) . '</div>';
     $html .= '</div>';
     return $html;
 }
Ejemplo n.º 3
0
/**
 * Ajax response for the widget calendar 
 *
 *  This gets the month being requested and generates the
 * html code to view that month and its events. 
 *
 *@since 1.0
 *@access private
 *@ignore
*/
function eventorganiser_widget_cal()
{
    /*Retrieve the month we are after. $month must be a 
    		DateTime object of the first of that month*/
    if (isset($_GET['eo_month'])) {
        $month = new DateTime($_GET['eo_month'] . '-01');
    } else {
        $month = new DateTime('now');
        $month = date_create($month->format('Y-m-1'));
    }
    $args = array();
    //Restrict by category and/or venue
    foreach (array('event-venue', 'event-category') as $tax) {
        if (empty($_GET[$tax])) {
            continue;
        }
        $terms = explode(',', trim($_GET[$tax]));
        $args['tax_query'][] = array('taxonomy' => $tax, 'field' => 'slug', 'terms' => $terms, 'operator' => 'IN');
    }
    //Options for the calendar
    $args['showpastevents'] = empty($_GET['showpastevents']) ? 0 : 1;
    $args['link-to-single'] = empty($_GET['link-to-single']) ? 0 : 1;
    $args['show-long'] = empty($_GET['show-long']) ? 0 : 1;
    echo json_encode(EO_Calendar_Widget::generate_output($month, $args));
    exit;
}
function eventorganiser_widget_cal()
{
    /*Retrieve the month we are after. $month must be a 
    		DateTime object of the first of that month*/
    if (isset($_GET['eo_month'])) {
        $month = new DateTime($_GET['eo_month'] . '-01');
    } else {
        $month = new DateTime('now');
        $month = date_create($month->format('Y-m-1'));
    }
    //Options for the calendar
    $args = array('showpastevents' => empty($_GET['showpastevents']) ? 0 : 1);
    echo json_encode(EO_Calendar_Widget::generate_output($month, $args));
    exit;
}