Make WordPress Core

Ticket #43922: 43922.2.diff

File 43922.2.diff, 3.0 KB (added by coreymckrill, 7 years ago)

Refresh

  • src/wp-admin/includes/admin-filters.php

     
    133133add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 );
    134134
    135135// Privacy hooks
     136add_filter( 'wp_privacy_personal_data_erasure_page', 'wp_privacy_process_personal_data_erasure_page', 10, 5 );
    136137add_filter( 'wp_privacy_personal_data_export_page', 'wp_privacy_process_personal_data_export_page', 10, 7 );
    137138add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 );
    138139
  • src/wp-admin/includes/user.php

     
    918918}
    919919
    920920/**
     921 * Intercept personal data eraser page ajax responses in order to determine if the request is complete yet.
     922 * @see wp_privacy_personal_data_erasure_page
     923 * @since 4.9.6
     924 *
     925 * @param array $response The response from the personal data eraser for the given page.
     926 * @param int $eraser_index The index of the personal data eraser. Begins at 1.
     927 * @param string $email_address The email address of the user whose personal data this is.
     928 * @param int $page The page of personal data for this eraser. Begins at 1.
     929 * @param int $request_id The request ID for this personal data erasure.
     930 * @return array The filtered response.
     931 */
     932function wp_privacy_process_personal_data_erasure_page( $response, $eraser_index, $email_address, $page, $request_id ) {
     933        /* Do some simple checks on the shape of the response from the eraser.
     934         * If the eraser response is malformed, don't attempt to consume it - let it
     935         * pass through to generate a warning to the user by default ajax processing.
     936         */
     937        if ( ! is_array( $response ) ) {
     938                return $response;
     939        }
     940
     941        if ( ! array_key_exists( 'done', $response ) ) {
     942                return $response;
     943        }
     944
     945        if ( ! array_key_exists( 'items_removed', $response ) ) {
     946                return $response;
     947        }
     948
     949        if ( ! array_key_exists( 'items_retained', $response ) ) {
     950                return $response;
     951        }
     952
     953        if ( ! array_key_exists( 'messages', $response ) ) {
     954                return $response;
     955        }
     956
     957        // Get the request data.
     958        $request = wp_get_user_request_data( $request_id );
     959
     960        if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
     961                wp_send_json_error( __( 'Invalid request ID when processing eraser data.' ) );
     962        }
     963
     964        // If we are not yet on the last page of the last exporter, return now.
     965        $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() );
     966        $is_last_eraser = $eraser_index === count( $erasers );
     967        $eraser_done = $response['done'];
     968        if ( ! $is_last_eraser || ! $eraser_done ) {
     969                return $response;
     970        }
     971
     972        // Update the request to completed state.
     973        _wp_privacy_completed_request( $request_id );
     974
     975        return $response;
     976}
     977
     978/**
    921979 * Add requests pages.
    922980 *
    923981 * @since 4.9.6