WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/get plugin data

Contents

Description

Parse the plugin contents to retrieve plugin's metadata.

The metadata of the plugin's data searches for the following in the plugin's header. All plugin data must be on its own line. For plugin description, it must not have any newlines or only parts of the description will be displayed and the same goes for the plugin data.

Plugin data returned array contains the following:

  • 'Name' - Name of the plugin, must be unique.
  • 'Title' - Title of the plugin and the link to the plugin's web site.
  • 'Description' - Description of what the plugin does and/or notes from the author.
  • 'Author' - The author's name
  • 'AuthorURI' - The authors web site address.
  • 'Version' - The plugin version number.
  • 'PluginURI' - Plugin web site address.
  • 'TextDomain' - Plugin's text domain for localization.
  • 'DomainPath' - Plugin's relative directory path to .mo files.
  • 'Network' - Boolean. Whether the plugin can only be activated network wide.

NOTE This only works in the admin!

Usage

<?php get_plugin_data$plugin_file$markup true$translate true ?>

Parameters

$plugin_file
(string) (required) Absolute path to the plugin file
Default: None
$markup
(boolean) (optional) If the returned data should have HTML markup applied
Default: true
$translate
(boolean) (optional) If the returned data should be translated
Default: true

Return Values

  • array
 $default_headers = array(
   'Name'        => 'Plugin Name',
   'PluginURI'   => 'Plugin URI',
   'Version'     => 'Version',
   'Description' => 'Description',
   'Author'      => 'Author',
   'AuthorURI'   => 'Author URI',
   'TextDomain'  => 'Text Domain',
   'DomainPath'  => 'Domain Path',
   'Network'     => 'Network',
   // Site Wide Only is deprecated in favor of Network.
   '_sitewide'   => 'Site Wide Only',
 );

Sample output

array(11) {
  ["Name"]=>
  string(19) "Orbisius CyberStore"
  ["PluginURI"]=>
  string(72) "http://club.orbisius.com/products/wordpress-plugins/orbisius-cyberstore/"
  ["Version"]=>
  string(5) "2.0.4"
  ["Description"]=>
  string(203) "Start selling digital products such as e-books, plugins, themes, reports in less than 3 minutes. <cite>By <a href="http://orbisius.com" title="Visit author homepage">Svetoslav Marinov (Slavi)</a>.</cite>"
  ["Author"]=>
  string(89) "<a href="http://orbisius.com" title="Visit author homepage">Svetoslav Marinov (Slavi)</a>"
  ["AuthorURI"]=>
  string(19) "http://orbisius.com"
  ["TextDomain"]=>
  string(0) ""
  ["DomainPath"]=>
  string(0) ""
  ["Network"]=>
  bool(false)
  ["Title"]=>
  string(136) "<a href="http://club.orbisius.com/products/wordpress-plugins/orbisius-cyberstore/" title="Visit plugin homepage">Orbisius CyberStore</a>"
  ["AuthorName"]=>
  string(25) "Svetoslav Marinov (Slavi)"
}

Change Log

Since: 1.5.0

Source File

get_plugin_data() is located in wp-admin/includes/plugin.php.

Related

More in get_plugin_data function documentation

See also index of Function Reference and index of Template Tags.