arraypress / edd-register-fields
A comprehensive library for registering custom fields in Easy Digital Downloads admin interface
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/arraypress/edd-register-fields
Requires
- php: >=8.0
This package is auto-updated.
Last update: 2025-12-17 18:21:00 UTC
README
Add custom fields to Easy Digital Downloads download editor, pricing options, and sidebar metaboxes with a simple, clean API.
Installation
composer require arraypress/edd-register-fields
Basic Usage
Download Settings Fields
Add custom fields to the download settings tab:
// Register custom download settings fields edd_register_download_settings_fields( [ 'product_settings' => [ 'title' => 'Product Settings', 'description' => 'Additional product configuration options', 'fields' => [ 'is_featured' => [ 'type' => 'checkbox_toggle', 'label' => 'Featured Product', 'description' => 'Mark this product as featured', 'default' => false ], 'product_weight' => [ 'type' => 'number', 'label' => 'Weight (for sorting)', 'description' => 'Higher numbers appear first', 'default' => 0, 'attributes' => [ 'min' => 0, 'max' => 9999 ] ] ] ] ] );
Single Price Options
Add fields that appear when variable pricing is disabled:
// Register single price option fields edd_register_single_price_fields( [ 'license_options' => [ 'fields' => [ 'site_limit' => [ 'type' => 'number', 'label' => 'Site Limit', 'default' => 1, 'prefix' => 'Max:', 'suffix' => 'sites' ], 'includes_support' => [ 'type' => 'checkbox_toggle', 'label' => 'Includes Support', 'default' => true ] ] ] ] );
Variable Price Options
Add fields to each variable price row:
// Register variable price fields edd_register_variable_price_fields( [ 'license_tiers' => [ 'title' => 'License Options', 'fields' => [ 'is_popular' => [ 'type' => 'checkbox_toggle', 'label' => 'Popular', 'default' => false ], 'license_limit' => [ 'type' => 'number', 'label' => 'Site Limit', 'default' => 1, 'attributes' => [ 'min' => 1, 'max' => 999 ] ] ] ] ] );
Sidebar Metaboxes
Add custom metaboxes to the download editor sidebar:
// Register sidebar metaboxes edd_register_sidebar_metaboxes( [ 'seo_settings' => [ 'title' => 'SEO Settings', 'priority' => 'high', 'sections' => [ 'meta_options' => [ 'title' => 'Meta Options', 'fields' => [ 'meta_title' => [ 'type' => 'text', 'label' => 'Custom Meta Title', 'class' => 'widefat' ], 'exclude_sitemap' => [ 'type' => 'checkbox_toggle', 'label' => 'Exclude from Sitemap', 'default' => false ] ] ] ] ] ] );
Custom Sections
Register custom sections with configurable fields:
// Register custom sections edd_register_sections( [ 'custom_section' => CustomSection::class ] ); // Example custom section class class CustomSection extends ArrayPress\EDD\Fields\ConfigurableSection { protected $id = 'custom_section'; protected $priority = 25; protected $icon = 'admin-tools'; protected function get_section_config(): array { return [ 'title' => 'Custom Section', 'fields' => [ 'custom_field' => [ 'type' => 'text', 'label' => 'Custom Field', 'description' => 'A custom field example', 'default' => '' ] ] ]; } }
Field Types
| Type | Description | Example |
|---|---|---|
text |
Text input | 'type' => 'text' |
textarea |
Multi-line text | 'type' => 'textarea' |
number |
Number input | 'type' => 'number' |
email |
Email input | 'type' => 'email' |
url |
URL input | 'type' => 'url' |
select |
Dropdown select | 'type' => 'select' |
checkbox |
Checkbox | 'type' => 'checkbox' |
checkbox_toggle |
EDD toggle | 'type' => 'checkbox_toggle' |
radio |
Radio buttons | 'type' => 'radio' |
currency |
Currency input | 'type' => 'currency' |
color |
Color picker | 'type' => 'color' |
Field Options
Common Options
| Option | Description | Example |
|---|---|---|
type |
Field type | 'text' |
label |
Field label | 'Product Name' |
description |
Help text | 'Enter the product name' |
default |
Default value | 'Default value' |
required |
Required field | true |
class |
CSS classes | 'regular-text' |
attributes |
HTML attributes | ['min' => 0, 'max' => 100] |
Select/Radio Options
'product_type' => [ 'type' => 'select', 'label' => 'Product Type', 'options' => [ 'digital' => 'Digital Product', 'physical' => 'Physical Product', 'service' => 'Service' ], 'default' => 'digital' ]
Number Fields
'priority' => [ 'type' => 'number', 'label' => 'Priority', 'default' => 0, 'attributes' => [ 'min' => 0, 'max' => 100, 'step' => 5 ] ]
Requirements
- PHP 7.4+
- WordPress 5.0+
- Easy Digital Downloads 3.0+
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the GPL-2.0-or-later License.