[wp-trac] [WordPress Trac] #44354: Improve `WP_Privacy_Requests_Table` to manage columns
WordPress Trac
noreply at wordpress.org
Thu Jan 21 19:49:02 UTC 2021
#44354: Improve `WP_Privacy_Requests_Table` to manage columns
-------------------------------------------------+-------------------------
Reporter: 7studio | Owner: garrett-
| eclipse
Type: enhancement | Status: accepted
Priority: normal | Milestone: 5.7
Component: Privacy | Version: 4.9.6
Severity: normal | Resolution:
Keywords: has-patch has-screenshots needs- | Focuses:
dev-note | administration
-------------------------------------------------+-------------------------
Comment (by xkon):
As mentioned by @TimothyBlynJacobs in [comment:25] filtering the column
names is already provided. In the PR provided an extra action is added to
the `column_default()` of `WP_Privacy_Requests_Table` to allow custom
column data to be added as well.
For consistency instead of using the `$this->request_type` from previous
patches & comments, I'm using the `$this->screen->id` instead to keep the
action & filter naming convention aligned.
**Testing:**
You can test the PR provided by adding this code in a mu-plugin and you
should see the new columns being created on the Personal Data Export &
Erasure tables.
{{{
<?php
add_filter(
'manage_export-personal-data_columns',
function ( $columns ) {
$columns['my_export_column'] = __( 'Custom Column EX' );
return $columns;
}
);
add_action(
'manage_export-personal-data_custom_column' ,
function( $columns, $item ) {
switch( $columns ) {
case 'my_export_column':
echo 'Something';
break;
}
},
10,
2
);
add_filter(
'manage_erase-personal-data_columns',
function ( $columns ) {
$columns['my_erase_column'] = __( 'Custom Column ER' );
return $columns;
}
);
add_action(
'manage_erase-personal-data_custom_column',
function( $columns, $item ) {
switch( $columns ) {
case 'my_erase_column':
echo 'Something Else';
break;
}
},
10,
2
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44354#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list