From b8a918dcaa73a3d0c0a5e1bc47b07a155f7ce1c0 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <desrosj@git.wordpress.org> Date: Tue, 19 Mar 2019 16:53:46 +0000 Subject: [PATCH] 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 --- src/wp-includes/functions.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 9088937094..86cdabe7e0 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -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; } /**