} /** * Load the plugin, if we meet requirements. * @filter plugins_loaded */ public static function load() { require_once self::$directory_path . 'includes/class-evaluate-metric-type.php'; require_once self::$directory_path . 'includes/class-evaluate-metrics.php'; require_once self::$directory_path . 'includes/class-evaluate-voting.php'; if (is_admin()) { require_once self::$directory_path . 'admin/class-evaluate-manager.php'; require_once self::$directory_path . 'admin/class-evaluate-shortcodes.php'; require_once self::$directory_path . 'admin/class-evaluate-metric-table.php'; } require_once self::$directory_path . 'includes/class-evaluate-settings.php'; } public static function activate() { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $sql = "CREATE TABLE " . self::$metric_table . " (\n\t\t\tmetric_id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\tname varchar(64) NOT NULL,\n\t\t\ttype varchar(10) NOT NULL DEFAULT 'one-way',\n\t\t\toptions blob NOT NULL,\n\t\t\trestrictions tinyint(1) NOT NULL DEFAULT '1',\n\t\t\tcreated timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\tmodified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY (metric_id) );"; dbDelta($sql); // TODO: We need a way to store metric votes. Maybe they should be individually stored. Maybe add a 'field_id' column $sql = "CREATE TABLE " . self::$voting_table . " (\n\t\t\tmetric_id int(11) NOT NULL,\n\t\t\tcontext_id varchar(40) NOT NULL,\n\t\t\tuser_id varchar(40) NOT NULL,\n\t\t\tvote tinyblob NOT NULL,\n\t\t\tdate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY (metric_id, context_id, user_id) );"; dbDelta($sql); $sql = "CREATE TABLE " . self::$scores_table . " (\n\t\t\tmetric_id int(11) NOT NULL,\n\t\t\tcontext_id varchar(40) NOT NULL,\n\t\t\tcount int(11) NOT NULL,\n\t\t\tvalue float NOT NULL,\n\t\t\taverage float NOT NULL,\n\t\t\tdata blob NOT NULL,\n\t\t\tPRIMARY KEY (metric_id, context_id) );"; dbDelta($sql); } } Evaluate::init();