Download the PHP package arraypress/wp-conditions without Composer
On this page you can find all versions of the php package arraypress/wp-conditions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arraypress/wp-conditions
More information about arraypress/wp-conditions
Files in arraypress/wp-conditions
Package wp-conditions
Short Description A flexible conditions/rules engine for WordPress with admin UI, REST API search, and extensible condition types.
License GPL-2.0-or-later
Homepage https://github.com/arraypress/wp-conditions
Informations about the package wp-conditions
Conditions
Let a shop owner build a rule — "logged-in customers in the UK, on a weekend" — from an admin screen, and check it in code.
What it does
Anything with rules ends up needing this: a discount that applies to some carts, a fee that applies to some countries, a notice shown to some users. Hard-coding them means a release every time one changes; a settings field means parsing whatever the owner typed.
This gives the owner a builder — pick a condition, an operator, a value, and group them with any/all — and gives you one call that answers true or false.
Features
- Register a set of rules with its own admin screen, from one call
- Give owners built-in conditions — user role, country, day of week, cart total
- Add a condition of your own, with its own operators and values
- Group rules so any or all of them must match
- Search for posts, terms and users inside a rule, rather than typing ids
- Check a set from your own code, against whatever context you have
- Ask which rules matched, when the answer needs explaining
Installation
Quick start
Register the set, and the screen that edits it:
Then, at the point the rule matters:
check_conditions() is true when any rule set matches;
check_all_conditions() requires all of them.
Behind a proxy
The IP and country conditions read the visitor's address from the request.
Behind Cloudflare or a load balancer the address they see is the proxy's, and
the real one arrives in a header any client could also send — so forwarded
headers are believed only from proxies on a trusted list. Cloudflare's ranges
are on it by default; add your own with the ARRAYPRESS_TRUSTED_PROXIES
constant or the arraypress_trusted_proxies filter from wp-ip-utils.
Requirements
- PHP 8.3 or later
- WordPress 7.1 or later
License
GPL-2.0-or-later
All versions of wp-conditions with dependencies
arraypress/wp-abuseipdb Version dev-main
arraypress/wp-accept-language-utils Version dev-main
arraypress/wp-array-utils Version dev-main
arraypress/wp-composer-assets Version dev-main
arraypress/wp-countries Version dev-main
arraypress/wp-email-utils Version dev-main
arraypress/wp-ip-utils Version dev-main
arraypress/wp-ipinfo Version dev-main
arraypress/wp-ipqualityscore Version dev-main
arraypress/wp-proxycheck Version dev-main
arraypress/wp-referrer-utils Version dev-main
arraypress/wp-string-utils Version dev-main
arraypress/wp-user-agent-utils Version dev-main