function widget($args, $instance) { extract($args); $the_title = apply_filters('widget_title', $instance['my_calendar_today_title'], $instance, $args); $the_template = $instance['my_calendar_today_template']; $the_substitute = $instance['my_calendar_no_events_text']; $the_category = $instance['my_calendar_today_category'] == '' ? 'default' : esc_attr($instance['my_calendar_today_category']); $author = !isset($instance['my_calendar_today_author']) || $instance['my_calendar_today_author'] == '' ? 'all' : esc_attr($instance['my_calendar_today_author']); $host = !isset($instance['mc_host']) || $instance['mc_host'] == '' ? 'all' : esc_attr($instance['mc_host']); $default_link = is_numeric(get_option('mc_uri')) ? get_permalink(get_option('mc_uri')) : get_option('mc_uri'); $widget_link = !empty($instance['my_calendar_today_linked']) && $instance['my_calendar_today_linked'] == 'yes' ? $default_link : ''; $widget_link = !empty($instance['mc_link']) ? esc_url($instance['mc_link']) : $widget_link; $widget_title = empty($the_title) ? '' : $the_title; $offset = 60 * 60 * get_option('gmt_offset'); if (strpos($widget_title, '{date}') !== false) { $widget_title = str_replace('{date}', date_i18n(get_option('mc_date_format'), time() + $offset), $widget_title); } $widget_title = $widget_link == '' ? $widget_title : "<a href='{$widget_link}'>{$widget_title}</a>"; $widget_title = $widget_title != '' ? $before_title . $widget_title . $after_title : ''; $the_events = my_calendar_todays_events($the_category, $the_template, $the_substitute, $author, $host); if ($the_events != '') { echo $before_widget; echo $widget_title; echo $the_events; echo $after_widget; } }
function my_calendar_insert_today($atts) { extract(shortcode_atts(array('category' => 'default', 'author' => 'default', 'host' => 'default', 'template' => 'default', 'fallback' => ''), $atts, 'my_calendar_today')); global $user_ID; if ($author == 'current') { $author = apply_filters('mc_display_author', $user_ID, 'today'); } if ($host == 'current') { $host = apply_filters('mc_display_host', $user_ID, 'today'); } return my_calendar_todays_events($category, $template, $fallback, $author, $host); }