feat: add connection diagnostics
This commit is contained in:
@@ -51,6 +51,20 @@ if ( array() === $sync_pairs ) {
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Displays redirect status only. ?>
|
||||
<?php if ( isset( $_GET['wpcs_connection_ok'] ) ) : ?>
|
||||
<div class="notice notice-success">
|
||||
<p><?php echo esc_html__( 'REST connection succeeded.', 'wp-content-sync' ); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Displays redirect status only. ?>
|
||||
<?php if ( isset( $_GET['wpcs_connection_error'] ) ) : ?>
|
||||
<div class="notice notice-error">
|
||||
<p><?php echo esc_html( sanitize_text_field( wp_unslash( $_GET['wpcs_connection_error'] ) ) ); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2><?php echo esc_html__( 'Configuration', 'wp-content-sync' ); ?></h2>
|
||||
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||
<input type="hidden" name="action" value="wpcs_save_settings" />
|
||||
@@ -176,6 +190,26 @@ if ( array() === $sync_pairs ) {
|
||||
<?php submit_button( __( 'Save Settings', 'wp-content-sync' ) ); ?>
|
||||
</form>
|
||||
|
||||
<h2><?php echo esc_html__( 'Connection Diagnostics', 'wp-content-sync' ); ?></h2>
|
||||
<p><?php echo esc_html__( 'Test whether each configured destination site accepts REST requests with the saved application password.', 'wp-content-sync' ); ?></p>
|
||||
<?php foreach ( $sync_pairs as $index => $pair ) : ?>
|
||||
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||
<input type="hidden" name="action" value="wpcs_test_connection" />
|
||||
<input type="hidden" name="pair_index" value="<?php echo esc_attr( (string) $index ); ?>" />
|
||||
<?php wp_nonce_field( 'wpcs_test_connection', 'wpcs_connection_nonce' ); ?>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: sync pair name. */
|
||||
esc_html__( 'Pair: %s', 'wp-content-sync' ),
|
||||
esc_html( '' !== $pair['name'] ? $pair['name'] : __( 'Unnamed sync pair', 'wp-content-sync' ) )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php submit_button( __( 'Test REST Connection', 'wp-content-sync' ), 'secondary' ); ?>
|
||||
</form>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<h2><?php echo esc_html__( 'File Package Import', 'wp-content-sync' ); ?></h2>
|
||||
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" enctype="multipart/form-data">
|
||||
<input type="hidden" name="action" value="wpcs_import_package" />
|
||||
|
||||
Reference in New Issue
Block a user