/
home
/
altere25
/
.trash
/
wp-to-sanity-migration.10
/
/home/altere25/.trash/wp-to-sanity-migration.10
mkdir
upload
Name
Size
Mode
Actions
acf-json\.gitkeep
0
0644
edit
dl
rm
assets\css\admin.css
12113
0644
edit
dl
rm
assets\js\admin.js
52894
0644
edit
dl
rm
includes\class-ad-admin.php
10358
0644
edit
dl
rm
includes\class-ad-ai-client.php
10724
0644
edit
dl
rm
includes\class-ad-auth.php
9189
0644
edit
dl
rm
includes\class-ad-cli.php
8671
0644
edit
dl
rm
includes\class-ad-extractor.php
17237
0644
edit
dl
rm
includes\class-ad-mcp.php
6429
0644
edit
dl
rm
includes\class-ad-plugin-core.php
10252
0644
edit
dl
rm
includes\class-ad-progress.php
8022
0644
edit
dl
rm
includes\class-ad-rest.php
43443
0644
edit
dl
rm
includes\class-ad-uninstall.php
1966
0644
edit
dl
rm
includes\class-ad-webhook.php
24172
0644
edit
dl
rm
languages\.gitkeep
0
0644
edit
dl
rm
templates\admin\wizard.php
29414
0644
edit
dl
rm
wp-to-sanity-migration\acf-json\.gitkeep
0
0644
edit
dl
rm
wp-to-sanity-migration\assets\
0
0644
edit
dl
rm
wp-to-sanity-migration\assets\css\admin.css
12113
0644
edit
dl
rm
wp-to-sanity-migration\assets\js\admin.js
52894
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-admin.php
10358
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-ai-client.php
10724
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-auth.php
9189
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-cli.php
8671
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-extractor.php
17237
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-mcp.php
6429
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-plugin-core.php
10252
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-progress.php
8022
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-rest.php
43443
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-uninstall.php
1966
0644
edit
dl
rm
wp-to-sanity-migration\includes\class-ad-webhook.php
24172
0644
edit
dl
rm
wp-to-sanity-migration\languages\.gitkeep
0
0644
edit
dl
rm
wp-to-sanity-migration\package.json
220
0644
edit
dl
rm
wp-to-sanity-migration\readme.txt
8174
0644
edit
dl
rm
wp-to-sanity-migration\templates\
0
0644
edit
dl
rm
wp-to-sanity-migration\templates\admin\wizard.php
29414
0644
edit
dl
rm
wp-to-sanity-migration\uninstall.php
365
0644
edit
dl
rm
wp-to-sanity-migration\wp-to-sanity-migration.php
4418
0644
edit
dl
rm
Edit:
/home/altere25/.trash/wp-to-sanity-migration.10/includes\class-ad-admin.php
(10358B)
<?php /** * Altered Digital Migration — Admin UI * * Single unified wizard replaces all previous admin pages. One menu, * one page, one linear 10-step flow. Back-compat menu slug preserved * so existing bookmarks keep working. * * @package AlteredDigitalMigration */ if (!defined('ABSPATH')) { exit; } class AD_Admin { /** @var AD_Plugin_Core */ private $core; /** @var AD_Progress */ private $progress; public function __construct(AD_Plugin_Core $core, AD_Progress $progress) { $this->core = $core; $this->progress = $progress; } public function register_hooks(): void { add_action('admin_menu', [$this, 'add_admin_menu']); add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_assets']); add_action('admin_notices', [$this, 'admin_notices']); // Multisite network admin page (only renders when network-activated). add_action('network_admin_menu', [$this, 'add_network_admin_menu']); add_action('network_admin_edit_ad_network_settings', [$this, 'handle_network_settings_save']); } // ----------------------------------------------------------------- // Menus // ----------------------------------------------------------------- public function add_admin_menu(): void { // Single menu — the unified wizard. Slug stays 'wp-to-sanity' for // back-compat so existing bookmarks keep working. add_menu_page( __('WP to Sanity', 'wp-to-sanity-migration'), __('WP to Sanity', 'wp-to-sanity-migration'), 'manage_options', 'wp-to-sanity', [$this, 'render_wizard_page'], 'dashicons-migrate', 80 ); } // ----------------------------------------------------------------- // Assets // ----------------------------------------------------------------- public function enqueue_admin_assets(string $hook): void { // Only load on the wizard page (toplevel_page_wp-to-sanity). if ($hook !== 'toplevel_page_wp-to-sanity') { return; } wp_enqueue_style('ad-admin', AD_PLUGIN_URL . 'assets/css/admin.css', [], AD_VERSION); wp_enqueue_script('ad-admin', AD_PLUGIN_URL . 'assets/js/admin.js', ['jquery'], AD_VERSION, true); wp_localize_script('ad-admin', 'wpToSanity', [ 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('wp_to_sanity_admin'), 'restUrl' => rest_url('altered-digital/v1/'), 'restUrlV1' => rest_url('wp-to-sanity/v1/'), 'restNonce' => wp_create_nonce('wp_rest'), // Hosted T&C page (Phase B). Defaults to the docs site; filterable. 'tcUrl' => apply_filters('altered_digital_terms_url', 'https://docs.altereddigital.io/terms'), ]); } // ----------------------------------------------------------------- // Notices // ----------------------------------------------------------------- public function admin_notices(): void { $tenant_id = $this->core->setting('tenant_id', ''); $webhook_url = $this->core->setting('webhook_url', ''); if (empty($tenant_id) && empty($webhook_url)) { echo '<div class="notice notice-warning is-dismissible"><p>' . '<a href="' . esc_url(admin_url('admin.php?page=wp-to-sanity')) . '">' . esc_html__('WP to Sanity: Complete the migration wizard to get started.', 'wp-to-sanity-migration') . '</a></p></div>'; } if (!function_exists('acf')) { echo '<div class="notice notice-info is-dismissible"><p>' . esc_html__('WP to Sanity: ACF Pro is recommended for full field migration support.', 'wp-to-sanity-migration') . '</p></div>'; } } // ----------------------------------------------------------------- // Wizard renderer // ----------------------------------------------------------------- public function render_wizard_page(): void { $settings = $this->core->settings(); $post_types = get_post_types(['public' => true], 'objects'); $taxonomies = get_taxonomies(['public' => true], 'objects'); include AD_PLUGIN_DIR . 'templates/admin/wizard.php'; } // ----------------------------------------------------------------- // Multisite network admin // ----------------------------------------------------------------- /** * Network admin menu — only added when the plugin is network-activated. * Lets the network admin push product-wide settings (Supabase, AI service * URL) to every subsite in one shot. Per-site overrides still win for * site-specific keys (webhook_secret, tenant_id, post_types). */ public function add_network_admin_menu(): void { if (!$this->core->is_network_activated()) { return; } add_menu_page( __('WP to Sanity', 'wp-to-sanity-migration'), __('WP to Sanity', 'wp-to-sanity-migration'), 'manage_network_options', 'ad-network-settings', [$this, 'render_network_settings_page'], 'dashicons-migrate', 80 ); } public function render_network_settings_page(): void { $sites = get_sites(['number' => 0]); $pushed = isset($_GET['pushed']) ? absint($_GET['pushed']) : 0; ?> <div class="wrap"> <h1><?php echo esc_html__('WP to Sanity — Network Settings', 'wp-to-sanity-migration'); ?></h1> <p class="description"> <?php echo esc_html__('Push product-wide settings (Supabase URL, AI Service URL) to every subsite. Per-site settings (webhook secret, tenant id, post types) are preserved.', 'wp-to-sanity-migration'); ?> </p> <?php if ($pushed > 0): ?> <div class="notice notice-success is-dismissible"><p><?php echo esc_html(sprintf(__('Settings pushed to %d sites.', 'wp-to-sanity-migration'), $pushed)); ?></p></div> <?php endif; ?> <form method="post" action="edit.php?action=ad_network_settings"> <?php wp_nonce_field('ad_network_settings'); ?> <table class="form-table"> <tr> <th scope="row"><label for="supabase_url"><?php echo esc_html__('Supabase URL', 'wp-to-sanity-migration'); ?></label></th> <td><input type="url" name="supabase_url" id="supabase_url" value="<?php echo esc_attr($this->core->setting('supabase_url', '')); ?>" class="regular-text"></td> </tr> <tr> <th scope="row"><label for="supabase_anon_key"><?php echo esc_html__('Supabase Anon Key', 'wp-to-sanity-migration'); ?></label></th> <td><input type="text" name="supabase_anon_key" id="supabase_anon_key" value="<?php echo esc_attr($this->core->setting('supabase_anon_key', '')); ?>" class="regular-text"></td> </tr> <tr> <th scope="row"><label for="ai_service_url"><?php echo esc_html__('AI Service URL', 'wp-to-sanity-migration'); ?></label></th> <td><input type="url" name="ai_service_url" id="ai_service_url" value="<?php echo esc_attr($this->core->setting('ai_service_url', '')); ?>" class="regular-text"></td> </tr> </table> <p class="submit"><input type="submit" class="button button-primary" value="<?php echo esc_attr__('Push to all sites', 'wp-to-sanity-migration'); ?>"></p> </form> <h2><?php echo esc_html__('Sites', 'wp-to-sanity-migration'); ?></h2> <table class="widefat"> <thead><tr><th><?php echo esc_html__('Site', 'wp-to-sanity-migration'); ?></th><th><?php echo esc_html__('Tenant ID', 'wp-to-sanity-migration'); ?></th><th><?php echo esc_html__('Webhook URL', 'wp-to-sanity-migration'); ?></th></tr></thead> <tbody> <?php foreach ($sites as $site): ?> <?php switch_to_blog((int) $site->blog_id); $tenant = get_option('ad_settings', [])['tenant_id'] ?? ''; $wh = get_option('ad_settings', [])['webhook_url'] ?? ''; restore_current_blog(); ?> <tr> <td><?php echo esc_html($site->blogname . ' (' . $site->domain . $site->path . ')'); ?></td> <td><?php echo esc_html($tenant ?: '—'); ?></td> <td><?php echo esc_html($wh ?: '—'); ?></td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php } /** * Handle the network settings form submission. Pushes the product-wide * keys to every subsite's ad_settings option, preserving site-specific keys. */ public function handle_network_settings_save(): void { check_admin_referer('ad_network_settings'); if (!current_user_can('manage_network_options')) { wp_die(__('Insufficient permissions.', 'wp-to-sanity-migration')); } $push = [ 'supabase_url' => esc_url_raw($_POST['supabase_url'] ?? ''), 'supabase_anon_key' => sanitize_text_field($_POST['supabase_anon_key'] ?? ''), 'ai_service_url' => esc_url_raw($_POST['ai_service_url'] ?? ''), ]; $sites = get_sites(['fields' => 'ids', 'number' => 0]); $pushed = 0; foreach ($sites as $site_id) { switch_to_blog((int) $site_id); $existing = get_option('ad_settings', []); if (!is_array($existing)) { $existing = []; } // Merge — push keys overwrite, site-specific keys preserved. $merged = array_merge($existing, $push); update_option('ad_settings', $merged); restore_current_blog(); $pushed++; } wp_safe_redirect( add_query_arg(['page' => 'ad-network-settings', 'pushed' => $pushed], network_admin_url('admin.php')) ); exit; } }
Save
cmd:
run