<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[42986] trunk/src: Privacy: add means to erase personal data by username or email address.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/42986">42986</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/42986","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-04-18 22:29:59 +0000 (Wed, 18 Apr 2018)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Privacy: add means to erase personal data by username or email address. First run.

Props allendav, coreymckrill, ericdaams, azaozz.
See <a href="https://core.trac.wordpress.org/ticket/43637">#43637</a>, <a href="https://core.trac.wordpress.org/ticket/43602">#43602</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminadminajaxphp">trunk/src/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminincludesuserphp">trunk/src/wp-admin/includes/user.php</a></li>
<li><a href="#trunksrcwpadminjsxfnjs">trunk/src/wp-admin/js/xfn.js</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminadminajaxphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/admin-ajax.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/admin-ajax.php 2018-04-17 21:08:38 UTC (rev 42985)
+++ trunk/src/wp-admin/admin-ajax.php   2018-04-18 22:29:59 UTC (rev 42986)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -130,6 +130,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        'get-community-events',
</span><span class="cx" style="display: block; padding: 0 10px">        'edit-theme-plugin-file',
</span><span class="cx" style="display: block; padding: 0 10px">        'wp-privacy-export-personal-data',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        'wp-privacy-erase-personal-data',
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> // Deprecated
</span></span></pre></div>
<a id="trunksrcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ajax-actions.php      2018-04-17 21:08:38 UTC (rev 42985)
+++ trunk/src/wp-admin/includes/ajax-actions.php        2018-04-18 22:29:59 UTC (rev 42986)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4328,10 +4328,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_ajax_wp_privacy_export_personal_data() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-//      check_ajax_referer( 'wp-privacy-export-personal-data', 'security' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ check_ajax_referer( 'wp-privacy-export-personal-data', 'security' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! current_user_can( 'manage_options' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_send_json_error( 'access denied' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_send_json_error( __( 'Error: Invalid request.' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $email_address  = sanitize_text_field( $_POST['email'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4341,7 +4341,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Filters the array of exporter callbacks.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 4.9.5.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $args {
</span><span class="cx" style="display: block; padding: 0 10px">         *     An array of callable exporters of personal data. Default empty array.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4429,7 +4429,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * Allows the export response to be consumed by destinations in addition to Ajax.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 4.9.5
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array  $response        The personal data for the given exporter and page.
</span><span class="cx" style="display: block; padding: 0 10px">         * @param int    $exporter_index  The index of the exporter that provided this data.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4443,3 +4443,197 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        wp_send_json_success( $response );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Ajax handler for erasing personal data.
+ *
+ * @since 4.9.6
+ */
+function wp_ajax_wp_privacy_erase_personal_data() {
+       $request_id  = (int) $_POST['id'];
+
+       if ( empty( $request_id ) ) {
+               wp_send_json_error( __( 'Error: Invalid request ID.' ) );
+       }
+
+       if ( ! current_user_can( 'delete_users' ) ) {
+               wp_send_json_error( __( 'Error: Invalid request.' ) );
+       }
+
+       check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' );
+
+       // Find the request CPT
+       $request = get_post( $request_id );
+       if ( 'user_remove_request' !== $request->post_type ) {
+               wp_send_json_error( __( 'Error: Invalid request ID.' ) );
+       }
+
+       $email_address = get_post_meta( $request_id, '_user_email', true );
+
+       if ( ! is_email( $email_address ) ) {
+               wp_send_json_error( __( 'Error: Invalid email address in request.' ) );
+       }
+
+       $eraser_index = (int) $_POST['eraser'];
+       $page         = (int) $_POST['page'];
+
+       /**
+        * Filters the array of personal data eraser callbacks.
+        *
+        * @since 4.9.6
+        *
+        * @param array $args {
+        *     An array of callable erasers of personal data. Default empty array.
+        *     [
+        *         callback             string Callable eraser that accepts an email address and
+        *                                     a page and returns an array with the number of items
+        *                                     removed, the number of items retained and any messages
+        *                                     from the eraser, as well as if additional pages are
+        *                                     available.
+        *         eraser_friendly_name string Translated user facing friendly name for the eraser.
+        *     ]
+        * }
+        */
+       $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() );
+
+       // Do we have any registered erasers?
+       if ( 0 < count( $erasers ) ) {
+               if ( $eraser_index < 1 ) {
+                       wp_send_json_error( __( 'Error: Eraser index cannot be less than one.' ) );
+               }
+
+               if ( $eraser_index > count( $erasers ) ) {
+                       wp_send_json_error( __( 'Error: Eraser index is out of range.' ) );
+               }
+
+               if ( $page < 1 ) {
+                       wp_send_json_error( __( 'Error: Page index cannot be less than one.' ) );
+               }
+
+               $index = $eraser_index - 1; // Convert to zero based for eraser index
+               $eraser = $erasers[ $index ];
+               if ( ! is_array( $eraser ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Expected an array describing the eraser at index %d.' ),
+                                       $eraser_index
+                               )
+                       );
+               }
+               if ( ! array_key_exists( 'callback', $eraser ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Eraser array at index %d does not include a callback.' ),
+                                       $eraser_index
+                               )
+                       );
+               }
+               if ( ! is_callable( $eraser['callback'] ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Eraser callback at index %d is not a valid callback.' ),
+                                       $eraser_index
+                               )
+                       );
+               }
+               if ( ! array_key_exists( 'eraser_friendly_name', $eraser ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Eraser array at index %d does not include a friendly name.' ),
+                                       $eraser_index
+                               )
+                       );
+               }
+
+               $callback = $erasers[ $index ]['callback'];
+               $eraser_friendly_name = $erasers[ $index ]['eraser_friendly_name'];
+
+               $response = call_user_func( $callback, $email_address, $page );
+               if ( is_wp_error( $response ) ) {
+                       wp_send_json_error( $response );
+               }
+
+               if ( ! is_array( $response ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Did not receive array from %s eraser (index %d).' ),
+                                       $eraser_friendly_name,
+                                       $eraser_index
+                               )
+                       );
+               }
+               if ( ! array_key_exists( 'num_items_removed', $response ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Expected num_items_removed key in response array from %s eraser (index %d).' ),
+                                       $eraser_friendly_name,
+                                       $eraser_index
+                               )
+                       );
+               }
+               if ( ! array_key_exists( 'num_items_retained', $response ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Expected num_items_retained key in response array from %s eraser (index %d).' ),
+                                       $eraser_friendly_name,
+                                       $eraser_index
+                               )
+                       );
+               }
+               if ( ! array_key_exists( 'messages', $response ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Expected messages key in response array from %s eraser (index %d).' ),
+                                       $eraser_friendly_name,
+                                       $eraser_index
+                               )
+                       );
+               }
+               if ( ! is_array( $response['messages'] ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Expected messages key to reference an array in response array from %s eraser (index %d).' ),
+                                       $eraser_friendly_name,
+                                       $eraser_index
+                               )
+                       );
+               }
+               if ( ! array_key_exists( 'done', $response ) ) {
+                       wp_send_json_error(
+                               sprintf(
+                                       __( 'Error: Expected done flag in response array from %s eraser (index %d).' ),
+                                       $eraser_friendly_name,
+                                       $eraser_index
+                               )
+                       );
+               }
+       } else {
+               // No erasers, so we're done
+               $response = array(
+                       'num_items_removed' => 0,
+                       'num_items_retained' => 0,
+                       'messages' => array(),
+                       'done' => true,
+               );
+       }
+
+       /**
+        * Filters a page of personal data eraser data.
+        *
+        * Allows the erasure response to be consumed by destinations in addition to Ajax.
+        *
+        * @since 4.9.6
+        *
+        * @param array  $response        The personal data for the given exporter and page.
+        * @param int    $exporter_index  The index of the exporter that provided this data.
+        * @param string $email_address   The email address associated with this personal data.
+        * @param int    $page            The zero-based page for this response.
+        * @param int    $request_id      The privacy request post ID associated with this request.
+        */
+       $response = apply_filters( 'wp_privacy_personal_data_erasure_page', $response, $eraser_index, $email_address, $page, $request_id );
+       if ( is_wp_error( $response ) ) {
+               wp_send_json_error( $response );
+       }
+
+       wp_send_json_success( $response );
+}
</ins></span></pre></div>
<a id="trunksrcwpadminincludesuserphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/user.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/user.php      2018-04-17 21:08:38 UTC (rev 42985)
+++ trunk/src/wp-admin/includes/user.php        2018-04-18 22:29:59 UTC (rev 42986)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -583,7 +583,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Get action description from the name.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @return string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -600,7 +600,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Log a request and send to the user.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @param string $email_address Email address sending the request to.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -640,7 +640,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Resend an existing request and return the result.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @param int $privacy_request_id Request ID.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -680,7 +680,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Marks a request as completed by the admin and logs the datetime.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @param int $privacy_request_id Request ID.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -705,27 +705,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Handle list table actions.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function _wp_personal_data_handle_actions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( isset( $_POST['export_personal_data_email_retry'] ) ) { // WPCS: input var ok.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $_POST['privacy_action_email_retry'] ) ) { // WPCS: input var ok.
</ins><span class="cx" style="display: block; padding: 0 10px">                 check_admin_referer( 'bulk-privacy_requests' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $request_id = absint( current( array_keys( (array) wp_unslash( $_POST['export_personal_data_email_retry'] ) ) ) ); // WPCS: input var ok, sanitization ok.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $request_id = absint( current( array_keys( (array) wp_unslash( $_POST['privacy_action_email_retry'] ) ) ) ); // WPCS: input var ok, sanitization ok.
</ins><span class="cx" style="display: block; padding: 0 10px">                 $result     = _wp_privacy_resend_request( $request_id );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( is_wp_error( $result ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        add_settings_error(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'export_personal_data_email_retry',
-                               'export_personal_data_email_retry',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'privacy_action_email_retry',
+                               'privacy_action_email_retry',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $result->get_error_message(),
</span><span class="cx" style="display: block; padding: 0 10px">                                'error'
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><span class="cx" style="display: block; padding: 0 10px">                } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        add_settings_error(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'export_personal_data_email_retry',
-                               'export_personal_data_email_retry',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'privacy_action_email_retry',
+                               'privacy_action_email_retry',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 __( 'Confirmation request re-resent successfully.' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'updated'
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -837,7 +837,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Personal data export.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function _wp_personal_data_export_page() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -898,22 +898,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Personal data anonymization.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function _wp_personal_data_removal_page() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! current_user_can( 'manage_options' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'delete_users' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 wp_die( esc_html__( 'Sorry, you are not allowed to manage privacy on this site.' ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        _wp_personal_data_handle_actions();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        // "Borrow" xfn.js for now so we don't have to create new files.
+       wp_enqueue_script( 'xfn' );
+
</ins><span class="cx" style="display: block; padding: 0 10px">         $requests_table = new WP_Privacy_Data_Removal_Requests_Table( array(
</span><span class="cx" style="display: block; padding: 0 10px">                'plural'   => 'privacy_requests',
</span><span class="cx" style="display: block; padding: 0 10px">                'singular' => 'privacy_request',
</span><span class="cx" style="display: block; padding: 0 10px">        ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">         $requests_table->process_bulk_action();
</span><span class="cx" style="display: block; padding: 0 10px">        $requests_table->prepare_items();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">         ?>
</span><span class="cx" style="display: block; padding: 0 10px">        <div class="wrap nosubsub">
</span><span class="cx" style="display: block; padding: 0 10px">                <h1><?php esc_html_e( 'Remove Personal Data' ); ?></h1>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -959,7 +964,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Add requests pages.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function _wp_privacy_hook_requests_page() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -982,7 +987,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * which inherit from WP_Privacy_Requests_Table should define this.
</span><span class="cx" style="display: block; padding: 0 10px">         * e.g. 'export_personal_data'
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @var string $request_type Name of action.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -991,7 +996,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Post type to be used.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @var string $post_type The post type.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1000,7 +1005,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Get columns to show in the list table.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array Array of columns.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1018,7 +1023,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Get a list of sortable columns.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @return array
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1029,7 +1034,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Default primary column.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1041,7 +1046,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * Get an associative array ( id => link ) with the list
</span><span class="cx" style="display: block; padding: 0 10px">         * of views available on this table.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @return array
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1066,7 +1071,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Get bulk actions.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @return array
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1080,7 +1085,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Process bulk actions.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        public function process_bulk_action() {
</span><span class="cx" style="display: block; padding: 0 10px">                $action      = $this->current_action();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1129,7 +1134,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Prepare items to output.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        public function prepare_items() {
</span><span class="cx" style="display: block; padding: 0 10px">                global $wpdb;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1194,7 +1199,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Checkbox column.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $item Item being shown.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1206,7 +1211,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Status column.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $item Item being shown.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1243,7 +1248,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Convert timestamp for display.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param int $timestamp Event timestamp.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1265,7 +1270,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Default column handler.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $item         Item being shown.
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $column_name Name of column being shown.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1284,7 +1289,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Actions column. Overriden by children.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $item Item being shown.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1296,7 +1301,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Next steps column. Overriden by children.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $item Item being shown.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1305,7 +1310,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Generates content for a single row of the table
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param object $item The current item
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1320,7 +1325,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Embed scripts used to perform actions. Overriden by children.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        public function embed_scripts() {}
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1328,13 +1333,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * WP_Privacy_Data_Export_Requests_Table class.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table {
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Action name for the requests this table will work with.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @var string $request_type Name of action.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1343,7 +1348,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Post type for the requests.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @var string $post_type The post type.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1352,14 +1357,29 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Actions column.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $item Item being shown.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function column_email( $item ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $exporters       = apply_filters( 'wp_privacy_personal_data_exporters', array() );
+               $exporters_count = count( $exporters );
+               $request_id      = $item['request_id'];
+               $nonce           = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
+
+               $download_data_markup = '<div class="download_personal_data" ' .
+                       'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' .
+                       'data-request-id="' . esc_attr( $request_id ) . '" ' .
+                       'data-nonce="' . esc_attr( $nonce ) .
+                       '">';
+
+               $download_data_markup .= '<span class="download_personal_data_idle"><a href="#" >' . __( 'Download Personal Data' ) . '</a></span>' .
+                       '<span style="display:none" class="download_personal_data_processing" >' . __( 'Downloading Data...' ) . '</span>' .
+                       '<span style="display:none" class="download_personal_data_failed">' . __( 'Download Failed!' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>';
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $row_actions = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'download_data' => __( 'Download Personal Data' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'download_data' => $download_data_markup,
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                return sprintf( '%1$s %2$s', $item['email'], $this->row_actions( $row_actions ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1368,7 +1388,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Next steps column.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $item Item being shown.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1383,7 +1403,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                // TODO Complete in follow on patch.
</span><span class="cx" style="display: block; padding: 0 10px">                                break;
</span><span class="cx" style="display: block; padding: 0 10px">                        case 'request-failed':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                submit_button( __( 'Retry' ), 'secondary', 'export_personal_data_email_retry[' . $item['request_id'] . ']', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         submit_button( __( 'Retry' ), 'secondary', 'privacy_action_email_retry[' . $item['request_id'] . ']', false );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 break;
</span><span class="cx" style="display: block; padding: 0 10px">                        case 'request-completed':
</span><span class="cx" style="display: block; padding: 0 10px">                                echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1398,13 +1418,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * WP_Privacy_Data_Removal_Requests_Table class.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Requests_Table {
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Action name for the requests this table will work with.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @var string $request_type Name of action.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1413,7 +1433,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Post type for the requests.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @var string $post_type The post type.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1422,21 +1442,35 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Actions column.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $item Item being shown.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function column_email( $item ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $row_actions = array(
-                       // TODO Complete in follow on patch.
-                       'remove_data' => __( 'Remove Personal Data' ),
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $row_actions = array();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // If we have a user ID, include a delete user action.
-               if ( ! empty( $item['user_id'] ) ) {
-                       // TODO Complete in follow on patch.
-                       $row_actions['delete_user'] = __( 'Delete User' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Allow the administrator to "force remove" the personal data even if confirmation has not yet been received
+               $status = get_post_status( $item['request_id'] );
+               if ( 'request-confirmed' !== $status ) {
+                       $erasers       = apply_filters( 'wp_privacy_personal_data_erasers', array() );
+                       $erasers_count = count( $erasers );
+                       $request_id    = $item['request_id'];
+                       $nonce         = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
+
+                       $remove_data_markup = '<div class="remove_personal_data force_remove_personal_data" ' .
+                               'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' .
+                               'data-request-id="' . esc_attr( $request_id ) . '" ' .
+                               'data-nonce="' . esc_attr( $nonce ) .
+                               '">';
+
+                       $remove_data_markup .= '<span class="remove_personal_data_idle"><a href="#" >' . __( 'Force Remove Personal Data' ) . '</a></span>' .
+                               '<span style="display:none" class="remove_personal_data_processing" >' . __( 'Removing Data...' ) . '</span>' .
+                               '<span style="display:none" class="remove_personal_data_failed">' . __( 'Force Remove Failed!' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>';
+
+                       $row_actions = array(
+                               'remove_data' => $remove_data_markup,
+                       );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                return sprintf( '%1$s %2$s', $item['email'], $this->row_actions( $row_actions ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1445,11 +1479,47 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Next steps column.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 5.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 4.9.6
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $item Item being shown.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function column_next_steps( $item ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $status = get_post_status( $item['request_id'] );
+
+               switch ( $status ) {
+                       case 'request-pending':
+                               esc_html_e( 'Waiting for confirmation' );
+                               break;
+                       case 'request-confirmed':
+                               $erasers       = apply_filters( 'wp_privacy_personal_data_erasers', array() );
+                               $erasers_count = count( $erasers );
+                               $request_id    = $item['request_id'];
+                               $nonce         = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
+
+                               echo '<div class="remove_personal_data" ' .
+                                       'data-force-erase="1" ' .
+                                       'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' .
+                                       'data-request-id="' . esc_attr( $request_id ) . '" ' .
+                                       'data-nonce="' . esc_attr( $nonce ) .
+                                       '">';
+
+                               ?>
+                               <span class="remove_personal_data_idle"><a class="button" href="#" ><?php _e( 'Remove Personal Data' ); ?></a></span>
+                               <span style="display:none" class="remove_personal_data_processing button updating-message" ><?php _e( 'Removing Data...' ); ?></span>
+                               <span style="display:none" class="remove_personal_data_failed"><?php _e( 'Removing Data Failed!' ); ?> <a class="button" href="#" ><?php _e( 'Retry' ); ?></a></span>
+                               <?php
+
+                               break;
+                       case 'request-failed':
+                               submit_button( __( 'Retry' ), 'secondary', 'privacy_action_email_retry[' . $item['request_id'] . ']', false );
+                               break;
+                       case 'request-completed':
+                               echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array(
+                                       'action' => 'delete',
+                                       'request_id' => array( $item['request_id'] ),
+                               ), admin_url( 'tools.php?page=remove_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>';
+                               break;
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminjsxfnjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/xfn.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/xfn.js      2018-04-17 21:08:38 UTC (rev 42985)
+++ trunk/src/wp-admin/js/xfn.js        2018-04-18 22:29:59 UTC (rev 42986)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -20,3 +20,124 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $( '#link_rel' ).val( ( isMe ) ? 'me' : inputs.substr( 0,inputs.length - 1 ) );
</span><span class="cx" style="display: block; padding: 0 10px">        });
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+// Privacy request action handling
+
+jQuery( document ).ready( function( $ ) {
+       var strings = window.privacyToolsL10n || {};
+
+       function set_action_state( $action, state ) {
+               $action.children().hide();
+               $action.children( '.' + state ).show();
+       }
+
+       function clearResultsAfterRow( $requestRow ) {
+               if ( $requestRow.next().hasClass( 'request-results' ) ) {
+                       $requestRow.next().remove();
+               }
+       }
+
+       function appendResultsAfterRow( $requestRow, classes, summaryMessage, additionalMessages ) {
+               clearResultsAfterRow( $requestRow );
+               if ( additionalMessages.length ) {
+                       // TODO - render additionalMessages after the summaryMessage
+               }
+
+               $requestRow.after( function() {
+                       return '<tr class="request-results"><td colspan="5"><div class="notice inline notice-alt ' + classes + '"><p>' +
+                               summaryMessage +
+                               '</p></div></td></tr>';
+               } );
+       }
+
+       $( '.remove_personal_data a' ).click( function( event ) {
+               event.preventDefault();
+               event.stopPropagation();
+
+               var $this         = $( this );
+               var $action       = $this.parents( '.remove_personal_data' );
+               var $requestRow   = $this.parents( 'tr' );
+               var requestID     = $action.data( 'request-id' );
+               var nonce         = $action.data( 'nonce' );
+               var erasersCount  = $action.data( 'erasers-count' );
+
+               var removedCount  = 0;
+               var retainedCount = 0;
+               var messages      = [];
+
+               $action.blur();
+               clearResultsAfterRow( $requestRow );
+
+               function on_erasure_done_success() {
+                       set_action_state( $action, 'remove_personal_data_idle' );
+                       var summaryMessage = strings.noDataFound;
+                       var classes = 'notice-success';
+                       if ( 0 == removedCount ) {
+                               if ( 0 == retainedCount ) {
+                                       summaryMessage = strings.noDataFound;
+                               } else {
+                                       summaryMessage = strings.noneRemoved;
+                                       classes = 'notice-warning';
+                               }
+                       } else {
+                               if ( 0 == retainedCount ) {
+                                       summaryMessage = strings.foundAndRemoved;
+                               } else {
+                                       summaryMessage = strings.someNotRemoved;
+                                       classes = 'notice-warning';
+                               }
+                       }
+                       appendResultsAfterRow( $requestRow, 'notice-success', summaryMessage, [] );
+               }
+
+               function on_erasure_failure( textStatus, error ) {
+                       set_action_state( $action, 'remove_personal_data_failed' );
+                       appendResultsAfterRow( $requestRow, 'notice-error', strings.anErrorOccurred, [] );
+               }
+
+               function do_next_erasure( eraserIndex, pageIndex ) {
+                       $.ajax( {
+                               url: ajaxurl,
+                               data: {
+                                       action: 'wp-privacy-erase-personal-data',
+                                       eraser: eraserIndex,
+                                       id: requestID,
+                                       page: pageIndex,
+                                       security: nonce,
+                               },
+                               method: 'post'
+                       } ).done( function( response ) {
+                               if ( ! response.success ) {
+                                       on_erasure_failure( 'error', response.data );
+                                       return;
+                               }
+                               var responseData = response.data;
+                               if ( responseData.num_items_removed ) {
+                                       removedCount += responseData.num_items_removed;
+                               }
+                               if ( responseData.num_items_retained ) {
+                                       retainedCount += responseData.num_items_removed;
+                               }
+                               if ( responseData.messages ) {
+                                       messages = messages.concat( responseData.messages );
+                               }
+                               if ( ! responseData.done ) {
+                                       setTimeout( do_next_erasure( eraserIndex, pageIndex + 1 ) );
+                               } else {
+                                       if ( eraserIndex < erasersCount ) {
+                                               setTimeout( do_next_erasure( eraserIndex + 1, 1 ) );
+                                       } else {
+                                               on_erasure_done_success();
+                                       }
+                               }
+                       } ).fail( function( jqxhr, textStatus, error ) {
+                               on_erasure_failure( textStatus, error );
+                       } );
+               }
+
+               // And now, let's begin
+               set_action_state( $action, 'remove_personal_data_processing' );
+
+               do_next_erasure( 1, 1 );
+       } )
+} );
</ins></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php   2018-04-17 21:08:38 UTC (rev 42985)
+++ trunk/src/wp-includes/script-loader.php     2018-04-18 22:29:59 UTC (rev 42986)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -709,6 +709,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array( 'jquery' ), false, 1 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                did_action( 'init' ) && $scripts->localize(
+                       'xfn', 'privacyToolsL10n', array(
+                               'noDataFound'     => __( 'No personal data was found for this user.' ),
+                               'foundAndRemoved' => __( 'All of the personal data found for this user was removed.' ),
+                               'noneRemoved'     => __( 'Personal data was found for this user but was not removed.' ),
+                               'someNotRemoved'  => __( 'Personal data was found for this user but some of the personal data found was not removed.' ),
+                               'anErrorOccurred' => __( 'An error occurred while attempting to find and remove personal data.' ),
+                       )
+               );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array( 'jquery-ui-sortable' ), false, 1 );
</span><span class="cx" style="display: block; padding: 0 10px">                did_action( 'init' ) && $scripts->localize(
</span></span></pre>
</div>
</div>

</body>
</html>