WordPress Developer Ukraine, Kyiv
PHP Fibers: Cooperative Concurrency for WordPress Background Tasks

PHP Fibers: Cooperative Concurrency for WordPress Background Tasks

PHP Fibers, parallel HTTP requests and background work in WordPress PHP 8.1 added Fibers, and articles promise “concurrency for WordPress” since then. A Fiber is a function that can pause itself and be resumed later; it does not run in parallel with anything. Without an event loop that does non-blocking I/O while fibers wait, they…
WordPress HTTP API: wp_remote_get and wp_remote_post Best Practices

WordPress HTTP API: wp_remote_get and wp_remote_post Best Practices

WordPress HTTP API: wp_remote_get() and wp_remote_post() best practices The WordPress HTTP API (wp_remote_get(), wp_remote_post(), wp_remote_request()) wraps the transport (cURL or PHP streams) in one interface with the same arguments and the same response format everywhere. Used carelessly it gives silent failures, hung pages and API rate limits; used well it needs four habits: check errors,…
WordPress Application Passwords for Secure REST API Authentication

WordPress Application Passwords for Secure REST API Authentication

WordPress Application Passwords for secure REST API authentication Application Passwords (WordPress 5.6+) let external scripts, apps and services authenticate to the REST API and XML-RPC without the user’s main password. Each one is a 24-character credential created per user and per application in Users → Profile → Application Passwords, shown in plain text only once…
Cache Expensive Operations with the WordPress Transients API

Cache Expensive Operations with the WordPress Transients API

Cache expensive operations with the WordPress Transients API The Transients API stores cached data with an expiration time. The same set_transient() and get_transient() calls use the wp_options table on a default install and memory (Redis, Memcached) when a persistent object cache is active, without any code changes. Good candidates are remote API responses, heavy WP_Query…
Register Custom REST API Endpoints with Authentication and Schema Validation in WordPress

Register Custom REST API Endpoints with Authentication and Schema Valida ...

Register custom REST API endpoints with authentication and schema validation register_rest_route() adds your own endpoints to the WordPress REST API. A route has a namespace (by convention myplugin/v1), a path (with optional regex parameters) and one or more handlers, each with HTTP methods, a callback, a permission callback and a description of the parameters. The…