Download the PHP package mituu/acf-default-value-initializer without Composer
On this page you can find all versions of the php package mituu/acf-default-value-initializer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mituu/acf-default-value-initializer
More information about mituu/acf-default-value-initializer
Files in mituu/acf-default-value-initializer
Package acf-default-value-initializer
Short Description ACF plugin to automatically initialize default values for existing posts and users
License GPL-2.0-or-later
Informations about the package acf-default-value-initializer
ACF Default Value Initializer
A WordPress plugin that automatically initializes default values for Advanced Custom Fields (ACF) on existing posts and users.
Description
When you add new ACF fields with default values to existing content, WordPress typically only applies these defaults to new posts/users created after the field was added. This plugin solves that problem by automatically applying default values to existing content that doesn't have a value for the field.
Features
- 🔄 Automatic Default Value Application: Applies default values to existing posts/users when fields are saved
- ⚙️ Field-Level Control: Enable/disable default value initialization per field
- 🎯 Selective Processing: Only processes content that doesn't already have a value for the field
- 🔧 Manual Processing: Admin interface button for manual initialization
- 📝 Multiple Post Types: Works with posts, pages, custom post types, and users
- 🛡️ Safe Processing: Only updates empty fields, preserves existing data
- 🎨 Clean Admin UI: Seamless integration with ACF field settings
Requirements
- WordPress: 6.4 or higher
- PHP: 8.1 or higher
- ACF: Advanced Custom Fields (free or Pro version)
Installation
Via Composer
Manual Installation
- Download the plugin
- Upload to
/wp-content/plugins/acf-default-value-initializer/ - Activate through the WordPress admin
Enabling Default Value Initialization
- Go to Custom Fields > Field Groups in your WordPress admin
- Edit any field group
- For each field you want to initialize defaults:
- Open the field settings
- Enable the "Initialize Default Values" checkbox
- Set your desired default value for the field
- Save the field group
Supported Field Types
The plugin supports default value initialization for:
- Text, Textarea, Number, Email, URL, Password
- Select, Checkbox, Radio, Button Group, True/False
- Date Picker, Date Time Picker, Time Picker, Color Picker
- Range, WYSIWYG, oEmbed
- User, Post Object, Page Link, Relationship, Taxonomy
- Image, File, Gallery
Manual Processing
If you need to manually trigger default value initialization:
- Edit a field group in the ACF admin
- Look for the "🔄 Initialize Default Values" button
- Click the button to manually process all existing content for this field group
How It Works
Automatic Processing
When you save a field group with fields that have "Initialize Default Values" enabled:
- The plugin identifies all posts/users that match the field group's location rules
- For each field with initialization enabled, it checks if the post/user has a value
- If no value exists, it applies the field's default value
- Existing values are never overwritten
Processing Flow
Technical Details
Plugin Structure
Key Classes
Plugin: Main plugin initialization and coordinationHooks: WordPress action/filter hooks managementFieldSettings: ACF field settings modificationsDefaultValueProcessor: Core logic for applying default values
Hooks and Filters
The plugin uses these WordPress hooks:
acf/save_post- Triggers default value processingacf/render_field_settings- Adds the initialization checkboxwp_ajax_acf_dvi_process_field_group- Handles manual processing
Configuration
Field-Level Settings
Each ACF field can be individually configured:
Location Rules
The plugin respects ACF location rules, so default values are only applied to content that matches the field group's location conditions.
Development
Local Development Setup
Code Standards
- PHP 8.1+ with strict types
- PSR-4 autoloading
- WordPress coding standards
- Comprehensive error handling
Changelog
Version 1.0.0
- Initial release
- Automatic default value initialization
- Field-level control settings
- Manual processing interface
- Support for all major ACF field types
Support
For issues, feature requests, or contributions:
License
This project is licensed under the GPL v2 or later - see the LICENSE for details.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request