Only show the relevant updates in the notices Closes #4977

This commit is contained in:
Mike Jolley 2014-02-28 13:42:48 +00:00 committed by Coen Jacobs
parent 5448e1bedc
commit f1189f5aac
1 changed files with 21 additions and 7 deletions

View File

@ -679,18 +679,22 @@ class WC_Install {
// Output Upgrade Notice // Output Upgrade Notice
$matches = null; $matches = null;
$regexp = '~==\s*Upgrade Notice\s*==\s*=\s*[0-9.]+\s*=(.*)(=\s*' . preg_quote( WC_VERSION ) . '\s*=|$)~Uis'; $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( WC_VERSION ) . '\s*=|$)~Uis';
if ( preg_match( $regexp, $response['body'], $matches ) ) { if ( preg_match( $regexp, $response['body'], $matches ) ) {
$notices = (array) preg_split('~[\r\n]+~', trim( $matches[1] ) ); $version = trim( $matches[1] );
$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
echo '<div style="font-weight: normal; background: #cc99c2; color: #fff !important; border: 1px solid #b76ca9; padding: 9px; margin: 9px 0;">'; if ( version_compare( WC_VERSION, $version, '<' ) ) {
foreach ( $notices as $index => $line ) { echo '<div style="font-weight: normal; background: #cc99c2; color: #fff !important; border: 1px solid #b76ca9; padding: 9px; margin: 9px 0;">';
echo '<p style="margin: 0; font-size: 1.1em; color: #fff; text-shadow: 0 1px 1px #b574a8;">' . preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) . '</p>';
foreach ( $notices as $index => $line ) {
echo '<p style="margin: 0; font-size: 1.1em; color: #fff; text-shadow: 0 1px 1px #b574a8;">' . preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) . '</p>';
}
echo '</div>';
} }
echo '</div>';
} }
// Output Changelog // Output Changelog
@ -710,13 +714,23 @@ class WC_Install {
echo '<ul style="list-style: disc inside; margin: 9px 0 9px 20px; overflow:hidden; zoom: 1;">'; echo '<ul style="list-style: disc inside; margin: 9px 0 9px 20px; overflow:hidden; zoom: 1;">';
$ul = true; $ul = true;
} }
$line = preg_replace( '~^\s*\*\s*~', '', htmlspecialchars( $line ) ); $line = preg_replace( '~^\s*\*\s*~', '', htmlspecialchars( $line ) );
echo '<li style="width: 50%; margin: 0; float: left; ' . ( $index % 2 == 0 ? 'clear: left;' : '' ) . '">' . $line . '</li>'; echo '<li style="width: 50%; margin: 0; float: left; ' . ( $index % 2 == 0 ? 'clear: left;' : '' ) . '">' . $line . '</li>';
} else { } else {
$version = trim( current( explode( '-', str_replace( '=', '', $line ) ) ) );
if ( version_compare( WC_VERSION, $version, '>=' ) ) {
break;
}
if ( $ul ) { if ( $ul ) {
echo '</ul>'; echo '</ul>';
$ul = false; $ul = false;
} }
echo '<p style="margin: 9px 0;">' . htmlspecialchars( $line ) . '</p>'; echo '<p style="margin: 9px 0;">' . htmlspecialchars( $line ) . '</p>';
} }
} }