From 53f212ebbef7bd73ffa4f35589efd0edf5cd347f Mon Sep 17 00:00:00 2001 From: desrosj Date: Tue, 19 Mar 2019 16:54:52 +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. Built from https://develop.svn.wordpress.org/trunk@44935 git-svn-id: http://core.svn.wordpress.org/trunk@44766 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 30 +++++++++++++++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 9088937094..86cdabe7e0 100644 --- a/wp-includes/functions.php +++ b/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 `

`. + * @param string $after Markup to output after the annotation. Default `

`. */ -function wp_update_php_annotation() { +function wp_update_php_annotation( $before = '

', $after = '

' ) { + $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 '

'; - 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, see the official WordPress documentation.' ), esc_url( $default_url ) ); - echo'

'; + + return $annotation; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index df4a09187a..ed4a5639ca 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-alpha-44934'; +$wp_version = '5.2-alpha-44935'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.