Search by

arraypress / wp-status-badge

arraypress

This package is abandoned and no longer maintained. No replacement package was suggested.

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: 533

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-11-18 10:55:27 UTC


README

This library has moved. It is now part of sugarcommerce/status-badge (namespace SugarCommerce\StatusBadge, PHP 8.3+). That package's README has a "Moving from arraypress/wp-*" table. This repository is archived and read-only.

Status Badge

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',
] );

The glyph

A badge is a tint, a dot and the word. Each type also has a glyph, a Heroicons outline icon (heroicons-outline:check-circle, clock, x-circle, information-circle, minus-circle), which get_icon() returns. With arraypress/wp-field-kit installed it is in the markup as inline SVG with the class arraypress-icon, hidden by the stylesheet; a stylesheet that wants it shown can show it:

.wp-status-badge .arraypress-icon { display: inline-block; width: 14px; height: 14px; }

The kit is suggested, not required. Without it there is no glyph, and the badge looks the same.

Requirements

  • PHP 8.3 or later
  • WordPress 7.1 or later
  • arraypress/wp-field-kit (optional), for the glyph

License

GPL-2.0-or-later