The top of all bootstrap files for WordPress plugins begin with an important comment block. Below is a sample of a multiline comment block which describes the plugin and provides name, URI, Author, Author URI, and Version.
Create a file named fabulous.php and place it in the wp-content/plugins directory of WordPress.
PHP:
<?php
/**
* Plugin Name: Fabulous
* Plugin URI: www.tuxreports.com
* Description: A test Plugin
* Author: LPH
* Author URI: www.tuxreports.com
* Version: 1.0.0
*/
It turns out the function get_plugin_data can be used to grab the information in the comments of a bootstrap file if logged into the administration area of WordPress. For example, below is a sample of code to pull the array of information within the $data variable.
PHP:
function admin_notice() {
if ( is_admin() ) {
$data = get_plugin_data(__FILE__);
var_dump($data);
}
}
add_action( 'admin_notices', 'admin_notice' );
Code:
array (size=11)
'Name' => string 'Fabulous' (length=8)
'PluginURI' => string 'http://www.tuxreports.com' (length=25)
'Version' => string '1.0.0' (length=5)
'Description' => string 'A test Plugin <cite>By <a href="http://www.tuxreports.com">LPH</a>.</cite>' (length=74)
'Author' => string '<a href="http://www.tuxreports.com">LPH</a>' (length=43)
'AuthorURI' => string 'http://www.tuxreports.com' (length=25)
'TextDomain' => string '' (length=0)
'DomainPath' => string '' (length=0)
'Network' => boolean false
'Title' => string '<a href="http://www.tuxreports.com">Fabulous</a>' (length=48)
'AuthorName' => string 'LPH' (length=3)
This means $data['Version'] would return the string '1.0.0' -- something which might be very useful.