Index: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-organizer-reminders/wordcamp-organizer-reminders.php
===================================================================
--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-organizer-reminders/wordcamp-organizer-reminders.php	(revision 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-organizer-reminders/wordcamp-organizer-reminders.php	(working copy)
@@ -0,0 +1,87 @@
+<?php
+
+/*
+ * Plugin Name: WordCamp Organizer Reminders
+ * Description: Automatically e-mail WordCamp organizers with various reminders at specified intervals.
+ * Version:     0.1
+ * Author:      Ian Dunn 
+ */
+
+class WordCampOrganizerReminders {
+	var $emails = array(
+		// The index is the number of days before the event that the e-mail should be sent
+		3 => array(
+			'subject' => 'Camera Kits',
+			'body'    => 'Did you remember to do something with the camera kits?'
+		),
+		
+		4 => array(
+			'subject' => 'Venue Insurance',
+			'body'    => 'Did you remember to get venue insurance?'
+		)
+	);
+
+	/**
+	 * Constructor
+	 */
+	public function __construct() {
+		$this->emails = apply_filters( 'wcor_emails', $this->emails );
+		add_action( 'wcor_send_emails', array( $this, 'send_emails' ) );
+	}
+
+	/**
+	 * Schedule cron job when plugin is activated  
+	 */
+	public function activate() {
+		if ( wp_next_scheduled( 'wcor_send_emails' ) === false ) {
+			wp_schedule_event(
+				current_time( 'timestamp' ),
+				'daily',
+				'wcor_send_emails'
+			);
+		}
+	}
+	
+	/**
+	 * Clear cron job when plugin is deactivated
+	 */
+	public function deactivate() {
+		wp_clear_scheduled_hook( 'wcor_send_emails' );
+	}
+
+	/**
+	 * Send the email reminders
+	 */
+	public function send_emails() {
+		$upcoming_wordcamps = get_posts( array(
+			'posts_per_page'  => -1,
+			'post_type'       => 'wordcamp',
+			'meta_query'      => array(
+				array(
+					'key'     => 'Start Date (YYYY-mm-dd)',
+					'value'   => current_time( 'timestamp' ),
+					'compare' => '>=',
+				)
+			)
+		) );
+		
+		foreach( $upcoming_wordcamps as $wordcamp ) {
+			$organizers_email          = get_post_meta( $wordcamp->ID, 'E-mail Address', true );
+			$number_of_days_until_camp = floor( ( get_post_meta( $wordcamp->ID, 'Start Date (YYYY-mm-dd)', true ) - current_time( 'timestamp' ) ) / DAY_IN_SECONDS );
+			
+			if ( isset( $this->emails[ $number_of_days_until_camp ] ) && is_email( $organizers_email ) ) {
+				wp_mail(
+					$organizers_email,
+					$wordcamp->post_title .' Reminder: ' . $this->emails[ $number_of_days_until_camp ]['subject'],
+					$this->emails[ $number_of_days_until_camp ]['body']
+				);
+				
+				sleep( 1 ); // don't send e-mails too fast, or it might increase the risk of being flagged as spam
+			}
+		}
+	}
+}
+
+$GLOBALS['WordCampOrganizerReminders'] = new WordCampOrganizerReminders();
+register_activation_hook(   __FILE__, array( $GLOBALS['WordCampOrganizerReminders'], 'activate' ) );
+register_deactivation_hook( __FILE__, array( $GLOBALS['WordCampOrganizerReminders'], 'deactivate' ) );
\ No newline at end of file
