General: Add a way to specify a direct link for a user to update PHP.
A direct URL to where a user can update PHP for their website can now be specified in one of two ways: - Defining the `WP_DIRECT_UPDATE_PHP_URL` environment variable. - Returning a URL to the `wp_direct_php_update_url` filter. When a URL is specified, an additional “Update PHP” button will be displayed at the bottom of the Core dashboard widget informing administrators that their site is running an outdated version of PHP (see [42832]). Fixes #46074. Props afragen, desrosj, lukecarbis. Built from https://develop.svn.wordpress.org/trunk@44814 git-svn-id: http://core.svn.wordpress.org/trunk@44646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d2f9cbf7be
commit
ec417a34a7
|
@ -1647,6 +1647,7 @@ function wp_dashboard_php_nag() {
|
|||
<?php
|
||||
|
||||
wp_update_php_annotation();
|
||||
wp_direct_php_update_button();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6830,3 +6830,58 @@ function wp_update_php_annotation() {
|
|||
);
|
||||
echo'</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL for directly updating the PHP version the site is running on.
|
||||
*
|
||||
* A URL will only be returned if the `WP_DIRECT_UPDATE_PHP_URL` environment variable is specified or
|
||||
* by using the {@see 'wp_direct_php_update_url'} filter. This allows hosts to send users directly to
|
||||
* the page where they can update PHP to a newer version.
|
||||
*
|
||||
* @return string URL for directly updating PHP or empty string.
|
||||
*/
|
||||
function wp_get_direct_php_update_url() {
|
||||
$direct_update_url = '';
|
||||
|
||||
if ( false !== getenv( 'WP_DIRECT_UPDATE_PHP_URL' ) ) {
|
||||
$direct_update_url = getenv( 'WP_DIRECT_UPDATE_PHP_URL' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the URL for directly updating the PHP version the site is running on from the host.
|
||||
*
|
||||
* @since 5.1.1
|
||||
*
|
||||
* @param string $direct_update_url URL for directly updating PHP.
|
||||
*/
|
||||
$direct_update_url = apply_filters( 'wp_direct_php_update_url', $direct_update_url );
|
||||
|
||||
return $direct_update_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a button directly linking to a PHP update process.
|
||||
*
|
||||
* This provides hosts with a way for users to be sent directly to their PHP update process.
|
||||
*
|
||||
* The button is only displayed if a URL is returned by `wp_get_direct_php_update_url()`.
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
function wp_direct_php_update_button() {
|
||||
$direct_update_url = wp_get_direct_php_update_url();
|
||||
|
||||
if ( empty( $direct_update_url ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<p class="button-container">';
|
||||
printf(
|
||||
'<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>',
|
||||
esc_url( $direct_update_url ),
|
||||
__( 'Update PHP' ),
|
||||
/* translators: accessibility text */
|
||||
__( '(opens in a new tab)' )
|
||||
);
|
||||
echo '</p>';
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.2-alpha-44813';
|
||||
$wp_version = '5.2-alpha-44814';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue