Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Data::get_file_version( string $file )

Retrieve metadata from a file.


Description Description

Copied from WCs get_file_version which is based on WP Core’s get_file_data function.


Top ↑

Parameters Parameters

$file

(string) (Required) Path to the file.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/class.llms.data.php

	private 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' );

		// Pull only the first 8kiB of the file in..
		$file_data = fread( $fp, 8192 );

		// PHP will close file handle, but we are good citizens..
		fclose( $fp );

		// 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;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.11.2 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.