| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Provide a admin area view for the plugin |
| 5 |
* |
| 6 |
* This file is used to markup the admin-facing aspects of the plugin. |
| 7 |
* |
| 8 |
* @link https://trewknowledge.com |
| 9 |
* @since 1.0.0 |
| 10 |
* |
| 11 |
* @package GDPR |
| 12 |
* @subpackage admin/partials |
| 13 |
*/ |
| 14 |
|
| 15 |
?> |
| 16 |
|
| 17 |
<div class="wrap gdpr"> |
| 18 |
<h1><?php esc_html_e( 'Requests', 'gdpr' ); ?></h1> |
| 19 |
<?php settings_errors(); ?> |
| 20 |
<div class="nav-tab-wrapper"> |
| 21 |
<?php foreach ( $tabs as $key => $value ) : ?> |
| 22 |
<a href="<?php echo esc_url( '#' . $key ); ?>" class="nav-tab"> |
| 23 |
<?php echo esc_html( $value['name'] ); ?> |
| 24 |
<?php if ( $value['count'] ) : ?> |
| 25 |
<span class="gdpr-pending-requests-badge"><?php echo esc_html( $value['count'] ); ?></span> |
| 26 |
<?php endif ?> |
| 27 |
</a> |
| 28 |
<?php endforeach; ?> |
| 29 |
</div> |
| 30 |
|
| 31 |
<div class="gdpr-tab hidden" data-id="rectify"> |
| 32 |
<h2><?php esc_html_e( 'Rectify Data', 'gdpr' ); ?></h2> |
| 33 |
<table class="widefat gdpr-request-table"> |
| 34 |
<thead> |
| 35 |
<tr> |
| 36 |
<th><?php esc_html_e( 'Email', 'gdpr' ); ?></th> |
| 37 |
<th class="text-center"><?php esc_html_e( 'Date of Request', 'gdpr' ); ?></th> |
| 38 |
<th class="text-center"><?php esc_html_e( 'Information', 'gdpr' ); ?></th> |
| 39 |
<th class="text-center"><?php esc_html_e( 'Actions', 'gdpr' ); ?></th> |
| 40 |
</tr> |
| 41 |
</thead> |
| 42 |
<tbody> |
| 43 |
<?php if ( isset( $rectify ) && ! empty( $rectify ) ) : ?> |
| 44 |
<?php foreach ( $rectify as $i => $request ) : ?> |
| 45 |
<tr> |
| 46 |
<td class="row-title"><?php echo esc_html( $request['email'] ); ?></td> |
| 47 |
<td class="text-center"><?php echo esc_html( $request['date'] ); ?></td> |
| 48 |
<td class="text-center"> |
| 49 |
<?php |
| 50 |
echo wp_kses( |
| 51 |
wpautop( wp_unslash( $request['data'] ) ), array( |
| 52 |
'p' => true, |
| 53 |
'br' => true, |
| 54 |
) |
| 55 |
); |
| 56 |
?> |
| 57 |
</td> |
| 58 |
<td class="text-center"> |
| 59 |
<form class="frm-process-rectification" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post"> |
| 60 |
<?php wp_nonce_field( 'gdpr-request-nonce', 'gdpr_cancel_rectify_nonce' ); ?> |
| 61 |
<input type="hidden" name="action" value="gdpr_cancel_request"> |
| 62 |
<input type="hidden" name="type" value="rectify"> |
| 63 |
<input type="hidden" name="index" value="<?php echo esc_attr( $i ); ?>"> |
| 64 |
<input type="hidden" name="user_email" value="<?php echo esc_attr( $request['email'] ); ?>"> |
| 65 |
<?php submit_button( esc_html__( 'Cancel Request', 'gdpr' ), 'delete', '', false ); ?> |
| 66 |
</form> |
| 67 |
<form class="frm-process-rectification" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post"> |
| 68 |
<?php wp_nonce_field( 'gdpr-mark-as-resolved', 'gdpr_rectify_mark_resolved_nonce' ); ?> |
| 69 |
<input type="hidden" name="action" value="gdpr_mark_resolved"> |
| 70 |
<input type="hidden" name="type" value="rectify"> |
| 71 |
<input type="hidden" name="index" value="<?php echo esc_attr( $i ); ?>"> |
| 72 |
<input type="hidden" name="user_email" value="<?php echo esc_attr( $request['email'] ); ?>"> |
| 73 |
<?php submit_button( esc_html__( 'Mark as Resolved', 'gdpr' ), 'primary', '', false ); ?> |
| 74 |
</form> |
| 75 |
</td> |
| 76 |
</tr> |
| 77 |
<?php endforeach ?> |
| 78 |
<?php else : ?> |
| 79 |
<tr> |
| 80 |
<td colspan="4" class="text-center"> |
| 81 |
<?php esc_html_e( 'No pending requests', 'gdpr' ); ?> |
| 82 |
</td> |
| 83 |
</tr> |
| 84 |
<?php endif ?> |
| 85 |
</tbody> |
| 86 |
<tfoot> |
| 87 |
<tr> |
| 88 |
<th><?php esc_html_e( 'Email', 'gdpr' ); ?></th> |
| 89 |
<th class="text-center"><?php esc_html_e( 'Date of Request', 'gdpr' ); ?></th> |
| 90 |
<th class="text-center"><?php esc_html_e( 'Information', 'gdpr' ); ?></th> |
| 91 |
<th class="text-center"><?php esc_html_e( 'Actions', 'gdpr' ); ?></th> |
| 92 |
</tr> |
| 93 |
</tfoot> |
| 94 |
</table> |
| 95 |
</div> |
| 96 |
|
| 97 |
<div class="gdpr-tab hidden" data-id="complaint"> |
| 98 |
<h2><?php esc_html_e( 'Complaints', 'gdpr' ); ?></h2> |
| 99 |
<table class="widefat gdpr-request-table"> |
| 100 |
<thead> |
| 101 |
<tr> |
| 102 |
<th><?php esc_html_e( 'Email', 'gdpr' ); ?></th> |
| 103 |
<th class="text-center"><?php esc_html_e( 'Date of Complaint', 'gdpr' ); ?></th> |
| 104 |
<th class="text-center"><?php esc_html_e( 'Information', 'gdpr' ); ?></th> |
| 105 |
<th class="text-center"><?php esc_html_e( 'Actions', 'gdpr' ); ?></th> |
| 106 |
</tr> |
| 107 |
</thead> |
| 108 |
<tbody> |
| 109 |
<?php if ( isset( $complaint ) && ! empty( $complaint ) ) : ?> |
| 110 |
<?php foreach ( $complaint as $i => $request ) : ?> |
| 111 |
<tr> |
| 112 |
<td class="row-title"><?php echo esc_html( $request['email'] ); ?></td> |
| 113 |
<td class="text-center"><?php echo esc_html( $request['date'] ); ?></td> |
| 114 |
<td class="text-center"><?php echo esc_html( wp_unslash( $request['data'] ) ); ?></td> |
| 115 |
<td class="text-center"> |
| 116 |
<form class="frm-process-complaint" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post"> |
| 117 |
<?php wp_nonce_field( 'gdpr-request-nonce', 'gdpr_cancel_complaint_nonce' ); ?> |
| 118 |
<input type="hidden" name="action" value="gdpr_cancel_request"> |
| 119 |
<input type="hidden" name="type" value="complaint"> |
| 120 |
<input type="hidden" name="index" value="<?php echo esc_attr( $i ); ?>"> |
| 121 |
<input type="hidden" name="user_email" value="<?php echo esc_attr( $request['email'] ); ?>"> |
| 122 |
<?php submit_button( esc_html__( 'Cancel Request', 'gdpr' ), 'delete', '', false ); ?> |
| 123 |
</form> |
| 124 |
<form class="frm-process-complaint" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post"> |
| 125 |
<?php wp_nonce_field( 'gdpr-mark-as-resolved', 'gdpr_complaint_mark_resolved_nonce' ); ?> |
| 126 |
<input type="hidden" name="action" value="gdpr_mark_resolved"> |
| 127 |
<input type="hidden" name="type" value="complaint"> |
| 128 |
<input type="hidden" name="index" value="<?php echo esc_attr( $i ); ?>"> |
| 129 |
<input type="hidden" name="user_email" value="<?php echo esc_attr( $request['email'] ); ?>"> |
| 130 |
<?php submit_button( esc_html__( 'Mark as Resolved', 'gdpr' ), 'primary', '', false ); ?> |
| 131 |
</form> |
| 132 |
</td> |
| 133 |
</tr> |
| 134 |
<?php endforeach ?> |
| 135 |
<?php else : ?> |
| 136 |
<tr> |
| 137 |
<td colspan="4" class="text-center"> |
| 138 |
<?php esc_html_e( 'No pending requests', 'gdpr' ); ?> |
| 139 |
</td> |
| 140 |
</tr> |
| 141 |
<?php endif ?> |
| 142 |
</tbody> |
| 143 |
<tfoot> |
| 144 |
<tr> |
| 145 |
<th><?php esc_html_e( 'Email', 'gdpr' ); ?></th> |
| 146 |
<th class="text-center"><?php esc_html_e( 'Date of Complaint', 'gdpr' ); ?></th> |
| 147 |
<th class="text-center"><?php esc_html_e( 'Information', 'gdpr' ); ?></th> |
| 148 |
<th class="text-center"><?php esc_html_e( 'Actions', 'gdpr' ); ?></th> |
| 149 |
</tr> |
| 150 |
</tfoot> |
| 151 |
</table> |
| 152 |
</div> |
| 153 |
|
| 154 |
<div class="gdpr-tab hidden" data-id="delete"> |
| 155 |
<h2><?php esc_html_e( 'Right to erasure', 'gdpr' ); ?></h2> |
| 156 |
<div class="postbox not-full"> |
| 157 |
<form class="gdpr-manual-email-lookup" method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>"> |
| 158 |
<div class="inside"> |
| 159 |
<input type="hidden" name="action" value="gdpr_add_to_deletion_requests"> |
| 160 |
<?php wp_nonce_field( 'gdpr-add-to-deletion-requests', 'gdpr_deletion_requests_nonce' ); ?> |
| 161 |
<h4> |
| 162 |
<label for="gdpr-request-email-lookup"><?php esc_html_e( 'Manually add a user', 'gdpr' ); ?></label> |
| 163 |
</h4> |
| 164 |
<input type="email" name="user_email" class="gdpr-request-email-lookup regular-text" placeholder="<?php esc_attr_e( 'email@domain.com', 'gdpr' ); ?>" required> |
| 165 |
<?php submit_button( esc_html__( 'Submit', 'gdpr' ), 'primary', '', false ); ?> |
| 166 |
</div> |
| 167 |
</form> |
| 168 |
</div> |
| 169 |
<table class="widefat gdpr-request-table"> |
| 170 |
<thead> |
| 171 |
<tr> |
| 172 |
<th><?php esc_html_e( 'Email', 'gdpr' ); ?></th> |
| 173 |
<th class="text-center"><?php esc_html_e( 'Date of Request', 'gdpr' ); ?></th> |
| 174 |
<th class="text-center"><?php esc_html_e( 'Review', 'gdpr' ); ?></th> |
| 175 |
<th class="text-center"><?php esc_html_e( 'Actions', 'gdpr' ); ?></th> |
| 176 |
</tr> |
| 177 |
</thead> |
| 178 |
<tbody> |
| 179 |
<?php if ( isset( $delete ) && ! empty( $delete ) ) : ?> |
| 180 |
<?php $index = 0; ?> |
| 181 |
<?php foreach ( $delete as $i => $request ) : ?> |
| 182 |
<?php $user = get_user_by( 'email', $request['email'] ); ?> |
| 183 |
<tr class="<?php echo ( 0 === $index % 2 ? '' : 'alternate' ); ?>"> |
| 184 |
<td class="row-title"><?php echo esc_html( $request['email'] ); ?></td> |
| 185 |
<td class="text-center"><?php echo esc_html( $request['date'] ); ?></td> |
| 186 |
<td class="text-center"> |
| 187 |
<?php |
| 188 |
if ( GDPR_Requests::user_has_content( $user ) ) { |
| 189 |
echo '<button class="button gdpr-review" data-index="' . esc_attr( $index ) . '">' . esc_html__( 'Review', 'gdpr' ) . '</button>'; |
| 190 |
} else { |
| 191 |
esc_html_e( 'No content to review', 'gdpr' ); |
| 192 |
} |
| 193 |
?> |
| 194 |
<?php if ( GDPR_Requests::user_has_content( $user ) ) : ?> |
| 195 |
<?php else : ?> |
| 196 |
<?php endif; ?> |
| 197 |
</td> |
| 198 |
<td class="text-center"> |
| 199 |
<form class="frm-process-user-deletion" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post"> |
| 200 |
<?php wp_nonce_field( 'gdpr-request-nonce', 'gdpr_cancel_delete_nonce' ); ?> |
| 201 |
<input type="hidden" name="action" value="gdpr_cancel_request"> |
| 202 |
<input type="hidden" name="type" value="delete"> |
| 203 |
<input type="hidden" name="user_email" value="<?php echo esc_attr( $request['email'] ); ?>"> |
| 204 |
<input type="hidden" name="index" value="<?php echo esc_attr( $i ); ?>"> |
| 205 |
<?php submit_button( esc_html__( 'Cancel Request', 'gdpr' ), 'delete', '', false ); ?> |
| 206 |
</form> |
| 207 |
<form class="frm-process-user-deletion" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post"> |
| 208 |
<?php wp_nonce_field( 'gdpr-request-delete-user', 'gdpr_delete_user' ); ?> |
| 209 |
<input type="hidden" name="action" value="gdpr_delete_user"> |
| 210 |
<input type="hidden" name="user_email" value="<?php echo esc_attr( $request['email'] ); ?>"> |
| 211 |
<input type="hidden" name="index" value="<?php echo esc_attr( $i ); ?>"> |
| 212 |
<?php submit_button( esc_html__( 'Delete User', 'gdpr' ), 'primary', '', false ); ?> |
| 213 |
</form> |
| 214 |
</td> |
| 215 |
</tr> |
| 216 |
<?php if ( GDPR_Requests::user_has_content( $user ) ) : ?> |
| 217 |
<tr class="review" data-index="<?php echo esc_attr( $index ); ?>"> |
| 218 |
<td colspan="4"> |
| 219 |
<div class="hidden"> |
| 220 |
<table class="widefat"> |
| 221 |
<thead> |
| 222 |
<tr> |
| 223 |
<th><?php esc_html_e( 'Content Type', 'gdpr' ); ?></th> |
| 224 |
<th class="text-center"><?php esc_html_e( 'Count', 'gdpr' ); ?></th> |
| 225 |
<th class="text-center"><?php esc_html_e( 'Review', 'gdpr' ); ?></th> |
| 226 |
<th class="text-center"><?php esc_html_e( 'Reassign', 'gdpr' ); ?></th> |
| 227 |
<th class="text-center"><?php esc_html_e( 'Action', 'gdpr' ); ?></th> |
| 228 |
</tr> |
| 229 |
</thead> |
| 230 |
<tbody> |
| 231 |
<?php $post_types = get_post_types( array( 'public' => true ), 'objects' ); ?> |
| 232 |
<?php foreach ( $post_types as $pt ) : ?> |
| 233 |
<?php |
| 234 |
$uid = get_user_by( 'email', $request['email'] ); |
| 235 |
if ( $uid && $uid instanceof WP_User ) { |
| 236 |
$uid = $uid->ID; |
| 237 |
} |
| 238 |
if ( defined( 'WPCOM_IS_VIP_ENV' ) && WPCOM_IS_VIP_ENV ) { |
| 239 |
$count = wpcom_vip_count_user_posts( $uid, $pt->name ); |
| 240 |
} else { |
| 241 |
$count = count_user_posts( $uid, $pt->name ); |
| 242 |
} |
| 243 |
if ( '0' === $count ) { |
| 244 |
continue; |
| 245 |
} |
| 246 |
?> |
| 247 |
<tr> |
| 248 |
<td class="row-title"><?php echo esc_attr( $pt->label ); ?></td> |
| 249 |
<td class="text-center"><?php echo esc_attr( $count ); ?></td> |
| 250 |
<td class="text-center"> |
| 251 |
<a href="<?php echo esc_url( admin_url( 'edit.php?post_type=' . $pt->name . '&author=' . $uid ) ); ?>" target="_blank" class="button"><?php echo esc_html( $pt->labels->view_items ); ?></a> |
| 252 |
</td> |
| 253 |
<td class="text-center"> |
| 254 |
<select name="reassign" class="gdpr-reassign"> |
| 255 |
<option value="0"></option> |
| 256 |
<?php $admins = get_users( array( 'role' => 'administrator' ) ); ?> |
| 257 |
<?php foreach ( $admins as $admin ) : ?> |
| 258 |
<option value="<?php echo esc_attr( $admin->ID ); ?>"><?php echo esc_html( $admin->display_name ); ?></option> |
| 259 |
<?php endforeach; ?> |
| 260 |
</select> |
| 261 |
</td> |
| 262 |
<td class="text-center"> |
| 263 |
<form method="post" class="gdpr-reassign-content"> |
| 264 |
<?php wp_nonce_field( 'gdpr-reassign-content-action', 'gdpr_reassign_content_nonce' ); ?> |
| 265 |
<input type="hidden" name="user_email" value="<?php echo esc_attr( $request['email'] ); ?>"> |
| 266 |
<input type="hidden" name="reassign_to" value=""> |
| 267 |
<input type="hidden" name="post_type" value="<?php echo esc_attr( $pt->name ); ?>"> |
| 268 |
<input type="hidden" name="post_count" value="<?php echo esc_attr( $count ); ?>"> |
| 269 |
<?php submit_button( esc_html__( 'Reassign', 'gdpr' ), 'primary', '', false, array( 'disabled' => true ) ); ?> |
| 270 |
<span class="spinner"></span> |
| 271 |
<p class="hidden"><strong><?php esc_html_e( 'Resolved', 'gdpr' ); ?></strong></p> |
| 272 |
</form> |
| 273 |
<span class="spinner"></span> |
| 274 |
</td> |
| 275 |
</tr> |
| 276 |
<?php endforeach; ?> |
| 277 |
<?php |
| 278 |
$comment_count = get_comments( |
| 279 |
array( |
| 280 |
'author_email' => $request['email'], |
| 281 |
'include_unapproved' => true, |
| 282 |
'count' => true, |
| 283 |
) |
| 284 |
); |
| 285 |
|
| 286 |
if ( $comment_count ) { |
| 287 |
?> |
| 288 |
<tr> |
| 289 |
<td class="row-title"><?php esc_html_e( 'Comments', 'gdpr' ); ?></td> |
| 290 |
<td class="text-center"><?php echo esc_html( $comment_count ); ?></td> |
| 291 |
<td class="text-center"><a href="<?php echo esc_url( admin_url( 'edit-comments.php?comment_status=all&s=' . rawurlencode( $request['email'] ) ) ); ?>" target="_blank" class="button"><?php esc_html_e( 'View Comments', 'gdpr' ); ?></a></td> |
| 292 |
<td></td> |
| 293 |
<td class="text-center"> |
| 294 |
<form method="post" class="gdpr-anonymize-comments"> |
| 295 |
<?php wp_nonce_field( 'gdpr-anonymize-comments-action', 'gdpr_anonymize_comments_nonce' ); ?> |
| 296 |
<input type="hidden" name="user_email" value="<?php echo esc_attr( $request['email'] ); ?>"> |
| 297 |
<input type="hidden" name="comment_count" value="<?php echo esc_attr( $comment_count ); ?>"> |
| 298 |
<?php submit_button( esc_html__( 'Anonymize', 'gdpr' ), 'primary', '', false ); ?> |
| 299 |
<span class="spinner"></span> |
| 300 |
<p class="hidden"><strong><?php esc_html_e( 'Resolved', 'gdpr' ); ?></strong></p> |
| 301 |
</form> |
| 302 |
</td> |
| 303 |
</tr> |
| 304 |
<?php |
| 305 |
} |
| 306 |
?> |
| 307 |
</tbody> |
| 308 |
<tr> |
| 309 |
</tr> |
| 310 |
</table> |
| 311 |
</div> |
| 312 |
</td> |
| 313 |
</tr> |
| 314 |
<?php endif ?> |
| 315 |
<?php $index++; ?> |
| 316 |
<?php endforeach; ?> |
| 317 |
<?php else : ?> |
| 318 |
<tr> |
| 319 |
<td colspan="4" class="text-center"> |
| 320 |
<?php esc_html_e( 'No pending requests', 'gdpr' ); ?> |
| 321 |
</td> |
| 322 |
</tr> |
| 323 |
<?php endif ?> |
| 324 |
</tbody> |
| 325 |
<tfoot> |
| 326 |
<tr> |
| 327 |
<th><?php esc_html_e( 'Email', 'gdpr' ); ?></th> |
| 328 |
<th class="text-center"><?php esc_html_e( 'Date of Request', 'gdpr' ); ?></th> |
| 329 |
<th class="text-center"><?php esc_html_e( 'Review', 'gdpr' ); ?></th> |
| 330 |
<th class="text-center"><?php esc_html_e( 'Actions', 'gdpr' ); ?></th> |
| 331 |
</tr> |
| 332 |
</tfoot> |
| 333 |
</table> |
| 334 |
</div> |
| 335 |
|
| 336 |
<!-- #poststuff --> |
| 337 |
</div> |
| 338 |
|