arraypress / edd-register-columns
Lightweight library for registering custom columns in Easy Digital Downloads tables.
Package info
github.com/arraypress/edd-register-columns
pkg:composer/arraypress/edd-register-columns
Requires
- php: >=8.3
- arraypress/wp-array-utils: *
- arraypress/wp-register-columns: *
Requires (Dev)
- phpcompatibility/phpcompatibility-wp: ^2.1
- phpunit/phpunit: ^12.0
- squizlabs/php_codesniffer: ^3.13.5
- wp-coding-standards/wpcs: ^3.4
This package is auto-updated.
Last update: 2026-08-25 15:45:17 UTC
README
Add custom columns to Easy Digital Downloads' admin tables — orders, customers, discounts, downloads, licences, subscriptions and commissions.
The engine is
wp-register-columns, which
does the same for WordPress's own list tables. This adds what is EDD's: its
tables, and manage_shop_settings as the capability a column needs, because
somebody running a store is not necessarily an administrator of the site it is
on.
Installation
composer require arraypress/edd-register-columns
Requirements
- PHP 8.3+
- WordPress 5.0+
- Easy Digital Downloads 3.0+
Quick Start
Downloads
edd_register_download_columns( [ 'sku' => [ 'label' => __( 'SKU', 'text-domain' ), 'meta_key' => 'edd_sku', 'sortable' => true, 'position' => 'after:title', ], ] );
Orders
edd_register_order_columns( [ 'tax_amount' => [ 'label' => __( 'Tax', 'text-domain' ), 'display_callback' => function( $order ) { return edd_currency_filter( edd_format_amount( $order->tax ) ); }, 'sortable' => true, 'position' => 'after:amount', ], ] );
Customers
edd_register_customer_columns( [ 'lifetime_value' => [ 'label' => __( 'LTV', 'text-domain' ), 'display_callback' => function( $customer ) { return edd_currency_filter( edd_format_amount( $customer->purchase_value ) ); }, 'position' => 'after:spent', ], ] );
Discounts
edd_register_discount_columns( [ 'usage_percent' => [ 'label' => __( 'Usage %', 'text-domain' ), 'display_callback' => function( $discount ) { if ( $discount->max_uses <= 0 ) return '∞'; return sprintf( '%d%%', ( $discount->use_count / $discount->max_uses ) * 100 ); }, 'sortable' => true, 'position' => 'after:uses', ], ] );
Commissions (EDD Commissions)
edd_register_commission_columns( [ 'commission_type' => [ 'label' => __( 'Type', 'text-domain' ), 'display_callback' => function( $commission ) { return ucfirst( esc_html( $commission->type ) ); }, 'position' => 'after:rate', ], ] );
Development
composer install composer test # PHPUnit composer lint # WordPress coding standards composer format:check # Formatting only composer format # Apply formatting fixes
The suite stubs the handful of WordPress and EDD functions the library touches, so it runs without a WordPress install.
Licenses (EDD Software Licensing)
edd_register_license_columns( [ 'license_version' => [ 'label' => __( 'Version', 'text-domain' ), 'display_callback' => function( $license, $item ) { $version = edd_software_licensing()->license_meta_db->get_meta( $license->ID, '_edd_sl_version', true ); return ! empty( $version ) ? esc_html( $version ) : '—'; }, 'position' => 'after:title', ], ] );
Subscriptions (EDD Recurring)
edd_register_subscription_columns( [ 'times_billed' => [ 'label' => __( 'Renewals', 'text-domain' ), 'display_callback' => function( $subscription ) { $times_billed = absint( $subscription->get_total_payments() ) - 1; return $times_billed > 0 ? number_format_i18n( $times_billed ) : '0'; }, 'position' => 'after:period', ], ] );
Column Options
[
'label' => '', // Column header. Escaped for you.
'meta_key' => '', // Meta to read the value from
'sortby' => '', // Sort by a property instead of by meta
'position' => '', // 'after:column' or 'before:column'
'sortable' => false, // Offer the column as sortable
'numeric' => false, // Sort by meta_value_num, so 9 sorts before 80
'desc_first' => false, // Sort descending on the first click
'display_callback' => null, // What the cell contains
'permission_callback' => null, // Whether this user sees the column
'width' => null, // A CSS length, a percentage, or 'auto'
]
`numeric` and `desc_first` are separate on purpose. `numeric` is about how to
compare — a meta value sorted as text puts 9 after 80 — and `desc_first` is
which end to start from. They used to be one key, so every column declared
numeric also started descending, which is not what the word means.
Without a `permission_callback` a column requires `manage_shop_settings`.
Position Examples
'position' => 'after:title', // Place after the title column 'position' => 'before:date', // Place before the date column
Sortable Support
| Table | Sortable |
|---|---|
| Downloads | ✅ Yes |
| Orders | ✅ Yes |
| Customers | ❌ No |
| Discounts | ✅ Yes |
| Commissions | ❌ No |
| Licenses | ✅ Yes |
| Subscriptions | ❌ No |
Removing Columns
edd_register_download_columns( [ 'new_column' => [ /* ... */ ], ], [ 'sales', 'earnings' ] // Remove these columns );
License
GPL-2.0-or-later