Welcome to WPSE. I think I see your issue, but without access to the output of rwmb_meta( 'modules', array( 'object_type' => 'setting' ), 'kdc-site-functions' )
, I cannot be sure.
Your problem appears to be that you are looping through $all_modules, but using in_array()
to examine $active_modules. Based on your loop, here is what I would expect to read:
// Because you are looping through $all_modules for $module, I assume you should use it...
foreach ( $all_modules as $module ) {
// If I examine $module, this should not throw and error
if ( in_array( 'products', $module, true ) ) {
require plugin_dir_path( __FILE__ ) . $module['path'];
}
}
Looking at your current code, I would assume that you are getting a failure (FALSE) value back from rwmb_meta()
, then popping that into your in_array()
function causes your error.
Otherwise, I would suggest you at least examine the results of your rwmb_meta()
function, to ensure it is an array:
if (is_array($active_modules) && !empty($active_modules)){
// other code here...
}
Hope this solves it! Good luck.