-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use WP_DB_Table base class * Update docs
- Loading branch information
Showing
7 changed files
with
458 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
wp-site-aliases/includes/classes/class-wp-db-table-site-aliases.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/** | ||
* Site Aliases Database: WP_DB_Table_Site_Aliases class | ||
* | ||
* @package Plugins/Sites/Aliases/Database/Object | ||
*/ | ||
|
||
// Exit if accessed directly | ||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Setup the global "blog_aliases" database table | ||
* | ||
* @since 5.0.0 | ||
*/ | ||
final class WP_DB_Table_Site_Aliases extends WP_DB_Table { | ||
|
||
/** | ||
* @var string Table name | ||
*/ | ||
protected $name = 'blog_aliases'; | ||
|
||
/** | ||
* @var string Database version | ||
*/ | ||
protected $version = 201703150001; | ||
|
||
/** | ||
* @var boolean This is a global table | ||
*/ | ||
protected $global = true; | ||
|
||
/** | ||
* Setup the database schema | ||
* | ||
* @since 5.0.0 | ||
*/ | ||
protected function set_schema() { | ||
$max_index_length = 191; | ||
$this->schema = "id bigint(20) NOT NULL auto_increment, | ||
blog_id bigint(20) NOT NULL, | ||
domain varchar(255) NOT NULL, | ||
created datetime NOT NULL default '0000-00-00 00:00:00', | ||
status varchar(20) NOT NULL default 'active', | ||
type varchar(20) NOT NULL default 'mask', | ||
PRIMARY KEY (id), | ||
KEY blog_id (blog_id,domain(50),status,type), | ||
KEY domain (domain({$max_index_length}))"; | ||
} | ||
|
||
/** | ||
* Handle schema changes | ||
* | ||
* @since 5.0.0 | ||
*/ | ||
protected function upgrade() { | ||
|
||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
wp-site-aliases/includes/classes/class-wp-db-table-site-aliasmeta.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/** | ||
* Site Alias Meta: WP_DB_Table_Site_Aliasmeta class | ||
* | ||
* @package Plugins/Sites/Aliases/Database/Meta | ||
*/ | ||
|
||
// Exit if accessed directly | ||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Setup the global "blog_aliasmeta" database table | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
final class WP_DB_Table_Site_Aliasmeta extends WP_DB_Table { | ||
|
||
/** | ||
* @var string Table name | ||
*/ | ||
protected $name = 'blog_aliasmeta'; | ||
|
||
/** | ||
* @var string Database version | ||
*/ | ||
protected $version = 201703150001; | ||
|
||
/** | ||
* @var boolean This is a global table | ||
*/ | ||
protected $global = true; | ||
|
||
/** | ||
* Setup the database schema | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
protected function set_schema() { | ||
$max_index_length = 191; | ||
$this->schema = "meta_id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
blog_alias_id bigint(20) NOT NULL, | ||
meta_key varchar(255) DEFAULT NULL, | ||
meta_value longtext DEFAULT NULL, | ||
KEY blog_alias_id (blog_alias_id), | ||
KEY meta_key (meta_key({$max_index_length}))"; | ||
} | ||
|
||
/** | ||
* Handle schema changes | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
protected function upgrade() { | ||
|
||
// 1.0.0 to 2.0.0 | ||
if ( version_compare( (int) $this->db_version, 201609100003, '<=' ) ) { | ||
$this->db->query( "ALTER TABLE {$this->table_name} CHANGE `id` `meta_id` BIGINT(20) NOT NULL AUTO_INCREMENT;" ); | ||
} | ||
} | ||
} |
Oops, something went wrong.