Make WordPress Core

Ticket #45686: 45686.2.diff

File 45686.2.diff, 4.5 KB (added by flixos90, 6 years ago)
  • src/wp-admin/includes/dashboard.php

     
    16091609}
    16101610
    16111611/**
    1612  * Displays the PHP upgrade nag.
     1612 * Displays the PHP update nag.
    16131613 *
    1614  * @since 5.0.0
     1614 * @since 5.1.0
    16151615 */
    16161616function wp_dashboard_php_nag() {
    16171617        $response = wp_check_php_version();
     
    16261626                $msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
    16271627        }
    16281628
     1629        $update_url  = wp_get_update_php_url();
     1630        $default_url = wp_get_default_update_php_url();
     1631
    16291632        ?>
    16301633        <p><?php echo $msg; ?></p>
    16311634
     
    16341637
    16351638        <p class="button-container">
    16361639                <?php
    1637                         printf(
    1638                                 '<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
    1639                                 esc_url( _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page' ) ),
    1640                                 __( 'Learn more about updating PHP' ),
    1641                                 /* translators: accessibility text */
    1642                                 __( '(opens in a new tab)' )
    1643                         );
     1640                printf(
     1641                        '<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
     1642                        esc_url( $update_url ),
     1643                        __( 'Learn more about updating PHP' ),
     1644                        /* translators: accessibility text */
     1645                        __( '(opens in a new tab)' )
     1646                );
    16441647                ?>
    16451648        </p>
    16461649        <?php
     1650
     1651        if ( $update_url !== $default_url ) {
     1652                ?>
     1653                <p class="description">
     1654                        <?php
     1655                        printf(
     1656                                /* translators: %s: default Update PHP page URL */
     1657                                __( '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>.' ),
     1658                                esc_url( $default_url )
     1659                        );
     1660                        ?>
     1661                </p>
     1662                <?php
     1663        }
    16471664}
    16481665
    16491666/**
    16501667 * Adds an additional class to the PHP nag if the current version is insecure.
    16511668 *
    1652  * @since 5.0.0
     1669 * @since 5.1.0
    16531670 *
    16541671 * @param array $classes Metabox classes.
    16551672 * @return array Modified metabox classes.
     
    16651682}
    16661683
    16671684/**
    1668  * Checks if the user needs to upgrade PHP.
     1685 * Checks if the user needs to update PHP.
    16691686 *
    1670  * @since 5.0.0
     1687 * @since 5.1.0
    16711688 *
    16721689 * @return array|false $response Array of PHP version data. False on failure.
    16731690 */
  • src/wp-includes/functions.php

     
    65536553                }
    65546554        }
    65556555}
     6556
     6557/**
     6558 * Gets the URL to learn more about updating the PHP version the site is running on.
     6559 *
     6560 * This URL can be overridden by specifying an environment variable `WP_UPDATE_PHP_URL` or by using the
     6561 * {@see 'wp_update_php_url'} filter. Providing an empty string is not allowed and will result in the
     6562 * default URL being used. Furthermore the page the URL links to should preferably be localized in the
     6563 * site language.
     6564 *
     6565 * @since 5.1.0
     6566 *
     6567 * @return string URL to learn more about updating PHP.
     6568 */
     6569function wp_get_update_php_url() {
     6570        $default_url = wp_get_default_update_php_url();
     6571
     6572        $update_url = $default_url;
     6573        if ( false !== getenv( 'WP_UPDATE_PHP_URL' ) ) {
     6574                $update_url = getenv( 'WP_UPDATE_PHP_URL' );
     6575        }
     6576
     6577        /**
     6578         * Filters the URL to learn more about updating the PHP version the site is running on.
     6579         *
     6580         * Providing an empty string is not allowed and will result in the default URL being used. Furthermore
     6581         * the page the URL links to should preferably be localized in the site language.
     6582         *
     6583         * @since 5.1.0
     6584         *
     6585         * @param string $update_url URL to learn more about updating PHP.
     6586         */
     6587        $update_url = apply_filters( 'wp_update_php_url', $update_url );
     6588
     6589        if ( empty( $update_url ) ) {
     6590                $update_url = $default_url;
     6591        }
     6592
     6593        return $update_url;
     6594}
     6595
     6596/**
     6597 * Gets the default URL to learn more about updating the PHP version the site is running on.
     6598 *
     6599 * Do not use this function to retrieve this URL. Instead, use {@see wp_get_update_php_url()} when relying on the URL.
     6600 * This function does not allow modifying the returned URL, and is only used to compare the actually used URL with the
     6601 * default one.
     6602 *
     6603 * @since 5.1.0
     6604 * @access private
     6605 *
     6606 * @return string Default URL to learn more about updating PHP.
     6607 */
     6608function wp_get_default_update_php_url() {
     6609        return _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page' );
     6610}