Site Health: Make sure the submit_button() function is available in request_filesystem_credentials().

This avoids a fatal error when the function is called via REST API from `WP_Site_Health_Auto_Updates::test_check_wp_filesystem_method()`.

Props lakrisgubben, mukesh27, Clorith, SergeyBiryukov.
Fixes #53206.

git-svn-id: https://develop.svn.wordpress.org/trunk@50979 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2021-05-24 19:23:05 +00:00
parent 44e2c71fb5
commit 6296427dd7
2 changed files with 8 additions and 2 deletions

View File

@ -273,7 +273,7 @@ class WP_Site_Health_Auto_Updates {
* @return array The test results.
*/
function test_check_wp_filesystem_method() {
// Make sure the `request_filesystem_credentials` function is available during our REST call.
// Make sure the `request_filesystem_credentials()` function is available during our REST API call.
if ( ! function_exists( 'request_filesystem_credentials' ) ) {
require_once ABSPATH . '/wp-admin/includes/file.php';
}
@ -324,7 +324,7 @@ class WP_Site_Health_Auto_Updates {
return false;
}
// Make sure the `get_core_checksums` function is available during our REST call.
// Make sure the `get_core_checksums()` function is available during our REST API call.
if ( ! function_exists( 'get_core_checksums' ) ) {
require_once ABSPATH . '/wp-admin/includes/update.php';
}

View File

@ -2369,6 +2369,12 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( $submitted_form[ $field ] ) . '" />';
}
}
// Make sure the `submit_button()` function is available during the REST API call
// from WP_Site_Health_Auto_Updates::test_check_wp_filesystem_method().
if ( ! function_exists( 'submit_button' ) ) {
require_once ABSPATH . '/wp-admin/includes/template.php';
}
?>
<p class="request-filesystem-credentials-action-buttons">
<?php wp_nonce_field( 'filesystem-credentials', '_fs_nonce', false, true ); ?>