Get file headers in custom file

Use get_file_data( $file, $headers ):

$file_data = get_file_data( __FILE__, array ( 'Plugin Name' ) );

echo "the name is " . $file_data[0];

Make sure the first parameter points to an existing file.

It will find all lines that are formatted like regular plugins headers or the headers of a style.css.

In my plugin T5 Opera Speed Dial Preview I use it to show the link to my bug tracker:

$data = get_file_data( __FILE__, array ( 'Feedback URI' ) );
return empty ( $data ) ? '' : $data[0];

Leave a Comment