One-time execution added
This commit is contained in:
parent
0a001acac9
commit
949bf9d26f
17
README.md
17
README.md
@ -1,8 +1,8 @@
|
||||
# Statify Blacklist #
|
||||
* Contributors: Stefan Kalscheuer
|
||||
* Requires at least: 3.9
|
||||
* Tested up to: 4.5
|
||||
* Stable tag: 1.0.0
|
||||
* Tested up to: 4.5.3
|
||||
* Stable tag: 1.1.0
|
||||
* License: GPLv3 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
@ -15,9 +15,12 @@ This plugin adds customizable blacklist to Statify to allow blocking of referer
|
||||
####Referer Blacklist
|
||||
Add a list of domains (for simplicity onl second-level, e.g. _example.com_ which blocks _everything.example.com_).
|
||||
|
||||
#### CleanUp Database
|
||||
Filters can be applied to data stored in database after modifying filter rules or for one-time clean-up.
|
||||
|
||||
|
||||
### Compatibility ###
|
||||
This plugin requires Statify to be installed. The extension has been tested with Statify 1.4.3
|
||||
This plugin requires Statify to be installed. The extension has been tested with Statify 1.4.2
|
||||
The plugin is capable of handling multisite installations.
|
||||
|
||||
### Credits ###
|
||||
@ -29,3 +32,11 @@ The plugin is capable of handling multisite installations.
|
||||
### Requirements ###
|
||||
* PHP 5.2.4
|
||||
* WordPress 3.9
|
||||
* Statify plugin installed and activated (tested with 1.4.2)
|
||||
|
||||
## Changelog
|
||||
#### 1.1.0 / 15.08.2016
|
||||
* One-time execution on database
|
||||
|
||||
#### 1.0.0 / 14.08.2016
|
||||
* First release
|
@ -49,8 +49,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function plugin_actions_links($links, $file)
|
||||
{
|
||||
public static function plugin_actions_links($links, $file) {
|
||||
$base = self::$multisite ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' );
|
||||
|
||||
if( $file == STATIFYBLACKLIST_BASE && current_user_can('manage_options') ) {
|
||||
@ -61,4 +60,25 @@ class StatifyBlacklist_Admin extends StatifyBlacklist
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter database for cleanup.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public static function cleanup_database() {
|
||||
global $wpdb;
|
||||
|
||||
/* Build filter regexp */
|
||||
$refererRegexp = str_replace('.', '\.', implode('|', self::$_options['referer']));
|
||||
if (!empty($refererRegexp)) {
|
||||
/* Execute filter on database */
|
||||
$wpdb->query(
|
||||
$wpdb->prepare("DELETE FROM `$wpdb->statify` WHERE referrer REGEXP %s", $refererRegexp)
|
||||
);
|
||||
}
|
||||
|
||||
/* Optimize DB */
|
||||
$wpdb->query("OPTIMIZE TABLE `$wpdb->statify`");
|
||||
}
|
||||
}
|
35
readme.txt
Normal file
35
readme.txt
Normal file
@ -0,0 +1,35 @@
|
||||
=== Statify Blacklist ===
|
||||
Contributors: Stefan Kalscheuer
|
||||
Tags: stats, extension, blacklist, filter
|
||||
Requires at least: 3.9
|
||||
Tested up to: 4.5.3
|
||||
Stable tag: trunk
|
||||
License: GPLv3 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Extension for the Statify statistics plugin. Provides a customizable referer blacklist.
|
||||
|
||||
== Description ==
|
||||
A blacklist extension for the famous [Statify](http://statify.de) Wordpress plugin.
|
||||
|
||||
This plugin adds customizable blacklist to Statify to allow blocking of referer spam or internal interactions.
|
||||
|
||||
== Requirements ==
|
||||
* PHP 5.2.4
|
||||
* WordPress 3.9
|
||||
* Statify plugin (tested with 1.4.2)
|
||||
|
||||
== Installation ==
|
||||
1. Upload the plugin files to the `/wp-content/plugins/statify-blacklist` directory, or install the plugin through the WordPress plugins screen directly.
|
||||
1. Activate the plugin through the 'Plugins' screen in WordPress
|
||||
1. Use the Settings->Plugin Name screen to configure the plugin
|
||||
1. (Make your instructions match the desired user flow for activating and installing your plugin. Include any steps that might be needed for explanatory purposes)
|
||||
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.1.0 / 15.08.2016 =
|
||||
* One-time execution on database
|
||||
|
||||
= 1.0.0 / 14.08.2016 =
|
||||
* First release
|
@ -6,9 +6,9 @@ Text Domain: statify-blacklist
|
||||
Domain Path: /lang
|
||||
Author: stklcode
|
||||
Author URI: https://stklcode.de
|
||||
Plugin URI: https://wordpress.org/plugins/statifyRefererBlacklist
|
||||
Plugin URI: https://wordpress.org/plugins/statify-blacklist
|
||||
License: GPLv3 or later
|
||||
Version: 1.0.0
|
||||
Version: 1.1.0
|
||||
*/
|
||||
|
||||
/* Quit */
|
||||
|
@ -1,13 +1,18 @@
|
||||
<?php
|
||||
|
||||
/* Update plugin options */
|
||||
if ( ! empty($_POST['statifyblacklist']) ) {
|
||||
StatifyBlacklist::update_options(
|
||||
array(
|
||||
'active_referer' => (int)@$_POST['statifyblacklist']['active_referer'],
|
||||
'referer' => explode("\r\n", $_POST['statifyblacklist']['referer'])
|
||||
)
|
||||
);
|
||||
if ( !empty($_POST['statifyblacklist']) ) {
|
||||
if (!empty($_POST['cleanUp'])) {
|
||||
/* CleanUp DB */
|
||||
StatifyBlacklist_Admin::cleanup_database();
|
||||
} else {
|
||||
StatifyBlacklist::update_options(
|
||||
array(
|
||||
'active_referer' => (int)@$_POST['statifyblacklist']['active_referer'],
|
||||
'referer' => explode("\r\n", $_POST['statifyblacklist']['referer'])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -33,6 +38,13 @@ if ( ! empty($_POST['statifyblacklist']) ) {
|
||||
</ul>
|
||||
<?php wp_nonce_field('statify-blacklist-settings'); ?>
|
||||
|
||||
<p class="submit"><input class="button-primary" type="submit" name="submit" value="<?php _e('Save Changes') ?>"></p>
|
||||
<p class="submit">
|
||||
<input class="button-primary" type="submit" name="submit" value="<?php _e('Save Changes') ?>">
|
||||
<hr>
|
||||
<input class="button-secondary" type="submit" name="cleanUp" value="<?php esc_html_e('CleanUp Database', 'statify-blacklist') ?>"
|
||||
onclick="return confirm('Do you really want to apply filters to database? This cannot be undone.');">
|
||||
<br>
|
||||
<small>(<?php esc_html_e('Applies filter (even if disabled) to data stored in database. This cannot be undone!', 'statify-blacklist'); ?>)</small>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user