Skip to content

Commit

Permalink
Bump to 5.0.0.
Browse files Browse the repository at this point in the history
* Use WP_DB_Table base class
* Update docs
  • Loading branch information
JJJ committed Mar 15, 2017
1 parent 8535411 commit 0f19743
Show file tree
Hide file tree
Showing 7 changed files with 458 additions and 267 deletions.
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: johnjamesjacoby, stuttter
Tags: blog, site, meta, multisite, alias, domain, mapping
Requires at least: 4.5
Tested up to: 4.8
Stable tag: 4.0.0
Stable tag: 5.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9Q4F4EL5YJ62J
Expand Down Expand Up @@ -74,7 +74,10 @@ https://github.com/stuttter/wp-site-aliases/

== Changelog ==

= [4.0.0] - 2017-03-17 =
= [5.0.0] - 2017-03-17 =
* Extend the WP_DB_Table base class

= [4.0.0] - 2017-02-17 =
* Single-site support

= [3.0.0] - 2016-12-06 =
Expand Down
26 changes: 12 additions & 14 deletions wp-site-aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

/**
* Plugin Name: WP Site Aliases
* Plugin URI: http:https://wordpress.org/plugins/wp-site-aliases/
* Plugin URI: https:https://wordpress.org/plugins/wp-site-aliases/
* Author: John James Jacoby
* Author URI: https://profiles.wordpress.org/johnjamesjacoby/
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Description: User-defined site-aliases for your multisite installation
* Version: 3.0.0
* Version: 5.0.0
* Text Domain: wp-site-aliases
* Domain Path: /wp-site-aliases/assets/languages/
*/
Expand All @@ -30,9 +30,11 @@ function _wp_site_aliases() {
$plugin_path = wp_site_aliases_get_plugin_path();

// Classes
require_once $plugin_path . 'includes/classes/class-wp-db-table.php';
require_once $plugin_path . 'includes/classes/class-wp-db-table-site-aliases.php';
require_once $plugin_path . 'includes/classes/class-wp-db-table-site-aliasmeta.php';
require_once $plugin_path . 'includes/classes/class-wp-site-alias.php';
require_once $plugin_path . 'includes/classes/class-wp-site-alias-query.php';
require_once $plugin_path . 'includes/classes/class-wp-site-aliases-db-tables.php';

// Required Files
require_once $plugin_path . 'includes/functions/abstraction.php';
Expand All @@ -51,20 +53,16 @@ function _wp_site_aliases() {
require_once ABSPATH . WPINC . '/class-wp-network.php';
}

// Register database table
if ( empty( $GLOBALS['wpdb']->blog_aliases ) ) {
$GLOBALS['wpdb']->blog_aliases = "{$GLOBALS['wpdb']->base_prefix}blog_aliases";
$GLOBALS['wpdb']->blog_aliasmeta = "{$GLOBALS['wpdb']->base_prefix}blog_aliasmeta";
$GLOBALS['wpdb']->ms_global_tables[] = 'blog_aliases';
$GLOBALS['wpdb']->ms_global_tables[] = 'blog_aliasmeta';
}
// Tables
new WP_DB_Table_Site_Aliasmeta();
new WP_DB_Table_Site_Aliases();

// Register global cache group
wp_cache_add_global_groups( array( 'blog-aliases', 'blog_alias_meta' ) );
}

/**
* Return the path to the plugin's root file
* Return the path to the plugin root file
*
* @since 1.0.0
*
Expand All @@ -75,7 +73,7 @@ function wp_site_aliases_get_plugin_file() {
}

/**
* Return the path to the plugin's directory
* Return the path to the plugin directory
*
* @since 1.0.0
*
Expand All @@ -86,7 +84,7 @@ function wp_site_aliases_get_plugin_path() {
}

/**
* Return the plugin's URL
* Return the plugin URL
*
* @since 1.0.0
*
Expand All @@ -104,5 +102,5 @@ function wp_site_aliases_get_plugin_url() {
* @return int
*/
function wp_site_aliases_get_asset_version() {
return 201612060003;
return 201703150001;
}
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() {

}
}
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;" );
}
}
}
Loading

0 comments on commit 0f19743

Please sign in to comment.