Make WordPress Core


Ignore:
Timestamp:
03/19/2019 04:53:46 PM (6 years ago)
Author:
desrosj
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r44921 r44935  
    68046804 *
    68056805 * @since 5.1.0
    6806  */
    6807 function wp_update_php_annotation() {
     6806 * @since 5.2.0 Added the `$before` and `$after` parameters.
     6807 *
     6808 * @param string $before Markup to output before the annotation. Default `<p class="description">`.
     6809 * @param string $after  Markup to output after the annotation. Default `</p>`.
     6810 */
     6811function wp_update_php_annotation( $before = '<p class="description">', $after = '</p>' ) {
     6812    $annotation = wp_get_update_php_annotation();
     6813
     6814    echo $before . $annotation . $after;
     6815}
     6816
     6817/**
     6818 * Returns the default annotation for the web hosting altering the "Update PHP" page URL.
     6819 *
     6820 * This function is to be used after {@see wp_get_update_php_url()} to return a consistent
     6821 * annotation if the web host has altered the default "Update PHP" page URL.
     6822 *
     6823 * @since 5.2.0
     6824 *
     6825 * @return string $message Update PHP page annotation. An empty string if no custom URLs are provided.
     6826 */
     6827function wp_get_update_php_annotation() {
    68086828    $update_url  = wp_get_update_php_url();
    68096829    $default_url = wp_get_default_update_php_url();
    68106830
    68116831    if ( $update_url === $default_url ) {
    6812         return;
    6813     }
    6814 
    6815     echo '<p class="description">';
    6816     printf(
     6832        return '';
     6833    }
     6834
     6835    $annotation = sprintf(
    68176836        /* translators: %s: default Update PHP page URL */
    68186837        __( '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>.' ),
    68196838        esc_url( $default_url )
    68206839    );
    6821     echo'</p>';
     6840
     6841    return $annotation;
    68226842}
    68236843
Note: See TracChangeset for help on using the changeset viewer.