# updraftcentral/0.3.5/classes/activation.php

UpdraftCentral Dashboard, version 0.3.5. 85 lines.

- Page: https://pluginprobe.com/plugins/updraftcentral/0.3.5/code/classes/activation.php
- Raw: https://pluginprobe.com/plugins/updraftcentral/0.3.5/raw/classes/activation.php
- Modified: 2016-03-31T11:12:04+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/updraftcentral/0.3.5/code/classes/activation.php#L10-L20`.

```php
<?php

if (!defined('UD_CENTRAL_DIR')) die('Security check');

class UpdraftCentral_Activation {

	private $table_prefix;

	public function __construct() {
		$this->table_prefix = defined('UPDRAFTCENTRAL_TABLE_PREFIX') ? UPDRAFTCENTRAL_TABLE_PREFIX : 'updraftcentral_';
		$this->create_tables();
	}

	public function create_tables() {
		global $wpdb;

// 		$wpdb->hide_errors();

		$our_prefix = $wpdb->prefix.$this->table_prefix;
		$collate = '';

		if ( $wpdb->has_cap( 'collation' ) ) {
			if ( ! empty($wpdb->charset ) ) {
				$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
			}
			if ( ! empty($wpdb->collate ) ) {
				$collate .= " COLLATE $wpdb->collate";
			}
		}

		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );

		// Important: obey the magical/arbitrary rules for formatting this stuff: https://codex.wordpress.org/Creating_Tables_with_Plugins
		// Otherwise, you get SQL errors and unwanted header output warnings when activating
		
		$create_tables = "CREATE TABLE ".$our_prefix."sites (
			site_id bigint(20) NOT NULL auto_increment,
			user_id bigint(20) NOT NULL,
			url varchar(300) NOT NULL,
			key_local_private blob,
			key_remote_public blob,
			key_name_indicator varchar(200) NOT NULL,
			description text,
			sequence_id bigint(20) DEFAULT 0,
			remote_user_id bigint(20) NOT NULL,
			remote_user_login varchar(60),
			remote_site_id bigint(20) DEFAULT 0,
			connection_method varchar(30),
			send_cors_headers tinyint(1) DEFAULT 1,
			PRIMARY KEY  (site_id),
			KEY user_id (user_id),
			KEY url (url)
			) $collate;
		";
		// KEY attribute_name (attribute_name)
		dbDelta($create_tables);

		$create_tables = "CREATE TABLE ".$our_prefix."site_temporary_keys (
			key_id bigint(20) NOT NULL auto_increment,
			key_local_private blob,
			key_remote_public blob,
			created bigint(20),
			PRIMARY KEY  (key_id),
			KEY created (created)
			) $collate;
		";
		
		dbDelta($create_tables);

		$max_index_length = 191;
		$create_tables = "CREATE TABLE ".$our_prefix."sitemeta (
			meta_id bigint(20) NOT NULL auto_increment,
			site_id bigint(20) NOT NULL default '0',
			meta_key varchar(255) default NULL,
			meta_value longtext,
			PRIMARY KEY  (meta_id),
			KEY meta_key (meta_key($max_index_length)),
			KEY site_id (site_id)
			) $collate;
		";

		dbDelta($create_tables);
	}
}

```
