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>';
|
echo '<div class="notice inline notice-error notice-alt"><p>';
|
||||||
if ( ! $compatible_php && ! $compatible_wp ) {
|
if ( ! $compatible_php && ! $compatible_wp ) {
|
||||||
_e( 'This plugin doesn’t work with your versions of WordPress and PHP. ' );
|
_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(
|
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>.' ),
|
__( '<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' ),
|
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(
|
printf(
|
||||||
/* translators: %s: "Updating PHP" page URL */
|
/* translators: %s: "Update WordPress" screen URL */
|
||||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
__( '<a href="%s">Please update WordPress</a>.' ),
|
||||||
esc_url( __( 'https://wordpress.org/support/update-php/' ) )
|
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 ) {
|
} elseif ( ! $compatible_wp ) {
|
||||||
_e( 'This plugin doesn’t work with your version of WordPress. ' );
|
_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 ) {
|
} elseif ( ! $compatible_php ) {
|
||||||
_e( 'This plugin doesn’t work with your version of PHP. ' );
|
_e( 'This plugin doesn’t work with your version of PHP. ' );
|
||||||
|
if ( current_user_can( 'update_php' ) ) {
|
||||||
printf(
|
printf(
|
||||||
/* translators: %s: "Updating PHP" page URL */
|
/* translators: %s: "Update PHP" page URL */
|
||||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||||
esc_url( __( 'https://wordpress.org/support/update-php/' ) )
|
esc_url( wp_get_update_php_url() )
|
||||||
);
|
);
|
||||||
|
wp_update_php_annotation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo '</p></div>';
|
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.' );
|
$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>
|
<p><?php echo $msg; ?></p>
|
||||||
|
|
||||||
|
@ -1639,7 +1636,7 @@ function wp_dashboard_php_nag() {
|
||||||
<?php
|
<?php
|
||||||
printf(
|
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>',
|
'<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' ),
|
__( 'Learn more about updating PHP' ),
|
||||||
/* translators: accessibility text */
|
/* translators: accessibility text */
|
||||||
__( '(opens in a new tab)' )
|
__( '(opens in a new tab)' )
|
||||||
|
@ -1648,19 +1645,7 @@ function wp_dashboard_php_nag() {
|
||||||
</p>
|
</p>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ( $update_url !== $default_url ) {
|
wp_update_php_annotation();
|
||||||
?>
|
|
||||||
<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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -762,12 +762,19 @@ function install_plugin_information() {
|
||||||
|
|
||||||
if ( ! $compatible_php ) {
|
if ( ! $compatible_php ) {
|
||||||
echo '<div class="notice notice-error notice-alt"><p>';
|
echo '<div class="notice notice-error notice-alt"><p>';
|
||||||
|
_e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
|
||||||
|
if ( current_user_can( 'update_php' ) ) {
|
||||||
printf(
|
printf(
|
||||||
/* translators: "Updating PHP" page URL */
|
/* translators: %s: "Update 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>.' ),
|
' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
|
||||||
esc_url( __( 'https://wordpress.org/support/update-php/' ) )
|
esc_url( wp_get_update_php_url() )
|
||||||
);
|
);
|
||||||
echo '</p></div>';
|
echo '</p>';
|
||||||
|
wp_update_php_annotation();
|
||||||
|
} else {
|
||||||
|
echo '</p>';
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $tested_wp ) {
|
if ( ! $tested_wp ) {
|
||||||
|
|
|
@ -6716,3 +6716,28 @@ function wp_get_update_php_url() {
|
||||||
function wp_get_default_update_php_url() {
|
function wp_get_default_update_php_url() {
|
||||||
return _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page' );
|
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
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue