|
1 <?php |
|
2 /** |
|
3 * List Table API: WP_Privacy_Data_Export_Requests_List_Table class |
|
4 * |
|
5 * @package WordPress |
|
6 * @subpackage Administration |
|
7 * @since 4.9.6 |
|
8 */ |
|
9 |
|
10 if ( ! class_exists( 'WP_Privacy_Requests_Table' ) ) { |
|
11 require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-requests-table.php'; |
|
12 } |
|
13 |
|
14 /** |
|
15 * WP_Privacy_Data_Export_Requests_Table class. |
|
16 * |
|
17 * @since 4.9.6 |
|
18 */ |
|
19 class WP_Privacy_Data_Export_Requests_List_Table extends WP_Privacy_Requests_Table { |
|
20 /** |
|
21 * Action name for the requests this table will work with. |
|
22 * |
|
23 * @since 4.9.6 |
|
24 * |
|
25 * @var string $request_type Name of action. |
|
26 */ |
|
27 protected $request_type = 'export_personal_data'; |
|
28 |
|
29 /** |
|
30 * Post type for the requests. |
|
31 * |
|
32 * @since 4.9.6 |
|
33 * |
|
34 * @var string $post_type The post type. |
|
35 */ |
|
36 protected $post_type = 'user_request'; |
|
37 |
|
38 /** |
|
39 * Actions column. |
|
40 * |
|
41 * @since 4.9.6 |
|
42 * |
|
43 * @param WP_User_Request $item Item being shown. |
|
44 * @return string Email column markup. |
|
45 */ |
|
46 public function column_email( $item ) { |
|
47 /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
|
48 $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); |
|
49 $exporters_count = count( $exporters ); |
|
50 $request_id = $item->ID; |
|
51 $nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id ); |
|
52 |
|
53 $download_data_markup = '<div class="export-personal-data" ' . |
|
54 'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' . |
|
55 'data-request-id="' . esc_attr( $request_id ) . '" ' . |
|
56 'data-nonce="' . esc_attr( $nonce ) . |
|
57 '">'; |
|
58 |
|
59 $download_data_markup .= '<span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download Personal Data' ) . '</button></span>' . |
|
60 '<span class="export-personal-data-processing hidden">' . __( 'Downloading Data...' ) . ' <span class="export-progress"></span></span>' . |
|
61 '<span class="export-personal-data-success hidden"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download Personal Data Again' ) . '</button></span>' . |
|
62 '<span class="export-personal-data-failed hidden">' . __( 'Download failed.' ) . ' <button type="button" class="button-link">' . __( 'Retry' ) . '</button></span>'; |
|
63 |
|
64 $download_data_markup .= '</div>'; |
|
65 |
|
66 $row_actions = array( |
|
67 'download-data' => $download_data_markup, |
|
68 ); |
|
69 |
|
70 return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) ); |
|
71 } |
|
72 |
|
73 /** |
|
74 * Displays the next steps column. |
|
75 * |
|
76 * @since 4.9.6 |
|
77 * |
|
78 * @param WP_User_Request $item Item being shown. |
|
79 */ |
|
80 public function column_next_steps( $item ) { |
|
81 $status = $item->status; |
|
82 |
|
83 switch ( $status ) { |
|
84 case 'request-pending': |
|
85 esc_html_e( 'Waiting for confirmation' ); |
|
86 break; |
|
87 case 'request-confirmed': |
|
88 /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
|
89 $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); |
|
90 $exporters_count = count( $exporters ); |
|
91 $request_id = $item->ID; |
|
92 $nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id ); |
|
93 |
|
94 echo '<div class="export-personal-data" ' . |
|
95 'data-send-as-email="1" ' . |
|
96 'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' . |
|
97 'data-request-id="' . esc_attr( $request_id ) . '" ' . |
|
98 'data-nonce="' . esc_attr( $nonce ) . |
|
99 '">'; |
|
100 |
|
101 ?> |
|
102 <span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle"><?php _e( 'Send Export Link' ); ?></button></span> |
|
103 <span class="export-personal-data-processing hidden"><?php _e( 'Sending Email...' ); ?> <span class="export-progress"></span></span> |
|
104 <span class="export-personal-data-success success-message hidden"><?php _e( 'Email sent.' ); ?></span> |
|
105 <span class="export-personal-data-failed hidden"><?php _e( 'Email could not be sent.' ); ?> <button type="button" class="button-link export-personal-data-handle"><?php _e( 'Retry' ); ?></button></span> |
|
106 <?php |
|
107 |
|
108 echo '</div>'; |
|
109 break; |
|
110 case 'request-failed': |
|
111 echo '<button type="submit" class="button-link" name="privacy_action_email_retry[' . $item->ID . ']" id="privacy_action_email_retry[' . $item->ID . ']">' . __( 'Retry' ) . '</button>'; |
|
112 break; |
|
113 case 'request-completed': |
|
114 echo '<a href="' . esc_url( |
|
115 wp_nonce_url( |
|
116 add_query_arg( |
|
117 array( |
|
118 'action' => 'delete', |
|
119 'request_id' => array( $item->ID ), |
|
120 ), |
|
121 admin_url( 'export-personal-data.php' ) |
|
122 ), |
|
123 'bulk-privacy_requests' |
|
124 ) |
|
125 ) . '">' . esc_html__( 'Remove request' ) . '</a>'; |
|
126 break; |
|
127 } |
|
128 } |
|
129 } |