Skip to content

Commit

Permalink
Add PhastPress as an incompatible plugin (#56)
Browse files Browse the repository at this point in the history
* add phastpress as an incompatible plugin
add a new section for plugin_compatibility to use with incompatible plugins

* push review fixes into the table if there are incompatible plugins

* we don't need to use OB if we say pass false to the $output param

* if we're only outputting incompatible plugins, filter the array

* add the plugin_compatibility field to other incompatible plugins

* add test for output compatibility status table

* fix typo
(plugin -> plugins)

* remove redundant reuse of output_compatibility_status_table

Co-authored-by: Phil Tyler <[email protected]>

---------

Co-authored-by: Phil Tyler <[email protected]>
  • Loading branch information
jazzsequence and pwtyler authored Aug 30, 2024
1 parent 35224b9 commit 05ff4fc
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 6 deletions.
63 changes: 57 additions & 6 deletions inc/site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ function output_compatibility_content( $tab ) {
*
* @param array $plugins
* @param bool $output
* @param bool $incompatible True if only incompatible plugin issues should be displayed.
*/
function output_compatibility_status_table( $plugins, $output = true ) {
function output_compatibility_status_table( $plugins, $output = true, $incompatible = false ) {
ob_start();
?>
<table class='widefat striped health-check-table' role='presentation'>
Expand All @@ -148,6 +149,14 @@ function output_compatibility_status_table( $plugins, $output = true ) {
</thead>
<tbody>
<?php

// Filter out incompatible plugins. This allows us to re-use the status table for different types of compatibility issues.
if ( $incompatible && ( ! isset( $plugins['plugin_compatibility'] ) || $plugins['plugin_compatibility'] !== 'incompatible' ) ) {
$plugins = array_filter( $plugins, function ( $plugins ) {
return $plugins['plugin_compatibility'] === 'incompatible';
} );
}

foreach ( $plugins as $field ) {
/* translators: %s: A plugin's compatibility status. */
$status = sprintf( __( '%s', 'pantheon' ), ucfirst( $field['plugin_status'] ) );
Expand Down Expand Up @@ -291,6 +300,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#adthrive-ads'
)
),
'plugin_compatibility' => 'incompatible',
],
'all-in-one-wp-migration' => [
'plugin_status' => esc_html__( 'Incompatible', 'pantheon' ),
Expand All @@ -302,6 +312,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#all-in-one-wp-migration'
)
),
'plugin_compatibility' => 'incompatible',
],
'bookly' => [
'plugin_status' => esc_html__( 'Incompatible', 'pantheon' ),
Expand All @@ -313,6 +324,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#bookly'
)
),
'plugin_compatibility' => 'incompatible',
],
'coming-soon' => [
'plugin_status' => esc_html__( 'Partial Compatibility', 'pantheon' ),
Expand Down Expand Up @@ -390,6 +402,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#h5p'
)
),
'plugin_compatibility' => 'incompatible',
],
'hm-require-login' => [
'plugin_status' => esc_html__( 'Incompatible', 'pantheon' ),
Expand All @@ -401,6 +414,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#hm-require-login'
)
),
'plugin_compatibility' => 'incompatible',
],
'hummingbird-performance' => [
'plugin_status' => esc_html__( 'Partial Compatibility', 'pantheon' ),
Expand All @@ -423,6 +437,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#hyperdb'
)
),
'plugin_compatibility' => 'incompatible',
],
'iwp-client' => [
'plugin_status' => esc_html__( 'Incompatible', 'pantheon' ),
Expand All @@ -434,6 +449,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#infinitewp'
)
),
'plugin_compatibility' => 'incompatible',
],
'instashow' => [
'plugin_status' => esc_html__( 'Incompatible', 'pantheon' ),
Expand All @@ -445,6 +461,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#instashow'
)
),
'plugin_compatibility' => 'incompatible',
],
'wp-maintenance-mode' => [
'plugin_status' => esc_html__( 'Incompatible', 'pantheon' ),
Expand All @@ -456,6 +473,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#maintenance-mode'
)
),
'plugin_compatibility' => 'incompatible',
],
'worker' => [
'plugin_status' => esc_html__( 'Partial Compatibility', 'pantheon' ),
Expand All @@ -478,6 +496,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#monarch-social-sharing'
)
),
'plugin_compatibility' => 'incompatible',
],
'new-relic' => [
'plugin_status' => esc_html__( 'Partial Compatibility', 'pantheon' ),
Expand Down Expand Up @@ -533,6 +552,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#query-monitor'
)
),
'plugin_compatibility' => 'incompatible',
],
'site24x7' => [
'plugin_status' => esc_html__( 'Partial Compatibility', 'pantheon' ),
Expand All @@ -555,6 +575,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#smush-pro'
)
),
'plugin_compatibility' => 'incompatible',
],
'better-wp-security' => [
'plugin_status' => esc_html__( 'Partial Compatibility', 'pantheon' ),
Expand All @@ -577,6 +598,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#unbounce-landing-pages'
)
),
'plugin_compatibility' => 'incompatible',
],
'unyson' => [
'plugin_status' => esc_html__( 'Partial Compatibility', 'pantheon' ),
Expand Down Expand Up @@ -610,6 +632,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#weather-station'
)
),
'plugin_compatibility' => 'incompatible',
],
'webp-express' => [
'plugin_status' => esc_html__( 'Partial Compatibility', 'pantheon' ),
Expand Down Expand Up @@ -676,6 +699,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#wp-phpmyadmin'
)
),
'plugin_compatibility' => 'incompatible',
],
'wp-reset' => [
'plugin_status' => esc_html__( 'Incompatible', 'pantheon' ),
Expand All @@ -687,6 +711,7 @@ function get_compatibility_review_fixes() {
'https://docs.pantheon.io/plugins-known-issues#wp-reset'
)
),
'plugin_compatibility' => 'incompatible',
],
'wp-ban' => [
'plugin_status' => esc_html__( 'Partial Compatibility', 'pantheon' ),
Expand Down Expand Up @@ -732,6 +757,18 @@ function get_compatibility_review_fixes() {
)
),
],
'phastpress' => [
'plugin_status' => esc_html__( 'Incompatible', 'pantheon' ),
'plugin_slug' => 'phastpress/phastpress.php',
'plugin_message' => wp_kses_post(
sprintf(
/* translators: %s: the link to relevant documentation. */
__( 'Read more about the issue <a href="%s" target="_blank">here</a>.', 'pantheon' ),
'https://docs.pantheon.io/plugins-known-issues#phastpress'
)
),
'plugin_compatibility' => 'incompatible',
],
];

