Skip to content

Commit

Permalink
Merge pull request #100 from CastosHQ/release/1.7.0
Browse files Browse the repository at this point in the history
Release/1.7.0
  • Loading branch information
zahardev authored Nov 7, 2024
2 parents 8f75d4b + ae231e6 commit 7bc3218
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 87 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seriously-simple-stats",
"version": "1.5.2",
"version": "1.7.0",
"main": "build/index.js",
"author": "CastosHQ",
"devDependencies": {
Expand Down
72 changes: 2 additions & 70 deletions php/classes/class-ssp-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Stats {

/**
* The single instance of SSP_Stats.
* @var object
* @var self
* @access private
* @since 1.0.0
*/
Expand Down Expand Up @@ -213,12 +213,6 @@ public function bootstrap( $file, $version, $db_version ) {
// Get required episode IDs for stats
add_action( 'init', array( $this, 'load_episode_ids' ), 11 );

// Add admin notice to upgrade stats table
add_action( 'admin_notices', array( $this, 'maybe_notify_stats_update' ) );

// Anonymise the IP address details stored in the database
add_action( 'admin_init', array( $this, 'maybe_update_stats_data' ), 11 );

// Add stats meta box to episodes edit screen
add_action( 'ssp_meta_boxes', array( $this, 'post_meta_box' ), 10, 1 );

Expand Down Expand Up @@ -1149,8 +1143,7 @@ public function load_localisation () {
*
* @since 1.0.0
* @static
* @see SSP_Stats()
* @return Main SSP_Stats instance
* @return self SSP_Stats instance
*/
public static function instance ( $file = '', $version = '1.0.0', $db_version = '1.0.0' ) {
if ( is_null( self::$_instance ) ) {
Expand Down Expand Up @@ -1284,65 +1277,4 @@ public function dashboard_widget_callback(){
echo $html;

}

/**
* Checks if the ssp_stats_ips_updated option is set, if not shows a message to the user.
*/
public function maybe_notify_stats_update(){
$ssp_stats_ips_updated = get_option( 'ssp_stats_ips_updated', 'no' );
if ( 'yes' === $ssp_stats_ips_updated ) {
return;
}
$data_upgrade_url = add_query_arg( array( 'upgrade_stats_table' => 'anonymise_ip' ) );
?>
<div class="notice notice-warning">
<p><?php _e( 'Seriously Simple Stats needs to perform an update to the stats database table. Click below to perform this one-time update.', 'seriously-simple-stats' ); ?></p>
<p><a href="<?php echo $data_upgrade_url ?>"><?php _e( 'Upgrade stats table.', 'seriously-simple-stats' ); ?></a></p>
</div>
<?php
}

/**
* Attempt to update the stats table
*/
public function maybe_update_stats_data(){

if ( ! isset( $_GET['upgrade_stats_table'] ) ) {
return;
}

$upgrade_stats_table = filter_var( $_GET['upgrade_stats_table'], FILTER_SANITIZE_STRING );
if ( ! 'anonymise_ip' === $upgrade_stats_table ) {
return;
}

global $wpdb;
$query = "UPDATE {$wpdb->prefix}ssp_stats SET ip_address = CONCAT( SUBSTRING_INDEX( ip_address, '.', 3 ) , '.0' )";
$affected_rows = $wpdb->query($query);

if (false === $affected_rows){
add_action( 'admin_notices', array( $this, 'update_stats_data_failed' ) );
}else {
update_option( 'ssp_stats_ips_updated', 'yes' );
add_action( 'admin_notices', array( $this, 'update_stats_data_succeeded' ) );
}

}

public function update_stats_data_failed(){
?>
<div class="notice notice-warning is-dismissible">
<p><?php _e( 'An error occurred updating the stats database table, please try again or contact support.', 'seriously-simple-stats' ); ?></p>
</div>
<?php
}

public function update_stats_data_succeeded(){
?>
<div class="notice notice-success is-dismissible">
<p><?php _e( 'Updating the stats database table completed successfully.', 'seriously-simple-stats' ); ?></p>
</div>
<?php
}

}
12 changes: 9 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== Seriously Simple Stats ===
Contributors: PodcastMotor, psykro, zahardoc, simondowdles, hlashbrooke, seriouspodcaster
Tags: seriously simple podcasting, stats, statistics, listeners, analytics, podcast, podcasting, ssp, free, add-ons, extensions, addons
Requires at least: 4.4
Tested up to: 6.5
Stable tag: 1.6.0
Requires at least: 5.3
Tested up to: 6.6
Stable tag: 1.7.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -78,6 +78,12 @@ Yes. This plugin uses the [Crawler Detect](https://github.com/JayBizzle/Crawler-

== Changelog ==

= 1.7.0 =
* 2024-09-17
* [UPDATE] Removed outdated database update and notice functionality.
* [UPDATE] Security improvements
* [UPDATE] Updated supported WordPress version

= 1.6.0 =
* 2024-06-26
* [UPDATE] Updated supported WordPress version
Expand Down
15 changes: 6 additions & 9 deletions seriously-simple-stats.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/*
* Plugin Name: Seriously Simple Stats
* Version: 1.6.0
* Version: 1.7.0
* Plugin URI: https://wordpress.org/plugins/seriously-simple-stats
* Description: Integrated analytics and stats tracking for Seriously Simple Podcasting.
* Author: Castos
* Author URI: https://www.castos.com/
* Requires at least: 4.4
* Tested up to: 6.5
* Requires at least: 5.3
* Tested up to: 6.6
*
* Text Domain: seriously-simple-stats
* Domain Path: /languages
Expand All @@ -18,7 +18,6 @@
*
* @author Castos
* @since 1.2.0
*
*/

if ( ! defined( 'ABSPATH' ) ) {
Expand All @@ -27,7 +26,7 @@

use SeriouslySimpleStats\Classes\Stats;

define( 'SSP_STATS_VERSION', '1.6.0' );
define( 'SSP_STATS_VERSION', '1.7.0' );
define( 'SSP_STATS_DIR_PATH', plugin_dir_path( __FILE__ ) );

require_once SSP_STATS_DIR_PATH . 'vendor/autoload.php';
Expand All @@ -45,13 +44,11 @@
/**
* Returns the main instance of SSP_Stats to prevent the need to use globals.
*
* @return Object Stats
* @return Stats
* @since 1.0.0
*/
function SSP_Stats() {
$ssp_stats = Stats::instance( __FILE__, SSP_STATS_VERSION, '1.0.0' );

return $ssp_stats;
return Stats::instance( __FILE__, SSP_STATS_VERSION );
}

SSP_Stats();
Expand Down
8 changes: 4 additions & 4 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package Seriously_Simple_Stats
*/

use SeriouslySimpleStats\Classes\Stats;

$_tests_dir = getenv( 'WP_TESTS_DIR' );

if ( ! $_tests_dir ) {
Expand All @@ -23,12 +25,10 @@
* This is because the plugin file checks to ensure that a verion of SSP is installed
* and for unit tests that check would fail
*
* @return Main
* @return Stats
*/
function SSP_Stats() {
$instance = SSP_Stats::instance( __FILE__, SSP_STATS_VERSION, '1.0.0' );

return $instance;
return Stats::instance( __FILE__, SSP_STATS_VERSION, '1.0.0' );
}

/**
Expand Down

0 comments on commit 7bc3218

Please sign in to comment.