Universal HTML Field Generator for WordPress
Minimalist, extensible library for creating fields in WordPress with support for:
52 field types, dependency system, all storage types, and built-in WP components.
Features • Installation • Quick Start • Field Types • Examples • Dependencies • RU version
- 🚀 52 Field Types — Basic, choice, advanced, composite, and specialized fields
- 🔗 Dependency System — 12 operators with AND/OR logic for field visibility
- 📦 Multiple Storages — Post meta, options, term meta, user meta, comment meta
- 🎨 WP Components — wp_editor, wp-color-picker, wp.media, CodeMirror integration
- 🔌 Zero Dependencies — Uses only built-in WordPress scripts and components
- 🌍 i18n Ready — Translations included (Russian)
- 📊 Interactive Demo — Live examples page in WordPress admin
- PHP 8.0+
- WordPress 4.6+
- Clone or download to
wp-content/plugins/wp-field - Run
composer install - Activate the plugin
// Simple text field
WP_Field::make([
'id' => 'shop_name',
'type' => 'text',
'label' => 'Shop Name',
]);
// Select with dependency
WP_Field::make([
'id' => 'delivery_type',
'type' => 'select',
'label' => 'Delivery Type',
'options' => ['courier' => 'Courier', 'pickup' => 'Pickup'],
]);
WP_Field::make([
'id' => 'delivery_address',
'type' => 'text',
'label' => 'Delivery Address',
'dependency' => [
['delivery_type', '==', 'courier'],
],
]);use WP_Field\WP_Field;
// Dispatch to output
WP_Field::make($field_config, true, 'post', $post_id);
// Save to options
WP_Field::make($field_config, false, 'options');
// Term meta
WP_Field::make($field_config, false, 'term', $term_id);
// User meta
WP_Field::make($field_config, false, 'user', $user_id);
// Comment meta
WP_Field::make($field_config, false, 'comment', $comment_id);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
WP_Field::make([
'id' => 'courier_address',
'type' => 'text',
'label' => 'Delivery Address',
'dependency' => [
['delivery_type', '==', 'courier'],
],
]);
// Multiple conditions (AND)
WP_Field::make([
'id' => 'special_field',
'type' => 'text',
'label' => 'Special Field',
'dependency' => [
['field1', '==', 'value1'],
['field2', '!=', 'value2'],
'relation' => 'AND',
],
]);
// Multiple conditions (OR)
WP_Field::make([
'id' => 'notification',
'type' => 'text',
'label' => 'Notification',
'dependency' => [
['type', '==', 'sms'],
['type', '==', 'email'],
'relation' => 'OR',
],
]);WP_Field::make([
'id' => 'work_times',
'type' => 'repeater',
'label' => 'Work Times',
'min' => 1,
'max' => 7,
'add_text' => 'Add Day',
'fields' => [
[
'id' => 'day',
'type' => 'select',
'label' => 'Day',
'options' => ['mon' => 'Mon', 'tue' => 'Tue'],
],
[
'id' => 'from',
'type' => 'time',
'label' => 'From',
],
[
'id' => 'to',
'type' => 'time',
'label' => 'To',
],
],
]);WP_Field::make([
'id' => 'address',
'type' => 'group',
'label' => 'Address',
'fields' => [
['id' => 'city', 'type' => 'text', 'label' => 'City'],
['id' => 'street', 'type' => 'text', 'label' => 'Street'],
['id' => 'number', 'type' => 'text', 'label' => 'Number'],
],
]);WP_Field::make([
'id' => 'custom_css',
'type' => 'code_editor',
'label' => 'Custom CSS',
'mode' => 'css', // css, javascript, php, html
'height' => '400px',
]);WP_Field::make([
'id' => 'menu_icon',
'type' => 'icon',
'label' => 'Menu Icon',
'library' => 'dashicons',
]);WP_Field::make([
'id' => 'location',
'type' => 'map',
'label' => 'Location',
'api_key' => 'YOUR_GOOGLE_MAPS_API_KEY',
'zoom' => 12,
'center' => ['lat' => 55.7558, 'lng' => 37.6173],
]);WP_Field::make([
'id' => 'menu_order',
'type' => 'sortable',
'label' => 'Menu Order',
'options' => [
'home' => 'Home',
'about' => 'About',
'services' => 'Services',
'contact' => 'Contact',
],
]);WP_Field::make([
'id' => 'color_scheme',
'type' => 'palette',
'label' => 'Color Scheme',
'palettes' => [
'blue' => ['#0073aa', '#005a87', '#003d82'],
'green' => ['#28a745', '#218838', '#1e7e34'],
'red' => ['#dc3545', '#c82333', '#bd2130'],
],
]);WP_Field::make([
'id' => 'cta_button',
'type' => 'link',
'label' => 'CTA Button',
]);
// Get value:
$link = get_post_meta($post_id, 'cta_button', true);
// ['url' => '...', 'text' => '...', 'target' => '_blank']WP_Field::make([
'id' => 'settings_accordion',
'type' => 'accordion',
'label' => 'Settings',
'sections' => [
[
'title' => 'General',
'open' => true,
'fields' => [
['id' => 'title', 'type' => 'text', 'label' => 'Title'],
],
],
[
'title' => 'Advanced',
'fields' => [
['id' => 'desc', 'type' => 'textarea', 'label' => 'Description'],
],
],
],
]);WP_Field::make([
'id' => 'heading_typography',
'type' => '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 52 field types in action:
👉 Tools → WP_Field Examples
or
👉 /wp-admin/tools.php?page=wp-field-examples
The page includes:
- ✅ All field types with live examples
- ✅ Code for each field
- ✅ 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: 52+
- Dependency Operators: 12
- Storage Types: 5
- External Dependencies: 0
- WordPress: 4.6+
- PHP: 7.4+
- 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)