Custom Field For Dev
Code-First Custom Meta Fields for WordPress
by quidelantoine · github.com/quidelantoine/cfdev-plugin · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/quidelantoine/cfdev-plugin/archive/refs/heads/main.zipCFDev — Code-First Custom Meta Fields for WordPress
Declare custom fields in PHP. No admin UI configuration. No database config drift.
English docs · Lire en français
What is CFDev?
CFDev is a WordPress plugin for developers who want to declare custom fields in PHP and never touch the database config again. Post meta, term meta, user meta — everything is registered in code, versioned with your project, and deployed without migration scripts.
What you get out of the box:
- 30+ field types — text, image, file, select, checkboxes, date, wysiwyg, color, gallery, link, and more
- Post, term and user meta — attach meta boxes to any CPT or taxonomy, and field groups to user profiles
- Options pages — global site settings stored in
wp_options, with sub-pages, bundles, tabs, and accordion — no ACF Options add-on needed - Layout containers — group fields into Bundles (repeatable row groups), Tabs, or Accordions for clean, structured edit screens
- Repeatable fields — any field can be made repeatable with AJAX-powered add/remove
- 25+ validation rules — required, min/max, regex, email, URL… enforced server-side, errors survive the redirect
- File cache — resolved field data cached to disk, invalidated on save, ready for high-traffic reads
- Admin helper — a built-in back-office panel to inspect all registered fields, browse cached data, and flush the cache in one click
- REST API — expose any field (including options) via WP REST with a single
'rest' => trueflag
register_cfdev_post_type(['book', 'books'], ['public' => true])
->addTaxonomy('genre')
->addMetaBox('book_details', 'Book Details', [
['id' => 'subtitle', 'type' => 'text', 'label' => 'Subtitle', 'required' => true],
['id' => 'cover', 'type' => 'image', 'label' => 'Cover Image'],
['id' => 'pages', 'type' => 'number', 'label' => 'Page Count'],
['id' => 'published', 'type' => 'date', 'label' => 'Published Date'],
]);
Requirements
| Minimum | Recommended | |
|---|---|---|
| PHP | 8.2 | 8.3+ |
| WordPress | 6.5 | latest |
Installation
Option 1 — Upload via WordPress Admin (recommended)
Download the latest cfdev-plugin-x.x.x.zip from GitHub Releases, then upload it via WordPress Admin → Plugins → Add New → Upload Plugin.
Option 2 — Manual copy
Extract the zip, rename the folder to cfdev-plugin if needed, then copy it to wp-content/plugins/.
⚠️ Some zip extractors rename the folder after the zip filename (e.g.
cfdev-plugin-1.0.4). Rename it tocfdev-pluginbefore copying.
No Composer required. The plugin ships with a built-in PSR-4 autoloader — no
vendor/directory, no build step.
Quick Start
Create a file in your theme (e.g. cfdev-fields.php) and load it, or use functions.php:
add_action('init', static function (): void {
register_cfdev_post_type('product', ['public' => true])
->addMetaBox('product_info', 'Product Info', [
['id' => 'price', 'type' => 'number', 'label' => 'Price', 'required' => true],
['id' => 'photo', 'type' => 'image', 'label' => 'Photo'],
['id' => 'brochure', 'type' => 'file', 'label' => 'Brochure PDF'],
]);
});
Read data in your template:
$cache = new \Weblitzer\CFDev\Cache\CacheManager();
$data = $cache->post(get_the_ID());
$product = $data['groups']['product_info'] ?? [];
echo esc_html($product['price'] ?? '');
echo '<img src="' . esc_url($product['photo']['medium'] ?? '') . '" alt="' . esc_attr($product['photo']['alt'] ?? '') . '">';
Documentation
English
| Guide | Description |
|---|---|
| Installation | Requirements, install, production build |
| Quick Start | First post type, meta box and template |
| Field Types | All 30+ field types with options |
| Layouts | Bundle, Tabs, Accordion |
| Validation | 25+ built-in validation rules |
| Term Meta | Fields on taxonomy terms — all forms and patterns |
| User Meta | Fields on user profiles — roles, locations, order |
| Options Pages | Global site settings in wp_options — sub-pages, layouts, REST |
| Cache | File cache — setup, invalidation, performance |
| Admin UI | CFDev admin pages (Fields, Cache) |
| REST API | Expose fields via WP REST API |
| Repeatable & AJAX | Repeatable fields and AJAX loading |
| Admin Columns | Custom columns in post/term/user lists |
| WooCommerce | Custom fields on products and product categories |
Français
| Guide | Description |
|---|---|
| Installation | Prérequis, installation, build production |
| Démarrage rapide | Premier post type, meta box et template |
| Types de champs | Tous les types de champs avec options |
| Layouts | Bundle, Tabs, Accordion |
| Validation | 25+ règles de validation intégrées |
| Pages d'options | Réglages globaux dans wp_options — sous-pages, layouts, REST |
| Cache | Cache fichier — activation, invalidation, perf |
| Interface admin | Pages admin CFDev (Champs, Cache) |
| REST API | Exposer les champs via WP REST API |
| Répétable & AJAX | Champs répétables et chargement AJAX |
| Colonnes admin | Colonnes dans les listes post/terme/user |
| WooCommerce | Champs personnalisés sur les produits et catégories |
Translations
The admin interface is fully translated into 10 languages:
🇫🇷 French · 🇪🇸 Spanish · 🇩🇪 German · 🇧🇷 Portuguese (BR)
🇳🇱 Dutch · 🇮🇹 Italian · 🇯🇵 Japanese · 🇨🇳 Chinese (Simplified)
🇷🇺 Russian · 🇵🇱 Polish
Translation files are located in the languages/ directory (.po, .mo, .l10n.php).
To contribute a new locale, copy languages/cfdev.pot and translate it with Loco Translate or Poedit.
License
GPL-2.0-or-later