Title: get_plugin_data
Published: April 25, 2014
Last modified: August 20, 2026

---

# get_plugin_data( string $plugin_file, bool $markup = true, bool $translate = true ): array

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#wp--skip-link--target)

Parses the plugin contents to retrieve plugin’s metadata.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#description)󠁿

All plugin headers must be on their own line. Plugin description must not have any
newlines, otherwise only parts of the description will be displayed.
The below is
formatted for printing.

    ```php
    /*
    Plugin Name: Name of the plugin.
    Plugin URI: The home page of the plugin.
    Description: Plugin description.
    Author: Plugin author's name.
    Author URI: Link to the author's website.
    Version: Plugin version.
    Text Domain: Optional. Unique identifier, should be same as the one used in
         load_plugin_textdomain().
    Domain Path: Optional. Only useful if the translations are located in a
         folder above the plugin's base path. For example, if .mo files are
         located in the locale folder then Domain Path will be "/locale/" and
         must have the first slash. Defaults to the base folder the plugin is
         located in.
    Network: Optional. Specify "Network: true" to require that a plugin is activated
         across all sites in an installation. This will prevent a plugin from being
         activated on a single site when Multisite is enabled.
    Requires at least: Optional. Specify the minimum required WordPress version.
    Requires PHP: Optional. Specify the minimum required PHP version.
    * / # Remove the space to close comment.
    ```

The first 8 KB of the file will be pulled in and if the plugin data is not within
that first 8 KB, then the plugin author should correct their plugin and move the
plugin data headers to the top.

The plugin file is assumed to have permissions to allow for scripts to read the 
file. This is not checked however and the file is only opened for reading.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#parameters)󠁿

 `$plugin_file`stringrequired

Absolute path to the main plugin file.

`$markup`booloptional

If the returned data should have HTML markup applied.

Default:`true`

`$translate`booloptional

If the returned data should be translated.

Default:`true`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#return)󠁿

 array Plugin data. Values will be empty if not supplied by the plugin.

 * `Name` string
 * Name of the plugin. Should be unique.
 * `PluginURI` string
 * Plugin URI.
 * `Version` string
 * Plugin version.
 * `Description` string
 * Plugin description.
 * `Author` string
 * Plugin author’s name.
 * `AuthorURI` string
 * Plugin author’s website address (if set).
 * `TextDomain` string
 * Plugin textdomain.
 * `DomainPath` string
 * Plugin’s relative directory path to .mo files.
 * `Network` bool
 * Whether the plugin can only be activated network-wide.
 * `RequiresWP` string
 * Minimum required version of WordPress.
 * `RequiresPHP` string
 * Minimum required version of PHP.
 * `UpdateURI` string
 * ID of the plugin for update purposes, should be a URI.
 * `RequiresPlugins` string
 * Comma separated list of dot org plugin slugs.
 * `Title` string
 * Title of the plugin and link to the plugin’s site (if set).
 * `AuthorName` string
 * Plugin author’s name.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#source)󠁿

    ```php
    function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {

    	$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',
    		'RequiresWP'      => 'Requires at least',
    		'RequiresPHP'     => 'Requires PHP',
    		'UpdateURI'       => 'Update URI',
    		'RequiresPlugins' => 'Requires Plugins',
    		// Site Wide Only is deprecated in favor of Network.
    		'_sitewide'       => 'Site Wide Only',
    	);

    	$plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );

    	// Site Wide Only is the old header for Network.
    	if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) {
    		/* translators: 1: Site Wide Only: true, 2: Network: true */
    		_deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), '<code>Site Wide Only: true</code>', '<code>Network: true</code>' ) );
    		$plugin_data['Network'] = $plugin_data['_sitewide'];
    	}
    	$plugin_data['Network'] = ( 'true' === strtolower( $plugin_data['Network'] ) );
    	unset( $plugin_data['_sitewide'] );

    	// If no text domain is defined fall back to the plugin slug.
    	if ( ! $plugin_data['TextDomain'] ) {
    		$plugin_slug = dirname( plugin_basename( $plugin_file ) );
    		if ( '.' !== $plugin_slug && ! str_contains( $plugin_slug, '/' ) ) {
    			$plugin_data['TextDomain'] = $plugin_slug;
    		}
    	}

    	if ( $markup || $translate ) {
    		$plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
    	} else {
    		$plugin_data['Title']      = $plugin_data['Name'];
    		$plugin_data['AuthorName'] = $plugin_data['Author'];
    	}

    	return $plugin_data;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/plugin.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/plugin.php#L74)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/plugin.php#L74-L121)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#related)󠁿

| Uses | Description | 
| [_get_plugin_data_markup_translate()](https://developer.wordpress.org/reference/functions/_get_plugin_data_markup_translate/)`wp-admin/includes/plugin.php` |

Sanitizes plugin data, optionally adds markup, optionally translates.

  | 
| [get_file_data()](https://developer.wordpress.org/reference/functions/get_file_data/)`wp-includes/functions.php` |

Retrieves metadata from a file.

  | 
| [plugin_basename()](https://developer.wordpress.org/reference/functions/plugin_basename/)`wp-includes/plugin.php` |

Gets the basename of a plugin.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_deprecated_argument()](https://developer.wordpress.org/reference/functions/_deprecated_argument/)`wp-includes/functions.php` |

Marks a function argument as deprecated and inform when it has been used.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#)

| Used by | Description | 
| [_wp_get_entity_view_config_posttype_wp_template()](https://developer.wordpress.org/reference/functions/_wp_get_entity_view_config_posttype_wp_template/)`wp-includes/view-config.php` |

Provides the view configuration for the `wp_template` post type.

  | 
| [WP_REST_Templates_Controller::get_wp_templates_author_text_field()](https://developer.wordpress.org/reference/classes/wp_rest_templates_controller/get_wp_templates_author_text_field/)`wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php` |

Returns a human readable text for the author of the template.

  | 
| [WP_REST_Plugins_Controller::create_item()](https://developer.wordpress.org/reference/classes/wp_rest_plugins_controller/create_item/)`wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php` |

Uploads a plugin and optionally activates it.

  | 
| [validate_plugin_requirements()](https://developer.wordpress.org/reference/functions/validate_plugin_requirements/)`wp-admin/includes/plugin.php` |

Validates the plugin requirements for WordPress version and PHP version.

  | 
| [wp_ajax_delete_plugin()](https://developer.wordpress.org/reference/functions/wp_ajax_delete_plugin/)`wp-admin/includes/ajax-actions.php` |

Handles deleting a plugin via AJAX.

  | 
| [wp_ajax_update_plugin()](https://developer.wordpress.org/reference/functions/wp_ajax_update_plugin/)`wp-admin/includes/ajax-actions.php` |

Handles updating a plugin via AJAX.

  | 
| [WP_Automatic_Updater::update()](https://developer.wordpress.org/reference/classes/wp_automatic_updater/update/)`wp-admin/includes/class-wp-automatic-updater.php` |

Updates an item, if appropriate.

  | 
| [Plugin_Upgrader::bulk_upgrade()](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/)`wp-admin/includes/class-plugin-upgrader.php` |

Upgrades several plugins at once.

  | 
| [Plugin_Upgrader::check_package()](https://developer.wordpress.org/reference/classes/plugin_upgrader/check_package/)`wp-admin/includes/class-plugin-upgrader.php` |

Checks that the source package contains a valid plugin.

  | 
| [get_dropins()](https://developer.wordpress.org/reference/functions/get_dropins/)`wp-admin/includes/plugin.php` |

Checks the wp-content directory and retrieve all drop-ins with any plugin data.

  | 
| [is_network_only_plugin()](https://developer.wordpress.org/reference/functions/is_network_only_plugin/)`wp-admin/includes/plugin.php` |

Checks for “Network: true” in the plugin header to see if this should be activated only as a network wide plugin. The plugin would also work when Multisite is not enabled.

  | 
| [get_plugins()](https://developer.wordpress.org/reference/functions/get_plugins/)`wp-admin/includes/plugin.php` |

Checks the plugins directory and retrieve all plugin files with plugin data.

  | 
| [get_mu_plugins()](https://developer.wordpress.org/reference/functions/get_mu_plugins/)`wp-admin/includes/plugin.php` |

Checks the mu-plugins directory and retrieve all mu-plugin files with any plugin data.

  |

[Show 8 more](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.5.0](https://developer.wordpress.org/reference/since/6.5.0/) | Added support for `Requires Plugins` header. | 
| [5.8.0](https://developer.wordpress.org/reference/since/5.8.0/) | Added support for `Update URI` header. | 
| [5.3.0](https://developer.wordpress.org/reference/since/5.3.0/) | Added support for `Requires at least` and `Requires PHP` headers. | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#comment-content-3030)
 2.    [Aamer Shahzad](https://profiles.wordpress.org/talentedaamer/)  [  8 years ago  ](https://developer.wordpress.org/reference/functions/get_plugin_data/#comment-3030)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F%23comment-3030)
     Vote results for this note: 8[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F%23comment-3030)
 4.      ```php
         if ( is_admin() ) {
         	if( ! function_exists('get_plugin_data') ){
         		require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
         	}
         	$plugin_data = get_plugin_data( __FILE__ );
     
         	echo "<pre>";
         	print_r( $plugin_data );
         	echo "</pre>";
         }
         ```
     
 5.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F%3Freplytocom%3D3030%23feedback-editor-3030)
 6.   [Skip to note 5 content](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#comment-content-5864)
 7.    [yo35](https://profiles.wordpress.org/yo35/)  [  4 years ago  ](https://developer.wordpress.org/reference/functions/get_plugin_data/#comment-5864)
 8.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F%23comment-5864)
     Vote results for this note: 4[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F%23comment-5864)
 9.  Warning: `get_plugin_data(..)` is NOT available by default (not even in the admin).
     The pattern proposed by Aamer Shahzad with `if ( ! function_exists( 'get_plugin_data')){
     require_once ... }` seems to be mandatory before using `get_plugin_data(..)` (
     although not documented).
 10. Otherwise, the whole site may crash with a fatal PHP error “call to undefined 
     function”.
 11.  * The `get_plugin_data()` function is available by default and can be used to
        obtain information about any plugins. Example of getting a plugin name: `$plugin_data
        = get_plugin_data( __FILE__ );` `$plugin_name = $plugin_data['Name']; `
      * [Faisal Ahammad](https://profiles.wordpress.org/faisalahammad/) [3 years ago](https://developer.wordpress.org/reference/functions/get_plugin_data/#comment-6851)
      * I confirm that get_plugin_data may not be available and not checking for `function_exist('
        get_plugin_data')` will potentially crash your site and lock you out of the
        admin
      * [n0ck](https://profiles.wordpress.org/n0ck/) [2 years ago](https://developer.wordpress.org/reference/functions/get_plugin_data/#comment-7078)
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F%3Freplytocom%3D5864%23feedback-editor-5864)
 13.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/get_plugin_data/?output_format=md#comment-content-2109)
 14.   [pepe](https://profiles.wordpress.org/pputzer/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/get_plugin_data/#comment-2109)
 15. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F%23comment-2109)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F%23comment-2109)
 16. If `$markup` or `$translate` are set to `true` (as they are by default), the function
     indirectly calls `wptexturize`, potentially breaking other plugins if this happens
     before the `init` hook.
 17.  * Another alternative (depending on circumstances) could be to use [`get_file_data()`](https://developer.wordpress.org/reference/functions/get_file_data/)
        instead. It’s the same function as used by `get_plugin_data()`, but without
        the ‘bells and whistles’. And because `get_file_data()` lives in `wp-includes/
        functions.php`, there is no need to include `wp-admin/includes/plugin.php` 
        on non-admin screens.
      * [Bart Kuijper](https://profiles.wordpress.org/spartelfant/) [6 years ago](https://developer.wordpress.org/reference/functions/get_plugin_data/#comment-4694)
 18.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F%3Freplytocom%3D2109%23feedback-editor-2109)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_plugin_data%2F)
before being able to contribute a note or feedback.