Make WordPress Core


Ignore:
Timestamp:
01/16/2019 05:05:37 PM (6 years ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

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

    r44625 r44627  
    67176717    return _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page' );
    67186718}
     6719
     6720/**
     6721 * Prints the default annotation for the web host altering the "Update PHP" page URL.
     6722 *
     6723 * This function is to be used after {@see wp_get_update_php_url()} to display a consistent
     6724 * annotation if the web host has altered the default "Update PHP" page URL.
     6725 *
     6726 * @since 5.1.0
     6727 */
     6728function wp_update_php_annotation() {
     6729    $update_url  = wp_get_update_php_url();
     6730    $default_url = wp_get_default_update_php_url();
     6731
     6732    if ( $update_url === $default_url ) {
     6733        return;
     6734    }
     6735
     6736    echo '<p class="description">';
     6737    printf(
     6738        /* translators: %s: default Update PHP page URL */
     6739        __( '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>.' ),
     6740        esc_url( $default_url )
     6741    );
     6742    echo'</p>';
     6743}
Note: See TracChangeset for help on using the changeset viewer.