/**
  * Print the widget content.
  *
  * @since 3.0.0
  *
  * @param array $args     Display arguments.
  * @param array $instance The settings for the particular instance of the widget.
  */
 public function widget($args, $instance)
 {
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     $id = isset($instance['calendar_id']) ? absint($instance['calendar_id']) : 0;
     if ($id > 0) {
         simcal_print_calendar($id);
     }
     echo $args['after_widget'];
 }
/**
 * Print a calendar.
 * @deprecated Use simcal_print_calendar()
 */
function gce_print_calendar($feed_ids, $display, $args)
{
    $id = 0;
    if (is_numeric($feed_ids)) {
        $id = intval($feed_ids);
    } elseif (is_array($feed_ids)) {
        $id = isset($feed_ids[0]) ? intval($feed_ids[0]) : '';
    }
    if ($id > 0) {
        simcal_print_calendar($id);
    }
}
 /**
  * Filter post content to output a calendar.
  *
  * @since  3.0.0
  *
  * @param  string $the_content
  *
  * @return string
  */
 public function filter_post_content($the_content)
 {
     if (is_singular()) {
         global $post;
         if ('calendar' == $post->post_type) {
             if (is_admin() && !defined('DOING_AJAX')) {
                 return '';
             } else {
                 ob_start();
                 simcal_print_calendar($post);
                 return ob_get_clean();
             }
         } else {
             $post_types = array();
             $settings = get_option('simple-calendar_settings_calendars');
             if (isset($settings['general']['attach_calendars_posts'])) {
                 $post_types = $settings['general']['attach_calendars_posts'];
             }
             if (empty($post_types)) {
                 return $the_content;
             }
             if (in_array($post->post_type, (array) $post_types)) {
                 $id = absint(get_post_meta($post->ID, '_simcal_attach_calendar_id', true));
                 if ($id > 0) {
                     $pos = esc_attr(get_post_meta($post->ID, '_simcal_attach_calendar_position', true));
                     ob_start();
                     if ('after' == $pos) {
                         echo $the_content;
                         simcal_print_calendar($id);
                     } elseif ('before' == $pos) {
                         simcal_print_calendar($id);
                         echo $the_content;
                     } else {
                         echo $the_content;
                     }
                     return ob_get_clean();
                 }
             }
         }
     }
     return $the_content;
 }