Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
Last active Nov 14, 2018
Embed
What would you like to do?
composer setup with CMB2 in project file
{
"name": "client/project",
"description": "Client Name",
"authors": [],
"type": "project",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
},
{
"type": "package",
"package": {
"name": "johnbillion/extended-cpts",
"version": "4.2.0",
"type": "wordpress-muplugin",
"source": {
"type": "git",
"url": "https://github.com/johnbillion/extended-cpts",
"reference": "tags/4.2.0"
},
"require": {
"composer/installers": "~1.0"
},
"autoload": {
"files": [
"extended-cpts.php"
]
}
}
},
{
"type": "package",
"package": {
"name": "cmb2/cmb2",
"version": "2.4.2",
"type": "wordpress-muplugin",
"source": {
"type": "git",
"url": "https://github.com/cmb2/cmb2",
"reference": "tags/v2.4.2"
}
}
}
],
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"wpackagist-plugin/gutenberg": "~4.1",
"johnbillion/extended-cpts": "^4.2",
"wpackagist-plugin/wp-redis": "^0.7",
"cmb2/cmb2": "^2.4.2"
},
"require-dev": {
"wpackagist-plugin/debug-bar": "9999999-dev",
"wpackagist-plugin/debug-bar-extender": "9999999-dev",
"wpackagist-plugin/debug-bar-cron": "9999999-dev",
"wpackagist-plugin/developer": "9999999-dev",
"wpackagist-plugin/rewrite-rules-inspector": "9999999-dev",
"wpackagist-plugin/log-deprecated-notices": "9999999-dev",
"wpackagist-plugin/query-monitor": "9999999-dev",
"phpunit/phpunit": "~6.5",
"10up/wp_mock": "~0.3",
"squizlabs/php_codesniffer": "~3.3",
"humanmade/coding-standards": "~0.5",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4"
},
"extra": {
"installer-paths": {
"plugins/{$name}/": ["type:wordpress-plugin"],
"mu-plugins/{$name}/": ["type:wordpress-muplugin"]
}
}
}
<?php
/*
Plugin Name: Plugin Loader
Description: Loads the MU plugins required to run the site. This file exists in wp-content/mu-plugins and it is assumed
that the composer packages we're including are also stored here.
Version: 1.0
*/
if ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) {
return;
}
// Plugins to be loaded for any site
$global_mu_plugins = [
'extended-cpts/extended-cpts.php',
'cmb2/init.php',
];
// Load the plugin files
foreach ( $global_mu_plugins as $file ) {
if ( file_exists( WPMU_PLUGIN_DIR . '/' . $file ) ) {
require_once WPMU_PLUGIN_DIR . '/' . $file;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment