/
home
/
altere25
/
.trash
/
wp-to-sanity-companion-1
/
/home/altere25/.trash/wp-to-sanity-companion-1
mkdir
upload
Name
Size
Mode
Actions
assets\css\admin.css
7611
0644
edit
dl
rm
assets\js\admin.js
8534
0644
edit
dl
rm
assets\js\claude-connect.js
6502
0644
edit
dl
rm
includes\class-ad-admin.php
26374
0644
edit
dl
rm
includes\class-ad-ai-client.php
8153
0644
edit
dl
rm
includes\class-ad-auth.php
9189
0644
edit
dl
rm
includes\class-ad-cli.php
8669
0644
edit
dl
rm
includes\class-ad-extractor.php
12210
0644
edit
dl
rm
includes\class-ad-mcp.php
6429
0644
edit
dl
rm
includes\class-ad-plugin-core.php
7947
0644
edit
dl
rm
includes\class-ad-progress.php
8022
0644
edit
dl
rm
includes\class-ad-rest.php
31008
0644
edit
dl
rm
includes\class-ad-uninstall.php
1924
0644
edit
dl
rm
includes\class-ad-webhook.php
14854
0644
edit
dl
rm
package.json
220
0644
edit
dl
rm
templates\admin\claude-connect.php
5152
0644
edit
dl
rm
templates\admin\dashboard.php
10457
0644
edit
dl
rm
templates\admin\export.php
16570
0644
edit
dl
rm
templates\admin\log.php
10849
0644
edit
dl
rm
templates\admin\onboarding-v2.php
3827
0644
edit
dl
rm
templates\admin\onboarding.php
10714
0644
edit
dl
rm
templates\admin\progress.php
2443
0644
edit
dl
rm
templates\admin\schema-preview.php
5213
0644
edit
dl
rm
uninstall.php
365
0644
edit
dl
rm
wp-to-sanity-companion.php
4269
0644
edit
dl
rm
Edit:
/home/altere25/.trash/wp-to-sanity-companion-1/templates\admin\onboarding.php
(10714B)
<?php /** * Onboarding / Connect wizard template * * 3-step self-service connection flow: * 1. Enter Service URL + Admin Token + Webhook Secret * 2. Handshake (server-side wp_remote_post to {service_url}/connect) * 3. Test connection (server-side wp_remote_get to {service_url}/health) * * All browser→Worker calls are proxied through WP REST (handle_connect / * handle_connect_test), which perform wp_remote_* server-side. The admin * token is therefore never exposed to the browser beyond this form. * * @package WPtoSanity */ if (!defined('ABSPATH')) { exit; } $plugin = WP_to_Sanity_Plugin::get_instance(); $settings = $plugin->settings(); $service_url = $settings['service_url'] ?? ''; $webhook_secret = $settings['webhook_secret'] ?? ''; $webhook_url = $settings['webhook_url'] ?? ''; $connected = !empty($service_url) && !empty($webhook_url); ?> <div class="wrap wp-to-sanity-onboarding"> <h1><?php echo esc_html(get_admin_page_title()); ?></h1> <?php if ($connected) : ?> <div class="notice notice-success is-dismissible"> <p><?php esc_html_e('This site is connected to a WP-to-Sanity Worker.', 'wp-to-sanity'); ?></p> <p><strong><?php esc_html_e('Service URL:', 'wp-to-sanity'); ?></strong> <code><?php echo esc_html($service_url); ?></code> <strong><?php esc_html_e('Webhook URL:', 'wp-to-sanity'); ?></strong> <code><?php echo esc_html($webhook_url); ?></code></p> </div> <?php endif; ?> <div class="wp-to-sanity-wizard"> <!-- Step 1: Enter credentials --> <div class="wizard-step active" data-step="1"> <h2><span class="step-number">1</span> <?php esc_html_e('Enter your Worker details', 'wp-to-sanity'); ?></h2> <p class="description"> <?php esc_html_e('These come from the output of your one-click deploy script (pnpm deploy:worker:setup).', 'wp-to-sanity'); ?> </p> <table class="form-table"> <tr> <th scope="row"><label for="wps_service_url"><?php esc_html_e('Service URL', 'wp-to-sanity'); ?></label></th> <td> <input type="url" id="wps_service_url" class="regular-text" placeholder="https://wp-to-sanity-migration.<your-subdomain>.workers.dev" value="<?php echo esc_attr($service_url); ?>"> <p class="description"><?php esc_html_e('The base URL of your deployed Cloudflare Worker (no trailing slash).', 'wp-to-sanity'); ?></p> </td> </tr> <tr> <th scope="row"><label for="wps_admin_token"><?php esc_html_e('Admin Token', 'wp-to-sanity'); ?></label></th> <td> <input type="password" id="wps_admin_token" class="regular-text" autocomplete="off" placeholder="<?php echo $connected ? '••••••••••••••••' : ''; ?>"> <p class="description"><?php esc_html_e('Bearer token used to authenticate the Worker admin endpoints. Stored server-side in wp_options; never sent to the browser after saving.', 'wp-to-sanity'); ?></p> </td> </tr> <tr> <th scope="row"><label for="wps_webhook_secret"><?php esc_html_e('Webhook Secret', 'wp-to-sanity'); ?></label></th> <td> <input type="text" id="wps_webhook_secret" class="regular-text" value="<?php echo esc_attr($webhook_secret); ?>"> <p class="description"><?php esc_html_e('The WP_WEBHOOK_SECRET generated by the deploy script. Must match the Worker exactly for webhook signatures to verify.', 'wp-to-sanity'); ?></p> </td> </tr> </table> <p> <button type="button" class="button button-primary" id="wps-connect-btn"> <?php esc_html_e('Connect', 'wp-to-sanity'); ?> </button> </p> </div> <!-- Step 2: Handshake result --> <div class="wizard-step" data-step="2" style="display:none;"> <h2><span class="step-number">2</span> <?php esc_html_e('Handshake', 'wp-to-sanity'); ?></h2> <div id="wps-connect-result" class="wps-result-box"></div> <p> <button type="button" class="button" id="wps-test-btn"> <?php esc_html_e('Test Connection', 'wp-to-sanity'); ?> </button> <button type="button" class="button button-primary" id="wps-continue-btn" style="display:none;"> <?php esc_html_e('Continue', 'wp-to-sanity'); ?> </button> </p> </div> <!-- Step 3: Health probe --> <div class="wizard-step" data-step="3" style="display:none;"> <h2><span class="step-number">3</span> <?php esc_html_e('Test Connection', 'wp-to-sanity'); ?></h2> <div id="wps-test-result" class="wps-result-box"></div> <p> <a href="<?php echo admin_url('admin.php?page=wp-to-sanity-export'); ?>" class="button button-primary"> <?php esc_html_e('Go to Export', 'wp-to-sanity'); ?> </a> </p> </div> </div> </div> <style> .wp-to-sanity-wizard { max-width: 720px; margin-top: 20px; } .wizard-step { background: #fff; border: 1px solid #c3c4c7; border-radius: 8px; padding: 20px; margin-bottom: 20px; } .wizard-step h2 { display: flex; align-items: center; gap: 10px; margin-top: 0; } .step-number { display: inline-flex; width: 28px; height: 28px; background: #2271b1; color: #fff; border-radius: 50%; align-items: center; justify-content: center; font-size: 14px; font-weight: bold; } .wps-result-box { background: #f0f0f1; border-radius: 4px; padding: 12px 16px; margin: 12px 0; font-family: monospace; font-size: 12px; white-space: pre-wrap; max-height: 320px; overflow-y: auto; } .wps-result-box.ok { background: #f0fff4; border-left: 4px solid #00a32a; } .wps-result-box.err { background: #fef2f2; border-left: 4px solid #d63638; } .wps-result-box .row { margin: 4px 0; } .wps-result-box .label { color: #646970; } </style> <script> jQuery(document).ready(function($) { function showStep(n) { $('.wizard-step').removeClass('active').hide(); $('.wizard-step[data-step="' + n + '"]').addClass('active').show(); } function failBox($box, msg) { $box.removeClass('ok').addClass('err').text(msg); } // Step 1 → 2: connect handshake (proxied server-side via /connect REST route) $('#wps-connect-btn').on('click', function() { var $btn = $(this); var $box = $('#wps-connect-result'); $btn.prop('disabled', true); $box.removeClass('ok err').text('<?php echo esc_js(__('Sending handshake...', 'wp-to-sanity')); ?>'); $.ajax({ url: wpToSanity.restUrl + 'connect', method: 'POST', headers: { 'X-WP-Nonce': wpToSanity.restNonce }, data: { service_url: $('#wps_service_url').val(), admin_token: $('#wps_admin_token').val(), webhook_secret: $('#wps_webhook_secret').val() } }).done(function(resp) { if (resp && resp.success && resp.data && resp.data.connected) { var d = resp.data; $box.removeClass('err').addClass('ok').empty(); $box.append('<div class="row"><span class="label">connected:</span> true</div>'); $box.append('<div class="row"><span class="label">sanityProjectId:</span> ' + (d.sanityProjectId || '—') + '</div>'); $box.append('<div class="row"><span class="label">dataset:</span> ' + (d.dataset || '—') + '</div>'); $box.append('<div class="row"><span class="label">webhookEndpoint:</span> ' + (d.webhookEndpoint || '—') + '</div>'); $box.append('<div class="row"><span class="label">webhookSecretMatch:</span> ' + (d.webhookSecretMatch ? 'true' : 'false') + '</div>'); var cfg = d.configured || {}; $box.append('<div class="row"><span class="label">configured:</span> sanity=' + (cfg.sanity ? 1 : 0) + ', webhook=' + (cfg.webhook ? 1 : 0) + ', database=' + (cfg.database ? 1 : 0) + ', storage=' + (cfg.storage ? 1 : 0) + ', revalidate=' + (cfg.revalidate ? 1 : 0) + '</div>'); $('#wps-continue-btn').show(); showStep(2); } else { failBox($box, (resp && resp.data && resp.data.error) ? resp.data.error : '<?php echo esc_js(__('Connection failed.', 'wp-to-sanity')); ?>'); $btn.prop('disabled', false); } }).fail(function(xhr) { var msg = xhr.responseText || '<?php echo esc_js(__('Connection failed.', 'wp-to-sanity')); ?>'; try { var j = JSON.parse(xhr.responseText); if (j && j.data && j.data.error) { msg = j.data.error; } } catch (e) {} failBox($box, msg); $btn.prop('disabled', false); }); }); // Step 2 → 3: health probe (proxied server-side via /connect/test REST route) $('#wps-test-btn').on('click', function() { var $btn = $(this); var $box = $('#wps-test-result'); $btn.prop('disabled', true); $box.removeClass('ok err').text('<?php echo esc_js(__('Probing worker health...', 'wp-to-sanity')); ?>'); $.ajax({ url: wpToSanity.restUrl + 'connect/test', method: 'GET', headers: { 'X-WP-Nonce': wpToSanity.restNonce } }).done(function(resp) { if (resp && resp.success && resp.data) { $box.removeClass('err').addClass('ok').text(JSON.stringify(resp.data, null, 2)); showStep(3); } else { failBox($box, (resp && resp.data && resp.data.error) ? resp.data.error : '<?php echo esc_js(__('Health check failed.', 'wp-to-sanity')); ?>'); $btn.prop('disabled', false); } }).fail(function(xhr) { var msg = xhr.responseText || '<?php echo esc_js(__('Health check failed.', 'wp-to-sanity')); ?>'; try { var j = JSON.parse(xhr.responseText); if (j && j.data && j.data.error) { msg = j.data.error; } } catch (e) {} failBox($box, msg); $btn.prop('disabled', false); }); }); $('#wps-continue-btn').on('click', function() { showStep(3); }); }); </script>
Save
cmd:
run