|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Changelog. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Pronamic <[email protected]> |
|
6
|
|
|
* @copyright 2005-2021 Pronamic |
|
7
|
|
|
* @license GPL-3.0-or-later |
|
8
|
|
|
* @package Pronamic\WordPress\Pay |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
header( 'Content-Type: text/plain' ); |
|
12
|
|
|
|
|
13
|
|
|
$data = file_get_contents( __DIR__ . '/../changelog.json' ); |
|
14
|
|
|
|
|
15
|
|
|
// Check if file could be read. |
|
16
|
|
|
if ( false === $data ) { |
|
17
|
|
|
return; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
$changelog = json_decode( $data ); |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Render changes. |
|
24
|
|
|
* |
|
25
|
|
|
* @param string|array<int, object>|object $changes Changes. |
|
26
|
|
|
* @param int $level Level. |
|
27
|
|
|
* @return void |
|
28
|
|
|
*/ |
|
29
|
|
|
function render_changes( $changes, $level = 0 ) { |
|
30
|
|
|
$indent = $level * 2; |
|
31
|
|
|
|
|
32
|
|
|
// Changes string. |
|
33
|
|
|
if ( is_string( $changes ) ) { |
|
34
|
|
|
echo str_repeat( ' ', $indent ), '- ', $changes, "\r\n"; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
// Changes array. |
|
38
|
|
|
if ( is_array( $changes ) ) { |
|
39
|
|
|
foreach ( $changes as $change ) { |
|
40
|
|
|
render_changes( $change, $level ); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
// Changes object. |
|
45
|
|
|
if ( is_object( $changes ) ) { |
|
46
|
|
|
if ( isset( $changes->name ) ) { |
|
47
|
|
|
// Changes group. |
|
48
|
|
|
echo "\r\n"; |
|
49
|
|
|
echo '### ', $changes->name, "\r\n"; |
|
50
|
|
|
|
|
51
|
|
|
if ( isset( $changes->changes ) ) { |
|
52
|
|
|
render_changes( $changes->changes, $level ); |
|
53
|
|
|
} |
|
54
|
|
|
} else { |
|
55
|
|
|
if ( isset( $changes->description ) ) { |
|
56
|
|
|
render_changes( $changes->description, $level ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
if ( isset( $changes->changes ) ) { |
|
60
|
|
|
render_changes( $changes->changes, $level + 1 ); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
?> |
|
67
|
|
|
# Change Log |
|
68
|
|
|
|
|
69
|
|
|
All notable changes to this project will be documented in this file. |
|
70
|
|
|
|
|
71
|
|
|
This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com/). |
|
72
|
|
|
|
|
73
|
|
|
<?php |
|
74
|
|
|
|
|
75
|
|
|
foreach ( $changelog as $log ) { |
|
76
|
|
|
if ( 'Unreleased' === $log->version ) { |
|
77
|
|
|
echo '## [', $log->version, '][unreleased]', "\r\n"; |
|
78
|
|
|
} else { |
|
79
|
|
|
echo '## [', $log->version, '] - ', $log->date, "\r\n"; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
render_changes( $log->changes ); |
|
83
|
|
|
|
|
84
|
|
|
echo "\r\n"; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
$collection = new CachingIterator( new ArrayIterator( $changelog ), CachingIterator::TOSTRING_USE_CURRENT ); |
|
88
|
|
|
|
|
89
|
|
|
foreach ( $collection as $log ) { |
|
90
|
|
|
if ( $collection->hasNext() ) { |
|
91
|
|
|
$prev = $collection->getInnerIterator()->current(); |
|
92
|
|
|
|
|
93
|
|
|
if ( 'Unreleased' === $log->version ) { |
|
94
|
|
|
printf( |
|
95
|
|
|
'[unreleased]: https://github.com/pronamic/wp-pronamic-ideal/compare/%s...HEAD', |
|
96
|
|
|
$prev->version |
|
97
|
|
|
); |
|
98
|
|
|
} else { |
|
99
|
|
|
printf( |
|
100
|
|
|
'[%1$s]: https://github.com/pronamic/wp-pronamic-ideal/compare/%2$s...%1$s', |
|
101
|
|
|
$log->version, |
|
102
|
|
|
$prev->version |
|
103
|
|
|
); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
echo "\r\n"; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|