_wp_check_alternate_file_names

函式
_wp_check_alternate_file_names ( $filenames, $dir, $files )
Access
Private
引數
  • (string[]) $filenames Array of file names to check.
    Required:
  • (string) $dir The directory containing the files.
    Required:
  • (array) $files An array of existing files in the directory. May be empty.
    Required:
返回值
  • (bool) True if the tested file name could match an existing file, false otherwise.
定義位置
相關方法
_wp_check_existing_file_nameswp_check_filetype_get_template_edit_filenamewp_delete_filesanitize_file_name
引入
5.8.1
棄用
-

_wp_check_alternate_file_names: 這個函式用來檢查一個特定檔案是否存在備用檔名。它接收一個檔案路徑和一個備用檔名的列表,並返回第一個存在的備用檔案的路徑。

幫助函式,測試檔名陣列中的每一個是否與現有檔案衝突。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >