Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for one-off plugin naming exceptions #9

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

srtfisher
Copy link
Member

@srtfisher srtfisher commented Feb 9, 2024

Account for wordpress-fieldmanager having a main plugin file of fieldmanager.php. Also account for some other one-off plugins that don't follow the standard. Borrows work from Reflector (internal to Alley project).

Copy link
Member

@attackant attackant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions 🐙

@@ -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-' ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( 0 === strpos( $sanitized_plugin, 'wordpress-' ) ) {
if ( str_starts_with( $sanitized_plugin, 'wordpress-' ) ) {


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} elseif ( 0 === strpos( $sanitized_plugin, 'wp-' ) ) {
} elseif ( str_starts_with( $sanitized_plugin, 'wp-' ) ) {

// Plugin-specific exceptions that don't follow the standard pattern.
$paths = array_merge(
$paths,
(array) match ( $sanitized_plugin ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(array) match ( $sanitized_plugin ) {
match ( $sanitized_plugin ) {

Cast may be redundant here?

@srtfisher srtfisher merged commit ab8e622 into develop Feb 14, 2024
4 checks passed
@srtfisher srtfisher deleted the feature/plugin-name-exceptions branch February 14, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants