1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
<?php
namespace SIW\Admin;
use SIW\Properties;
class Properties_Page {
public static function init() {
$self = new self();
add_action( 'admin_menu', [ $self, 'add_properties_page'] ) ;
}
public function add_properties_page() {
add_management_page(
__( 'SIW Eigenschappen', 'siw' ),
__( 'SIW Eigenschappen', 'siw' ),
'edit_posts',
'siw-properties',
[ $this, 'render_properties_page' ]
);
}
public function render_properties_page() {
?>
<h2><?= esc_attr__( 'Eigenschappen', 'siw' ); ?></h2>
<table class="wp-list-table widefat">
<thead>
<tr>
<th class="row-title"><?= esc_attr__( 'Eigenschap', 'siw' ); ?></th>
<th class="row-title"><?= esc_attr__( 'Waarde', 'siw' ); ?></th>
<th class="row-title"><?= esc_attr__( 'Constante', 'siw' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th class="row-title"><?= esc_attr__( 'Eigenschap', 'siw' ); ?></th>
<th class="row-title"><?= esc_attr__( 'Waarde', 'siw' ); ?></th>
<th class="row-title"><?= esc_attr__( 'Constante', 'siw' ); ?></th>
</tr>
</tfoot>
<tbody>
<?php
$configuration = Properties::get_all();
$alternate = false;
foreach ( $configuration as $item ) {
$class = ( $alternate ) ? 'class = "alternate"' : '';
printf('<tr %s><td>%s</td><td>%s</td><td>%s</td></tr>', $class, esc_html( $item['description'] ), esc_html( $item['value'] ), esc_html( $item['name'] ) );
$alternate = ! $alternate;
}
?>
</tbody>
</table>
<?php
}
}