1: <?php
2:
3: 4: 5:
6: class Quform_Dashboard_Widget
7: {
8: 9: 10:
11: protected $repository;
12:
13: 14: 15:
16: protected $viewFactory;
17:
18: 19: 20:
21: protected $template;
22:
23: 24: 25:
26: protected $options;
27:
28: 29: 30: 31: 32:
33: public function __construct(Quform_Repository $repository, Quform_ViewFactory $viewFactory, Quform_Options $options)
34: {
35: $this->repository = $repository;
36: $this->viewFactory = $viewFactory;
37: $this->options = $options;
38: $this->template = QUFORM_TEMPLATE_PATH . '/admin/dashboard-widget.php';
39: }
40:
41: public function setup()
42: {
43: if (!$this->options->get('dashboardWidget') || !current_user_can('quform_view_entries')) {
44:
45: return;
46: }
47:
48: wp_enqueue_style('qfb-dashboard', Quform::adminUrl('css/dashboard.min.css'), array(), QUFORM_VERSION);
49: wp_add_dashboard_widget('qfb-dashboard-widget', Quform::getPluginName(), array($this, 'display'));
50: }
51:
52: public function display()
53: {
54: $data = array(
55: 'forms' => $this->repository->getAllFormsWithUnreadEntries()
56: );
57:
58: echo $this->viewFactory->create($this->template, $data)->render();
59: }
60: }
61: