barryhughes / wp-plugin-changelog-parser

Simple tool to programmatically extract changelog entries from a standard WordPress plugin readme file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WordPress Plugin Changelog Parser Build Status

A very simple tool that can parse a WordPress plugin readme.txt file and return the changelog data. All you need to do, in theory, is pass the path to the readme file.

use Harry_Bewes\WordPress\Changelog_Parser;

require 'vendor/autoload.php';

$changelog = ( new Changelog_Parser( '/path/to/plugin/readme.txt' ) )->get_changelog(); 

In return, you will receive an array-representation of the changelog. If the filepath is invalid, on the other hand, you'll receive an exception for your troubles—which you can catch and do stuff with. Assuming success, though, each key of the array is the version number and the value is an object containing properties date and entries (which will be an array of individual changelog entries).

[
    # An associative array where each key is the version number and
    # each value is a stdClass object
    '2.0' => {
        # The date property will always be set and will always be a string,
        # but may be empty
        'date'    => '2019-07-01',
        
        # The entries property will always be set and will always be an array,
        # but may be empty
        'entries' => [
            'Added support for foo',
            'Fixed bar',
        ]
    },
    # more versions...
]

Caveats & Notes

  • This is a quick-and-dirty get-the-job-done sort of library
  • It expects changelog files to be formatted in a very specific way, see the example in the test directory
  • Use at your own risk!
  • License: GPL-3.0

About

Simple tool to programmatically extract changelog entries from a standard WordPress plugin readme file.

License:GNU General Public License v3.0


Languages

Language:PHP 100.0%