Skip to content

Commit

Permalink
Create an ability to set max log lifetime #23
Browse files Browse the repository at this point in the history
  • Loading branch information
iworks committed Nov 27, 2024
1 parent d3d736c commit 6c66fd6
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
3 changes: 3 additions & 0 deletions includes/iworks/class-iworks-omnibus.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public function __construct() {
if ( $this->is_migrated_v4() ) {
include_once dirname( __FILE__ ) . '/omnibus/class-iworks-omnibus-logger-v4.php';
new iworks_omnibus_logger_v4();
include_once dirname( __FILE__ ) . '/omnibus/integration/v4/class-iworks-omnibus-integration-commons.php';
new iworks_omnibus_integration_commons();
} else {
include_once dirname( __FILE__ ) . '/omnibus/migration/class-iworks-omnibus-migration-v4.php';
new iworks_omnibus_migration_v4();
Expand Down Expand Up @@ -530,4 +532,5 @@ public function register_deactivation_hook() {
public function action_init_load_plugin_textdomain() {
load_plugin_textdomain( 'omnibus', false, plugin_basename( $this->root ) . '/languages' );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/*
Copyright 2024-PLUGIN_TILL_YEAR Marcin Pietrzak ([email protected])
this program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
defined( 'ABSPATH' ) || exit;

if ( class_exists( 'iworks_omnibus_integration_commons' ) ) {
return;
}

include_once 'class-iworks-omnibus-integration.php';

class iworks_omnibus_integration_commons extends iworks_omnibus_integration {

public function __construct() {
/**
* delete older records
*
* @since 4.0.0
*/
add_action( 'shutdown', array( $this, 'action_shutdown_maybe_delete_older_records' ) );
}

/**
* Delete older records
*
* @since 4.0.0
*/
public function action_shutdown_maybe_delete_older_records() {
global $wpdb;
/**
* do action before
*/
do_action( 'iworks/omnibus/action/before/delete_older_records' );
/**
* not in ajax
*/
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
/**
* really delete?
*/
if ( 'yes' !== get_option( $this->get_name( 'allow_to_delete' ) ) ) {
return;
}
/**
* delete
*/
$query = $wpdb->prepare(
sprintf(
'DELETE FROM %s WHERE created < ( CURRENT_DATE - INTERVAL %%d DAY )',
$wpdb->iworks_omnibus
),
max( 31, intval( get_option( $this->get_name( 'days_delete' ) ) ) )
);
$wpdb->query( $query );
/**
* do action after
*/
do_action( 'iworks/omnibus/action/after/delete_older_records' );
}
}
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ Project maintained on github at [iworks/omnibus](PLUGIN_GITHUB_WEBSITE).
* The [iWorks Rate](https://github.com/iworks/iworks-rate) module has been updated to 2.2.0.
* Display Omnibus with or without tax has been removed.
* The `load_plugin_textdomain()` function call has been fixed.
* The ability to auto clear older prices has been added. [#23](https://github.com/iworks/omnibus/issues/23)

= 3.0.3 (2024-08-09) =
* The omnibus price for variant in admin panel has been fixed.
Expand Down

0 comments on commit 6c66fd6

Please sign in to comment.