Make WordPress Core


Ignore:
Timestamp:
01/08/2019 05:26:38 PM (5 years ago)
Author:
flixos90
Message:

General: Make Update PHP notice link customizable.

After [42832], [42891] and [43006], this changeset refines the core notice informing about an outdated PHP version:

  • The link to the Update PHP information page can now be adjusted using either a WP_UPDATE_PHP_URL environment variable, or a new wp_update_php_url filter.
  • If that URL is different from the default one that points to https://wordpress.org/support/update-php/ or its localized equivalent, a note indicates that the linked resource has not been provided by WordPress itself, and the default URL is still linked to as an additional resource.
  • The URL for the default information page has been updated to use the slug update-php instead of upgrade-php.
  • @since annotations have been updated.

Going forward, admin areas that display information related to the PHP version should use the new function wp_get_update_php_url().

Props afragen, fierevere, flixos90, markjaquith, miss_jwo, nerrad, pento, schlessera, SergeyBiryukov, spacedmonkey.
Fixes #45686. See #41191.

File:
1 edited

Legend:

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

    r44467 r44476  
    65816581    }
    65826582}
     6583
     6584/**
     6585 * Gets the URL to learn more about updating the PHP version the site is running on.
     6586 *
     6587 * This URL can be overridden by specifying an environment variable `WP_UPDATE_PHP_URL` or by using the
     6588 * {@see 'wp_update_php_url'} filter. Providing an empty string is not allowed and will result in the
     6589 * default URL being used. Furthermore the page the URL links to should preferably be localized in the
     6590 * site language.
     6591 *
     6592 * @since 5.1.0
     6593 *
     6594 * @return string URL to learn more about updating PHP.
     6595 */
     6596function wp_get_update_php_url() {
     6597    $default_url = wp_get_default_update_php_url();
     6598
     6599    $update_url = $default_url;
     6600    if ( false !== getenv( 'WP_UPDATE_PHP_URL' ) ) {
     6601        $update_url = getenv( 'WP_UPDATE_PHP_URL' );
     6602    }
     6603
     6604    /**
     6605     * Filters the URL to learn more about updating the PHP version the site is running on.
     6606     *
     6607     * Providing an empty string is not allowed and will result in the default URL being used. Furthermore
     6608     * the page the URL links to should preferably be localized in the site language.
     6609     *
     6610     * @since 5.1.0
     6611     *
     6612     * @param string $update_url URL to learn more about updating PHP.
     6613     */
     6614    $update_url = apply_filters( 'wp_update_php_url', $update_url );
     6615
     6616    if ( empty( $update_url ) ) {
     6617        $update_url = $default_url;
     6618    }
     6619
     6620    return $update_url;
     6621}
     6622
     6623/**
     6624 * Gets the default URL to learn more about updating the PHP version the site is running on.
     6625 *
     6626 * Do not use this function to retrieve this URL. Instead, use {@see wp_get_update_php_url()} when relying on the URL.
     6627 * This function does not allow modifying the returned URL, and is only used to compare the actually used URL with the
     6628 * default one.
     6629 *
     6630 * @since 5.1.0
     6631 * @access private
     6632 *
     6633 * @return string Default URL to learn more about updating PHP.
     6634 */
     6635function wp_get_default_update_php_url() {
     6636    return _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page' );
     6637}
Note: See TracChangeset for help on using the changeset viewer.