public function widget($args, $instance) { extract($args); /* User-selected settings. */ $title = apply_filters('widget_title', $instance['title']); // get the current post global $post; if (isset($post->post_content)) { // check the post content for the short code if (strpos($post->post_content, '[ESPRESSO_CALENDAR') === FALSE) { // Before widget (defined by themes). echo $before_widget; // Title of widget (before and after defined by themes). if ($title) { echo $before_title . $title . $after_title; } $attributes = array('event_category_id' => $instance['category_id'], 'show_expired' => $instance['show_expired'], 'cal_view' => 'month', 'widget' => TRUE, 'header_left' => 'prev', 'header_center' => 'title', 'header_right' => 'next', 'titleFormat_month' => 'MMM yyyy'); // get calendar options $calendar_options = get_option('espresso_calendar_options', array()); if (isset($calendar_options['show_tooltips']) && $calendar_options['show_tooltips'] ? TRUE : FALSE) { wp_enqueue_style('qtip'); wp_enqueue_script('jquery-qtip'); } wp_enqueue_style('fullcalendar'); wp_enqueue_style('espresso_calendar'); wp_enqueue_script('espresso_calendar'); echo EE_Calendar::instance()->espresso_calendar($attributes); // After widget (defined by themes). echo $after_widget; } } }
/** *@singleton method used to instantiate class object *@access public *@return EE_Calendar instance */ public static function instance() { // check if class object is instantiated if (self::$_instance === NULL or !is_object(self::$_instance) or !is_a(self::$_instance, __CLASS__)) { self::$_instance = new self(); } return self::$_instance; }
function load_espresso_calendar_class() { // check for duplicate copy of Calendar addon if (class_exists('EE_Calendar')) { EE_Error::add_error(sprintf(__('It appears there are multiple copies of the Event Espresso Calendar installed on your server.%sPlease remove (delete) all copies except for this version: "%s"', 'event_espresso'), '<br />', EE_CALENDAR_VERSION), __FILE__, __FUNCTION__, __LINE__); add_action('admin_notices', 'espresso_calendar_activation_error'); return; } // todo: remove version check since this has been added to later versions of register_addon in EE core if (class_exists('EE_Addon') && version_compare(EVENT_ESPRESSO_VERSION, EE_CORE_VERSION_REQUIRED, '>=')) { // calendar_version require_once plugin_dir_path(__FILE__) . 'EE_Calendar.class.php'; EE_Calendar::register_addon(); } else { add_action('admin_notices', 'espresso_calendar_activation_error'); } }
/** * Add a settings link to the Plugins page, so people can go straight from the plugin page to the * settings page. */ public function plugin_actions($links, $file) { $calendar_file = EE_Calendar::plugin_file(); if ($file == $calendar_file) { $org_settings_link = '<a href="admin.php?page=espresso_calendar">' . __('Settings') . '</a>'; array_unshift($links, $org_settings_link); // before other links } return $links; }