A PHP library for parsing WordPress plugin and theme metadata.
This library is YahnisElsts's wp-extension-meta simply put into a composer package to be used in mordern PHP development. All I've added are some tests and modified some parts, so they'll work as a composer package.
All other credits to YahnisElsts!
A PHP library for parsing WordPress plugin and theme metadata. Point it at a ZIP package and it will:
- Tell you whether it contains a plugin or a theme.
- Give you the metadata from the comment header (Version, Description, Author URI, etc).
- Parse readme.txt into a list of headers and sections.
- Convert readme.txt contents from Markdown to HTML (optional).
To install simply
composer require capevace/wp-package-parser
Now you're able to use the parser!
use WPPackageParser\Parser; $filepath = __DIR__ . '/resources/test-plugin.zip'; $result = Parser::parse($filepath);
Array ( [header] => Array ( [Name] => Plugin Name [PluginURI] => http://example.com/ [Version] => 1.7 [Description] => This plugin does stuff. [Author] => Yahnis Elsts [AuthorURI] => http://w-shadow.com/ [TextDomain] => sample-plugin [DomainPath] => [Network] => [Title] => Plugin Name ) [readme] => Array ( [name] => Plugin Name [contributors] => Array (  => whiteshadow ) [tags] => Array (  => sample  => tag  => stuff ) [requires] => 3.2 [tested] => 3.5.1 [stable] => 1.7 [short_description] => This is the short description from the readme. [sections] => Array ( [Description] => This is the <em>Description</em> section of the readme. [Installation] => ... [Changelog] => ... ) ) [pluginFile] => sample-plugin/sample-plugin.php [stylesheet] => [type] => plugin )
Base code from YahnisElsts. Partially based on plugin header parsing code from the WordPress core.