Skip to content

Commit

Permalink
Compatibility layer - Add manual fix required warning for WP Cerber (#59
Browse files Browse the repository at this point in the history
)

* remove unnecessary spacing

* define wp-cerber fix

* apply the wp-cerber fix

* replace copy pasta

* add the wp cerber base class

* remove the WP Cerber automatic fix
this doesn't actually solve the issue. the fix will need to be manual

* add wp-cerber to the list of manual fixes

* add a filter so the plugins reported on site health can be filtered
  • Loading branch information
jazzsequence authored Sep 6, 2024
1 parent 05ff4fc commit c9f69cb
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,59 @@ Allows you to disable the cache control headers that are sent by the Pantheon Pa
add_filter( 'pantheon_skip_cache_control', '__return_true' );
```

#### `pantheon_compatibility_known_issues_plugins`
Allows you to filter plugins with known compatibility issues on Pantheon so they are excluded from the Site Health check.

**Default Value:** An array of plugins with known issues, e.g.:
```php
[
'big-file-uploads' => [
'plugin_status' => esc_html__( 'Manual Fix Required', 'pantheon' ),
'plugin_slug' => 'tuxedo-big-file-uploads/tuxedo_big_file_uploads.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#big-file-uploads'
)
),
],
'jetpack' => [
'plugin_status' => esc_html__( 'Manual Fix Required', 'pantheon' ),
'plugin_slug' => 'jetpack/jetpack.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#jetpack'
)
),
],
'wordfence' => [
'plugin_status' => esc_html__( 'Manual Fix Required', 'pantheon' ),
'plugin_slug' => 'wordfence/wordfence.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#wordfence'
)
),
],
]
```

**Example:**
```php
// Filter a specific plugin out of the known issues list.
add_filter( 'pantheon_compatibility_known_issues_plugins', function( $plugins ) {
if ( isset( $plugins['plugin-slug'] ) ) {
unset( $plugins['plugin-slug'] );
}
return $plugins;
} );
```

### Actions
#### `pantheon_cache_settings_page_top`
Runs at the top of the Pantheon Page Cache settings page.
Expand Down
2 changes: 1 addition & 1 deletion inc/compatibility/fixes/class-updatevaluefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UpdateValueFix {
* @return void
*/
public static function apply( $option_name, $option_key, $option_value ) {
$options = json_decode( get_option( $option_name ) );
$options = json_decode( get_option( $option_name ) );
$options->$option_key = $option_value;
update_option( $option_name, json_encode( $options ) );
}
Expand Down
19 changes: 18 additions & 1 deletion inc/site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ function get_compatibility_manual_fixes() {
)
),
],
'wp-cerber' => [
'plugin_status' => esc_html__( 'Manual Fix Required', 'pantheon' ),
'plugin_slug' => 'wp-cerber/wp-cerber.php',
'plugin_message' => wp_kses_post(
sprintf(
/* translators: %s: the link to relevant documentation. */
__( 'WP Cerber conflicts with Pantheon\'s Global CDN caching. Read more about the issue <a href="%s" target="_blank">here</a>.', 'pantheon' ),
'https://docs.pantheon.io/plugins-known-issues#wp-cerber'
)
)
]
];

return add_plugin_names_to_known_issues(
Expand Down Expand Up @@ -280,7 +291,12 @@ function add_plugin_names_to_known_issues( $plugins ) {
}
}

return $plugins;
/**
* Allow the list of plugins with known issues to be filtered.
*
* @param array $plugins The list of plugins with known issues.
*/
return apply_filters( 'pantheon_compatibility_known_issues_plugins', $plugins );
}

/**
Expand Down Expand Up @@ -843,6 +859,7 @@ 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' ),
Expand Down

0 comments on commit c9f69cb

Please sign in to comment.