Add pull functionality to Oribi Sync with user confirmation
This commit is contained in:
BIN
dist/oribi-tech-sync.zip
vendored
BIN
dist/oribi-tech-sync.zip
vendored
Binary file not shown.
@@ -79,6 +79,18 @@ add_action( 'admin_post_oribi_sync_dry_run', function () {
|
||||
exit;
|
||||
} );
|
||||
|
||||
add_action( 'admin_post_oribi_sync_pull', function () {
|
||||
if ( ! current_user_can( 'manage_options' ) ) wp_die( 'Permission denied.' );
|
||||
check_admin_referer( 'oribi_sync_pull' );
|
||||
|
||||
$result = oribi_sync_run();
|
||||
|
||||
set_transient( 'oribi_sync_result', $result, 60 );
|
||||
|
||||
wp_redirect( add_query_arg( 'oribi_sync_done', 'pull', admin_url( 'options-general.php?page=oribi-sync' ) ) );
|
||||
exit;
|
||||
} );
|
||||
|
||||
add_action( 'admin_post_oribi_sync_clear_pat', function () {
|
||||
if ( ! current_user_can( 'manage_options' ) ) wp_die( 'Permission denied.' );
|
||||
check_admin_referer( 'oribi_sync_clear_pat' );
|
||||
@@ -149,7 +161,11 @@ function oribi_sync_settings_page() {
|
||||
|
||||
<?php if ( $sync_result ): ?>
|
||||
<div class="notice <?php echo $sync_result['ok'] ? 'notice-success' : 'notice-error'; ?> is-dismissible">
|
||||
<p><strong><?php echo $done === 'dry' ? 'Dry-run results' : 'Sync complete'; ?></strong></p>
|
||||
<p><strong><?php
|
||||
if ( $done === 'dry' ) echo 'Dry-run results';
|
||||
elseif ( $done === 'pull' ) echo 'Pull complete';
|
||||
else echo 'Sync complete';
|
||||
?></strong></p>
|
||||
<?php oribi_sync_render_result_list( $sync_result ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -266,6 +282,16 @@ function oribi_sync_settings_page() {
|
||||
onclick="return confirm('Pull from repo then push local changes. Continue?');">
|
||||
Sync (Pull & Push)
|
||||
</a>
|
||||
<a href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=oribi_sync_pull' ), 'oribi_sync_pull' ) ); ?>"
|
||||
class="button"
|
||||
onclick="return confirm('Pull content from the repo (no push). Continue?');">
|
||||
Pull Only
|
||||
</a>
|
||||
<a href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=oribi_sync_push_all' ), 'oribi_sync_push_all' ) ); ?>"
|
||||
class="button"
|
||||
onclick="return confirm('Push all synced pages to the repo (no pull). Continue?');">
|
||||
Push Only
|
||||
</a>
|
||||
<a href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=oribi_sync_dry_run' ), 'oribi_sync_dry_run' ) ); ?>"
|
||||
class="button">
|
||||
Dry Run
|
||||
@@ -274,11 +300,6 @@ function oribi_sync_settings_page() {
|
||||
class="button">
|
||||
Preview Theme
|
||||
</a>
|
||||
<a href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=oribi_sync_push_all' ), 'oribi_sync_push_all' ) ); ?>"
|
||||
class="button"
|
||||
onclick="return confirm('Push ALL synced pages to the repo?');">
|
||||
Push All
|
||||
</a>
|
||||
</p>
|
||||
<?php if ( $last_run ): ?>
|
||||
<p class="oribi-sync-muted">Last sync: <?php echo esc_html( $last_run ); ?></p>
|
||||
|
||||
Reference in New Issue
Block a user