public function testOndateSlug() { global $wp_rewrite; update_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/'); $options = eventorganiser_get_option(false); $options['url_on'] = 'events-on'; update_option('eventorganiser_options', $options); eventorganiser_cpt_register(); $GLOBALS['wp_rewrite']->init(); flush_rewrite_rules(); $this->go_to(eo_get_event_archive_link(2014, 03)); $this->assertTrue(eo_is_event_archive('month')); $this->assertEquals('2014-03-01', eo_get_event_archive_date('Y-m-d')); $this->assertEquals('http://example.org/events/event/events-on/2014/03', eo_get_event_archive_link(2014, 03)); }
function eventorganiser_site_install() { global $wpdb; $eventorganiser_db_version = defined('EVENT_ORGANISER_VER') ? EVENT_ORGANISER_VER : false; eventorganiser_wpdb_fix(); $charset_collate = ''; if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } //Events table $sql_events_table = "CREATE TABLE " . $wpdb->eo_events . " (\n\t\tevent_id bigint(20) NOT NULL AUTO_INCREMENT,\n\t\tpost_id bigint(20) NOT NULL,\n\t\tStartDate DATE NOT NULL,\n\t\tEndDate DATE NOT NULL,\n\t\tStartTime TIME NOT NULL,\n\t\tFinishTime TIME NOT NULL,\n\t\tevent_occurrence bigint(20) NOT NULL,\n\t\tPRIMARY KEY (event_id),\n\t\tKEY StartDate (StartDate),\n\t\tKEY EndDate (EndDate)\n\t\t)" . $charset_collate; //Venue meta table $sql_venuemeta_table = "CREATE TABLE {$wpdb->prefix}eo_venuemeta (\n\t\tmeta_id bigint(20) unsigned NOT NULL auto_increment,\n\t\teo_venue_id bigint(20) unsigned NOT NULL default '0',\n \t\tmeta_key varchar(255) default NULL,\n\t\tmeta_value longtext,\n\t\tPRIMARY KEY (meta_id),\n\t\tKEY eo_venue_id (eo_venue_id),\n\t\tKEY meta_key (meta_key)\n\t\t) {$charset_collate}; "; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql_events_table); dbDelta($sql_venuemeta_table); //Add options and capabilities $eventorganiser_options = array('supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), 'event_redirect' => 'events', 'dateformat' => 'dd-mm', 'prettyurl' => 1, 'templates' => 1, 'addtomenu' => 0, 'excludefromsearch' => 0, 'showpast' => 0, 'group_events' => '', 'url_venue' => 'events/event', 'url_venue' => 'events/venues', 'url_cat' => 'events/category', 'url_tag' => 'events/tag', 'navtitle' => __('Events', 'eventorganiser'), 'eventtag' => 1, 'feed' => 1, 'runningisnotpast' => 0, 'deleteexpired' => 0); add_option('eventorganiser_options', $eventorganiser_options); /* Add existing notices */ $notices = array('autofillvenue17', 'changedtemplate17'); add_option('eventorganiser_admin_notices', $notices); //Add roles to administrator global $wp_roles; $all_roles = $wp_roles->roles; $eventorganiser_roles = array('edit_events' => __('Edit Events', 'eventorganiser'), 'publish_events' => __('Publish Events', 'eventorganiser'), 'delete_events' => __('Delete Events', 'eventorganiser'), 'edit_others_events' => __('Edit Others\' Events', 'eventorganiser'), 'delete_others_events' => __('Delete Other\'s Events', 'eventorganiser'), 'read_private_events' => __('Read Private Events', 'eventorganiser'), 'manage_venues' => __('Manage Venues', 'eventorganiser'), 'manage_event_categories' => __('Manage Event Categories & Tags', 'eventorganiser')); foreach ($all_roles as $role_name => $display_name) { $role = $wp_roles->get_role($role_name); if ($role->has_cap('manage_options')) { foreach ($eventorganiser_roles as $eo_role => $eo_role_display) { $role->add_cap($eo_role); } } } //End foreach $all_roles //Manually register CPT and CTs ready for flushing eventorganiser_create_event_taxonomies(); eventorganiser_cpt_register(); //Flush rewrite rules only on activation, and after CPT/CTs has been registered. flush_rewrite_rules(); }
function eventorganiser_install() { global $wpdb, $eventorganiser_db_version; eventorganiser_wpdb_fix(); $charset_collate = ''; if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } //Events table $sql_events_table = "CREATE TABLE " . $wpdb->eo_events . " (\n\t\tevent_id bigint(20) NOT NULL AUTO_INCREMENT,\n\t\tpost_id bigint(20) NOT NULL,\n\t\tVenue bigint(20) NOT NULL,\n\t\tStartDate DATE NOT NULL,\n\t\tEndDate DATE NOT NULL,\n\t\tStartTime TIME NOT NULL,\n\t\tFinishTime TIME NOT NULL,\n\t\tevent_schedule text NOT NULL,\n\t\tevent_schedule_meta text NOT NULL,\n\t\tevent_frequency smallint NOT NULL,\n\t\tevent_occurrence bigint(20) NOT NULL,\n\t\tevent_allday TINYINT(1) NOT NULL,\n\t\treoccurrence_start DATE NOT NULL,\n\t\treoccurrence_end DATE NOT NULL,\n\t\tPRIMARY KEY (event_id))" . $charset_collate; //Venue meta table $sql_venuemeta_table = "CREATE TABLE {$wpdb->prefix}eo_venuemeta (\n\t\tmeta_id bigint(20) unsigned NOT NULL auto_increment,\n\t\teo_venue_id bigint(20) unsigned NOT NULL default '0',\n \t\tmeta_key varchar(255) default NULL,\n\t\tmeta_value longtext,\n\t\tPRIMARY KEY (meta_id),\n\t\tKEY eo_venue_id (eo_venue_id),\n\t\tKEY meta_key (meta_key)\n\t\t) {$charset_collate}; "; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql_events_table); dbDelta($sql_venuemeta_table); //Add options and capabilities $eventorganiser_options = array('supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), 'event_redirect' => 'events', 'dateformat' => 'dd-mm', 'prettyurl' => 1, 'templates' => 1, 'addtomenu' => 0, 'excludefromsearch' => 0, 'showpast' => 0, 'group_events' => '', 'url_venue' => 'events/event', 'url_venue' => 'events/venues', 'url_cat' => 'events/category', 'url_tag' => 'events/tag', 'navtitle' => __('Events', 'eventorganiser'), 'eventtag' => 1, 'feed' => 1, 'runningisnotpast' => 0, 'deleteexpired' => 0); update_option("eventorganiser_version", $eventorganiser_db_version); add_option('eventorganiser_options', $eventorganiser_options); //Add roles to administrator global $wp_roles, $eventorganiser_roles; $all_roles = $wp_roles->roles; foreach ($all_roles as $role_name => $display_name) { $role = $wp_roles->get_role($role_name); if ($role->has_cap('manage_options')) { foreach ($eventorganiser_roles as $eo_role => $eo_role_display) { $role->add_cap($eo_role); } } } //End foreach $all_roles //Manually register CPT and CTs ready for flushing eventorganiser_create_event_taxonomies(); eventorganiser_cpt_register(); //Flush rewrite rules only on activation, and after CPT/CTs has been registered. flush_rewrite_rules(); }