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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
<?php
namespace AutomateWoo;
/** * Dashboard_Widget class. * * @since 2.8 */ abstract class Dashboard_Widget {
/** * Widget's ID * * @var string */ public $id;
/** * Widget's title. * * @var string optional */ public $title = '';
/** * Set date range for widget. * * @var DateTime */ public $date_from;
/** * Set date range for widget. * * @var DateTime */ public $date_to;
/** * Show/hide widget. * * @var bool */ public $display = true;
/** * Current instance of dashboard controller. * * @var Admin\Controllers\Dashboard */ public $controller;
/** * Get widget's ID. * * @return string */ public function get_id() { return $this->id; }
/** * Set GMT date range. * * @param DateTime $from * @param DateTime $to */ public function set_date_range( $from, $to ) { $this->date_from = $from; $this->date_to = $to; }
/** * Display the widget. */ public function output() { ob_start(); $this->output_before(); $this->output_content(); $this->output_after(); $output = ob_get_clean();
if ( $this->display ) { echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } }
/** * Output the widget content. */ protected function output_content() {}
/** * Output before the widget content. */ protected function output_before() { $classes = 'automatewoo-dashboard-widget automatewoo-dashboard-widget--' . $this->get_id(); echo '<div class="' . esc_attr( $classes ) . '">'; echo '<div class="automatewoo-dashboard-widget__content">'; }
/** * Output after the widget content. */ protected function output_after() { echo '</div></div>'; } }
|