Skip to content

Added Site Health Notice for incorrect folder names#3553

Open
andrewlimaza wants to merge 1 commit intostrangerstudios:devfrom
andrewlimaza:site-health-information
Open

Added Site Health Notice for incorrect folder names#3553
andrewlimaza wants to merge 1 commit intostrangerstudios:devfrom
andrewlimaza:site-health-information

Conversation

@andrewlimaza
Copy link
Contributor

@andrewlimaza andrewlimaza commented Dec 23, 2025

  • ENHANCEMENT: Added Site Health critical issue notification if plugins are using development/GitHub slugs.

Resolves: #767

Marking this as a draft PR as we will want to reword it and possibly add more notices for other conflicts we find.

Screenshot 2025-12-23 at 13 02 59

* ENHANCEMENT: Added Site Health critical issue notification if plugins are using development/GitHub slugs.
@dparker1005 dparker1005 added this to the 3.7 milestone Jan 6, 2026
@andrewlimaza andrewlimaza marked this pull request as ready for review February 5, 2026 13:15
@dparker1005 dparker1005 requested a review from Copilot February 6, 2026 17:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a WordPress Site Health “critical” status test to detect Paid Memberships Pro Add Ons installed with incorrect folder names (e.g., GitHub “-master” slugs), complementing the existing Site Health “Info” debug field.

Changes:

  • Registers a new site_status_tests check for incorrect PMPro Add On folder names.
  • Extends the existing “Incorrect Add On Folder Names” debug info field to drive the new status test logic.
  • Adds internal state tracking ($file_errors) to indicate when incorrect folder names were detected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if ( ! empty( $errors ) ) {
self::$file_errors = true;
$formatted_response = implode( " | \n", $errors );
} else {
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

get_add_ons_with_incorrect_folder_name() sets self::$file_errors = true when errors exist, but never resets it back to false when no errors are found. This makes the result dependent on call order within a request (e.g., a prior call that found errors can cause site_health_incorrect_addon_folder_names() to report a critical issue even after a later call finds none). Set self::$file_errors based on the current $errors every call, or avoid shared mutable state and just return/check the underlying array from PMPro_AddOns::get_add_ons_with_incorrect_folder_names().

Suggested change
} else {
} else {
self::$file_errors = false;

Copilot uses AI. Check for mistakes.
'description' => __( 'One or more Paid Memberships Pro Add Ons have incorrect folder names which may cause issues with updates and translations. Please review the Site Health Info > Paid Memberships Pro tab for details.', 'paid-memberships-pro' ),
'test' => 'pmpro-incorrect-addon-folder-names',
);
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

site_health_incorrect_addon_folder_names() returns a result array only when an issue is found and otherwise returns null. Site Health test callbacks are expected to always return a structured result array (including a passing “good” status), otherwise WordPress may treat the test as invalid or trigger notices when consuming the result. Return an explicit “good” result when no incorrect folder names are detected.

Suggested change
}
}
// Explicitly return a "good" result when no incorrect folder names are detected.
return array(
'label' => __( 'Incorrect Paid Memberships Pro Add On Folder Names', 'paid-memberships-pro' ),
'status' => 'good',
'badge' => array(
'label' => __( 'PMPro', 'paid-memberships-pro' ),
'color' => 'blue',
),
'description' => __( 'All Paid Memberships Pro Add On folder names are correct.', 'paid-memberships-pro' ),
'test' => 'pmpro-incorrect-addon-folder-names',
);

Copilot uses AI. Check for mistakes.
Comment on lines 128 to 132
'pmpro-add-ons-incorrect-folder-names' => [
'label' => __( 'Incorrect Add On Folder Names', 'paid-memberships-pro' ),
'value' => self::get_add_ons_with_incorrect_folder_name(),
],
],
'pmpro-current-site-url' => [
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

There is inconsistent indentation on the closing bracket for the pmpro-add-ons-incorrect-folder-names field; it uses spaces and is misaligned compared to the surrounding array formatting. This is likely to fail phpcs/formatting checks—align it with the other entries.

Copilot uses AI. Check for mistakes.
Comment on lines 44 to 47
public function hook() {
add_filter( 'debug_information', [ $this, 'debug_information' ] );
add_filter( 'site_status_tests', [ $this, 'register_site_health_tests' ] );
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The new site_status_tests filter is added in hook(), but unhook() only removes the debug_information filter. If unhook() is ever used, the Site Health test callback will remain registered; add the corresponding remove_filter( 'site_status_tests', [ $this, 'register_site_health_tests' ] ) in unhook() (or make hook/unhook symmetrical via a shared callback reference).

Copilot uses AI. Check for mistakes.
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.

Help people transition from plugins they've downloaded on GitHub (-master)

2 participants