mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@44627 git-svn-id: http://core.svn.wordpress.org/trunk@44458 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
601d13a657
commit
94fb16f03f
@ -635,19 +635,27 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
echo '<div class="notice inline notice-error notice-alt"><p>';
|
||||
if ( ! $compatible_php && ! $compatible_wp ) {
|
||||
_e( 'This plugin doesn’t work with your versions of WordPress and PHP. ' );
|
||||
if ( current_user_can( 'update_core' ) ) {
|
||||
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
|
||||
printf(
|
||||
/* translators: 1: "Update WordPress" screen URL, 2: "Updating PHP" page URL */
|
||||
/* translators: 1: "Update WordPress" screen URL, 2: "Update PHP" page URL */
|
||||
__( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
|
||||
self_admin_url( 'update-core.php' ),
|
||||
esc_url( __( 'https://wordpress.org/support/update-php/' ) )
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
} else {
|
||||
wp_update_php_annotation();
|
||||
} elseif ( current_user_can( 'update_core' ) ) {
|
||||
printf(
|
||||
/* translators: %s: "Updating PHP" page URL */
|
||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( __( 'https://wordpress.org/support/update-php/' ) )
|
||||
/* translators: %s: "Update WordPress" screen URL */
|
||||
__( '<a href="%s">Please update WordPress</a>.' ),
|
||||
self_admin_url( 'update-core.php' )
|
||||
);
|
||||
} elseif ( current_user_can( 'update_php' ) ) {
|
||||
printf(
|
||||
/* translators: %s: "Update PHP" page URL */
|
||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
wp_update_php_annotation();
|
||||
}
|
||||
} elseif ( ! $compatible_wp ) {
|
||||
_e( 'This plugin doesn’t work with your version of WordPress. ' );
|
||||
@ -660,11 +668,14 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
}
|
||||
} elseif ( ! $compatible_php ) {
|
||||
_e( 'This plugin doesn’t work with your version of PHP. ' );
|
||||
printf(
|
||||
/* translators: %s: "Updating PHP" page URL */
|
||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( __( 'https://wordpress.org/support/update-php/' ) )
|
||||
);
|
||||
if ( current_user_can( 'update_php' ) ) {
|
||||
printf(
|
||||
/* translators: %s: "Update PHP" page URL */
|
||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
wp_update_php_annotation();
|
||||
}
|
||||
}
|
||||
echo '</p></div>';
|
||||
}
|
||||
|
@ -1626,9 +1626,6 @@ function wp_dashboard_php_nag() {
|
||||
$msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
|
||||
}
|
||||
|
||||
$update_url = wp_get_update_php_url();
|
||||
$default_url = wp_get_default_update_php_url();
|
||||
|
||||
?>
|
||||
<p><?php echo $msg; ?></p>
|
||||
|
||||
@ -1639,7 +1636,7 @@ function wp_dashboard_php_nag() {
|
||||
<?php
|
||||
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( $update_url ),
|
||||
esc_url( wp_get_update_php_url() ),
|
||||
__( 'Learn more about updating PHP' ),
|
||||
/* translators: accessibility text */
|
||||
__( '(opens in a new tab)' )
|
||||
@ -1648,19 +1645,7 @@ function wp_dashboard_php_nag() {
|
||||
</p>
|
||||
<?php
|
||||
|
||||
if ( $update_url !== $default_url ) {
|
||||
?>
|
||||
<p class="description">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: default Update PHP page URL */
|
||||
__( '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>.' ),
|
||||
esc_url( $default_url )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
wp_update_php_annotation();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -762,12 +762,19 @@ function install_plugin_information() {
|
||||
|
||||
if ( ! $compatible_php ) {
|
||||
echo '<div class="notice notice-error notice-alt"><p>';
|
||||
printf(
|
||||
/* translators: "Updating PHP" page URL */
|
||||
__( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>, so unfortunately you cannot install it. <a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
|
||||
esc_url( __( 'https://wordpress.org/support/update-php/' ) )
|
||||
);
|
||||
echo '</p></div>';
|
||||
_e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
|
||||
if ( current_user_can( 'update_php' ) ) {
|
||||
printf(
|
||||
/* translators: %s: "Update PHP" page URL */
|
||||
' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
echo '</p>';
|
||||
wp_update_php_annotation();
|
||||
} else {
|
||||
echo '</p>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if ( ! $tested_wp ) {
|
||||
|
@ -6716,3 +6716,28 @@ function wp_get_update_php_url() {
|
||||
function wp_get_default_update_php_url() {
|
||||
return _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the default annotation for the web host altering the "Update PHP" page URL.
|
||||
*
|
||||
* This function is to be used after {@see wp_get_update_php_url()} to display a consistent
|
||||
* annotation if the web host has altered the default "Update PHP" page URL.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*/
|
||||
function wp_update_php_annotation() {
|
||||
$update_url = wp_get_update_php_url();
|
||||
$default_url = wp_get_default_update_php_url();
|
||||
|
||||
if ( $update_url === $default_url ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<p class="description">';
|
||||
printf(
|
||||
/* translators: %s: default Update PHP page URL */
|
||||
__( '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>.' ),
|
||||
esc_url( $default_url )
|
||||
);
|
||||
echo'</p>';
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.1-beta1-44626';
|
||||
$wp_version = '5.1-beta1-44627';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user