'Display nested array with WP_List_Table in WordPress [duplicate]
I'm trying to display WP application passwords on the front end. I have the password array below. I wish to use WP List Table to list down each password. I'm referring to this and this as tutorials.
Array
(
[0] => Array
(
[0] => Array
(
[uuid] => 81e423b9-2a69-47bc-b33e-4841a088c22c
[app_id] =>
[name] => Tst Key
[password] => $P$B0dCw8ME9RzhTT9Wvt8IdqhCvMcBKn1
[created] => 1653025473
[last_used] =>
[last_ip] =>
)
[1] => Array
(
[uuid] => 144d3e27-9bd6-4c07-beed-a41f1fa3ef17
[app_id] =>
[name] => wwwww
[password] => $P$BJTEnGYHccHuu9YiQX4EnxI8apCP6F.
[created] => 1653120256
[last_used] =>
[last_ip] =>
)
[2] => Array
(
[uuid] => 1378e1d6-253d-4aec-8ec2-546a6d5097ef
[app_id] =>
[name] => eeeeeeee
[password] => $P$BfkqvhFG/LAKosvMP4K/BtvjAvigME0
[created] => 1653120433
[last_used] =>
[last_ip] =>
)
[3] => Array
(
[uuid] => c61cc4f8-1baa-459b-800a-65839beb6581
[app_id] =>
[name] => rrrrrr
[password] => $P$BSvutXy84piwAOhGKDr1UQmNQRWQT21
[created] => 1653120474
[last_used] =>
[last_ip] =>
)
)
)
I keep getting nothing in the table list or I only get the first item if I use the column_default function below.
public function column_default( $item, $column_name ) {
for ( $x = 0; $x < count($item); $x++ ) {
error_log( "X: " . $x );
switch ( $column_name ) {
case 'uuid':
case 'name':
case 'created':
return $item[$x][ $column_name ];
default:
return 'N/A';
}
}
//switch ( $column_name ) {
// case 'uuid':
// case 'name':
// case 'created':
// return $item[ $column_name ];
// default:
// return 'N/A';
//}
}
Apparently, $x is always 0.
Any help is appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
