Download the PHP package arraypress/wp-inline-sync without Composer
On this page you can find all versions of the php package arraypress/wp-inline-sync. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arraypress/wp-inline-sync
More information about arraypress/wp-inline-sync
Files in arraypress/wp-inline-sync
Package wp-inline-sync
Short Description Lightweight WordPress library for inline batch sync operations with progress UI. Register sync operations that run directly on existing admin screens.
License GPL-2.0-or-later
Homepage https://github.com/arraypress/wp-inline-sync/
Informations about the package wp-inline-sync
Inline Sync
Pull a few thousand records from an API into WordPress, from a button on an admin screen, without the request timing out.
What it does
Importing anything sizeable means batching: fetch a page, process it, report progress, fetch the next — and doing that from an admin screen means a REST endpoint, a nonce, a JavaScript loop, a progress bar and somewhere to keep the cursor between calls.
This is that loop, written once. You supply two callbacks — one that fetches a page, one that handles a single record — and the batching, the progress UI and the error reporting are handled.
Features
- Import in batches from a button, without a request that can time out
- Show progress as it goes, with the name of the record being worked on
- Resume from a cursor, so a paginated API is walked properly
- Report a failure on one record without abandoning the rest of the run
- Put the button on one admin screen, rather than everywhere
- Keep two prefixed copies of the library from fighting over one endpoint
Installation
Quick start
Then, on the screen itself:
data_callback is handed a cursor and returns a page plus the next one.
process_callback gets one record at a time and does whatever the import
means — the loop between them is not yours to write.
Register on init, not admin_init. The button is an admin thing, but the
work happens over REST, and admin_init does not run on a REST request — a
sync registered there has a button and no endpoint behind it.
Requirements
- PHP 8.3 or later
- WordPress 7.1 or later
License
GPL-2.0-or-later