function widget($args, $instance) { /* this is the piece that actualy does the widget display */ global $amrW, $amr_options, $amr_limits, $amr_listtype, $amr_calendar_url, $amr_ical_am_doing, $change_view_allowed, $widget_icalno, $amr_been_here; /* used to detect if we are looping somehow - reset at the end of each widget or shortcode. */ // if (amr_a_nested_event_shortcode()) { return false; } //someone entered an event shortcode into event content - causing a loop of events lists inside event lists amr_ical_load_text(); // do we have to reload all over theplace ? wp does not always seem to have the translations $change_view_allowed = false; $amr_ical_am_doing = 'listwidget'; extract($args, EXTR_SKIP); /* this is for the before / after widget etc*/ unset($args); //nb do not delete this else mucks up the args later extract($instance, EXTR_SKIP); /* this is for the params etc*/ if (!empty($shortcode_urls)) { // get any args stored in the widget settings $args = shortcode_parse_atts($shortcode_urls); } if (empty($args['listtype'])) { $args['listtype'] = '4'; } $amr_listtype = (int) $args['listtype']; // if (!empty($externalicalonly) and $externalicalonly) { $args['eventpoststoo'] = '0'; } else { $args['eventpoststoo'] = '1'; } // $args['show_month_nav'] = '0'; // comment out, otherwise cannot have at all if requetsed? $args['headings'] = '1'; $args['show_views'] = '0'; $amrW = 'w'; /* to maintain consistency with previous version and prevent certain actions */ $criteria = amr_get_params($args); /* this may update listtype, limits etc */ // what was this for ?? if (isset($criteria['event'])) { unset($criteria['event']); } //*** later may need to check for other custo posttypes if (ICAL_EVENTS_DEBUG) { echo '<hr>ical list widget:' . $amr_listtype . ' <br />' . amr_echo_parameters(); } if (isset($doeventsummarylink) and !$doeventsummarylink) { $amrW = 'w_no_url'; } $moreurl = trim($moreurl, " "); $moreurl = empty($moreurl) ? null : $moreurl; $amr_calendar_url = esc_url($moreurl); if (ICAL_EVENTS_DEBUG) { echo 'Calendar url = ' . $amr_calendar_url; } if (isset($_REQUEST['lang'])) { $moreurl = add_query_arg('lang', $_REQUEST['lang'], $moreurl); } // wp 3.3.1 doesn't like html in titles anymore - why ? // if (!empty ($moreurl)) // $title = '<a title="'.__('Look for more','amr-ical-events-list').'" href= "'.$moreurl.'">'.__($title,'amr-ical-events-list') .'</a>'; if (!isset($widget_icalno)) { $widget_icalno = 0; } else { $widget_icalno = $widget_icalno + 1; } $content = amr_process_icalspec($criteria, $amr_limits['start'], $amr_limits['end'], $amr_limits['events'], $widget_icalno); //output... //var_dump($criteria); echo $before_widget; // if (!empty($criteria['headings'])) echo $before_title . apply_filters('widget_title', __($title, 'amr-ical-events-list')) . $after_title; echo $content; echo $after_widget; /* we made it out the other end without looping ?*/ $amr_been_here = false; }
function amr_do_weekscal_shortcode($attributes, $content = null) { global $amr_limits, $amr_listtype, $change_view_allowed, $amr_ical_am_doing, $amr_icalno, $amr_been_here; /* used to give each ical table a unique id on a page or post */ // This is the main function. It replaces [iCal URL]'s with events. Each as a separate list if no listtype set it to 8 /* Allow multiple urls and only one listtype */ /* merge atts with this array, so we will have a default list */ if (amr_a_nested_event_shortcode()) { return false; } //someone entered an event shortcode into event content - causing a loop of events lists inside event lists $change_view_allowed = true; $amr_ical_am_doing = 'weekscalendar'; $defaults['listtype'] = 11; $defaults['weeks'] = 2; $defaults['months'] = 0; $defaults['days'] = 14; $defaults['show_month_nav'] = 1; // will actually do weeks $defaults['show_views'] = ''; if (empty($attributes)) { $atts = $defaults; } else { $atts = array_merge($defaults, $attributes); } $criteria = amr_GET_params($atts); /* strip out and set any other attstributes - they will set the limits table */ /* criteria will be any selection */ /* separate out the other possible variables like list type, then just have the urls */ $id = amr_GET_id_for_shortcode(); // need this to increment icalno $content = amr_process_icalspec($criteria, $amr_limits['start'], $amr_limits['end'], $amr_limits['events'], $amr_icalno); $html = '<div ' . $id . ' >' . $content . '</div>'; /* we made it out the other end with out looping ?*/ $amr_been_here = false; return $html; }