Skip to content

Commit

Permalink
Merge pull request #9 from alleyinteractive/feature/plugin-name-excep…
Browse files Browse the repository at this point in the history
…tions

Account for one-off plugin naming exceptions
  • Loading branch information
srtfisher authored Feb 14, 2024
2 parents 3ef19b6 + 61daece commit ab8e622
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/coding-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
code-quality:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- develop
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
coding-standards:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `WP Plugin Loader` will be documented in this file.

## 0.1.2 - 2024-02-09

- Account for some one-off plugins that don't follow the standard naming conventions.

## 0.1.1 - 2023-07-24

- Added APCu caching for plugin folder lookups.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"alleyinteractive/composer-wordpress-autoloader": "^1.0"
},
"require-dev": {
"alleyinteractive/alley-coding-standards": "^1.0",
"alleyinteractive/alley-coding-standards": "^2.0",
"szepeviktor/phpstan-wordpress": "^1.1"
},
"config": {
Expand Down
18 changes: 18 additions & 0 deletions src/class-wp-plugin-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ protected function load_plugins(): void {
$paths[] = "$folder/$sanitized_plugin/$sanitized_plugin.php";
$paths[] = "$folder/$sanitized_plugin/plugin.php";
$paths[] = "$folder/$sanitized_plugin.php";

if ( 0 === strpos( $sanitized_plugin, 'wordpress-' ) ) {
$paths[] = "$folder/" . substr( $sanitized_plugin, 10 ) . "/$sanitized_plugin.php";
} elseif ( 0 === strpos( $sanitized_plugin, 'wp-' ) ) {
$paths[] = "$folder/" . substr( $sanitized_plugin, 3 ) . "/$sanitized_plugin.php";
}

// Plugin-specific exceptions that don't follow the standard pattern.
$paths = array_merge(
$paths,
(array) match ( $sanitized_plugin ) {
'logger' => [ "$folder/logger/ai-logger.php" ],
'shortcake' => [ "$folder/shortcake/dev.php" ],
'vip-decoupled-bundle' => [ "$folder/vip-decoupled-bundle/vip-decoupled.php" ],
'wp-updates-notifier' => [ "$folder/wp-updates-notifier/class-sc-wp-updates-notifier.php" ],
default => [],
},
);
}

foreach ( $paths as $path ) {
Expand Down

0 comments on commit ab8e622

Please sign in to comment.