Plugins: Use centralized API to display information about updating PHP when a plugin requires a higher version.

This changeset uses the API functions introduced in [44476] to link to the resource about updating PHP when highlighting a plugin's required PHP version is not met. It furthermore expands them, introducing a new `wp_update_php_annotation()` function that prints the markup to indicate that the default URL has been altered by the web host, allowing it to be reused universally.

Furthermore, this changeset adds missing `update_php` capability checks before displaying the information about updating PHP.

Props afragen.
Fixes #45986. See #43986, #45686.

Built from https://develop.svn.wordpress.org/trunk@44627


git-svn-id: http://core.svn.wordpress.org/trunk@44458 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz
2019-01-16 17:07:00 +00:00
parent 601d13a657
commit 94fb16f03f
5 changed files with 64 additions and 36 deletions

View File

@@ -762,12 +762,19 @@ function install_plugin_information() {
if ( ! $compatible_php ) {
echo '<div class="notice notice-error notice-alt"><p>';
printf(
/* translators: "Updating PHP" page URL */
__( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>, so unfortunately you cannot install it. <a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
esc_url( __( 'https://wordpress.org/support/update-php/' ) )
);
echo '</p></div>';
_e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
if ( current_user_can( 'update_php' ) ) {
printf(
/* translators: %s: "Update PHP" page URL */
' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
echo '</p>';
wp_update_php_annotation();
} else {
echo '</p>';
}
echo '</div>';
}
if ( ! $tested_wp ) {