General: Improve the PHP update notice annotation.

This change introduces the `wp_get_update_php_annotation()` function, which returns the message displayed when a host filters the direct PHP update or PHP update education URLs to indicate the information is site specific and provided by the host, not WordPress core.

It also updates `wp_update_php_annotation()` to accept a `$before` and `$after` parameter, which makes this notice more flexible for displaying in multiple locations within the admin area. Previously, the markup output in `wp_update_php_annotation()` was hardcoded, which was making it difficult to display it properly in multiple locations.

Props afragen, aaroncampbell, flixos90, TimothyBlynJacobs, desrosj.
Fixes #46044.

git-svn-id: https://develop.svn.wordpress.org/trunk@44935 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2019-03-19 16:53:46 +00:00
parent 60ea373df9
commit b8a918dcaa
1 changed files with 25 additions and 5 deletions

View File

@ -6803,22 +6803,42 @@ function wp_get_default_update_php_url() {
* annotation if the web host has altered the default "Update PHP" page URL.
*
* @since 5.1.0
* @since 5.2.0 Added the `$before` and `$after` parameters.
*
* @param string $before Markup to output before the annotation. Default `<p class="description">`.
* @param string $after Markup to output after the annotation. Default `</p>`.
*/
function wp_update_php_annotation() {
function wp_update_php_annotation( $before = '<p class="description">', $after = '</p>' ) {
$annotation = wp_get_update_php_annotation();
echo $before . $annotation . $after;
}
/**
* Returns the default annotation for the web hosting altering the "Update PHP" page URL.
*
* This function is to be used after {@see wp_get_update_php_url()} to return a consistent
* annotation if the web host has altered the default "Update PHP" page URL.
*
* @since 5.2.0
*
* @return string $message Update PHP page annotation. An empty string if no custom URLs are provided.
*/
function wp_get_update_php_annotation() {
$update_url = wp_get_update_php_url();
$default_url = wp_get_default_update_php_url();
if ( $update_url === $default_url ) {
return;
return '';
}
echo '<p class="description">';
printf(
$annotation = sprintf(
/* translators: %s: default Update PHP page URL */
__( 'This resource is provided by your web host, and is specific to your site. For more information, <a href="%s" target="_blank">see the official WordPress documentation</a>.' ),
esc_url( $default_url )
);
echo'</p>';
return $annotation;
}
/**