Ticket #46895: 46895-3.diff
File 46895-3.diff, 5.7 KB (added by , 5 years ago) |
---|
-
src/wp-admin/includes/privacy-tools.php
diff --git src/wp-admin/includes/privacy-tools.php src/wp-admin/includes/privacy-tools.php index a8a115b..feacff2 100644
function _wp_personal_data_cleanup_requests() { 234 234 * @return string The HTML for this group and its items. 235 235 */ 236 236 function wp_privacy_generate_personal_data_export_group_html( $group_data ) { 237 $group_html = '<h2>' . esc_html( $group_data['group_label'] ) . '</h2>'; 237 238 $group_html = '<h2>'; 239 $group_html .= esc_html( $group_data['group_label'] ); 240 241 if ( isset( $group_data['group_count'] ) && $group_data['group_count'] ) { 242 $items_count = count( (array) $group_data['items'] ); 243 if ( $items_count > 1 ) { 244 $group_html .= sprintf( ' <span class="count">(%d)</span>', $items_count ); 245 } 246 } 247 248 $group_html .= '</h2>'; 238 249 239 250 if ( ! empty( $group_data['group_description'] ) ) { 240 251 $group_html .= '<p>' . esc_html( $group_data['group_description'] ) . '</p>'; … … function wp_privacy_process_personal_data_export_page( $response, $exporter_inde 621 632 $group_id = $export_datum['group_id']; 622 633 $group_label = $export_datum['group_label']; 623 634 635 $group_count = false; 636 if ( isset( $export_datum['group_count'] ) ) { 637 $group_count = (bool) $export_datum['group_count']; 638 } 639 624 640 $group_description = ''; 625 641 if ( ! empty( $export_datum['group_description'] ) ) { 626 642 $group_description = $export_datum['group_description']; … … function wp_privacy_process_personal_data_export_page( $response, $exporter_inde 629 645 if ( ! array_key_exists( $group_id, $groups ) ) { 630 646 $groups[ $group_id ] = array( 631 647 'group_label' => $group_label, 648 'group_count' => $group_count, 632 649 'group_description' => $group_description, 633 650 'items' => array(), 634 651 ); -
src/wp-includes/comment.php
diff --git src/wp-includes/comment.php src/wp-includes/comment.php index 841bb9b..10edb95 100644
function wp_comments_personal_data_exporter( $email_address, $page = 1 ) { 3436 3436 $data_to_export[] = array( 3437 3437 'group_id' => 'comments', 3438 3438 'group_label' => __( 'Comments' ), 3439 'group_count' => true, 3439 3440 'group_description' => __( 'User’s comment data.' ), 3440 3441 'item_id' => "comment-{$comment->comment_ID}", 3441 3442 'data' => $comment_data_to_export, -
src/wp-includes/media.php
diff --git src/wp-includes/media.php src/wp-includes/media.php index 27b1eb8..4846279 100644
function wp_media_personal_data_exporter( $email_address, $page = 1 ) { 4309 4309 $data_to_export[] = array( 4310 4310 'group_id' => 'media', 4311 4311 'group_label' => __( 'Media' ), 4312 'group_count' => true, 4312 4313 'group_description' => __( 'User’s media data.' ), 4313 4314 'item_id' => "post-{$post->ID}", 4314 4315 'data' => $post_data_to_export, -
tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php
diff --git tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php index f9f6dd5..f15af95 100644
class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit 197 197 $this->assertNotContains( $data['items'][0]['images']['value'], $actual ); 198 198 $this->assertContains( '<th>Images are not allowed</th><td></td>', $actual ); 199 199 } 200 201 /** 202 * Test displaying group count. 203 * 204 * @ticket 46895 205 */ 206 public function test_group_html_generation_when_group_count_displayed() { 207 $data = array( 208 'group_label' => 'Test Data Group', 209 'group_count' => true, 210 'items' => array( 211 array( 212 array( 213 'name' => 'Field 1 Name', 214 'value' => 'Field 1 Value', 215 ), 216 ), 217 array( 218 array( 219 'name' => 'Field 2 Name', 220 'value' => 'Field 2 Value', 221 ), 222 ), 223 ), 224 ); 225 226 $actual = wp_privacy_generate_personal_data_export_group_html( $data ); 227 228 $this->assertContains( '<h2>Test Data Group', $actual ); 229 $this->assertContains( '<span class="count">(2)</span></h2>', $actual ); 230 $this->assertSame( 2, substr_count( $actual, '<table>' ) ); 231 } 232 233 /** 234 * Test hiding group count display. 235 * 236 * @ticket 46895 237 */ 238 public function test_group_html_generation_when_group_count_not_displayed() { 239 $data = array( 240 'group_label' => 'Test Data Group', 241 'group_count' => false, 242 'items' => array( 243 array( 244 array( 245 'name' => 'Field 1 Name', 246 'value' => 'Field 1 Value', 247 ), 248 ), 249 array( 250 array( 251 'name' => 'Field 2 Name', 252 'value' => 'Field 2 Value', 253 ), 254 ), 255 ), 256 ); 257 258 $actual = wp_privacy_generate_personal_data_export_group_html( $data ); 259 260 $this->assertContains( '<h2>Test Data Group</h2>', $actual ); 261 $this->assertNotContains( '<span class="count">', $actual ); 262 $this->assertSame( 2, substr_count( $actual, '<table>' ) ); 263 } 264 265 /** 266 * Test group count is not displayed for a single item. 267 * 268 * @ticket 46895 269 */ 270 public function test_group_html_generation_should_not_display_group_count_when_single_item() { 271 $data = array( 272 'group_label' => 'Test Data Group', 273 'group_count' => true, 274 'items' => array( 275 array( 276 array( 277 'name' => 'Field 1 Name', 278 'value' => 'Field 1 Value', 279 ), 280 ), 281 ), 282 ); 283 284 $actual = wp_privacy_generate_personal_data_export_group_html( $data ); 285 286 $this->assertContains( '<h2>Test Data Group</h2>', $actual ); 287 $this->assertNotContains( '<span class="count">', $actual ); 288 $this->assertSame( 1, substr_count( $actual, '<table>' ) ); 289 } 200 290 }