function extract_from_directory( $dir, $excludes = array(), $includes = array(), $prefix = '' ) { $old_cwd = getcwd(); chdir( $dir ); $translations = new Translations; $file_names = (array) scandir( '.' ); foreach ( $file_names as $file_name ) { if ( '.' == $file_name || '..' == $file_name ) continue; if ( preg_match( '/\.php$/', $file_name ) && $this->does_file_name_match( $prefix . $file_name, $excludes, $includes ) ) { $translations->merge_originals_with( $this->extract_from_file( $file_name, $prefix ) ); } if ( is_dir( $file_name ) ) { $translations->merge_originals_with( $this->extract_from_directory( $file_name, $excludes, $includes, $prefix . $file_name . '/' ) ); } } chdir( $old_cwd ); return $translations; }