';
/**
* Filters the compare table output for overwriting a plugin package on upload.
*
* @since 5.5.0
*
* @param string $table The output table with Name, Version, Author, RequiresWP, and RequiresPHP info.
* @param array $current_plugin_data Array with current plugin data.
* @param array $new_plugin_data Array with uploaded plugin data.
*/
echo apply_filters( 'install_plugin_overwrite_comparison', $table, $current_plugin_data, $new_plugin_data );
$install_actions = array();
$can_update = true;
$blocked_message = '
' . esc_html__( 'The plugin cannot be updated due to the following:' ) . '
';
$blocked_message .= '
';
$requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null;
$requires_wp = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null;
if ( ! is_php_version_compatible( $requires_php ) ) {
$error = sprintf(
/* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
__( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
PHP_VERSION,
$requires_php
);
$blocked_message .= '
' . esc_html( $error ) . '
';
$can_update = false;
}
if ( ! is_wp_version_compatible( $requires_wp ) ) {
$error = sprintf(
/* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */
__( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ),
esc_html( wp_get_wp_version() ),
$requires_wp
);
$blocked_message .= '
' . esc_html( $error ) . '
';
$can_update = false;
}
$blocked_message .= '
';
if ( $can_update ) {
if ( $this->is_downgrading ) {
$warning = sprintf(
/* translators: %s: Documentation URL. */
__( 'You are uploading an older version of a current plugin. You can continue to install the older version, but be sure to back up your database and files first.' ),
__( 'https://developer.wordpress.org/advanced-administration/security/backup/' )
);
} else {
$warning = sprintf(
/* translators: %s: Documentation URL. */
__( 'You are updating a plugin. Be sure to back up your database and files first.' ),
__( 'https://developer.wordpress.org/advanced-administration/security/backup/' )
);
}
echo '
' . $warning . '
';
$overwrite = $this->is_downgrading ? 'downgrade-plugin' : 'update-plugin';
$install_actions['overwrite_plugin'] = sprintf(
'%s',
wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'plugin-upload' ),
_x( 'Replace current with uploaded', 'plugin' )
);
} else {
echo $blocked_message;
}
$cancel_url = add_query_arg( 'action', 'upload-plugin-cancel-overwrite', $this->url );
$install_actions['plugins_page'] = sprintf(
'%s',
wp_nonce_url( $cancel_url, 'plugin-upload-cancel-overwrite' ),
__( 'Cancel and go back' )
);
/**
* Filters the list of action links available following a single plugin installation failure
* when overwriting is allowed.
*
* @since 5.5.0
*
* @param string[] $install_actions Array of plugin action links.
* @param object $api Object containing WordPress.org API plugin data.
* @param array $new_plugin_data Array with uploaded plugin data.
*/
$install_actions = apply_filters( 'install_plugin_overwrite_actions', $install_actions, $this->api, $new_plugin_data );
if ( ! empty( $install_actions ) ) {
printf(
'
%s
',
__( 'The uploaded file has expired. Please go back and upload it again.' )
);
echo '