Make WordPress Core

Ticket #43637: 43637.4.diff

File 43637.4.diff, 6.0 KB (added by desrosj, 7 years ago)
  • src/wp-admin/includes/ajax-actions.php

     
    45054505         *
    45064506         * @param array $args {
    45074507         *     An array of callable erasers of personal data. Default empty array.
    4508          *     [
    4509          *         callback             string Callable eraser that accepts an email address and
    4510          *                                     a page and returns an array with the number of items
    4511          *                                     removed, the number of items retained and any messages
    4512          *                                     from the eraser, as well as if additional pages are
    4513          *                                     available.
    4514          *         eraser_friendly_name string Translated user facing friendly name for the eraser.
    4515          *     ]
     4508         *
     4509         *     @type array {
     4510         *         Array of personal data erasers.
     4511         *
     4512         *         @type string $callback             Callable eraser that accepts an email address and
     4513         *                                            a page and returns an array with the number of
     4514         *                                            items removed, the number of items retained and
     4515         *                                            any messages from the eraser, as well as if
     4516         *                                            additional pages are available.
     4517         *         @type string $eraser_friendly_name Translated user facing friendly name for the
     4518         *                                            eraser.
     4519         *     }
    45164520         * }
    45174521         */
    45184522        $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() );
     
    45314535                        wp_send_json_error( __( 'Error: Page index cannot be less than one.' ) );
    45324536                }
    45334537
    4534                 $index = $eraser_index - 1; // Convert to zero based for eraser index
     4538                $index = $eraser_index - 1; // Convert to zero based for eraser index.
    45354539                $eraser = $erasers[ $index ];
    45364540                if ( ! is_array( $eraser ) ) {
    45374541                        wp_send_json_error(
    45384542                                sprintf(
    4539                                         __( 'Error: Expected an array describing the eraser at index %d.' ),
     4543                                        /* translators: %s: the array index */
     4544                                        __( 'Error: Expected an array describing the eraser at index %s.' ),
    45404545                                        $eraser_index
    45414546                                )
    45424547                        );
     
    45444549                if ( ! array_key_exists( 'callback', $eraser ) ) {
    45454550                        wp_send_json_error(
    45464551                                sprintf(
    4547                                         __( 'Error: Eraser array at index %d does not include a callback.' ),
     4552                                        /* translators: %s: the array index */
     4553                                        __( 'Error: Eraser array at index %s does not include a callback.' ),
    45484554                                        $eraser_index
    45494555                                )
    45504556                        );
     
    45524558                if ( ! is_callable( $eraser['callback'] ) ) {
    45534559                        wp_send_json_error(
    45544560                                sprintf(
    4555                                         __( 'Error: Eraser callback at index %d is not a valid callback.' ),
     4561                                        /* translators: %s: the array index */
     4562                                        __( 'Error: Eraser callback at index %s is not a valid callback.' ),
    45564563                                        $eraser_index
    45574564                                )
    45584565                        );
     
    45604567                if ( ! array_key_exists( 'eraser_friendly_name', $eraser ) ) {
    45614568                        wp_send_json_error(
    45624569                                sprintf(
    4563                                         __( 'Error: Eraser array at index %d does not include a friendly name.' ),
     4570                                        /* translators: %s: the array index */
     4571                                        __( 'Error: Eraser array at index %s does not include a friendly name.' ),
    45644572                                        $eraser_index
    45654573                                )
    45664574                        );
     
    45774585                if ( ! is_array( $response ) ) {
    45784586                        wp_send_json_error(
    45794587                                sprintf(
    4580                                         __( 'Error: Did not receive array from %s eraser (index %d).' ),
     4588                                        /* translators: 1: eraser friendly name, 2: array index */
     4589                                        __( 'Error: Did not receive array from %s eraser (index %s).' ),
    45814590                                        $eraser_friendly_name,
    45824591                                        $eraser_index
    45834592                                )
     
    45864595                if ( ! array_key_exists( 'num_items_removed', $response ) ) {
    45874596                        wp_send_json_error(
    45884597                                sprintf(
    4589                                         __( 'Error: Expected num_items_removed key in response array from %s eraser (index %d).' ),
     4598                                        /* translators: 1: eraser friendly name, 2: array index */
     4599                                        __( 'Error: Expected num_items_removed key in response array from %s eraser (index %s).' ),
    45904600                                        $eraser_friendly_name,
    45914601                                        $eraser_index
    45924602                                )
     
    45954605                if ( ! array_key_exists( 'num_items_retained', $response ) ) {
    45964606                        wp_send_json_error(
    45974607                                sprintf(
    4598                                         __( 'Error: Expected num_items_retained key in response array from %s eraser (index %d).' ),
     4608                                        /* translators: 1: eraser friendly name, 2: array index */
     4609                                        __( 'Error: Expected num_items_retained key in response array from %s eraser (index %s).' ),
    45994610                                        $eraser_friendly_name,
    46004611                                        $eraser_index
    46014612                                )
     
    46044615                if ( ! array_key_exists( 'messages', $response ) ) {
    46054616                        wp_send_json_error(
    46064617                                sprintf(
    4607                                         __( 'Error: Expected messages key in response array from %s eraser (index %d).' ),
     4618                                        /* translators: 1: eraser friendly name, 2: array index */
     4619                                        __( 'Error: Expected messages key in response array from %s eraser (index %s).' ),
    46084620                                        $eraser_friendly_name,
    46094621                                        $eraser_index
    46104622                                )
     
    46134625                if ( ! is_array( $response['messages'] ) ) {
    46144626                        wp_send_json_error(
    46154627                                sprintf(
    4616                                         __( 'Error: Expected messages key to reference an array in response array from %s eraser (index %d).' ),
     4628                                        /* translators: 1: eraser friendly name, 2: array index */
     4629                                        __( 'Error: Expected messages key to reference an array in response array from %s eraser (index %s).' ),
    46174630                                        $eraser_friendly_name,
    46184631                                        $eraser_index
    46194632                                )
     
    46224635                if ( ! array_key_exists( 'done', $response ) ) {
    46234636                        wp_send_json_error(
    46244637                                sprintf(
    4625                                         __( 'Error: Expected done flag in response array from %s eraser (index %d).' ),
     4638                                        /* translators: 1: eraser friendly name, 2: array index */
     4639                                        __( 'Error: Expected done flag in response array from %s eraser (index %s).' ),
    46264640                                        $eraser_friendly_name,
    46274641                                        $eraser_index
    46284642                                )
     
    46524666         * @param int    $request_id      The privacy request post ID associated with this request.
    46534667         */
    46544668        $response = apply_filters( 'wp_privacy_personal_data_erasure_page', $response, $eraser_index, $email_address, $page, $request_id );
     4669
    46554670        if ( is_wp_error( $response ) ) {
    46564671                wp_send_json_error( $response );
    46574672        }