grofftech / meta-box-generator
A WordPress plugin for generating Meta Boxes
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
Type:wordpress-plugin
pkg:composer/grofftech/meta-box-generator
Requires
- php: >=8.1
- php-di/php-di: 7.0.11
Requires (Dev)
- brain/monkey: v2.3.0
- phpunit/phpunit: 10.5.48
- wp-coding-standards/wpcs: 3.2.0
This package is auto-updated.
Last update: 2025-09-23 18:20:47 UTC
README
Meta Box Generator is a WordPress plugin for allowing database migrations to be done with code.
Requirements
- Composer version 2+ https://getcomposer.org/
Installation
Installing this plugin assumes you are managing plugins for a WordPress site with composer
or wp-packagist
. It is currently not part of the WordPress plugin repository so it can't be installed with wp-packagist
.
Add the following configuration to your composer.json
. If you are managing plugins with wp-packagist
, this configuration may already be present.
"extra": {
"installer-paths": {
"plugins/{$name}/": ["type:wordpress-plugin"]
}
}
Install with composer
composer require grofftech\wp-migrator
Usage
Metabox Configuration
Hook into the filter mbg_add_metabox_configuration_files
and include file(s) that have an array returned like the sample below. Make sure the filter is configured in your plugin during its initialization, so that it can be properly registered.
add_filter( 'mbg_add_metabox_configuration_files', 'add_files');
function add_files( $files ) {
$files[] = // Directory path to your file
return $files;
}
For your returned array, use the sample below. Replace the metabox.sample
key in the array to the name of the meta box you are configuring (e.g. metabox.article). Update the add_meta_box
configuration to be specific for your meta box. See https://developer.wordpress.org/reference/functions/add_meta_box/. Update the view
key to a directory path of your view file for the meta box.
return array(
'metabox.sample' => array(
'add_meta_box' => array(
'title' => __('Sample Meta Box', 'your_text_domain'), // The title of the meta box
'screen' => 'post', // The post type
'context' => 'advanced', // Where it should be displayed for the screen
'priority' => 'default', // default, high, low
'callback_args' => null, // Additional params for the callback
'include_custom_fields' => false
),
'custom_fields' => array()
),
'view' => // Directory path to your view file
)
);
If you need to include custom fields in your meta box, set the include_custom_fields
key to true
and configure an array of options for your custom view(s) using the sample below.
'custom_fields' => array(
'sample_custom_field' => array( // replace sample_custom_field your your custom field name
'is_single' => true, // ?
'default' => '', // ?
'delete_state' => '', // ?
'sanitize' => 'sanitize_text_field' // A WordPress sanitize function for your custom field
),
// Another custom field configuration would go here if multiple, configured just like above
),
See https://developer.wordpress.org/plugins/metadata/custom-meta-boxes/ for more information about custom meta boxes.