I have been using this function to automatically require PHP files in a directory.
function req_php_files($filepath) {
$Directory = new RecursiveDirectoryIterator($filepath);
$Iterator = new RecursiveIteratorIterator($Directory);
$Regex = new RegexIterator($Iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
$php_files = array();
foreach ($Regex as $file) {
array_push($php_files, $file[0]);
}
foreach ($php_files as $req_file) {
require_once $req_file;
}
}
This worked well up until recently for some reason now I'm getting an error when loading wp-admin
PHP Warning: array_keys() expects parameter 1 to be array, null given in /Applications/MAMP/htdocs/vac3/wp-admin/includes/plugin.php on line 1718
PHP Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/vac3/wp-admin/includes/plugin.php on line 1718
Here is how I call the function
$theme_path = 'wp-content/themes/' . get_template() . '/acf';
$theme_path_admin = '../wp-content/themes/' . get_template() . '/acf/';
if (!is_admin()) {
$filepath= new SplFileInfo($theme_path);
} else {
//filepath from admin
$filepath= new SplFileInfo($theme_path_admin);
}
req_php_files($filepath->getRealPath()); ?>
this is line 1718 in the /wp-admin/includes/plugin.php
foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {
My question is What part of my function is passing a non-array value to $_wp_submenu_nopriv?