GATHERPRESS_CORE_PATH, ) ); foreach ( $registered_autoloaders as $namespace => $path ) { $namespace_root = sprintf( '%s\\', $namespace ); $class_string = trim( $class_string, '\\' ); if ( empty( $class_string ) || false === strpos( $class_string, '\\' ) || 0 !== strpos( $class_string, $namespace_root ) ) { continue; } $structure = explode( '\\', str_replace( '_', '-', strtolower( $class_string ) ) ); $file = $structure[ count( $structure ) - 1 ]; $class_type = $structure[ count( $structure ) - 2 ]; array_shift( $structure ); array_pop( $structure ); array_unshift( $structure, 'includes' ); // Check if a specialized directory exists for this class type. $test_structure = $structure; array_pop( $test_structure ); array_push( $test_structure, 'classes', $class_type ); $specialized_dir = $path . DIRECTORY_SEPARATOR . implode( DIRECTORY_SEPARATOR, $test_structure ); if ( is_dir( $specialized_dir ) ) { array_pop( $structure ); array_push( $structure, 'classes', $class_type ); } else { $structure[] = 'classes'; } $structure[] = sprintf( 'class-%s.php', $file ); $resource_path = $path . DIRECTORY_SEPARATOR . implode( DIRECTORY_SEPARATOR, $structure ); $resource_path_valid = validate_file( $resource_path ); if ( file_exists( $resource_path ) && ( 0 === $resource_path_valid || 2 === $resource_path_valid ) ) { // Autoloader dynamically loads class files at runtime - cannot use 'use' keyword. require_once $resource_path; // NOSONAR. } } } ); } }