Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
Version 1.1.0
Browse files Browse the repository at this point in the history
* Removed: EDD Plugin Updater
* Fixed: Multiple WordPress Coding Standard issues
* Fixed: PHP 8.3 compatibility
  • Loading branch information
ajaydsouza committed Jan 2, 2024
1 parent 4f5415c commit 0959a23
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 248 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Top 10 - Fast Tracker

**Requires:** WordPress 5.6 and Top 10 v3.x
__Requires:__ WordPress 5.9 and Top 10 v3.x

**Tested up to:** 5.9
__Tested up to:__ WordPress 6.4

**License:** [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html)
__License:__ [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html)

**Plugin page:** [Top 10 - Fast Tracker](https://webberzone.com/downloads/top-10-fast-tracker/)
__Plugin page:__ [Top 10 - Fast Tracker](https://github.com/WebberZone/top-10-fast-tracker)

Track daily and total visits on your blog posts. Display the count as well as popular and trending posts.
High performance tracker for Top 10.

## Description

Older versions of [Top 10](https://webberzone.com/plugins/top-10/) included a high performance tracker that worked with an external excel file loading a minimal WordPress environment. This free addon will allow you to bring back this tracker and significantly speed up Top 10.
Older versions of [Top 10](https://webberzone.com/plugins/top-10/) included a high performance tracker that worked with an external JavaScript file loading a minimal WordPress environment. This free addon will allow you to bring back this tracker and significantly speed up Top 10.

This plugin is an addon to the [Top 10](https://webberzone.com/plugins/top-10/) plugin. You must have Top 10 v3.x installed for this plugin to work.

## Installation

Expand All @@ -22,11 +24,11 @@ Older versions of [Top 10](https://webberzone.com/plugins/top-10/) included a hi

3. Activate the Plugin in WP-Admin

4. Go to **Top 10** to select / deselect this tracker under **Counter and tracker options**
4. Go to __Top 10__ to select / deselect this tracker under **Counter and tracker options**

## Frequently Asked Questions

If you're looking for support for this addon, [create an issue in the Github repository](https://github.com/WebberZone/top-10-fast-tracker/issues). I also provide [premium _paid_ support via email](https://webberzone.com/support/).
If you're looking for support for this addon, [create an issue in the Github repository](https://github.com/WebberZone/top-10-fast-tracker/issues).

## About this repository

Expand Down
74 changes: 74 additions & 0 deletions includes/fast-tracker-js.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/**
* Update counts to database.
*
* @package Top_Ten_Fast_Tracker
*/

Header( 'content-type: application/x-javascript' );

// Force a short-init since we just need core WP, not the entire framework stack.
define( 'SHORTINIT', true );

// Build the wp-config.php path from a plugin/theme.
$wp_config_path = dirname( dirname( dirname( __DIR__ ) ) );
$wp_config_filename = '/wp-load.php';

// Check if the file exists in the root or one level up.
if ( ! file_exists( $wp_config_path . $wp_config_filename ) ) {
// Just in case the user may have placed wp-config.php one more level up from the root.
$wp_config_filename = dirname( $wp_config_path ) . $wp_config_filename;
}
// Require the wp-config.php file.
require $wp_config_filename;

// Include the now instantiated global $wpdb Class for use.
global $wpdb;


/**
* Use external tracker.
*
* @since 1.0.0
*/
function tptn_inc_count() {
global $wpdb;
$table_name = $wpdb->base_prefix . 'top_ten';
$table_name_daily = $wpdb->base_prefix . 'top_ten_daily';
$str = '';

$id = isset( $_POST['top_ten_id'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['top_ten_id'] ) ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Missing
$blog_id = isset( $_POST['top_ten_blog_id'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['top_ten_blog_id'] ) ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Missing
$activate_counter = isset( $_POST['activate_counter'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['activate_counter'] ) ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Missing
$top_ten_debug = isset( $_POST['top_ten_debug'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['top_ten_debug'] ) ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Missing

if ( $id > 0 ) {

if ( ( 1 === $activate_counter ) || ( 11 === $activate_counter ) ) {

$tt = $wpdb->query( $wpdb->prepare( "INSERT INTO {$table_name} (postnumber, cntaccess, blog_id) VALUES( %d, '1', %d ) ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $blog_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared

$str .= ( false === $tt ) ? 'tte' : 'tt' . $tt;
}

if ( ( 10 === $activate_counter ) || ( 11 === $activate_counter ) ) {

$current_date = current_time( 'Y-m-d H' );

$ttd = $wpdb->query( $wpdb->prepare( "INSERT INTO {$table_name_daily} (postnumber, cntaccess, dp_date, blog_id) VALUES( %d, '1', %s, %d ) ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $current_date, $blog_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared

$str .= ( false === $ttd ) ? ' ttde' : ' ttd' . $ttd;
}
}

// If the debug parameter is set then we output $str else we send a No Content header.
if ( 1 === $top_ten_debug ) {
echo esc_html( $str );
} else {
header( 'HTTP/1.0 204 No Content' );
header( 'Cache-Control: max-age=15, s-maxage=0' );
}
}

// Ajax Increment Counter.
tptn_inc_count();
65 changes: 0 additions & 65 deletions includes/fast-tracker.js.php

This file was deleted.

1 change: 0 additions & 1 deletion includes/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ function tptnft_add_tracker( $trackers ) {
);

return $trackers;

}
add_filter( 'tptn_get_tracker_types', 'tptnft_add_tracker' );
23 changes: 0 additions & 23 deletions phpunit.xml.dist

This file was deleted.

42 changes: 0 additions & 42 deletions phpunit/bootstrap.php

This file was deleted.

84 changes: 0 additions & 84 deletions phpunit/install.sh

This file was deleted.

10 changes: 0 additions & 10 deletions phpunit/tests/test-sample.php

This file was deleted.

16 changes: 12 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
Tags: popular posts, top 10, tracker
Contributors: webberzone, Ajay
Donate link: https://ajaydsouza.com/donate/
Stable tag: trunk
Requires at least: 5.4
Tested up to: 5.9
Stable tag: 1.1.0
Requires at least: 5.9
Tested up to: 6.4
Requires PHP: 7.4
License: GPLv2 or later

Addon for Top 10 that incorporates a high performance tracker.

== Description ==

Older versions of [Top 10](https://webberzone.com/plugins/top-10/) included a high performance tracker that worked with an external excel file loading a minimal WordPress environment. This free addon will allow you to bring back this tracker and significantly speed up Top 10.
Older versions of [Top 10](https://webberzone.com/plugins/top-10/) included a high performance tracker that worked with an external JavaScript file loading a minimal WordPress environment. This free addon will allow you to bring back this tracker and significantly speed up Top 10.

This plugin is an addon to the [Top 10](https://webberzone.com/plugins/top-10/) plugin. You must have Top 10 v3.x installed for this plugin to work.

= Contribute =

Expand Down Expand Up @@ -41,6 +43,12 @@ If you're looking for support [create an issue in the Github repository](https:/

== Changelog ==

= 1.1.0 =

* Removed: EDD Plugin Updater
* Fixed: Multiple WordPress Coding Standard issues
* Fixed: PHP 8.3 compatibility

= 1.0.0 =

* Initial commit
Expand Down
Loading

0 comments on commit 0959a23

Please sign in to comment.