Make WordPress Core

Ticket #46074: 46074.3.diff

File 46074.3.diff, 2.3 KB (added by desrosj, 6 years ago)
  • src/wp-admin/includes/dashboard.php

     
    16461646        <?php
    16471647
    16481648        wp_update_php_annotation();
     1649        wp_direct_php_update_button();
    16491650}
    16501651
    16511652/**
  • src/wp-includes/functions.php

     
    68306830        );
    68316831        echo'</p>';
    68326832}
     6833
     6834/**
     6835 * Gets the URL for directly updating the PHP version the site is running on.
     6836 *
     6837 * A URL will only be returned if the `WP_DIRECT_UPDATE_PHP_URL` environment variable is specified or
     6838 * by using the {@see 'wp_direct_php_update_url'} filter. This allows hosts to send users directly to
     6839 * the page where they can update PHP to a newer version.
     6840 *
     6841 * @return string URL for directly updating PHP or empty string.
     6842 */
     6843function wp_get_direct_php_update_url() {
     6844        $direct_update_url = '';
     6845
     6846        if ( false !== getenv( 'WP_DIRECT_UPDATE_PHP_URL' ) ) {
     6847                $direct_update_url = getenv( 'WP_DIRECT_UPDATE_PHP_URL' );
     6848        }
     6849
     6850        /**
     6851         * Filters the URL for directly updating the PHP version the site is running on from the host.
     6852         *
     6853         * @since 5.1.1
     6854         *
     6855         * @param string $direct_update_url URL for directly updating PHP.
     6856         */
     6857        $direct_update_url = apply_filters( 'wp_direct_php_update_url', $direct_update_url );
     6858
     6859        return $direct_update_url;
     6860}
     6861
     6862/**
     6863 * Display a button directly linking to a PHP update process.
     6864 *
     6865 * This provides hosts with a way for users to be sent directly to their PHP update process.
     6866 *
     6867 * The button is only displayed if a URL is returned by `wp_get_direct_php_update_url()`.
     6868 *
     6869 * @since 5.1.1
     6870 */
     6871function wp_direct_php_update_button() {
     6872        $direct_update_url = wp_get_direct_php_update_url();
     6873
     6874        if ( empty( $direct_update_url ) ) {
     6875                return;
     6876        }
     6877
     6878        echo '<p class="button-container">';
     6879        printf(
     6880                '<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>',
     6881                esc_url( $direct_update_url ),
     6882                __( 'Update your site PHP' ),
     6883                /* translators: accessibility text */
     6884                __( '(opens in a new tab)' )
     6885        );
     6886        echo '</p>';
     6887}