<?php
$content = <<<EOF
Some stuff before this notice which is not relevant.
== Upgrade Notice ==
= 1.3.0 =
When using Master Pro, 1.3.0 is the new minimal required version!
When using Master Pro, 1.3.0 is the new minimal required version!
When using Master Pro, 1.3.0 is the new minimal required version!
123123
= 1.1.0 =
When using Master Pro, 1.1.0 is the new minimal required version!
= 1.0.0 =
No upgrade - just install :)
[See changelog for all versions](https://plugins.svn.wordpress.org/master-pro/trunk/CHANGELOG.md).
EOF;
function parse_update_notice( string $content, string $new_version ) {
$regexp = '~==\s*Upgrade Notice\s*==\s*.*?=+\s*(' . preg_quote( $new_version ) . ')\s*=+\s*(.*?)(?=^=+\s*\d+\.\d+\.\d+\s*=+|^\s*?$)~ms';
if ( preg_match( $regexp, $content, $matches ) ) {
echo $matches[1], PHP_EOL;
echo $matches[2], PHP_EOL;
}
}
parse_update_notice($content, '1.3.0');
parse_update_notice($content, '1.1.0');
parse_update_notice($content, '1.0.0');
parse_update_notice($content, '0.1.0');
1.3.0
When using Master Pro, 1.3.0 is the new minimal required version!
When using Master Pro, 1.3.0 is the new minimal required version!
When using Master Pro, 1.3.0 is the new minimal required version!
1.1.0
When using Master Pro, 1.1.0 is the new minimal required version!
1.0.0
No upgrade - just install :)