Description
Searches for metadata in the first 8 KB of a file, such as a plugin or theme. Each piece of metadata must be on its own line. Fields can not span multiple lines, the value will get cut at the end of the first line.
If the file data is not within that first 8 KB, then the author should correct their plugin file and move the data headers to the top.
Source
File: wp-includes/functions.php
function get_file_data( $file, $default_headers, $context = '' ) {
$fp = fopen( $file, 'r' );
$file_data = fread( $fp, 8 * KB_IN_BYTES );
fclose( $fp );
$file_data = str_replace( "\r", "\n", $file_data );
$extra_headers = $context ? apply_filters( "extra_{$context}_headers", array() ) : array();
if ( $extra_headers ) {
$extra_headers = array_combine( $extra_headers, $extra_headers );
$all_headers = array_merge( $extra_headers, (array) $default_headers );
} else {
$all_headers = $default_headers;
}
foreach ( $all_headers as $field => $regex ) {
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) {
$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
} else {
$all_headers[ $field ] = '';
}
}
return $all_headers;
}