WordPress.org

Make WordPress Core

Ticket #37488: 37488.patch

File 37488.patch, 4.4 KB (added by ocean90, 4 years ago)
  • src/wp-admin/includes/ajax-actions.php

     
    35153515                wp_send_json_error( $status );
    35163516        }
    35173517
    3518         // Check filesystem credentials. `delete_plugins()` will bail otherwise.
     3518        // Check filesystem credentials. `delete_theme()` will bail otherwise.
     3519        $url = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet );
    35193520        ob_start();
    3520         $url = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet );
    3521         if ( false === ( $credentials = request_filesystem_credentials( $url ) ) || ! WP_Filesystem( $credentials ) ) {
     3521        $credentials = request_filesystem_credentials( $url );
     3522        ob_end_clean();
     3523        if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
    35223524                global $wp_filesystem;
    3523                 ob_end_clean();
    35243525
    35253526                $status['errorCode']    = 'unable_to_connect_to_filesystem';
    35263527                $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
     
    37713772        }
    37723773
    37733774        // Check filesystem credentials. `delete_plugins()` will bail otherwise.
     3775        $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' );
    37743776        ob_start();
    3775         $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' );
    3776         if ( false === ( $credentials = request_filesystem_credentials( $url ) ) || ! WP_Filesystem( $credentials ) ) {
     3777        $credentials = request_filesystem_credentials( $url );
     3778        ob_end_clean();
     3779        if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
    37773780                global $wp_filesystem;
    3778                 ob_end_clean();
    37793781
    37803782                $status['errorCode']    = 'unable_to_connect_to_filesystem';
    37813783                $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
  • src/wp-admin/includes/plugin.php

     
    782782        foreach ( $plugins as $plugin )
    783783                $checked[] = 'checked[]=' . $plugin;
    784784
    785         ob_start();
    786785        $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins');
    787         if ( false === ($credentials = request_filesystem_credentials($url)) ) {
    788                 $data = ob_get_clean();
    789786
     787        ob_start();
     788        $credentials = request_filesystem_credentials( $url );
     789        $data = ob_get_clean();
     790
     791        if ( false === $credentials ) {
    790792                if ( ! empty($data) ){
    791793                        include_once( ABSPATH . 'wp-admin/admin-header.php');
    792794                        echo $data;
     
    796798                return;
    797799        }
    798800
    799         if ( ! WP_Filesystem($credentials) ) {
    800                 request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
     801        if ( ! WP_Filesystem( $credentials ) ) {
     802                ob_start();
     803                request_filesystem_credentials( $url, '', true ); //Failed to connect, Error and request again
    801804                $data = ob_get_clean();
    802805
    803806                if ( ! empty($data) ){
  • src/wp-admin/includes/theme.php

     
    2323        if ( empty($stylesheet) )
    2424                return false;
    2525
    26         ob_start();
    27         if ( empty( $redirect ) )
     26        if ( empty( $redirect ) ) {
    2827                $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet);
    29         if ( false === ($credentials = request_filesystem_credentials($redirect)) ) {
    30                 $data = ob_get_clean();
     28        }
    3129
    32                 if ( ! empty($data) ){
     30        ob_start();
     31        $credentials = request_filesystem_credentials( $redirect );
     32        $data = ob_get_clean();
     33
     34        if ( false === ( $credentials ) ) {
     35                if ( ! empty( $data ) ){
    3336                        include_once( ABSPATH . 'wp-admin/admin-header.php');
    3437                        echo $data;
    3538                        include( ABSPATH . 'wp-admin/admin-footer.php');
     
    3841                return;
    3942        }
    4043
    41         if ( ! WP_Filesystem($credentials) ) {
    42                 request_filesystem_credentials($redirect, '', true); // Failed to connect, Error and request again
     44        if ( ! WP_Filesystem( $credentials ) ) {
     45                ob_start();
     46                request_filesystem_credentials( $redirect, '', true ); // Failed to connect, Error and request again
    4347                $data = ob_get_clean();
    4448
    4549                if ( ! empty($data) ) {