return add_plugin_names_to_known_issues(
Expand Down Expand Up @@ -805,18 +842,32 @@ function test_compatibility() {
}

if ( ! empty( $manual_fixes ) ) {
$manual_table = output_compatibility_status_table( $manual_fixes, false );
$description = sprintf(
'<p>%s</p>%s',
__( 'There are known compatibility issues with your active plugins that require manual fixes.', 'pantheon' ),
$manual_table
);

if ( ! empty( $review_fixes ) ) {
$review_table = output_compatibility_status_table( $review_fixes, false, true );
$description = sprintf(
'<p>%1$s</p>%2$s<p>%3$s</p>%4$s',
__( 'There are known compatibility issues with your active plugins that require manual fixes.', 'pantheon' ),
$manual_table,
__( 'There are known incompatibility issues with the following plugins.', 'pantheon' ),
$review_table
);
}

return [
'label' => __( 'One or more active plugins require a manual compatibility fix', 'pantheon' ),
'status' => 'critical',
'badge' => [
'label' => __( 'Pantheon', 'pantheon' ),
'color' => 'red',
],
'description' => sprintf(
'<p>%s</p>%s',
__( 'There are known compatibility issues with your active plugins that require manual fixes.', 'pantheon' ),
output_compatibility_status_table( $manual_fixes, false )
),
'description' => $description,
'test' => 'compatibility',
];
}
Expand Down
21 changes: 21 additions & 0 deletions tests/phpunit/test-compatibility-layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,25 @@ public function test_daily_pantheon_cron() {
$this->assertIsArray( $applied_fixes );
$this->assertArrayHasKey( 'wp-force-login/wp-force-login.php', $applied_fixes );
}

public function test_output_compatibility_status_table() {
$plugins = get_option( 'active_plugins' );
foreach ( [ 'tuxedo-big-file-uploads/tuxedo_big_file_uploads.php', 'phastpress/phastpress.php' ] as $plugin ) {
$plugins[] = $plugin;
}
update_option( 'active_plugins', $plugins );
wp_cache_delete( 'plugins', 'plugins' );

$manual_fixes = Pantheon\Site_Health\get_compatibility_manual_fixes();
$review_fixes = Pantheon\Site_Health\get_compatibility_review_fixes();

$manual_table = Pantheon\Site_Health\output_compatibility_status_table( $manual_fixes, false );

$this->assertStringContainsString( 'Big-file-uploads', $manual_table );
$this->assertStringContainsString( 'Manual Fix Required', $manual_table );

$review_table = Pantheon\Site_Health\output_compatibility_status_table( $review_fixes, false, true );
$this->assertStringContainsString( 'Phastpress', $review_table );
$this->assertStringContainsString( 'Incompatible', $review_table );
}
}

0 comments on commit 05ff4fc

Please sign in to comment.