Skip to main content

Bundling Meta Box

You can use Meta Box and its extensions as standalone plugins. You can also bundle them in your themes or plugins.

Licensing​

The rules are different for free and premium extensions. Free extensions are Meta Box, Meta Box Lite, and the free extensions on WordPress.org. Premium extensions are the extensions that you buy on metabox.io.

Where you bundleFree extensionsPremium extensions
Websites for you or your clientsAllowedAllowed with your license
Free products, such as plugins and themes on WordPress.orgAllowedNot allowed
Products and services that you sell to other people, such as premium plugins, themes, SaaS, hosting, and site maintenanceAllowedContact us for a custom pricing plan

Using TGM Plugin Activation​

Use this method for Meta Box and free extensions. Your theme or plugin declares them as dependencies. WordPress then installs them as normal plugins and updates them automatically.

Using Meta Box in eStar theme

  1. Download TGM Plugin Activation. For I'm going to use TGMPA in a:, select Plugin.
  2. Extract the .zip file.
  3. Copy the files class-tgm-plugin-activation.php and example.php to your theme or plugin folder.
  4. Open the example.php file and add Meta Box to the list of required plugins:
require_once __DIR__ . '/class-tgm-plugin-activation.php';

add_action( 'tgmpa_register', 'prefix_register_required_plugins' );

function prefix_register_required_plugins() {
$plugins = [
[
'name' => 'Meta Box',
'slug' => 'meta-box',
'required' => true,
],
];
$config = [
'id' => 'your-id',
];
tgmpa( $plugins, $config );
}
  1. Include the example.php file in the functions.php file of your theme or in the main file of your plugin.

Using Composer​

Use this method to put Meta Box and extensions in the vendor folder of your theme or plugin. This example bundles Meta Box in a plugin.

  1. In your plugin folder, create a composer.json file with this content:
{
"require": {
"wpmetabox/meta-box": "^5"
},
"autoload": {
"files": [
"vendor/wpmetabox/meta-box/meta-box.php"
]
}
}
  1. In your plugin folder, run composer install.
  2. Add this line to the main file of your plugin:
require 'vendor/autoload.php';

For more extensions, add them to the require and autoload lists. To install premium extensions, you must use your license key. Read the Composer documentation for the full steps.

Directly including extensions​

Not recommended

With this method, extensions do not update automatically. You must update them manually. Old versions can cause conflicts with new versions of WordPress, or with other plugins that use a different version of Meta Box. Use this method only if you cannot use the methods above.

  1. Copy the extension folder to your theme or plugin. You can put it in the root folder or in a subfolder.
  2. Include the main file of the extension in the functions.php file of your theme or in the main file of your plugin:
require get_template_directory() . '/mb-settings-page/mb-settings-page.php';