/
llms.class.meta.box.table.php
68 lines (60 loc) · 1.41 KB
/
llms.class.meta.box.table.php
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
<?php
/**
* Meta box Field: Table
*
* @package LifterLMS/Admin/PostTypes/MetaBoxes/Fields/Classes
*
* @since Unknown
* @version Unknown
*/
defined( 'ABSPATH' ) || exit;
/**
* LLMS_Metabox_Table_Field class
*
* @since Unknown
*/
class LLMS_Metabox_Table_Field extends LLMS_Metabox_Field implements Meta_Box_Field_Interface {
/**
* Class constructor
*
* @param array $_field Array containing information about field
*/
public function __construct( $_field ) {
$this->field = $_field;
}
/**
* outputs the Html for the given field
*
* @return void
*/
public function output() {
global $post;
parent::output(); ?>
<table class="llms-table zebra text-left">
<thead>
<?php foreach ( $this->field['titles'] as $title ) : ?>
<th><?php echo $title; ?></th>
<?php endforeach; ?>
</thead>
<tbody>
<?php if ( $this->field['table_data'] ) : ?>
<?php foreach ( $this->field['table_data'] as $row ) : ?>
<tr>
<?php foreach ( $row as $column ) : ?>
<td><?php echo $column; ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
<?php elseif ( $this->field['empty_message'] ) : ?>
<tr>
<td colspan="<?php count( $this->field['titles'] ); ?>">
<?php echo $this->field['empty_message']; ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php
parent::close_output();
}
}