Fix "undefined offset" warning notice on payment settings page (#33956)

* Fix undefined offset notice on payment settings page

* Add changelog
This commit is contained in:
Chi-Hsuan Huang 2022-07-18 16:54:02 +08:00 committed by GitHub
parent fa5c2430ac
commit 282d8daa26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix undefined offset notice on payment settings page

View File

@ -244,7 +244,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
$plugin_suggestions = array_filter(
$plugin_suggestions,
function( $plugin ) use ( $country, $filter_by, $active_plugins ) {
if ( ! isset( $plugin->{$filter_by} ) || ! isset( $plugin->image_72x72 ) || ! isset( $plugin->plugins ) || in_array( $plugin->plugins[0], $active_plugins, true ) ) {
if ( ! isset( $plugin->{$filter_by} ) || ! isset( $plugin->image_72x72 ) || ! isset( $plugin->plugins[0] ) || in_array( $plugin->plugins[0], $active_plugins, true ) ) {
return false;
}
return in_array( $country, $plugin->{$filter_by}, true );