<!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>[43011] trunk/src: Privacy: update and enhance the method to confirm user requests by email.</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/43011">43011</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/43011","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-27 17:30:28 +0000 (Fri, 27 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: update and enhance the method to confirm user requests by email. Introduce WP_User_Request to hold all request vars similarly to WP_Post.
Props mikejolley.
See <a href="https://core.trac.wordpress.org/ticket/43443">#43443</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<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="#trunksrcwpincludespostphp">trunk/src/wp-includes/post.php</a></li>
<li><a href="#trunksrcwpincludesuserphp">trunk/src/wp-includes/user.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<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-27 11:40:35 UTC (rev 43010)
+++ trunk/src/wp-admin/includes/ajax-actions.php 2018-04-27 17:30:28 UTC (rev 43011)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4463,12 +4463,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Find the request CPT
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = get_post( $request_id );
- if ( 'remove_personal_data' !== $request->post_title ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = wp_get_user_request_data( $request_id );
+
+ if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( __( 'Error: Invalid request ID.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $email_address = get_post_meta( $request_id, '_wp_user_request_user_email', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $email_address = $request->email;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_email( $email_address ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( __( 'Error: Invalid email address in request.' ) );
</span></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-27 11:40:35 UTC (rev 43010)
+++ trunk/src/wp-admin/includes/user.php 2018-04-27 17:30:28 UTC (rev 43011)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -626,10 +626,12 @@
</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"> update_post_meta( $request_id, '_wp_user_request_confirmed_timestamp', time() );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = wp_update_post( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'ID' => $request_data['request_id'],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'ID' => $request_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'request-confirmed',
</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"> return $request;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -772,6 +774,38 @@
</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"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Cleans up failed and expired requests before displaying the list table.
+ *
+ * @since 4.9.6
+ * @access private
+ */
+function _wp_personal_data_cleanup_requests() {
+ $expires = (int) apply_filters( 'user_request_key_expiration', DAY_IN_SECONDS );
+ $requests_query = new WP_Query( array(
+ 'post_type' => 'user_request',
+ 'posts_per_page' => -1,
+ 'post_status' => 'request-pending',
+ 'fields' => 'ids',
+ 'date_query' => array(
+ array(
+ 'column' => 'post_modified_gmt',
+ 'before' => $expires . ' seconds ago',
+ ),
+ ),
+ ) );
+
+ $request_ids = $requests_query->posts;
+
+ foreach ( $request_ids as $request_id ) {
+ wp_update_post( array(
+ 'ID' => $request_id,
+ 'post_status' => 'request-failed',
+ 'post_password' => '',
+ ) );
+ }
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Personal data export.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -783,6 +817,7 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ _wp_personal_data_cleanup_requests();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $requests_table = new WP_Privacy_Data_Export_Requests_Table( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'plural' => 'privacy_requests',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -844,6 +879,7 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ _wp_personal_data_cleanup_requests();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // "Borrow" xfn.js for now so we don't have to create new files.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'xfn' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -882,7 +918,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <form class="search-form wp-clearfix">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php $requests_table->search_box( __( 'Search Requests' ), 'requests' ); ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <input type="hidden" name="page" value="export_personal_data" />
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <input type="hidden" name="page" value="remove_personal_data" />
</ins><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" name="filter-status" value="<?php echo isset( $_REQUEST['filter-status'] ) ? esc_attr( sanitize_text_field( $_REQUEST['filter-status'] ) ) : ''; ?>" />
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" name="orderby" value="<?php echo isset( $_REQUEST['orderby'] ) ? esc_attr( sanitize_text_field( $_REQUEST['orderby'] ) ) : ''; ?>" />
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" name="order" value="<?php echo isset( $_REQUEST['order'] ) ? esc_attr( sanitize_text_field( $_REQUEST['order'] ) ) : ''; ?>" />
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -948,11 +984,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_columns() {
</span><span class="cx" style="display: block; padding: 0 10px"> $columns = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'cb' => '<input type="checkbox" />',
- 'email' => __( 'Requester' ),
- 'status' => __( 'Status' ),
- 'requested_timestamp' => __( 'Requested' ),
- 'next_steps' => __( 'Next Steps' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'cb' => '<input type="checkbox" />',
+ 'email' => __( 'Requester' ),
+ 'status' => __( 'Status' ),
+ 'created_timestamp' => __( 'Requested' ),
+ 'next_steps' => __( 'Next Steps' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> return $columns;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1000,7 +1036,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> SELECT post_status, COUNT( * ) AS num_posts
</span><span class="cx" style="display: block; padding: 0 10px"> FROM {$wpdb->posts}
</span><span class="cx" style="display: block; padding: 0 10px"> WHERE post_type = %s
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- AND post_title = %s
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ AND post_name = %s
</ins><span class="cx" style="display: block; padding: 0 10px"> GROUP BY post_status";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $results = (array) $wpdb->get_results( $wpdb->prepare( $query, $this->post_type, $this->request_type ), ARRAY_A );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1088,7 +1124,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> case 'resend':
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $request_ids as $request_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $resend = _wp_privacy_resend_request( $request_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $resend && ! is_wp_error( $resend ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $count++;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1124,10 +1160,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $posts_per_page = 20;
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => $this->post_type,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'title' => $this->request_type,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_name__in' => array( $this->request_type ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'posts_per_page' => $posts_per_page,
</span><span class="cx" style="display: block; padding: 0 10px"> 'offset' => isset( $_REQUEST['paged'] ) ? max( 0, absint( $_REQUEST['paged'] ) - 1 ) * $posts_per_page: 0,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'any',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 's' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : '',
</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"> if ( ! empty( $_REQUEST['filter-status'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1135,18 +1172,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $args['post_status'] = $filter_status;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $_REQUEST['s'] ) ) {
- $args['meta_query'] = array(
- $name_query,
- 'relation' => 'AND',
- array(
- 'key' => '_wp_user_request_user_email',
- 'value' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ): '',
- 'compare' => 'LIKE',
- ),
- );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> $requests_query = new WP_Query( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> $requests = $requests_query->posts;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1154,6 +1179,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->items[] = wp_get_user_request_data( $request->ID );
</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">+ $this->items = array_filter( $this->items );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->set_pagination_args(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'total_items' => $requests_query->found_posts,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1167,11 +1194,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $item Item being shown.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item Item being shown.
</ins><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_cb( $item ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return sprintf( '<input type="checkbox" name="request_id[]" value="%1$s" /><span class="spinner"></span>', esc_attr( $item['request_id'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return sprintf( '<input type="checkbox" name="request_id[]" value="%1$s" /><span class="spinner"></span>', esc_attr( $item->ID ) );
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1179,11 +1206,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $item Item being shown.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item Item being shown.
</ins><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_status( $item ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $status = get_post_status( $item['request_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $status = get_post_status( $item->ID );
</ins><span class="cx" style="display: block; padding: 0 10px"> $status_object = get_post_status_object( $status );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $status_object || empty( $status_object->label ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1194,10 +1221,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'request-confirmed':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $timestamp = $item['confirmed_timestamp'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $timestamp = $item->confirmed_timestamp;
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $timestamp = $item['completed_timestamp'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $timestamp = $item->completed_timestamp;
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1238,14 +1265,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $item Item being shown.
- * @param string $column_name Name of column being shown.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item Item being shown.
+ * @param string $column_name Name of column being shown.
</ins><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_default( $item, $column_name ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cell_value = $item[ $column_name ];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cell_value = $item->$column_name;
</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 ( in_array( $column_name, array( 'requested_timestamp' ), true ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( in_array( $column_name, array( 'created_timestamp' ), true ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return $this->get_timestamp_as_date( $cell_value );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1257,11 +1284,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $item Item being shown.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item Item being shown.
</ins><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">- return sprintf( '%1$s %2$s', $item['email'], $this->row_actions( array() ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return sprintf( '%1$s %2$s', $item->email, $this->row_actions( array() ) );
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1269,7 +1296,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $item Item being shown.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item Item being shown.
</ins><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><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1278,10 +1305,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param object $item The current item
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item The current item
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function single_row( $item ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $status = get_post_status( $item['request_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $status = $item->status;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<tr class="status-' . esc_attr( $status ) . '">';
</span><span class="cx" style="display: block; padding: 0 10px"> $this->single_row_columns( $item );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1325,13 +1352,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $item Item being shown.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item Item being shown.
</ins><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><span class="cx" style="display: block; padding: 0 10px"> $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() );
</span><span class="cx" style="display: block; padding: 0 10px"> $exporters_count = count( $exporters );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request_id = $item['request_id'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request_id = $item->ID;
</ins><span class="cx" style="display: block; padding: 0 10px"> $nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $download_data_markup = '<div class="download_personal_data" ' .
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1348,7 +1375,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'download_data' => $download_data_markup,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return sprintf( '%1$s %2$s', $item['email'], $this->row_actions( $row_actions ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return sprintf( '%1$s %2$s', $item->email, $this->row_actions( $row_actions ) );
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1356,10 +1383,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $item Item being shown.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item Item being shown.
</ins><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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $status = get_post_status( $item['request_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $status = $item->status;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'request-pending':
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1369,12 +1396,12 @@
</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', 'privacy_action_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->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="cx" style="display: block; padding: 0 10px"> 'action' => 'delete',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'request_id' => array( $item['request_id'] )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'request_id' => array( $item->ID )
</ins><span class="cx" style="display: block; padding: 0 10px"> ), admin_url( 'tools.php?page=export_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>';
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1410,18 +1437,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $item Item being shown.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item Item being shown.
</ins><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><span class="cx" style="display: block; padding: 0 10px"> $row_actions = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; 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'] );
</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 = $item->status;
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'request-confirmed' !== $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() );
</span><span class="cx" style="display: block; padding: 0 10px"> $erasers_count = count( $erasers );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request_id = $item['request_id'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request_id = $item->ID;
</ins><span class="cx" style="display: block; padding: 0 10px"> $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $remove_data_markup = '<div class="remove_personal_data force_remove_personal_data" ' .
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1439,7 +1466,7 @@
</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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return sprintf( '%1$s %2$s', $item['email'], $this->row_actions( $row_actions ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return sprintf( '%1$s %2$s', $item->email, $this->row_actions( $row_actions ) );
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1447,10 +1474,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $item Item being shown.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User_Request $item Item being shown.
</ins><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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $status = get_post_status( $item['request_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $status = $item->status;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'request-pending':
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1459,7 +1486,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> case 'request-confirmed':
</span><span class="cx" style="display: block; padding: 0 10px"> $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() );
</span><span class="cx" style="display: block; padding: 0 10px"> $erasers_count = count( $erasers );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request_id = $item['request_id'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request_id = $item->ID;
</ins><span class="cx" style="display: block; padding: 0 10px"> $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<div class="remove_personal_data" ' .
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1477,12 +1504,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</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', 'privacy_action_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->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="cx" style="display: block; padding: 0 10px"> 'action' => 'delete',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'request_id' => array( $item['request_id'] ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'request_id' => array( $item->ID ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ), admin_url( 'tools.php?page=remove_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>';
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludespostphp"></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/post.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/post.php 2018-04-27 11:40:35 UTC (rev 43010)
+++ trunk/src/wp-includes/post.php 2018-04-27 17:30:28 UTC (rev 43011)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3980,7 +3980,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) || 'user_request' === $post_type ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return $slug;
</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="trunksrcwpincludesuserphp"></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/user.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/user.php 2018-04-27 11:40:35 UTC (rev 43010)
+++ trunk/src/wp-includes/user.php 2018-04-27 17:30:28 UTC (rev 43011)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2840,13 +2840,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! in_array( $request_data['status'], array( 'request-pending', 'request-failed' ), true ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! in_array( $request_data->status, array( 'request-pending', 'request-failed' ), true ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</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"> update_post_meta( $request_id, '_wp_user_request_confirmed_timestamp', time() );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_post( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'ID' => $request_data['request_id'],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'ID' => $request_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'request-confirmed',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2862,7 +2862,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function _wp_privacy_account_request_confirmed_message( $message, $request_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $request = wp_get_user_request_data( $request_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $request && in_array( $request['action'], _wp_privacy_action_request_types(), true ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $request && in_array( $request->action_name, _wp_privacy_action_request_types(), true ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $message = '<p class="message">' . __( 'Action has been confirmed.' ) . '</p>';
</span><span class="cx" style="display: block; padding: 0 10px"> $message .= __( 'The site administrator has been notified and will fulfill your request as soon as possible.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2900,16 +2900,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check for duplicates.
</span><span class="cx" style="display: block; padding: 0 10px"> $requests_query = new WP_Query( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_type' => 'user_request',
- 'title' => $action_name,
- 'post_status' => 'any',
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => '_wp_user_request_user_email',
- 'value' => $email_address,
- ),
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_type' => 'user_request',
+ 'post_name__in' => array( $action_name ), // Action name stored in post_name column.
+ 'title' => $email_address, // Email address stored in post_title column.
+ 'post_status' => 'any',
+ 'fields' => 'ids',
</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"> if ( $requests_query->found_posts ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2918,7 +2913,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request_id = wp_insert_post( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => $user_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_title' => $action_name,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_name' => $action_name,
+ 'post_title' => $email_address,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => wp_json_encode( $request_data ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'request-pending',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'user_request',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2926,13 +2922,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_date_gmt' => current_time( 'mysql', true ),
</span><span class="cx" style="display: block; padding: 0 10px"> ), true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_wp_error( $request_id ) ) {
- return $request_id;
- }
-
- update_post_meta( $request_id, '_wp_user_request_user_email', $email_address );
- update_post_meta( $request_id, '_wp_user_request_confirmed_timestamp', false );
-
</del><span class="cx" style="display: block; padding: 0 10px"> return $request_id;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2963,7 +2952,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $description The default description.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $action_name The name of the request.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> return apply_filters( 'user_request_action_description', $description, $action_name );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2979,25 +2968,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_send_user_request( $request_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $request_id = absint( $request_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = get_post( $request_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = wp_get_user_request_data( $request_id );
</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 ( ! $request || 'user_request' !== $request->post_type ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $request ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'user_request_error', __( 'Invalid request.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'request-pending' !== $request->post_status ) {
- wp_update_post( array(
- 'ID' => $request_id,
- 'post_status' => 'request-pending',
- 'post_date' => current_time( 'mysql', false ),
- 'post_date_gmt' => current_time( 'mysql', true ),
- ) );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> $email_data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'action_name' => $request->post_title,
- 'email' => get_post_meta( $request->ID, '_wp_user_request_user_email', true ),
- 'description' => wp_user_request_action_description( $request->post_title ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'email' => $request->email,
+ 'description' => wp_user_request_action_description( $request->action_name ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'confirm_url' => add_query_arg( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'action' => 'confirmaction',
</span><span class="cx" style="display: block; padding: 0 10px"> 'request_id' => $request_id,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3045,12 +3024,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $email_data {
</span><span class="cx" style="display: block; padding: 0 10px"> * Data relating to the account action email.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string $action_name Name of the action being performed.
- * @type string $email The email address this is being sent to.
- * @type string $description Description of the action being performed so the user knows what the email is for.
- * @type string $confirm_url The link to click on to confirm the account action.
- * @type string $sitename The site name sending the mail.
- * @type string $siteurl The site URL sending the mail.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type WP_User_Request $request User request object.
+ * @type string $email The email address this is being sent to.
+ * @type string $description Description of the action being performed so the user knows what the email is for.
+ * @type string $confirm_url The link to click on to confirm the account action.
+ * @type string $sitename The site name sending the mail.
+ * @type string $siteurl The site URL sending the mail.
</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"> $content = apply_filters( 'user_request_action_email_content', $email_text, $email_data );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3066,7 +3045,7 @@
</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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Returns a confirmation key for a user action and stores the hashed version.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns a confirmation key for a user action and stores the hashed version for future comparison.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.6
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3085,8 +3064,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_hasher = new PasswordHash( 8, true );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_post_meta( $request_id, '_wp_user_request_confirm_key', $wp_hasher->HashPassword( $key ) );
- update_post_meta( $request_id, '_wp_user_request_confirm_key_timestamp', time() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_post( array(
+ 'ID' => $request_id,
+ 'post_status' => 'request-pending',
+ 'post_password' => $wp_hasher->HashPassword( $key ),
+ 'post_modified' => current_time( 'mysql', false ),
+ 'post_modified_gmt' => current_time( 'mysql', true ),
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $key;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3110,7 +3094,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'user_request_error', __( 'Invalid request.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! in_array( $request['status'], array( 'request-pending', 'request-failed' ), true ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! in_array( $request->status, array( 'request-pending', 'request-failed' ), true ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return __( 'This link has expired.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3123,8 +3107,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_hasher = new PasswordHash( 8, true );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $key_request_time = $request['confirm_key_timestamp'];
- $saved_key = $request['confirm_key'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $key_request_time = $request->modified_timestamp;
+ $saved_key = $request->confirm_key;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $saved_key ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3165,23 +3149,119 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_get_user_request_data( $request_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $request_id = absint( $request_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = get_post( $request_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $request_id );
</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 ( ! $request || 'user_request' !== $request->post_type ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $post || 'user_request' !== $post->post_type ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array(
- 'request_id' => $request->ID,
- 'user_id' => $request->post_author,
- 'email' => get_post_meta( $request->ID, '_wp_user_request_user_email', true ),
- 'action' => $request->post_title,
- 'requested_timestamp' => strtotime( $request->post_date_gmt ),
- 'confirmed_timestamp' => get_post_meta( $request->ID, '_wp_user_request_confirmed_timestamp', true ),
- 'completed_timestamp' => get_post_meta( $request->ID, '_wp_user_request_completed_timestamp', true ),
- 'request_data' => json_decode( $request->post_content, true ),
- 'status' => $request->post_status,
- 'confirm_key' => get_post_meta( $request_id, '_wp_user_request_confirm_key', true ),
- 'confirm_key_timestamp' => get_post_meta( $request_id, '_wp_user_request_confirm_key_timestamp', true ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return new WP_User_Request( $post );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * WP_User_Request class.
+ *
+ * Represents user request data loaded from a WP_Post object.
+ *
+ * @since 4.9.6
+ */
+final class WP_User_Request {
+ /**
+ * Request ID.
+ *
+ * @var int
+ */
+ public $ID = 0;
+
+ /**
+ * User ID.
+ *
+ * @var int
+ */
+
+ public $user_id = 0;
+
+ /**
+ * User email.
+ *
+ * @var int
+ */
+ public $email = '';
+
+ /**
+ * Action name.
+ *
+ * @var string
+ */
+ public $action_name = '';
+
+ /**
+ * Current status.
+ *
+ * @var string
+ */
+ public $status = '';
+
+ /**
+ * Timestamp this request was created.
+ *
+ * @var int|null
+ */
+ public $created_timestamp = null;
+
+ /**
+ * Timestamp this request was last modified.
+ *
+ * @var int|null
+ */
+ public $modified_timestamp = null;
+
+ /**
+ * Timestamp this request was confirmed.
+ *
+ * @var int
+ */
+ public $confirmed_timestamp = null;
+
+ /**
+ * Timestamp this request was completed.
+ *
+ * @var int
+ */
+ public $completed_timestamp = null;
+
+ /**
+ * Misc data assigned to this request.
+ *
+ * @var array
+ */
+ public $request_data = array();
+
+ /**
+ * Key used to confirm this request.
+ *
+ * @var string
+ */
+ public $confirm_key = '';
+
+ /**
+ * Constructor.
+ *
+ * @since 4.9.6
+ *
+ * @param WP_Post|object $post Post object.
+ */
+ public function __construct( $post ) {
+ $this->ID = $post->ID;
+ $this->user_id = $post->post_author;
+ $this->email = $post->post_title;
+ $this->action_name = $post->post_name;
+ $this->status = $post->post_status;
+ $this->created_timestamp = strtotime( $post->post_date_gmt );
+ $this->modified_timestamp = strtotime( $post->post_modified_gmt );
+ $this->confirmed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_confirmed_timestamp', true );
+ $this->completed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_completed_timestamp', true );
+ $this->request_data = json_decode( $post->post_content, true );
+ $this->confirm_key = $post->post_password;
+ }
+}
</ins></span></pre>
</div>
</div>
</body>
</html>