Feature #2 Hook CleanUp job to Statify cron action
This commit is contained in:
@ -52,8 +52,10 @@ class StatifyBlacklist {
|
||||
/* Get multisite status */
|
||||
self::$multisite = ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) );
|
||||
|
||||
/* Add Filter to statify hook */
|
||||
add_filter( 'statify_skip_tracking', array( 'StatifyBlacklist', 'apply_blacklist_filter' ) );
|
||||
/* Add Filter to statify hook if enabled */
|
||||
if ( self::$_options['active_referer'] != 1 ) {
|
||||
add_filter( 'statify_skip_tracking', array( 'StatifyBlacklist', 'apply_blacklist_filter' ) );
|
||||
}
|
||||
|
||||
/* Admin only filters */
|
||||
if ( is_admin() ) {
|
||||
@ -76,6 +78,13 @@ class StatifyBlacklist {
|
||||
add_filter( 'plugin_action_links', array( 'StatifyBlacklist_Admin', 'plugin_actions_links' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
/* CronJob to clean up database */
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
if ( self::$_options['cron_referer'] == 1 ) {
|
||||
add_action( 'statify_cleanup', array( 'StatifyBlacklist_Admin', 'cleanup_database' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,6 +99,7 @@ class StatifyBlacklist {
|
||||
get_option( 'statify-blacklist' ),
|
||||
array(
|
||||
'active_referer' => 0,
|
||||
'cron_referer' => 0,
|
||||
'referer' => array()
|
||||
)
|
||||
);
|
||||
|
@ -19,7 +19,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
||||
public static function update_options( $options = null ) {
|
||||
if ( isset( $options ) && current_user_can( 'manage_options' ) ) {
|
||||
/* Sanitize URLs and remove empty inputs */
|
||||
$givenReferer = $options['referer'];
|
||||
$givenReferer = $options['referer'];
|
||||
$sanitizedReferer = self::sanitizeURLs( $givenReferer );
|
||||
|
||||
/* Abort on errors */
|
||||
@ -110,11 +110,11 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
||||
* Filter database for cleanup.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @changed 1.2.1
|
||||
* @changed 1.2.0
|
||||
*/
|
||||
public static function cleanup_database() {
|
||||
/* Check user permissions */
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
if ( ! current_user_can( 'manage_options' ) && ! ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
|
||||
die( _e( 'Are you sure you want to do this?' ) );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user