The warnings you’re seeing are due to the fact that the variable $item
is not defined properly before it is accessed in the validate_dirlist
method of your plugin. Specifically, the code is trying to access the array offset on a variable that may not have been initialized.
The issue lies in this part of the code in the validate_dirlist
method (around line 211):
if ( $item['type'] === 'f' && strpos( $item, "." ) !== false ) {
return true;
}
The variable $item
is being used without being initialized first. To resolve this, you’ll need to iterate through the $list
array properly and ensure that $item
is defined before trying to access its properties.
Here’s the corrected version of your validate_dirlist
function:
private function validate_dirlist( $list ) {
foreach ( $list as $item ) {
// Ensure $item is defined and is an array
if ( ! isset( $item['type'] ) || ! is_array( $item ) ) {
continue; // Skip invalid or undefined items
}
// check if it's a file and contains a dot (.)
if ( $item['type'] === 'f' && strpos( $item['name'], "." ) !== false ) {
return true;
}
// validate subdirectories recursively
if ( $item['type'] === 'd' && ! empty( $item['files'] ) && is_array( $item['files'] ) ) {
if ( ! $this->validate_dirlist( $item['files'] ) ) {
return false;
}
}
}
return true;
}