Skip to content

Commit f4643dc

Browse files
committed
feat(env): Integrate Composer for WordPress plugin management
This change introduces Composer-based dependency management for WordPress plugins within the `wp-env` development environment. - `composer.json` is updated to define the project as `wordpress-theme` and utilizes `installer-paths` to install plugins into `.wp-env/plugins`. - Advanced Custom Fields (ACF) is now declared as a `require-dev` dependency and will be installed via Composer. - The `.wp-env.json` `afterStart` script is simplified to activate the plugin, leveraging the Composer installation. - `composer.lock` is removed and added to `.gitignore` to ensure a fresh, consistent dependency set on setup. - The `README.md` is updated to reflect the new development environment setup. This enhances environment consistency and provides better version control for WordPress plugin dependencies.
1 parent e346f76 commit f4643dc

5 files changed

Lines changed: 40 additions & 3505 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,9 @@ assets/conf-img/*.json
8888
### theme.json
8989
src/scss/01-abstract/_theme-json.scss
9090
theme.json
91+
92+
### wp-env
93+
.wp-env/
94+
95+
### Composer
96+
composer.lock

.wp-env.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
33
"core": null,
44
"phpVersion": "8.3",
5-
"themes": [ "." ],
6-
"plugins": [ "https://downloads.wordpress.org/plugin/advanced-custom-fields.zip" ],
5+
"testsEnvironment": false,
6+
"themes": [
7+
"."
8+
],
9+
"plugins": [
10+
".wp-env/plugins/advanced-custom-fields"
11+
],
712
"config": {
813
"WP_DEBUG": true,
914
"WP_DEBUG_LOG": true,
@@ -13,6 +18,6 @@
1318
"WP_DEVELOPMENT_MODE": "theme"
1419
},
1520
"lifecycleScripts": {
16-
"afterStart": "wp-env run cli --env-cwd=wp-content/themes/beapi-frontend-framework composer install --no-interaction"
21+
"afterStart": "wp-env run cli wp theme activate beapi-frontend-framework && wp-env run cli wp plugin activate advanced-custom-fields"
1722
}
18-
}
23+
}

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ On first start, wp-env will:
104104

105105
- Spin up WordPress (PHP 8.3)
106106
- Mount this theme from the current directory
107-
- Install the [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) plugin
108-
- Run `composer install` in the theme via the `afterStart` lifecycle script
107+
- Install and activate the [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) plugin
109108

110109
### URLs and credentials
111110

@@ -210,4 +209,4 @@ function customize_editor_settings( $settings ) {
210209

211210
return $settings;
212211
}
213-
```
212+
```

composer.json

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
{
22
"name": "beapi/beapi-frontend-framework",
33
"description": "Frontend Framework theme for WordPress",
4-
"type": "metapackage",
4+
"type": "wordpress-theme",
5+
"extra": {
6+
"installer-paths": {
7+
".wp-env/plugins/{$name}/": [
8+
"type:wordpress-plugin"
9+
]
10+
}
11+
},
12+
"repositories": [
13+
{
14+
"name": "wp-packages",
15+
"type": "composer",
16+
"url": "https://repo.wp-packages.org"
17+
}
18+
],
519
"require-dev": {
620
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
721
"overtrue/phplint": "^9.0",
822
"php-parallel-lint/php-parallel-lint": "^1.4",
923
"phpcompatibility/phpcompatibility-wp": "^2.1",
1024
"phpro/grumphp-shim": "^2.6",
1125
"roave/security-advisories": "dev-latest",
12-
"wp-coding-standards/wpcs": "^3.1"
26+
"wp-coding-standards/wpcs": "3.3.0",
27+
"wp-plugin/advanced-custom-fields": "6.8.4"
1328
},
14-
"scripts": {
29+
"scripts": {
1530
"cs": [
1631
"./vendor/bin/phpcs ."
1732
],
@@ -27,7 +42,11 @@
2742
"config": {
2843
"allow-plugins": {
2944
"dealerdirect/phpcodesniffer-composer-installer": true,
30-
"phpro/grumphp-shim": true
45+
"phpro/grumphp-shim": true,
46+
"composer/installers": true
47+
},
48+
"platform": {
49+
"php": "8.3.0"
3150
}
3251
}
3352
}

0 commit comments

Comments
 (0)