PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.2.3
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.2.3
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 3.2.3, at app/Modules/DashboardWidgetModule.php

121 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 href="<?php echo admin_url('admin.php?page=fluent_forms&route=entries&form_id=' . $stat->form_id); ?>">
43 <?php echo $stat->title; ?>
44 <span class="ff_total"><?php echo $stat->unreadCount; ?>/<?php echo $stat->total; ?></span>
45 </a>
46 </li>
47 <?php endforeach; ?>
48 </ul>
49 <?php if ( !defined('ENHANCED_BLOCKS_VERSION') && !defined('FLUENTFORMPRO') ) : ?>
50 <div class="ff_recommended_plugin">
51 Recommended Plugin: <b>Enhanced Blocks Page Builder Blocks for Gutenberg</b> <br />
52 <a href="<?php echo $this->getInstallUrl('enhanced-blocks'); ?>">Install</a>
53 | <a target="_blank" rel="noopener" href="https://wordpress.org/plugins/enhanced-blocks/">Learn More</a>
54 </div>
55 <?php endif; ?>
56 <style>
57 ul.ff_dashboard_stats {
58 margin: 0;
59 padding: 0;
60 list-style: none;
61 }
62
63 ul.ff_dashboard_stats li {
64 padding: 8px 12px;
65 border-bottom: 1px solid #eeeeee;
66 margin: 0 -12px;
67 cursor: pointer;
68 }
69
70 ul.ff_dashboard_stats li:hover {
71 background: #fafafa;
72 border-bottom: 1px solid #eeeeee;
73 }
74
75 ul.ff_dashboard_stats li:hover a {
76 color: black;
77 }
78
79 ul.ff_dashboard_stats li:nth-child(2n+2) {
80 background: #f9f9f9;
81 }
82
83 ul.ff_dashboard_stats li span.ff_total {
84 float: right;
85 }
86
87 ul.ff_dashboard_stats li a {
88 display: block;
89 color: #0073aa;
90 font-weight: 500;
91 font-size: 105%;
92 }
93
94 .ff_recommended_plugin {
95 padding: 15px 0px 0px;
96 }
97 .ff_recommended_plugin a {
98 font-weight: bold;
99 font-size: 110%;
100 }
101 </style>
102 <?php
103 }
104
105 private function getInstallUrl($plugin)
106 {
107 return wp_nonce_url(
108 self_admin_url('update.php?action=install-plugin&plugin=' . $plugin),
109 'install-plugin_' . $plugin
110 );
111 }
112
113 private function getUnreadCount($formId)
114 {
115 return wpFluent()->table('fluentform_submissions')
116 ->where('status', 'unread')
117 ->where('form_id', $formId)
118 ->count();
119 }
120 }
121