add_node( [ 'id' => 'oribi-sync-pull', 'title' => 'Pull Page', 'href' => '#', 'meta' => [ 'title' => 'Pull this page and theme from Git', ], ] ); }, 100 ); // AJAX handler for the admin bar pull button (no REST API exposure) add_action( 'wp_ajax_oribi_sync_pull_page', function () { check_ajax_referer( 'oribi_sync_pull_page' ); if ( ! current_user_can( 'manage_options' ) ) wp_send_json_error( 'Permission denied.', 403 ); $post_id = (int) ( $_POST['post_id'] ?? 0 ); if ( $post_id < 1 ) wp_send_json_error( 'Missing or invalid post_id.', 400 ); $result = oribi_sync_pull_page_from_repo( $post_id ); $result['ok'] ? wp_send_json_success( $result ) : wp_send_json_error( $result, 500 ); } ); // Front-end script that wires up the admin bar pull button add_action( 'wp_footer', function () { if ( ! is_user_logged_in() ) return; if ( ! current_user_can( 'manage_options' ) ) return; if ( ! is_singular() ) return; if ( ! is_admin_bar_showing() ) return; $post = get_queried_object(); if ( ! $post instanceof WP_Post ) return; $ajax_url = admin_url( 'admin-ajax.php' ); $nonce = wp_create_nonce( 'oribi_sync_pull_page' ); $post_id = (int) $post->ID; ?> 0 ) { $post = get_post( $post_id ); $result = ( $post && $post->post_type === 'post' ) ? oribi_sync_push_post( $post_id ) : oribi_sync_push_page( $post_id ); set_transient( 'oribi_sync_push_result', $result, 60 ); } wp_redirect( add_query_arg( 'oribi_sync_pushed', '1', admin_url( 'options-general.php?page=oribi-sync' ) ) ); exit; } ); add_action( 'admin_post_oribi_sync_push_all', function () { if ( ! current_user_can( 'manage_options' ) ) wp_die( 'Permission denied.' ); check_admin_referer( 'oribi_sync_push_all' ); $result = oribi_sync_push_all(); set_transient( 'oribi_sync_push_result', $result, 60 ); wp_redirect( add_query_arg( 'oribi_sync_pushed', 'all', admin_url( 'options-general.php?page=oribi-sync' ) ) ); exit; } ); // ─── Settings page renderer ────────────────────────────────────────────────── function oribi_sync_settings_page() { if ( ! current_user_can( 'manage_options' ) ) return; $repo = get_option( 'oribi_sync_repo', '' ); $branch = get_option( 'oribi_sync_branch', 'main' ); $provider = get_option( 'oribi_sync_provider', '' ); $has_pat = ! empty( get_option( 'oribi_sync_pat', '' ) ); $last_run = get_option( 'oribi_sync_last_run', '' ); $log = get_option( 'oribi_sync_log', [] ); // Transient results $sync_result = get_transient( 'oribi_sync_result' ); if ( $sync_result ) delete_transient( 'oribi_sync_result' ); $push_result = get_transient( 'oribi_sync_push_result' ); if ( $push_result ) delete_transient( 'oribi_sync_push_result' ); $saved = $_GET['oribi_sync_saved'] ?? ''; $done = $_GET['oribi_sync_done'] ?? ''; ?>
Settings saved.
PAT cleared.
Push results
Conflict — opened pull request for review.
Sync (Pull & Push) Pull Only Push Only Dry Run Preview Theme
Last sync:
'page', 'post_status' => 'publish', 'meta_key' => '_oribi_sync_checksum', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', ] ); if ( $synced_pages->have_posts() ): ?>| Page | Push |
|---|---|
|
/
PR
pushed |
| Post | Push |
|---|---|
|
—
PR
pushed |
| Time | Created | Updated | Errors |
|---|---|---|---|
No changes.
'; return; } echo '