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
|
<?php
namespace AutomateWoo;
defined( 'ABSPATH' ) || exit;
/** * Dashboard_Widget_Workflows class. */ class Dashboard_Widget_Workflows extends Dashboard_Widget {
/** * Widget's ID * * @var string */ public $id = 'workflows';
/** * Get array of featured workflows. * * @return array */ protected function get_featured() { if ( ! $this->date_to || ! $this->date_from ) { return []; }
$featured = [];
// Check for the most run workflow. $workflow = $this->controller->get_most_run_workflow(); if ( $workflow ) { $featured[] = [ 'workflow' => $workflow, 'description' => __( 'most run workflow', 'automatewoo' ), ]; }
// Get the highest converting workflow. $highest_converting_workflow = $this->controller->get_highest_converting_workflow(); if ( $highest_converting_workflow ) { $featured[] = [ 'workflow' => $highest_converting_workflow, 'description' => __( 'highest converting workflow', 'automatewoo' ), ]; }
return $featured; }
/** * Output the widget content. */ protected function output_content() { $features = $this->get_featured();
if ( empty( $features ) ) { $this->display = false; return; }
?>
<div class="automatewoo-dashboard__workflows"> <?php foreach ( $features as $feature ) : ?>
<?php /** * For IDE. * * @var $workflow Workflow */ $workflow = $feature['workflow']; ?>
<a class="automatewoo-dashboard__workflow" href="<?php echo esc_url( get_edit_post_link( $workflow->get_id() ) ); ?>">
<div class="automatewoo-dashboard__workflow-title"><?php echo esc_html( $workflow->get_title() ); ?></div> <div class="automatewoo-dashboard__workflow-description"><?php echo esc_html( $feature['description'] ); ?></div>
</a>
<?php endforeach; ?> </div>
<?php } }
return new Dashboard_Widget_Workflows();
|