函数原型
get_plugin_data( string $plugin_file, bool $markup = true, bool $translate = true ): array
函数描述
Parses the plugin contents to retrieve plugin’s metadata.
是否弃用
未弃用
函数参数
-
$plugin_file
string
Required - Absolute path to the main plugin file.
-
$markup
bool
Optional - If the returned data should have HTML markup applied.
Default:
true -
$translate
bool
Optional - If the returned data should be translated.
Default:
true
函数返回值
array Plugin data. Values will be empty if not supplied by the plugin.
NamestringName of the plugin. Should be unique.PluginURIstringPlugin URI.VersionstringPlugin version.DescriptionstringPlugin description.AuthorstringPlugin author’s name.AuthorURIstringPlugin author’s website address (if set).TextDomainstringPlugin textdomain.DomainPathstringPlugin’s relative directory path to .mo files.NetworkboolWhether the plugin can only be activated network-wide.RequiresWPstringMinimum required version of WordPress.RequiresPHPstringMinimum required version of PHP.UpdateURIstringID of the plugin for update purposes, should be a URI.TitlestringTitle of the plugin and link to the plugin’s site (if set).AuthorNamestringPlugin author’s name.
函数位置
File: wp-admin/includes/plugin.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.源码链接
变更日志
| Version | Description |
|---|---|
| 5.8.0 | Added support for Update URI header. |
| 5.3.0 | Added support for Requires at least and Requires PHP headers. |
| 1.5.0 | Introduced. |

