Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Source for the [Migrate to WordPress.com](https://wordpress.org/plugins/wpcom-mi
## Layout

- `plugin/` — plugin source. The BlogVault tree plus `reprint/`, the Reprint export glue.
- `plugin/reprint/` — `Exporter` (credentials, write veto, `?reprint-api-wpcom-migration`), `Settings_Page` (the Reprint migration screen), `REST_Controller` (provisioning routes), `bootstrap.php`.
- `plugin/reprint/` — `Exporter` (credentials, write veto, `?reprint-api-wpcom-migration`), `Settings_Page` (the Reprint migration screen), `Manual_Page` (the by-hand screen), `REST_Controller` (provisioning routes), `bootstrap.php`.
- `plugin/connection/` — `Connection` (package setup, connect, disconnect), `Connect_Page` (the connection section of the screen), `bootstrap.php`.
- `bin/build.sh` — writes `build/wpcom-migration/` and `build/wpcom-migration.zip`.
- `bin/check-autoload-manifest.php` — asserts which classes the ZIP publishes through the Jetpack autoloader.
- `tests/e2e/` — Playground blueprints and request scripts: one scenario per credential state, one that drives the Reprint migration screen, one that provisions through the REST routes, one that drives the WordPress.com connection.
- `tests/e2e/` — Playground blueprints and request scripts: one scenario per credential state, one that drives the Reprint migration screen, one that provisions through the REST routes, one that drives the WordPress.com connection, one that checks the admin menu, and one that checks the menu on a network.

## Build

Expand All @@ -26,18 +26,26 @@ To activate a source checkout directly (without a build), run `composer install

## The Reprint migration screen

`wp-admin/admin.php?page=wpcom-migration-status` (under the plugin's menu; `manage_options` to view and to set up by hand; the `administrator` role to connect, disconnect, or provision through the routes; single-site only). The screen shows one mode at a time — a heading, one sentence, at most one button, and the links that fit:
`wp-admin/admin.php?page=wpcom-migration-status` (the plugin's one menu entry; `manage_options` to view; the `administrator` role to connect, disconnect, or provision through the routes; single-site only). It carries the old main screen's design: the WordPress mark, a serif heading and one centred column. The screen shows one mode at a time — one sentence saying where the site stands, at most one button, and the links that fit:

| Mode | When | Shows |
|---|---|---|
| Not available on networks | Multisite | Nothing |
| The exporter runs on single sites only | Multisite | Nothing |
| The export secret no longer matches this site | The site's salts changed | *Log in with WordPress.com*, or *Continue on WordPress.com* when connected |
| Exporter on until *time* | A migration is running | *Continue on WordPress.com* and *Disconnect*, when connected |
| Connected as *login* | Logged in; the migration has not started | *Continue on WordPress.com*, a *Disconnect* link |
| Set up by WordPress.com | Provisioned with an application password | A *Log in with WordPress.com* link |
| Connect this site to WordPress.com | Fresh site | *Log in with WordPress.com* |
| The exporter is on until *time* | A migration is running | *Continue on WordPress.com* and *Disconnect*, when connected |
| Connected as *email* | Logged in; the migration has not started | *Continue on WordPress.com*, a *Disconnect* link |
| This site is set up and ready | Provisioned with an application password | A *Log in with WordPress.com* link |
| Log in with your WordPress.com account | Fresh site | *Log in with WordPress.com* |

`Settings_Page::mode()` picks the first that fits, top to bottom. The *Continue* link's target is filtered by `wpcom_migration_continue_url`. Under every mode but the first, a collapsed *Set up by hand* section holds the export secret form, the exporter toggle, the export URL and the WordPress.com blog ID. Deactivating the plugin disconnects and discards the secret and the exporter state.
`Settings_Page::mode()` picks the first that fits, top to bottom. The *Continue* link's target is filtered by `wpcom_migration_continue_url`.

The old BlogVault screen at `wp-admin/admin.php?page=wpcom-migration` is no longer in the sidebar. It stays reachable at its URL.

On a network the old screen keeps its row in the network admin, and the *Settings* link and the activation redirect lead there; subsites get no row. A brand whitelabelled with `hide` or `hide_from_menu` takes away the Reprint screen's row too; the screen stays reachable at its URL.

## Setting up Reprint manually

`wp-admin/admin.php?page=wpcom-migration-manual` (`manage_options`, single-site only). Nothing links to it; support gives out the URL. It holds the export secret form, a *Remove secret* button (which also turns the exporter off), the exporter toggle, the export URL and the WordPress.com blog ID. Deactivating the plugin disconnects and discards the secret and the exporter state.

## How WordPress.com provisions the exporter

Expand Down
1 change: 1 addition & 0 deletions bin/check-autoload-manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
'Automattic\\WPCOM_Migration\\Connect_Page',
'Automattic\\WPCOM_Migration\\Connection',
'Automattic\\WPCOM_Migration\\Reprint\\Exporter',
'Automattic\\WPCOM_Migration\\Reprint\\Manual_Page',
'Automattic\\WPCOM_Migration\\Reprint\\REST_Controller',
'Automattic\\WPCOM_Migration\\Reprint\\Settings_Page',
);
Expand Down
21 changes: 12 additions & 9 deletions plugin/connection/class-connect-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ public function render_connect_button( $primary ) {
<input type="hidden" name="action" value="<?php echo esc_attr( self::CONNECT_ACTION ); ?>" />
<?php wp_nonce_field( self::CONNECT_ACTION ); ?>
<p>
<button type="submit" name="wpcom_migration_connect_submit" class="<?php echo $primary ? 'button button-primary' : 'button-link'; ?>">
<button type="submit" name="wpcom_migration_connect_submit" class="<?php echo $primary ? 'wpcom-migration-button' : 'wpcom-migration-link'; ?>">
<?php esc_html_e( 'Log in with WordPress.com', 'wpcom-migration' ); ?>
</button>
</p>
<p class="description">
<p class="wpcom-migration-description">
<?php
printf(
/* translators: %s: link to the WordPress.com terms of service. */
Expand All @@ -216,7 +216,7 @@ public function render_connect_button( $primary ) {
public function render_continue_button( $primary ) {
?>
<p>
<a<?php echo $primary ? ' class="button button-primary"' : ''; ?> target="_top" href="<?php echo esc_url( self::continue_url() ); ?>">
<a<?php echo $primary ? ' class="wpcom-migration-button"' : ''; ?> target="_top" href="<?php echo esc_url( self::continue_url() ); ?>">
<?php esc_html_e( 'Continue on WordPress.com', 'wpcom-migration' ); ?>
</a>
</p>
Expand All @@ -232,22 +232,25 @@ public function render_disconnect_link() {
<input type="hidden" name="action" value="<?php echo esc_attr( self::DISCONNECT_ACTION ); ?>" />
<?php wp_nonce_field( self::DISCONNECT_ACTION ); ?>
<p>
<button type="submit" name="wpcom_migration_disconnect_submit" class="button-link button-link-delete"><?php esc_html_e( 'Disconnect', 'wpcom-migration' ); ?></button>
<span class="description"><?php esc_html_e( 'Removes this site\'s WordPress.com connection and the export secret WordPress.com installed.', 'wpcom-migration' ); ?></span>
<span class="wpcom-migration-description">
<button type="submit" name="wpcom_migration_disconnect_submit" class="wpcom-migration-link wpcom-migration-link--delete"><?php esc_html_e( 'Disconnect', 'wpcom-migration' ); ?></button>
<?php esc_html_e( 'Removes this site\'s WordPress.com connection and the export secret WordPress.com installed.', 'wpcom-migration' ); ?>
</span>
</p>
</form>
<?php
}

/**
* The WordPress.com login of the connected user, when the package has it.
* The WordPress.com email address of the connected user, when the package
* has it.
*
* @return string|null
*/
public static function connected_login() {
public static function connected_email() {
$user_data = Connection::connected_wpcom_user();
if ( is_array( $user_data ) && ! empty( $user_data['login'] ) ) {
return (string) $user_data['login'];
if ( is_array( $user_data ) && ! empty( $user_data['email'] ) ) {
return (string) $user_data['email'];
}

return null;
Expand Down
2 changes: 2 additions & 0 deletions plugin/reprint/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use Automattic\WPCOM_Migration\Reprint\Exporter;
use Automattic\WPCOM_Migration\Reprint\Manual_Page;
use Automattic\WPCOM_Migration\Reprint\REST_Controller;
use Automattic\WPCOM_Migration\Reprint\Settings_Page;

Expand Down Expand Up @@ -50,6 +51,7 @@ function wpcom_migration_settings_page( ?Settings_Page $page = null ) {

if ( is_admin() ) {
wpcom_migration_settings_page( new Settings_Page( $wpcom_migration_plugin_file ) );
new Manual_Page( $wpcom_migration_plugin_file );
}

unset( $wpcom_migration_plugin_file, $wpcom_migration_reprint_autoloader );
3 changes: 2 additions & 1 deletion plugin/reprint/class-exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ public static function record_event( $event, array $context = array() ) {
* Discards any stored export credentials.
*
* Runs on plugin activation and deactivation, clearing whatever was
* written while protect_options() was not in place.
* written while protect_options() was not in place; on disconnect; and
* from the by-hand screen's Remove secret button.
*/
public static function discard_credentials() {
$had_any = false;
Expand Down
Loading
Loading