[wp-trac] [WordPress Trac] #44354: Improve `WP_Privacy_Requests_Table` to manage columns
WordPress Trac
noreply at wordpress.org
Sat Jun 30 15:55:10 UTC 2018
#44354: Improve `WP_Privacy_Requests_Table` to manage columns
-------------------------+-----------------------------
Reporter: 7studio | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Privacy | Version: 4.9.6
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: administration
-------------------------+-----------------------------
Comment (by birgire):
Thanks for the ticket @7studio
[attachment:"44354.diff"] is a first pass to improve the column management
for the Requests list table.
We add the dynamic action in the default column handler:
{{{
do_action( "manage_{$this->request_type}_custom_column", $column_name,
$item );
}}}
that generates the following actions:
- {{{manage_export_personal_data_custom_column}}}.
- {{{manage_remove_personal_data_custom_column}}}
We also add the following columns filter:
{{{
return apply_filters( "manage_{$this->request_type}_columns", $columns );
}}}
that generates the following filters:
- {{{manage_export_personal_data_columns}}}.
- {{{manage_remove_personal_data_columns}}}
Another naming suggestion could be:
- {{{"manage_{$this->request_type}_requests_custom_column"}}}
- {{{"manage_{$this->request_type}_requests_columns"}}}
but that generates longer hook names.
It's interesting to see the mismatch regarding the output of column
methods in various list tables.
It's both echo and return, but from the
{{{WP_List_Table::single_row_columns()}}} it seems to expect return:
{{{
} elseif ( method_exists( $this, 'column_' . $column_name ) ) {
echo "<td $attributes>";
echo call_user_func( array( $this, 'column_' . $column_name ),
$item );
echo $this->handle_row_actions( $item, $column_name, $primary );
echo '</td>';
} else {
echo "<td $attributes>";
echo $this->column_default( $item, $column_name );
echo $this->handle_row_actions( $item, $column_name, $primary );
echo '</td>';
}
}}}
**Test Example
**
Here's a test example where we add a custom column called "Resend Email":
{{{
add_action( 'manage_export_personal_data_custom_column', function(
$column_name, $item ) {
if ( 'resend_email' === $column_name ) {
printf( '<input type="button" class="button" value="%s" />',
esc_attr( __( 'Resend Email' ) ) );
}
}, 10, 2 );
add_filter('manage_export_personal_data_columns', function( $columns ) {
if( is_array( $columns ) && ! isset( $columns['resend_email'] ) ) {
$columns['resend_email'] = __( 'Resend Email' );
}
return $columns;
} );
}}}
See the screenshot in [attachment:"custom-column.jpg"].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44354#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list