Skip to content

Commit

Permalink
[N/A] Stop/Log Emails + Local Config Setup & README update
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-viget committed May 2, 2024
1 parent 2d26ee5 commit 28c281d
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 3 deletions.
7 changes: 6 additions & 1 deletion client-mu-plugins/goodbids/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
"url": "https://wpackagist.org",
"only": [
"wpackagist-plugin/*"
]
},
{
"type":"composer",
Expand All @@ -58,8 +61,10 @@
"vlucas/phpdotenv": "^5.5",
"wpackagist-plugin/accessibility-checker": "^1.10",
"wpackagist-plugin/delete-me": "^3.1",
"wpackagist-plugin/log-emails": "^1.4",
"wpackagist-plugin/miniorange-oauth-20-server": "^6.0",
"wpackagist-plugin/olympus-google-fonts": "^3.6",
"wpackagist-plugin/stop-emails": "^1.2",
"wpackagist-plugin/svg-support": "^2.5",
"wpackagist-plugin/tidio-live-chat": "^6.0",
"wpackagist-plugin/top-bar": "^3.0",
Expand Down
38 changes: 37 additions & 1 deletion client-mu-plugins/goodbids/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 32 additions & 1 deletion client-mu-plugins/goodbids/src/classes/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ private function load_config(): bool {
if ( empty( $local['version'] ) || version_compare( $json['version'], $local['version'], '!=' ) ) {
Log::warning( 'Local config file version mismatch.' );
}
$json = array_merge( $json, $local );

$json = $this->merge_local_config( $json, $local );
}
}

Expand All @@ -323,6 +324,36 @@ private function load_config(): bool {
return true;
}

/**
* Merge local json config with the base json config.
*
* @since 1.0.1
*
* @param array $json
* @param array $local
*
* @return array
*/
private function merge_local_config( array $json, array $local ): array {
$merged = [];

foreach ( $json as $key => $value ) {
$merged[ $key ] = $value;

if ( empty( $local[ $key] ) ) {
continue;
}

if ( is_array( $value ) ) {
$merged[ $key ] = array_merge( $value, $local[ $key ] );
} else {
$merged[ $key ] = $local[ $key ];
}
}

return $merged;
}

/**
* Get a config value. You can use dot notation to get nested values.
*
Expand Down
16 changes: 16 additions & 0 deletions docs/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,19 @@ Set your `phpcs` standard to point to `/Absolute/Path/To/goodbids/.phpcs.xml",`
## Local Config Override

You can override the default local config by adding a `client-mu-plugins/goodbids/config.local.json` file. This will allow you to override specific settings without risk of committing to the repository.

Here is a recommended starting point for your local config file:

```json
{
"version": "1.0",
"advanced": {
"debug-mode": true,
"logging": true
},
"active-plugins": [
"log-emails",
"stop-emails"
]
}
```

0 comments on commit 28c281d

Please sign in to comment.