options = EL_Options::get_instance(); $this->shortcode = null; $this->styles_loaded = false; // ALWAYS: // Register translation add_action('plugins_loaded', array(&$this, 'load_textdomain')); // Register shortcodes add_shortcode('event-list', array(&$this, 'shortcode_event_list')); // Register widgets add_action('widgets_init', array(&$this, 'widget_init')); // Register RSS feed add_action('init', array(&$this, 'feed_init'), 10); // ADMIN PAGE: if(is_admin()) { // Include required php-files and initialize required objects require_once(EL_PATH.'admin/admin.php'); EL_Admin::get_instance()->init_admin_page(); } // FRONT PAGE: else { // Register actions add_action('wp_print_styles', array(&$this, 'print_styles')); } } // end constructor public function load_textdomain() { load_plugin_textdomain('event-list', false, basename(EL_PATH).'/languages'); } public function shortcode_event_list($atts) { if(null == $this->shortcode) { require_once(EL_PATH.'includes/sc_event-list.php'); $this->shortcode = SC_Event_List::get_instance(); if(!$this->styles_loaded) { // normally styles are loaded with wp_print_styles action in head // but if the shortcode is not in post content (e.g. included in a theme) it must be loaded here $this->enqueue_styles(); } } return $this->shortcode->show_html($atts); } public function feed_init() { if($this->options->get('el_enable_feed')) { include_once(EL_PATH.'includes/feed.php'); EL_Feed::get_instance(); } } public function widget_init() { // Widget "event-list" require_once(EL_PATH.'includes/widget.php'); return register_widget('EL_Widget'); } public function print_styles() { global $post; if(is_active_widget(null, null, 'event_list_widget') || (is_object($post) && strstr($post->post_content, '[event-list'))) { $this->enqueue_styles(); } } public function enqueue_styles() { if('' == $this->options->get('el_disable_css_file')) { wp_register_style('event-list', EL_URL.'includes/css/event-list.css'); wp_enqueue_style('event-list'); } $this->styles_loaded = true; } } // end class linkview // create a class instance $event_list = new Event_List(); ?>