PHPackages                             arraypress/wp-status-badge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arraypress/wp-status-badge

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arraypress/wp-status-badge
==========================

A lightweight WordPress library for rendering styled status badges

18PHP

Since Feb 3Pushed 3mo agoCompare

[ Source](https://github.com/arraypress/wp-status-badge)[ Packagist](https://packagist.org/packages/arraypress/wp-status-badge)[ RSS](/packages/arraypress-wp-status-badge/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

WordPress Status Badge
======================

[](#wordpress-status-badge)

A lightweight WordPress library for rendering styled status badges with automatic type detection. Works in both admin and frontend contexts with sensible defaults for common status values.

Features
--------

[](#features)

- 🎨 **Zero Configuration**: Common statuses like `active`, `pending`, `failed` just work
- 🏷️ **Five Badge Types**: Success, warning, danger, info, and default
- 🔧 **Custom Mappings**: Override or extend defaults with your own status-to-type mappings
- 🌐 **Admin &amp; Frontend**: Works everywhere with a standalone CSS file
- 📦 **Composer Assets**: Automatic stylesheet management via `wp-composer-assets`
- 🏗️ **Instance-Based**: No global state, no static registries, no side effects
- 🎯 **Auto Labels**: Status strings automatically converted to readable labels

Requirements
------------

[](#requirements)

- PHP 7.4 or later
- WordPress 5.0 or later

Installation
------------

[](#installation)

```
composer require arraypress/wp-status-badge
```

Basic Usage
-----------

[](#basic-usage)

### Rendering Badges

[](#rendering-badges)

```
use ArrayPress\StatusBadge\StatusBadge;

// All defaults — covers most common statuses
$badge = new StatusBadge();

echo $badge->render( 'active' );    // Green badge: "Active"
echo $badge->render( 'pending' );   // Amber badge: "Pending"
echo $badge->render( 'failed' );    // Red badge: "Failed"
echo $badge->render( 'new' );       // Blue badge: "New"
echo $badge->render( 'inactive' );  // Grey badge: "Inactive"
```

### Custom Mappings

[](#custom-mappings)

```
// Merge custom mappings over defaults
$badge = new StatusBadge( [
    'churned'  => 'danger',
    'trialing' => 'warning',
    'vip'      => 'success',
] );

echo $badge->render( 'churned' );   // Red badge: "Churned"
echo $badge->render( 'vip' );       // Green badge: "Vip"
echo $badge->render( 'active' );    // Still works — defaults preserved
```

### One-Off Overrides

[](#one-off-overrides)

```
$badge = new StatusBadge();

// Override type without changing the instance
echo $badge->render( 'custom_status', 'info' );

// Override both type and label
echo $badge->render( 'in_progress', 'warning', 'In Progress' );
```

### Early Asset Enqueueing

[](#early-asset-enqueueing)

```
// CSS enqueues automatically on first render(), but you can enqueue early
$badge = new StatusBadge();
$badge->enqueue();
```

Badge Types
-----------

[](#badge-types)

TypeColourExample Statuses`success`Greenactive, approved, completed, paid, published, verified`warning`Amberpending, draft, processing, scheduled, trial, on\_hold`danger`Redfailed, cancelled, expired, rejected, suspended, banned`info`Bluenew, updated, importing, syncing, notice`default`Greyinactive, disabled, archived, closed, paused, unknownType Detection
--------------

[](#type-detection)

```
$badge = new StatusBadge();

// Get the badge type for any status
$type = $badge->get_type( 'active' );    // "success"
$type = $badge->get_type( 'pending' );   // "warning"
$type = $badge->get_type( 'unknown_status' ); // "default"

// Boolean checks
if ( $badge->is_success( 'active' ) ) {
    // Status maps to success type
}

if ( $badge->is_danger( 'expired' ) ) {
    // Status maps to danger type
}

// Check any type
if ( $badge->is_type( 'draft', 'warning' ) ) {
    // Status maps to warning type
}
```

### Available Check Methods

[](#available-check-methods)

```
$badge->is_success( $status );  // Green statuses
$badge->is_warning( $status );  // Amber statuses
$badge->is_danger( $status );   // Red statuses
$badge->is_info( $status );     // Blue statuses
```

Labels
------

[](#labels)

```
// Labels auto-generate from status strings
StatusBadge::format_label( 'in_progress' );  // "In Progress"
StatusBadge::format_label( 'on-hold' );      // "On Hold"
StatusBadge::format_label( 'active' );       // "Active"

// Override label at render time
echo $badge->render( 'active', label: 'Currently Active' );
```

Utility Methods
---------------

[](#utility-methods)

```
$badge = new StatusBadge();

// Get the full status-to-type map
$map = $badge->get_map();

// Get the icon class for a badge type
$icon = $badge->get_icon( 'success' );  // "dashicons-yes-alt"
$icon = $badge->get_icon( 'danger' );   // "dashicons-dismiss"

// Get all valid badge types
$types = StatusBadge::get_types();  // ['success', 'warning', 'danger', 'info', 'default']
```

Default Status Map
------------------

[](#default-status-map)

The library ships with a comprehensive default map. All mappings are case-insensitive.

View full default map**Success:** active, approved, completed, confirmed, connected, delivered, enabled, live, open, paid, published, resolved, valid, verified, yes

**Warning:** awaiting, draft, expiring, on-hold, on\_hold, partially\_refunded, pending, processing, review, scheduled, trial, trialing, unpaid

**Danger:** banned, blocked, cancelled, canceled, declined, error, expired, failed, invalid, overdue, refunded, rejected, revoked, spam, suspended, terminated

**Info:** importing, info, new, notice, syncing, updated

**Default:** archived, closed, disabled, hidden, inactive, no, none, paused, trashed, unknown

Common Use Cases
----------------

[](#common-use-cases)

### Admin List Table Column

[](#admin-list-table-column)

```
$badge = new StatusBadge();

// In your column rendering
function column_status( $item ) {
    global $badge;
    return $badge->render( $item->get_status() );
}
```

### WooCommerce Order Statuses

[](#woocommerce-order-statuses)

```
$badge = new StatusBadge( [
    'wc-on-hold'    => 'warning',
    'wc-processing' => 'warning',
    'wc-completed'  => 'success',
    'wc-refunded'   => 'danger',
] );

echo $badge->render( $order->get_status() );
```

### Dashboard Widget

[](#dashboard-widget)

```
$badge = new StatusBadge();

foreach ( $items as $item ) {
    printf(
        '%s%s',
        esc_html( $item->get_title() ),
        $badge->render( $item->get_status() )
    );
}
```

### Frontend Display

[](#frontend-display)

```
// Works outside wp-admin — CSS is standalone
$badge = new StatusBadge();

echo '';
echo $badge->render( $order->status );
echo '';
```

API Reference
-------------

[](#api-reference)

### Constructor

[](#constructor)

ParameterTypeDefaultDescription`$custom``array``[]`Custom status-to-type mappings to merge### Rendering

[](#rendering)

MethodDescription`render($status, $type, $label)`Render badge HTML`enqueue()`Enqueue stylesheet without render### Type Detection

[](#type-detection-1)

MethodDescription`get_type($status)`Get badge type for a status`get_icon($type)`Get dashicon class for a badge type`is_type($status, $type)`Check if status maps to a specific type`is_success($status)`Check if status maps to success`is_warning($status)`Check if status maps to warning`is_danger($status)`Check if status maps to danger`is_info($status)`Check if status maps to info### Utility

[](#utility)

MethodDescription`get_map()`Get the full status-to-type map`get_types()`Get all valid badge types (static)`format_label($status)`Convert status string to label (static)Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This project is licensed under the GPL-2.0-or-later License.

Support
-------

[](#support)

- [Documentation](https://github.com/arraypress/wp-status-badge)
- [Issue Tracker](https://github.com/arraypress/wp-status-badge/issues)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance54

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd6eb8aff0903d87eb674d1ba3c5f3653899c0d7661504eb0deb7798ed86b643?d=identicon)[arraypress](/maintainers/arraypress)

---

Top Contributors

[![arraypress](https://avatars.githubusercontent.com/u/22668877?v=4)](https://github.com/arraypress "arraypress (2 commits)")

### Embed Badge

![Health badge](/badges/arraypress-wp-status-badge/health.svg)

```
[![Health](https://phpackages.com/badges/arraypress-wp-status-badge/health.svg)](https://phpackages.com/packages/arraypress-wp-status-badge)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
