Skip to content

Commit 317c483

Browse files
committed
wz_top_ten() to hold main instance
1 parent 20281fb commit 317c483

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

readme.txt

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Tags: popular posts, top 10, counter, statistics, tracker
33
Contributors: webberzone, ajay
44
Donate link: https://ajaydsouza.com/donate/
5-
Stable tag: 4.0.3
5+
Stable tag: 4.1.0
66
Requires at least: 6.3
77
Tested up to: 6.7
88
Requires PHP: 7.4
@@ -153,6 +153,8 @@ When you enabled the scheduled maintenance, Top 10 will create a cron job that w
153153

154154
= 4.1.0 =
155155

156+
Release post: [https://webberzone.com/announcements/top-10-v4-1-0/](https://webberzone.com/announcements/top-10-v4-1-0/)
157+
156158
* Features:
157159
* Import data from the WordPress Popular Posts plugin.
158160
* [Pro] Query Optimization: Add MySQL MAX_EXECUTION_TIME directive to prevent long-running queries from consuming excessive server resources. Configurable via settings and the `top_ten_query_max_execution_time` filter.
@@ -164,10 +166,12 @@ When you enabled the scheduled maintenance, Top 10 will create a cron job that w
164166
* Modifications:
165167
* Updated ChartJS and replaced Moment adapter with Luxon.
166168
* An admin notice is displayed when any Top 10 table is missing. The plugin will also automatically recreate the missing tables.
169+
* Introduced `wz_top_ten()` function to return the main instance of Top 10.
167170

168171
* Bug fixes:
169172
* Resolved issue where tables were not automatically created during plugin activation.
170173
* Fixed issue where the popular posts feed always displayed the post's full content even when Excerpt was selected under Reading settings.
174+
* Fixed "Not found" error when accessing the Daily Popular Posts feed.
171175

172176
= 4.0.4 =
173177

@@ -238,5 +242,5 @@ For previous changelog entries, please refer to the separate changelog.txt file
238242

239243
== Upgrade Notice ==
240244

241-
= 4.0.4 =
242-
Freemius SDK Updated. Minor other changes. Check out the release post or changelog for further information.
245+
= 4.1.0 =
246+
Enhancements: Improved performance optimizations. Updated Freemius SDK to the latest version. Added support for plugin dependencies. Enhanced the format of numbered lists. Renamed certain filters for clarity. Bug fixes: Resolved issues with admin column settings. Fixed meta_query parameter issues.

top-10.php

+21-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Plugin Name: Top 10
1515
* Plugin URI: https://webberzone.com/plugins/top-10/
1616
* Description: Count daily and total visits per post and display the most popular posts based on the number of views
17-
* Version: 4.1.0-beta1
17+
* Version: 4.1.0
1818
* Author: WebberZone
1919
* Author URI: https://webberzone.com
2020
* License: GPL-2.0+
@@ -36,7 +36,7 @@
3636
* @since 3.1.0
3737
*/
3838
if ( ! defined( 'TOP_TEN_VERSION' ) ) {
39-
define( 'TOP_TEN_VERSION', '4.0.4' );
39+
define( 'TOP_TEN_VERSION', '4.1.0' );
4040
}
4141

4242
/**
@@ -91,18 +91,35 @@
9191
// Load the autoloader.
9292
require_once TOP_TEN_PLUGIN_DIR . 'includes/autoloader.php';
9393

94+
95+
if ( ! function_exists( __NAMESPACE__ . '\wz_top_ten' ) ) {
96+
/**
97+
* Returns the main instance of Top 10 to prevent the need to use globals.
98+
*
99+
* @since 4.0.6
100+
*
101+
* @return Main Main instance of the plugin.
102+
*/
103+
function wz_top_ten(): Main {
104+
return Main::get_instance();
105+
}
106+
}
107+
94108
if ( ! function_exists( __NAMESPACE__ . '\load_tptn' ) ) {
95109
/**
96110
* The main function responsible for returning the one true Top 10 instance to functions everywhere.
97111
*
98112
* @since 3.3.0
99113
*/
100-
function load_tptn() {
101-
Main::get_instance();
114+
function load_tptn(): void {
115+
wz_top_ten();
102116
}
103117
add_action( 'plugins_loaded', __NAMESPACE__ . '\load_tptn' );
104118
}
105119

120+
// Register the activation hook.
121+
register_activation_hook( __FILE__, __NAMESPACE__ . '\Admin\Activator::activation_hook' );
122+
106123
/*
107124
*----------------------------------------------------------------------------
108125
* Include files

0 commit comments

Comments
 (0)