VOOZH about

URL: https://deepwiki.com/pcescato/ajc-bridge/5.3-bulk-operations-and-sync-history

⇱ Bulk Operations and Sync History | pcescato/ajc-bridge | DeepWiki


Loading...
Menu

Bulk Operations and Sync History

This page documents the administrative interfaces for bulk synchronization operations and sync history monitoring. These features allow administrators to synchronize multiple posts at once and track the status of synchronization operations across all content.

For individual post synchronization controls in the post list, see Admin Columns. For per-post dev.to syndication settings, see Post Meta Box.

Purpose and Scope

The Bulk Operations and Sync History functionality provides two admin interfaces:

  1. Bulk Operations - Allows administrators to enqueue all published posts for synchronization in a single operation
  2. Sync History - Displays recent synchronization attempts with status indicators, timestamps, and quick actions

These interfaces are implemented in the Settings class and rely on the Queue_Manager for actual sync orchestration.

Sources: admin/class-settings.php1273-1304

Page Structure

Both interfaces are registered as separate menu pages under the AJC Bridge menu. The bulk operations page is admin-only, while the sync history page is accessible to any user with publish_posts capability.


Sources: admin/class-settings.php1273-1285 admin/class-settings.php1292-1304

Bulk Synchronization

Interface Components

The bulk operations page provides a single-button interface to enqueue all published posts for synchronization. It includes real-time progress tracking and queue statistics.


Sources: admin/class-settings.php1311-1371 admin/class-settings.php1572-1595

Bulk Sync Button

The synchronization button triggers a JavaScript confirmation dialog before executing the bulk operation.

ElementImplementation
Button IDatomic-jamstack-bulk-sync-button
Confirmation Text"Are you sure you want to synchronize all published posts? This may take several minutes."
AJAX Actionajc_bridge_bulk_sync
Nonce Keyajc-bridge-bulk-sync
Required Capabilitymanage_options

Sources: admin/class-settings.php1315-1318 admin/class-settings.php103

Progress Tracking

The bulk sync interface includes a progress bar that displays the enqueue status in real-time.


The progress updates are handled client-side based on the AJAX response from ajax_bulk_sync(), which returns:


Sources: admin/class-settings.php1325-1329 admin/class-settings.php1580-1594

Queue Statistics

The statistics table displays real-time counts of posts in various sync states.


The statistics are populated by calling ajax_get_stats(), which delegates to Queue_Manager::get_queue_stats(). This method performs WordPress meta queries to count posts by _ajc_sync_status value.

StatisticMeta QueryDisplay Element ID
Total PostsCount all published posts/pagesstat-total
Successfully Synced_ajc_sync_status = 'success'stat-success
Pending_ajc_sync_status = 'pending'stat-pending
Processing_ajc_sync_status = 'processing'stat-processing
Errors_ajc_sync_status = 'error'stat-error
Not SyncedNo _ajc_sync_status metastat-not-synced

Sources: admin/class-settings.php1331-1364 admin/class-settings.php1602-1612

Sync History Display

Query Architecture

The sync history table displays the 20 most recent posts that have sync metadata, ordered by last sync timestamp.


Sources: admin/class-settings.php1393-1414

Permission-Based Filtering

The sync history implements two viewing modes based on user capabilities:






















User RoleView ScopeAuthor Column
AdministratorAll posts from all authorsVisible
Author/EditorOnly their own postsHidden

Sources: admin/class-settings.php1380-1411

Status Icons and Colors

Each sync status is represented by a colored icon in the history table:


The status display logic uses a switch statement to map meta values to visual indicators:


Sources: admin/class-settings.php1472-1498

Table Columns

The sync history table includes the following columns:

ColumnData SourceNotes
Post Titleget_the_title()Linked to edit page
IDget_the_ID()Post ID
Authorget_post_field('post_author')Admin view only
Typeget_post_type()post or page
Status_ajc_sync_status metaWith icon
Last Sync_ajc_sync_last metaFormatted with human_time_diff()
Commit_ajc_last_commit_url metaExternal link button
ActionsSync Now buttonDisabled if processing

Sources: admin/class-settings.php1427-1456

Timestamp Formatting

Last sync timestamps are stored as Unix timestamps and formatted as relative time:


Sources: admin/class-settings.php1501-1507

Commit URL Links

For GitHub-synced posts, the history table displays a link to the commit on GitHub:


The _ajc_last_commit_url meta is set by Git_API::create_commit() after successful GitHub operations.

Sources: admin/class-settings.php1536-1543

AJAX Operations

Single Post Sync

The "Sync Now" button in the history table triggers immediate synchronization for a specific post.


Sources: admin/class-settings.php1643-1664

AJAX Handler Implementation

The ajax_sync_single() method validates permissions and delegates to Queue_Manager:


The method enqueues the post with priority 5 (high priority) to ensure it processes before bulk-enqueued posts (default priority 10).

Sources: admin/class-settings.php1643-1664

JavaScript Integration

Asset Enqueuing

The settings JavaScript file is enqueued on all AJC Bridge admin pages:


Sources: admin/class-settings.php65-91

Localized Data

JavaScript handlers receive configuration through wp_localize_script():


Sources: admin/class-settings.php94-114

Post Meta Storage

Both interfaces rely on post meta keys set by Queue_Manager and Sync_Runner:

Meta KeySet ByPurpose
_ajc_sync_statusQueue_ManagerCurrent sync state: pending, processing, success, error
_ajc_sync_lastSync_RunnerUnix timestamp of last sync attempt
_ajc_retry_countQueue_ManagerNumber of retry attempts (max 3)
_ajc_last_commit_urlGit_APIGitHub commit URL for verification

Sources: admin/class-settings.php1399 admin/class-settings.php1463-1465

Empty State Handling

When no sync history exists, the interface displays an informational notice:


This occurs when:

  • No posts have been synced yet (no _ajc_sync_status meta exists)
  • For authors: they haven't authored any synced posts

Sources: admin/class-settings.php1416-1423

Security Model

All AJAX operations implement WordPress security best practices:































OperationNonce ActionRequired CapabilityValidates
Bulk Syncatomic-jamstack-bulk-syncmanage_optionsNone (all published posts)
Single Syncatomic-jamstack-sync-singlepublish_postspost_id via absint()
Get Statsatomic-jamstack-get-statsmanage_optionsNone (aggregate counts)

Sources: admin/class-settings.php1573 admin/class-settings.php1644 admin/class-settings.php1603