Search by

arraypress / wp-status-badge

arraypress

A lightweight WordPress library for rendering styled status badges

Package info

github.com/arraypress/wp-status-badge

Homepage

pkg:composer/arraypress/wp-status-badge

Statistics

Installs: 511

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.0 2026-08-25 21:14 UTC

This package is auto-updated.

Last update: 2026-09-04 17:32:21 UTC


README

Render a coloured pill for a status, without inventing the colours each time.

What it does

Every admin screen ends up showing statuses — completed, pending, failed, refunded — and every plugin picks its own greens and reds for them, so two plugins on one site disagree about what amber means.

This maps a status name to a type, and the type to a badge. completed and active are successes, pending and on-hold are warnings, failed and cancelled are dangers. You pass the status you already have; the colour and icon follow.

Features

  • Render a badge from a status name, with no colour decisions to make
  • Get sensible defaults for the statuses WordPress and commerce plugins use
  • Add your own statuses, or reassign one to a different type
  • Ask whether a status is a success, warning, danger or info, for logic elsewhere
  • Get a readable label from a machine status, so on-hold reads as "On hold"
  • Override the label when the automatic one is not quite right

Installation

composer require arraypress/wp-status-badge

Quick start

In a list-table column:

use ArrayPress\StatusBadge\StatusBadge;

$badges = new StatusBadge();

echo $badges->render( $order->status );

completed comes out green, failed red, pending amber — without the calling code knowing which is which.

Adding a status the defaults do not cover:

$badges = new StatusBadge( [
	'awaiting_stock' => 'warning',
] );

Requirements

  • PHP 8.3 or later
  • WordPress 7.1 or later

License

GPL-2.0-or-later