diff --git a/inc/admin/namespace.php b/inc/admin/namespace.php index d64d365..17ccf46 100644 --- a/inc/admin/namespace.php +++ b/inc/admin/namespace.php @@ -2,19 +2,28 @@ namespace MiniFAIR\Admin; +use Exception; use MiniFAIR; -use MiniFAIR\PLC\DID; use MiniFAIR\Keys; +use MiniFAIR\PLC\DID; use WP_Post; -const NONCE_CREATE_ACTION = 'minifair_create'; -const NONCE_SYNC_ACTION = 'minifair_sync'; +const ACTION_CREATE = 'create'; +const ACTION_EXPORT = 'export'; +const ACTION_IMPORT = 'import'; +const ACTION_KEY_ADD = 'key_add'; +const ACTION_KEY_REVOKE = 'key_revoke'; +const ACTION_SYNC = 'sync'; +const NONCE_PREFIX = 'minifair_'; const PAGE_SLUG = 'minifair'; function bootstrap() { // Register the admin menu and page before the PLC DID post type is registered. add_action( 'admin_menu', __NAMESPACE__ . '\\add_admin_menu', 0 ); - add_action( 'post_action_sync', __NAMESPACE__ . '\\maybe_on_sync' ); + add_action( 'post_action_' . ACTION_EXPORT, __NAMESPACE__ . '\\handle_action', 10, 1 ); + add_action( 'post_action_' . ACTION_KEY_ADD, __NAMESPACE__ . '\\handle_action', 10, 1 ); + add_action( 'post_action_' . ACTION_KEY_REVOKE, __NAMESPACE__ . '\\handle_action', 10, 1 ); + add_action( 'post_action_' . ACTION_SYNC, __NAMESPACE__ . '\\handle_action', 10, 1 ); // Hijack the post-new.php page to render our own form. add_action( 'replace_editor', function ( $res, WP_Post $post ) { @@ -44,6 +53,15 @@ function add_admin_menu() { } function load_settings_page() { + if ( ! isset( $_POST['action'] ) ) { + return; + } + + switch ( $_POST['action'] ) { + case ACTION_IMPORT: + on_import(); + break; + } } function render_settings_page() { @@ -115,6 +133,8 @@ function render_settings_page() { +
@@ -122,10 +142,71 @@ function render_settings_page() {
+ + + += wp_kses_post( __( 'Note: Registering a single DID with multiple sites may break your DID.', 'minifair' ) ); ?>
+