WC_Admin_Status::get_file_version()
Retrieve metadata from a file. Based on WP Core's get_file_data function.
Метод класса: WC_Admin_Status{}
Хуков нет.
Возвращает
Строку
.
Использование
$result = WC_Admin_Status::get_file_version( $file );
- $file(строка) (обязательный)
- Path to the file.
Список изменений
С версии 2.1.1 | Введена. |
Код WC_Admin_Status::get_file_version() WC Admin Status::get file version WC 9.8.1
public static function get_file_version( $file ) { // Avoid notices if file does not exist. if ( ! file_exists( $file ) ) { return ''; } // We don't need to write to the file, so just open for reading. $fp = fopen( $file, 'r' ); // @codingStandardsIgnoreLine. // Pull only the first 8kiB of the file in. $file_data = fread( $fp, 8192 ); // @codingStandardsIgnoreLine. // PHP will close file handle, but we are good citizens. fclose( $fp ); // @codingStandardsIgnoreLine. // Make sure we catch CR-only line endings. $file_data = str_replace( "\r", "\n", $file_data ); $version = ''; if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) { $version = _cleanup_header_comment( $match[1] ); } return $version; }