Skip to content

Commit 7af98e5

Browse files
committed
added count
1 parent 25b6a6c commit 7af98e5

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

cbxsearchtracker.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Plugin Name: CBX Search Tracker
44
* Description: Tracks WordPress search keywords and shows most searched keywords in admin dashboard.
5-
* Version: 1.2.0
5+
* Version: 1.2.1
66
* Author: Codeboxr
77
* Text Domain: cbxsearchtracker
88
* Domain Path: /languages
@@ -151,6 +151,15 @@ public function admin_page() {
151151
"SELECT * FROM {$this->table_name} ORDER BY search_count DESC LIMIT 100"
152152
);
153153

154+
$total_keywords = (int) $wpdb->get_var(
155+
"SELECT COUNT(*) FROM {$this->table_name}"
156+
);
157+
158+
$total_searches = (int) $wpdb->get_var(
159+
"SELECT SUM(search_count) FROM {$this->table_name}"
160+
);
161+
162+
154163
echo '<div class="wrap">';
155164
echo '<h1>' . esc_html__( 'Most Searched Keywords', 'cbxsearchtracker' ) . '</h1>';
156165

@@ -167,13 +176,25 @@ public function admin_page() {
167176
}
168177

169178

170-
// Delete All Button
171-
echo '<form method="post" style="margin-bottom:15px;">';
179+
echo '<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:15px;">';
180+
181+
// LEFT SIDE — Delete All Button
182+
echo '<form method="post">';
172183
wp_nonce_field('cbx_delete_all_keywords');
173184
echo '<input type="hidden" name="cbx_delete_all" value="1" />';
174185
echo '<input type="submit" class="button button-primary" value="' . esc_attr__('Delete All Keywords', 'cbxsearchtracker') . '" onclick="return confirm(\'Are you sure you want to delete all keywords?\');" />';
175186
echo '</form>';
176187

188+
// RIGHT SIDE — Total Stats
189+
echo '<div style="font-weight:600;">';
190+
echo esc_html__('Total Keywords:', 'cbxsearchtracker') . ' ' . esc_html($total_keywords);
191+
echo ' | ';
192+
echo esc_html__('Total Searches:', 'cbxsearchtracker') . ' ' . esc_html($total_searches);
193+
echo '</div>';
194+
195+
echo '</div>';
196+
197+
177198

178199
echo '<table class="widefat striped">';
179200
echo '<thead><tr>';

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: search, search analytics, keyword tracker, search tracker, admin dashboard
44
Requires at least: 5.8
55
Tested up to: 6.5
66
Requires PHP: 7.4
7-
Stable tag: 1.2.0
7+
Stable tag: 1.2.1
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010
Text Domain: cbxsearchtracker
@@ -73,6 +73,10 @@ Currently it tracks all searches. Zero-result filtering can be added in a future
7373
3. Empty state when no searches recorded
7474

7575
== Changelog ==
76+
= 1.2.1 =
77+
* Added total count for keywords
78+
* Added total count for total search
79+
7680
= 1.2.0 =
7781
* Added delete all feature
7882

0 commit comments

Comments
 (0)