diff --git a/admin.php b/admin.php
deleted file mode 100644
index 31b3f26..0000000
--- a/admin.php
+++ /dev/null
@@ -1,537 +0,0 @@
- title
- * @return array
- */
-function add_site_list_column( $columns ) {
- $columns['mercator_aliases'] = __( 'Aliases', 'mercator' );
- return $columns;
-}
-
-/**
- * Output the site list column
- *
- * @param string $column Column ID
- * @param int $site_id Site ID
- */
-function output_site_list_column( $column, $site_id ) {
- switch ( $column ) {
- case 'mercator_aliases':
- $mappings = Mapping::get_by_site( $site_id );
- if ( ! empty( $mappings ) ) {
- foreach ( $mappings as $mapping ) {
- // Kinda horrible formatting, but matches the existing
- echo esc_html( $mapping->get_domain() ) . '
';
- }
- }
-
- break;
- }
-}
-
-/**
- * Output the site tab if we're on the right page
- *
- * Outputs the link, then moves it into place using JS, as there are no hooks to
- * speak of.
- */
-function maybe_output_site_tab() {
- if ( ! is_network_admin() ) {
- return;
- }
-
- if ( $GLOBALS['parent_file'] !== 'sites.php' || $GLOBALS['submenu_file'] !== 'sites.php' ) {
- return;
- }
-
- $id = isset( $_REQUEST['id'] ) ? absint( $_REQUEST['id'] ) : 0;
- if ( empty( $id ) ) {
- return;
- }
-
- $class = ( ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] === 'mercator-aliases' ) ? ' nav-tab-active' : '';
-
-?>
-
-
-%2$s'), get_blogaddress_by_id( $id ), $site_url_no_http );
-
- // Load the page header
- global $title, $parent_file, $submenu_file;
- $title = sprintf( __( 'Aliases: %s', 'mercator' ), $site_url_no_http );
- $parent_file = 'sites.php';
- $submenu_file = 'sites.php';
- require_once(ABSPATH . 'wp-admin/admin-header.php');
-
- $add_link = add_query_arg(
- array(
- 'action' => 'mercator-add',
- 'id' => $id,
- ),
- network_admin_url( 'admin.php' )
- );
-?>
-
-
' . $msg . '
' . $domain . '';
- }
- else {
- // Note: we still use _n for languages which have special cases on
- // e.g. 3, 5, 10, etc
- $bulk_messages = array(
- 'activate' => _n( '%s alias activated.', '%s aliases activated.', $processed ),
- 'deactivate' => _n( '%s alias deactivated.', '%s aliases deactiaved.', $processed ),
- 'delete' => _n( '%s alias deleted.', '%s aliases deleted.', $processed ),
- 'add' => _n( '%s alias created.', '%s aliases created.', $processed ),
- 'edit' => _n( '%s alias updated.', '%s aliases updated.', $processed ),
- );
- $placeholder = number_format_i18n( $processed );
- }
- $bulk_messages = apply_filters( 'mercator_aliases_bulk_messages', $bulk_messages, $processed );
-
- if ( ! empty( $bulk_messages[ $did_action ] ) ) {
- $messages[] = sprintf( $bulk_messages[ $did_action ], $placeholder );
- }
- }
-
- output_page_header( $id, $messages );
-
-?>
-
-site_id ) ) {
- return new WP_Error( 'mercator.params.cannot_edit', __( 'You do not have permission to edit this site', 'mercator' ) );
- }
- }
-
- // Validate active flag
- $valid['active'] = empty( $params['active'] ) ? false : true;
-
- return $valid;
-}
-
-/**
- * Handle submission of the add page
- *
- * @return array|null List of errors. Issues a redirect and exits on success.
- */
-function handle_edit_page_submit( $id, $mapping ) {
- $messages = array();
- if ( empty( $mapping ) ) {
- $did_action = 'add';
- check_admin_referer( 'mercator-add-' . $id );
- }
- else {
- $did_action = 'edit';
- check_admin_referer( 'mercator-edit-' . $mapping->get_id() );
- }
-
- // Check that the parameters are correct first
- $params = validate_alias_parameters( wp_unslash( $_POST ) );
- if ( is_wp_error( $params ) ) {
- $messages[] = $params->get_error_message();
-
- if ( $params->get_error_code() === 'mercator.params.domain_invalid_chars' ) {
- $messages[] = __( 'Note: for internationalized domain names, use the ASCII form (e.g, xn--bcher-kva.example)', 'mercator' );
- }
-
- return $messages;
- }
- if ( empty( $mapping ) ) {
- // Create the actual mapping
- $result = $mapping = Mapping::create( $params['site'], $params['domain'], $params['active'] );
- }
- else {
- // Update our existing
- $result = $mapping->update( $params );
- }
-
- if ( is_wp_error( $result ) ) {
- $messages[] = $result->get_error_message();
-
- return $messages;
- }
-
- // Success, redirect to alias page
- $location = add_query_arg(
- array(
- 'action' => 'mercator-aliases',
- 'id' => $id,
- 'did_action' => $did_action,
- 'mappings' => $mapping->get_id(),
- 'processed' => 1,
- '_wpnonce' => wp_create_nonce( 'mercator-alias-added-' . $mapping->get_id() ),
- ),
- network_admin_url( 'admin.php' )
- );
- wp_safe_redirect( $location );
- exit;
-}
-
-/**
- * Output alias editing page
- */
-function output_edit_page() {
-
- $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
-
- if ( ! $id )
- wp_die( __('Invalid site ID.') );
-
- $id = absint( $id );
-
- $details = get_blog_details( $id );
- if ( ! can_edit_network( $details->site_id ) || (int) $details->blog_id !== $id )
- wp_die( __( 'You do not have permission to access this page.' ) );
-
- // Are we editing?
- $mapping = null;
- $form_action = network_admin_url( 'admin.php?action=mercator-add' );
- if ( ! empty( $_REQUEST['mapping'] ) ) {
- $mapping_id = absint( $_REQUEST['mapping'] );
- $mapping = Mapping::get( $mapping_id );
- if ( is_wp_error( $mapping ) || empty( $mapping ) ) {
- wp_die( __( 'Invalid alias ID.', 'mercator' ) );
- }
-
- $form_action = network_admin_url( 'admin.php?action=mercator-edit' );
- }
-
- // Handle form submission
- $messages = array();
- if ( ! empty( $_POST['submit'] ) ) {
- $messages = handle_edit_page_submit( $id, $mapping );
- }
-
- output_page_header( $id, $messages );
-
- if ( empty( $mapping ) || ! empty( $_POST['_wpnonce'] ) ) {
- $domain = empty( $_POST['domain'] ) ? '' : wp_unslash( $_POST['domain'] );
- $active = ! empty( $_POST['active'] );
- }
- else {
- $domain = $mapping->get_domain();
- $active = $mapping->is_active();
- }
-
-?>
-
-' . sprintf(
- __( 'Enhanced by Mercator', 'mercator' ),
- 'https://github.com/humanmade/Mercator',
- sprintf(
- __( 'Version %s', 'mercator' ),
- \Mercator\VERSION
- )
- ) . '';
- array_unshift( $meta, $note );
- return $meta;
-}
diff --git a/inc/admin/class-alias-list-table.php b/inc/admin/class-alias-list-table.php
deleted file mode 100644
index bd66fc2..0000000
--- a/inc/admin/class-alias-list-table.php
+++ /dev/null
@@ -1,244 +0,0 @@
-items = array();
-
- if ( empty( $this->_args['site_id'] ) ) {
- return;
- }
-
- $id = $this->_args['site_id'];
- $mappings = Mapping::get_by_site( $id );
- if ( is_wp_error( $mappings ) ) {
- \Mercator\warn_with_message( __( 'Could not fetch aliases for the site. This may indicate a database error.', 'mercator' ) );
- }
- if ( ! empty( $mappings ) ) {
- $this->items = $mappings;
- }
- }
-
- /**
- * Get columns for the table
- *
- * @return array Map of column ID => title
- */
- public function get_columns() {
- return array(
- 'cb' => '',
- 'domain' => _x( 'Domain', 'mercator' ),
- 'active' => _x( 'Active', 'mercator' ),
- );
- }
-
- /**
- * Get an associative array ( option_name => option_title ) with the list
- * of bulk actions available on this table.
- *
- * @since 3.1.0
- * @access protected
- *
- * @return array
- */
- protected function get_bulk_actions() {
- $actions = array(
- 'activate' => _x( 'Activate', 'mercator' ),
- 'deactivate' => _x( 'Deactivate', 'mercator' ),
- 'delete' => _x( 'Delete', 'mercator' ),
- );
-
- return apply_filters( 'mercator_alias_bulk_actions', $actions );
- }
-
- /**
- * Display the bulk actions dropdown.
- *
- * @since 3.1.0
- * @access protected
- *
- * @param string $which The location of the bulk actions: 'top' or 'bottom'.
- * This is designated as optional for backwards-compatibility.
- */
- protected function bulk_actions( $which = '' ) {
- if ( is_null( $this->_actions ) ) {
- $no_new_actions = $this->_actions = $this->get_bulk_actions();
- /**
- * Filter the list table Bulk Actions drop-down.
- *
- * The dynamic portion of the hook name, $this->screen->id, refers
- * to the ID of the current screen, usually a string.
- *
- * This filter can currently only be used to remove bulk actions.
- *
- * @since 3.5.0
- *
- * @param array $actions An array of the available bulk actions.
- */
- $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
- $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
- $two = '';
- echo '';
- wp_nonce_field( 'mercator-aliases-bulk-' . $this->_args['site_id'] );
- } else {
- $two = '2';
- }
-
- if ( empty( $this->_actions ) )
- return;
-
- echo "";
- echo "\n";
-
- submit_button( __( 'Apply' ), 'action', false, false, array( 'id' => "doaction$two" ) );
- echo "\n";
- }
-
- /**
- * Get the current action selected from the bulk actions dropdown.
- *
- * @since 3.1.0
- * @access public
- *
- * @return string|bool The action name or False if no action was selected
- */
- public function current_action() {
- if ( isset( $_REQUEST['bulk_action'] ) && -1 != $_REQUEST['bulk_action'] )
- return $_REQUEST['bulk_action'];
-
- if ( isset( $_REQUEST['bulk_action2'] ) && -1 != $_REQUEST['bulk_action2'] )
- return $_REQUEST['bulk_action2'];
-
- return false;
- }
-
- /**
- * Output extra "navigation" fields (section before/after the table)
- *
- * Outputs our Add New button above the table
- *
- * @param string $which Which tablenav to use (top/bottom)
- */
- protected function extra_tablenav( $which ) {
- global $status;
-
- if ( $which !== 'top' )
- return;
-
- $add_link = add_query_arg(
- array(
- 'action' => 'mercator-add',
- 'id' => $this->_args['site_id'],
- ),
- network_admin_url( 'admin.php' )
- );
- echo '