function intercept_page_load() { if (is_admin()) { return false; } global $wp_query; if (!isset($_GET['eab_format'])) { return false; } if ('ical' != strtolower($_GET['eab_format'])) { return false; } if (!(isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) && Eab_EventModel::POST_TYPE == $wp_query->query_vars['post_type'])) { return false; } if (!$wp_query->posts) { return false; } $request = array('format' => 'ical', Eab_ExporterFactory::DISPOSITION_KEY => isset($_GET['attachment']) ? Eab_Exporter::DISPOSITION_ATTACHMENT : Eab_Exporter::DISPOSITION_INLINE); $request[Eab_ExporterFactory::EXPORTER_KEY] = is_singular() ? Eab_Exporter::SCOPE_EVENT : Eab_Exporter::SCOPE_COLLECTION; if (is_singular()) { $request['event_id'] = $wp_query->get_queried_object_id(); } if (isset($_GET['recurring'])) { add_filter('eab-export-ical-recurring_instances', '__return_true'); } $request['event_time_calculus'] = $this->_data->get_option('eab_export-ical-time', 'gmt'); Eab_ExporterFactory::serve($request); }
/** * Initialize the plugin * * @see http://codex.wordpress.org/Plugin_API/Action_Reference * @see http://adambrown.info/p/wp_hooks/hook/init */ function init() { global $wpdb, $wp_rewrite, $current_user, $blog_id, $wp_version; $version = preg_replace('/-.*$/', '', $wp_version); if (preg_match('/mu\\-plugin/', PLUGINDIR) > 0) { load_muplugin_textdomain(self::TEXT_DOMAIN, dirname(plugin_basename(__FILE__)) . '/languages'); } else { load_plugin_textdomain(self::TEXT_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/languages'); } $taxonomies = new Eab_Taxonomies(); $taxonomies->register(); $event_structure = '/' . $this->_data->get_option('slug') . '/%event_year%/%event_monthnum%/%incsub_event%'; $wp_rewrite->add_rewrite_tag("%incsub_event%", '(.+?)', "incsub_event="); $wp_rewrite->add_rewrite_tag("%event_year%", '([0-9]{4})', "event_year="); $wp_rewrite->add_rewrite_tag("%event_monthnum%", '([0-9]{2})', "event_monthnum="); $wp_rewrite->add_permastruct('incsub_event', $event_structure, false); //wp_register_script('eab_jquery_ui', plugins_url('events-and-bookings/js/jquery-ui.custom.min.js'), array('jquery'), self::CURRENT_VERSION); wp_register_script('eab_admin_js', plugins_url('events-and-bookings/js/eab-admin.js'), array('jquery'), self::CURRENT_VERSION); wp_register_script('eab_event_js', plugins_url('events-and-bookings/js/eab-event.js'), array('jquery'), self::CURRENT_VERSION); wp_register_style('eab_jquery_ui', plugins_url('events-and-bookings/css/smoothness/jquery-ui-1.8.16.custom.css'), null, self::CURRENT_VERSION); wp_register_style('eab_admin', plugins_url('events-and-bookings/css/admin.css'), null, self::CURRENT_VERSION); wp_register_style('eab_front', plugins_url('events-and-bookings/css/front.css'), null, self::CURRENT_VERSION); if (defined('AGM_PLUGIN_URL')) { add_action('admin_print_scripts-post.php', array($this, 'js_editor_button')); add_action('admin_print_scripts-post-new.php', array($this, 'js_editor_button')); } $event_localized = array('view_all_bookings' => __('View all RSVPs', self::TEXT_DOMAIN), 'back_to_gettting_started' => __('Back to getting started', self::TEXT_DOMAIN), 'start_of_week' => get_option('start_of_week')); wp_localize_script('eab_admin_js', 'eab_event_localized', $event_localized); if (isset($_REQUEST['eab_step'])) { setcookie('eab_step', $_REQUEST['eab_step'], eab_current_time() + 3600 * 24); } else { if (isset($_COOKIE['eab_step'])) { $_REQUEST['eab_step'] = $_COOKIE['eab_step']; } } if (isset($_REQUEST['eab_export'])) { if (!class_exists('Eab_ExporterFactory')) { require_once EAB_PLUGIN_DIR . 'lib/class_eab_exporter.php'; } Eab_ExporterFactory::serve($_REQUEST); } }