Definition:
function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {}
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. The below is formatted for printing.
Parameters
- string $plugin_file: Path to the plugin file
- bool $markup: If the returned data should have HTML markup applied
- bool $translate: If the returned data should be translated
Return values
returns:See above for description.
Source code
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', // 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 ( empty( $plugin_data['Network'] ) && ! empty( $plugin_data['_sitewide'] ) ) { _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.' ), 'Site Wide Only: true', 'Network: true' ) ); $plugin_data['Network'] = $plugin_data['_sitewide']; } $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ); unset( $plugin_data['_sitewide'] ); //For backward compatibility by default Title is the same as Name. $plugin_data['Title'] = $plugin_data['Name']; if ( $markup || $translate ) $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); else $plugin_data['AuthorName'] = $plugin_data['Author']; return $plugin_data; }
1558
No comments yet... Be the first to leave a reply!