Skip to content

Commit a134ef1

Browse files
committed
Update code
1 parent 6f4bc4d commit a134ef1

4 files changed

Lines changed: 740 additions & 2043 deletions

File tree

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ A comprehensive, modern WordPress plugin boilerplate that follows WordPress codi
88

99
## 🚀 Features
1010

11-
- **Modern PHP Development**: PSR-4 autoloading, namespace organization
11+
- **Modern PHP Development*├── 📁 vendor/ # Composer dependencies
12+
├── 📄 composer.json # Composer configuration (includes Mozart)
13+
├── 📄 package.json # npm configuration
14+
├── 📄 webpack.config.js # Build configuration
15+
├── 📄 init-plugin.sh # Initialization script
16+
└── 📄 your-plugin.php # Main plugin file-4 autoloading, namespace organization
1217
- **WordPress Standards**: Follows WordPress Coding Standards (WPCS)
1318
- **Build System**: @wordpress/scripts with Webpack, Babel, and SCSS support
1419
- **Block Development**: Integrated Gutenberg block creation and registration
@@ -142,6 +147,7 @@ The boilerplate integrates with a comprehensive ecosystem of WordPress-specific
142147
|---------|---------|------------------|
143148
| `wpboilerplate/wpb-register-blocks` | Auto-register Gutenberg blocks from `build/blocks/` ||
144149
| `wpboilerplate/wpb-updater-checker-github` | GitHub-based plugin auto-updates ||
150+
| `coenjacobs/mozart` | PHP dependency scoping and prefixing to prevent conflicts | Manual |
145151

146152
### Dependency Management Packages
147153

@@ -408,6 +414,38 @@ composer require wpboilerplate/wpb-register-blocks
408414
composer require wpboilerplate/wpb-updater-checker-github
409415
```
410416

417+
#### Dependency Management & Build Tools
418+
419+
```bash
420+
# Mozart - PHP dependency scoping and namespacing (already included)
421+
# composer require coenjacobs/mozart:^0.7 # Already included in base composer.json
422+
```
423+
424+
**Mozart Integration**: Mozart helps prevent plugin conflicts by automatically scoping and prefixing third-party PHP dependencies. This is essential when multiple plugins use the same dependencies.
425+
426+
**Pre-installed**: Mozart is already included in the base `composer.json` as a core development tool.
427+
428+
**Configuration Example**:
429+
```json
430+
{
431+
"extra": {
432+
"mozart": {
433+
"dep_namespace": "WordPress_Plugin_Boilerplate\\Vendor\\",
434+
"dep_directory": "/src/dependencies/",
435+
"packages": [
436+
"vendor/package-name"
437+
]
438+
}
439+
}
440+
}
441+
```
442+
443+
**Usage**:
444+
- Mozart is already installed - just add configuration to `composer.json`
445+
- Configure which packages to scope in the `mozart.packages` array
446+
- Run `vendor/bin/mozart compose` to scope dependencies
447+
- All specified packages will be prefixed to avoid conflicts
448+
411449
#### Plugin Dependencies
412450

413451
```bash

agents.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ npm run makepot
194194
6. **wpboilerplate/acrossswp-acf-pro-dependency** - Advanced Custom Fields Pro dependency
195195
7. **wpboilerplate/wpb-view-analytics-dependency** - View analytics tracking
196196

197+
#### Core Development Tools:
198+
8. **coenjacobs/mozart** - PHP dependency scoping and namespacing to prevent plugin conflicts
199+
197200
#### Interactive Package Selection:
198201
The `init-plugin.sh` script provides an interactive interface for selecting WPBoilerplate packages during setup:
199202
- Displays package descriptions and purposes
@@ -209,6 +212,58 @@ The `init-plugin.sh` script provides an interactive interface for selecting WPBo
209212
4. Error handling for invalid selections
210213
5. Clear user feedback and status messages
211214

215+
**NOTE**: Mozart is already included in the base `composer.json` as a core development tool and doesn't need to be added to the interactive package selection process.
216+
217+
### Mozart Package Scoping Integration
218+
219+
#### Purpose & Benefits
220+
Mozart is a Composer plugin that helps prevent conflicts between WordPress plugins by:
221+
- **Dependency Scoping**: Automatically prefixes third-party library namespaces
222+
- **Conflict Prevention**: Prevents version conflicts when multiple plugins use the same libraries
223+
- **Isolation**: Ensures each plugin uses its own isolated version of dependencies
224+
- **Professional Development**: Essential for production plugins with external dependencies
225+
226+
#### Configuration in composer.json
227+
```json
228+
{
229+
"extra": {
230+
"mozart": {
231+
"dep_namespace": "WordPress_Plugin_Boilerplate\\Vendor\\",
232+
"dep_directory": "/src/dependencies/",
233+
"classmap_directory": "/classes/dependencies/",
234+
"classmap_prefix": "WPBP_",
235+
"packages": [
236+
"vendor/package-name"
237+
]
238+
}
239+
}
240+
}
241+
```
242+
243+
#### Usage Workflow
244+
```bash
245+
# 1. Mozart is already installed in composer.json
246+
# composer require coenjacobs/mozart:^0.7 # Already included
247+
248+
# 2. Configure Mozart in composer.json (see above)
249+
250+
# 3. Install your dependencies
251+
composer require vendor/library-name
252+
253+
# 4. Run Mozart to scope dependencies
254+
vendor/bin/mozart compose
255+
256+
# 5. Use scoped dependencies in code
257+
use WordPress_Plugin_Boilerplate\Vendor\LibraryName\ClassName;
258+
```
259+
260+
#### Integration Best Practices
261+
- **Always scope external libraries**: Prevents conflicts with other plugins
262+
- **Update mozart configuration**: When adding new dependencies
263+
- **Version control scoped files**: Include generated files in Git
264+
- **Test thoroughly**: Ensure scoped dependencies work correctly
265+
- **Documentation**: Document scoped namespace usage for team members
266+
212267
### PSR-4 Autoloading Configuration
213268
```json
214269
{

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"homepage": "https://github.com/WPBoilerplate/",
77
"minimum-stability": "dev",
88
"require": {
9-
"php": ">=7.4"
9+
"php": ">=7.4",
10+
"coenjacobs/mozart": "^0.7"
1011
},
1112
"keywords": [
1213
"wordpress",

0 commit comments

Comments
 (0)