_wp_check_alternate_file_names()WP 5.8.1

Helper function to test if each of an array of file names could conflict with existing files.

Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.

Хуков нет.

Возвращает

true|false. True if the tested file name could match an existing file, false otherwise.

Использование

_wp_check_alternate_file_names( $filenames, $dir, $files );
$filenames(string[]) (обязательный)
Array of file names to check.
$dir(строка) (обязательный)
The directory containing the files.
$files(массив) (обязательный)
An array of existing files in the directory. May be empty.

Список изменений

С версии 5.8.1 Введена.

Код _wp_check_alternate_file_names() WP 6.4.3

function _wp_check_alternate_file_names( $filenames, $dir, $files ) {
	foreach ( $filenames as $filename ) {
		if ( file_exists( $dir . $filename ) ) {
			return true;
		}

		if ( ! empty( $files ) && _wp_check_existing_file_names( $filename, $files ) ) {
			return true;
		}
	}

	return false;
}