PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.17
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.17
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / app / Modules / DashboardWidgetModule.php

DashboardWidgetModule.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 4.3.17, at app/Modules/DashboardWidgetModule.php

124 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules;
4
5 class DashboardWidgetModule
6 {
7 public function showStat()
8 {
9 global $wpdb;
10 $stats = wpFluent()->table('fluentform_submissions')
11 ->select([
12 'fluentform_forms.title',
13 'fluentform_submissions.form_id',
14 wpFluent()->raw('count(' . $wpdb->prefix . 'fluentform_submissions.id) as total'),
15 wpFluent()->raw('max(' . $wpdb->prefix . 'fluentform_submissions.id) as max_id'),
16 ])
17 ->orderBy('max_id', 'DESC')
18 ->groupBy('fluentform_submissions.form_id')
19 ->join('fluentform_forms', 'fluentform_forms.id', '=', 'fluentform_submissions.form_id')
20 ->limit(10)
21 ->get();
22
23 if (!$stats) {
24 echo 'You can see your submission stats here';
25 return;
26 }
27
28 foreach ($stats as $stat) {
29 $stat->unreadCount = $this->getUnreadCount($stat->form_id);
30 }
31
32 $this->printStats($stats);
33 return;
34 }
35
36 private function printStats($stats)
37 {
38 ?>
39 <ul class="ff_dashboard_stats">
40 <?php foreach ($stats as $stat): ?>
41 <li>
42 <a
43 href="<?php echo esc_url(admin_url('admin.php?page=fluent_forms&route=entries&form_id=' . $stat->form_id)); ?>">
44 <?php echo esc_html($stat->title); ?>
45 <span class="ff_total"><?php echo esc_attr($stat->unreadCount); ?>/<?php echo esc_attr($stat->total); ?></span>
46 </a>
47 </li>
48 <?php endforeach; ?>
49 </ul>
50 <?php if (!defined('FLUENTCRM') && !defined('FLUENTFORMPRO')) : ?>
51 <div class="ff_recommended_plugin">
52 Recommended Plugin: <b>FluentCRM - Email Marketing Automation For WordPress</b> <br />
53 <a
54 href="<?php echo esc_url($this->getInstallUrl('fluent-crm')); ?>">Install</a>
55 | <a target="_blank" rel="noopener" href="https://wordpress.org/plugins/fluent-crm/">Learn More</a>
56 </div>
57 <?php endif; ?>
58 <style>
59 ul.ff_dashboard_stats {
60 margin: 0;
61 padding: 0;
62 list-style: none;
63 }
64
65 ul.ff_dashboard_stats li {
66 padding: 8px 12px;
67 border-bottom: 1px solid #eeeeee;
68 margin: 0 -12px;
69 cursor: pointer;
70 }
71
72 ul.ff_dashboard_stats li:hover {
73 background: #fafafa;
74 border-bottom: 1px solid #eeeeee;
75 }
76
77 ul.ff_dashboard_stats li:hover a {
78 color: black;
79 }
80
81 ul.ff_dashboard_stats li:nth-child(2n+2) {
82 background: #f9f9f9;
83 }
84
85 ul.ff_dashboard_stats li span.ff_total {
86 float: right;
87 }
88
89 ul.ff_dashboard_stats li a {
90 display: block;
91 color: #0073aa;
92 font-weight: 500;
93 font-size: 105%;
94 }
95
96 .ff_recommended_plugin {
97 padding: 15px 0px 0px;
98 }
99
100 .ff_recommended_plugin a {
101 font-weight: bold;
102 font-size: 110%;
103 }
104 </style>
105 <?php
106 }
107
108 private function getInstallUrl($plugin)
109 {
110 return wp_nonce_url(
111 self_admin_url('update.php?action=install-plugin&plugin=' . $plugin),
112 'install-plugin_' . $plugin
113 );
114 }
115
116 private function getUnreadCount($formId)
117 {
118 return wpFluent()->table('fluentform_submissions')
119 ->where('status', 'unread')
120 ->where('form_id', $formId)
121 ->count();
122 }
123 }
124