HTML Fields Library for WordPress
A foundation for building custom frameworks, settings systems, and admin UIs.
Fluent API, 48 unique field types (+4 aliases), React/Vanilla UI, and modern v3 architecture.
Features • Installation • Quick Start • Field Types • Examples • Dependencies • RU version
- ✨ Fluent Interface — Chain methods like Laravel:
Field::text('name')->label('Name')->required() - 🔁 Repeater Fields — Infinite nesting support with min/max constraints
- 🎨 Flexible Content — ACF-style layout builder with multiple block types
- ⚛️ React UI — Modern React components with Vanilla JS fallback
- 🏗️ SOLID Architecture — Interfaces, traits, dependency injection
- 📦 Storage Strategies — PostMeta, TermMeta, UserMeta, Options, CustomTable
- 🛡️ Type Safety — PHPStan Level 9, strict types, full PHPDoc
- 🚀 48 Unique Field Types — Text, select, repeater, flexible content, and more
- ♻️ 4 Compatibility Aliases —
date_time,datetime-local,image_picker,imagepicker - 🔗 Conditional Logic — 14 operators with AND/OR relations
- 🧪 Full Test Coverage — Pest/PHPUnit tests with 100% pass rate
- 🎨 WP Components — Native WordPress UI integration
- 🌍 i18n Ready — Multilingual support
- PHP 8.3+
- WordPress 6.0+
- Composer (for installation)
composer require rwsite/wp-field- Clone or download to
wp-content/plugins/wp-field-plugin - Run
composer install --no-dev - Activate the plugin in WordPress admin
npm install
npm run builduse WpField\Field\Field;
use WpField\Container\MetaboxContainer;
// Fluent interface
$field = Field::text('email')
->label('Email Address')
->placeholder('user@example.com')
->required()
->email()
->class('regular-text');
// Render field
echo $field->render();
// Create metabox with fields
$metabox = new MetaboxContainer('product_details', [
'title' => 'Product Details',
'post_types' => ['product'],
]);
$metabox->addField(
Field::text('sku')->label('SKU')->required()
);
$metabox->addField(
Field::text('price')->label('Price')->required()
);
$metabox->register();$repeater = Field::repeater('team_members')
->label('Team Members')
->fields([
Field::text('name')->label('Name')->required(),
Field::text('position')->label('Position'),
Field::text('email')->label('Email')->email(),
])
->min(1)
->max(10)
->buttonLabel('Add Member')
->layout('table');$flexible = Field::flexibleContent('page_sections')
->label('Page Sections')
->addLayout('text_block', 'Text Block', [
Field::text('heading')->label('Heading'),
Field::text('content')->label('Content'),
])
->addLayout('image', 'Image', [
Field::text('image_url')->label('Image URL')->url(),
Field::text('caption')->label('Caption'),
])
->min(1)
->buttonLabel('Add Section');text— Text inputpassword— Password fieldemail— Email inputurl— URL inputtel— Telephone inputnumber— Number inputrange— Range sliderhidden— Hidden fieldtextarea— Multi-line text
select— Dropdown listmultiselect— Multiple selectionradio— Radio buttonscheckbox— Single checkboxcheckbox_group— Checkbox group
editor— wp_editormedia— Media library (ID or URL)image— Image with previewfile— File uploadgallery— Image gallerycolor— Color pickerdate— Date pickertime— Time pickerdatetime— Date and time
group— Nested fieldsrepeater— Repeating elements
switcher— On/off switcherspinner— Number spinnerbutton_set— Button selectionslider— Value sliderheading— Headingsubheading— Subheadingnotice— Notice (info/success/warning/error)content— Custom HTML contentfieldset— Field grouping
accordion— Collapsible sectionstabbed— Tabstypography— Typography settingsspacing— Spacing controlsdimensions— Size controlsborder— Border settingsbackground— Background optionslink_color— Link colorscolor_group— Color groupimage_select— Image selection
code_editor— Code editor with syntax highlightingicon— Icon picker from librarymap— Google Maps locationsortable— Drag & drop sortingsorter— Enabled/disabled sortingpalette— Color palettelink— Link field (URL + text + target)backup— Settings export/import
// Show field only if another field has specific value
Field::text('courier_address')
->label('Delivery Address')
->when('delivery_type', '==', 'courier');
// Multiple conditions (AND)
Field::text('special_field')
->label('Special Field')
->when('field1', '==', 'value1')
->when('field2', '!=', 'value2');
// Multiple conditions (OR)
Field::text('notification')
->label('Notification')
->when('type', '==', 'sms')
->orWhen('type', '==', 'email');Field::repeater('work_times')
->label('Work Times')
->min(1)
->max(7)
->buttonLabel('Add Day')
->fields([
Field::make('select', 'day')
->label('Day')
->options(['mon' => 'Mon', 'tue' => 'Tue']),
Field::make('time', 'from')
->label('From'),
Field::make('time', 'to')
->label('To'),
]);Field::make('group', 'address')
->label('Address')
->fields([
Field::text('city')->label('City'),
Field::text('street')->label('Street'),
Field::text('number')->label('Number'),
]);Field::make('code_editor', 'custom_css')
->label('Custom CSS')
->mode('css') // css, javascript, php, html
->height('400px');Field::make('icon', 'menu_icon')
->label('Menu Icon')
->library('dashicons');Field::make('map', 'location')
->label('Location')
->apiKey('YOUR_GOOGLE_MAPS_API_KEY')
->zoom(12)
->center(['lat' => 55.7558, 'lng' => 37.6173]);Field::make('sortable', 'menu_order')
->label('Menu Order')
->options([
'home' => 'Home',
'about' => 'About',
'services' => 'Services',
'contact' => 'Contact',
]);Field::make('palette', 'color_scheme')
->label('Color Scheme')
->palettes([
'blue' => ['#0073aa', '#005a87', '#003d82'],
'green' => ['#28a745', '#218838', '#1e7e34'],
'red' => ['#dc3545', '#c82333', '#bd2130'],
]);Field::make('link', 'cta_button')
->label('CTA Button');
// Get value:
// $link = get_post_meta($post_id, 'cta_button', true);
// ['url' => '...', 'text' => '...', 'target' => '_blank']Field::make('accordion', 'settings_accordion')
->label('Settings')
->sections([
[
'title' => 'General',
'open' => true,
'fields' => [
Field::text('title')->label('Title'),
],
],
[
'title' => 'Advanced',
'fields' => [
Field::make('textarea', 'desc')->label('Description'),
],
],
]);Field::make('typography', 'heading_typography')
->label('Heading Typography');
// Saved as:
// [
// 'font_family' => 'Arial',
// 'font_size' => '24',
// 'font_weight' => '700',
// 'line_height' => '1.5',
// 'text_align' => 'center',
// 'color' => '#333333'
// ]==— Equal!=— Not equal>,>=,<,<=— Comparisonin— In arraynot_in— Not in arraycontains— Containsnot_contains— Not containsempty— Emptynot_empty— Not empty
See all 48 field types in action:
👉 Tools → WP_Field Examples (Classic API demo)
👉 /wp-admin/tools.php?page=wp-field-examples
👉 Tools → WP_Field v3.0 Demo (Modern Fluent API)
👉 /wp-admin/tools.php?page=wp-field-v3-demo
The demo pages include:
- ✅ All 48 field types with live examples
- ✅ Code for each field
- ✅ Fluent API demonstrations (v3.0)
- ✅ Repeater and Flexible Content examples
- ✅ Conditional Logic with 14 operators
- ✅ React/Vanilla UI mode switching
- ✅ Dependency system demonstration
- ✅ Ability to save and test
add_filter('wp_field_types', function($types) {
$types['custom_type'] = ['render_custom', ['default' => 'value']];
return $types;
});add_filter('wp_field_icon_library', function($icons, $library) {
if ($library === 'fontawesome') {
return ['fa-home', 'fa-user', 'fa-cog', ...];
}
return $icons;
}, 10, 2);add_filter('wp_field_get_value', function($value, $storage_type, $key, $id, $field) {
if ($storage_type === 'custom') {
return get_custom_value($key, $id);
}
return $value;
}, 10, 5);See CHANGELOG.md for detailed version history.
- PHP Lines: 2705 (WP_Field.php)
- JS Lines: 1222 (wp-field.js)
- CSS Lines: 1839 (wp-field.css)
- Field Types: 48
- Dependency Operators: 12
- Storage Types: 5
- External Dependencies: 0
- WordPress: 6.0+
- PHP: 8.3+
- Dependencies: jQuery, jQuery UI Sortable, WordPress built-in components
- Browsers: Chrome, Firefox, Safari, Edge (latest 2 versions)
- Minimal CSS size: ~20KB
- Minimal JS size: ~15KB
- Lazy loading for heavy components (CodeMirror, Google Maps)
- Optimized selectors and events
GPL v2 or later
Aleksei Tikhomirov (https://rwsite.ru)