diff --git a/README.md b/README.md index da835d0..2430431 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ * License URI: https://www.gnu.org/licenses/gpl-3.0.html ## Description ## -A blacklist extension for the famous [Statify](https://de.wordpress.org/plugins/statify/) Wordpress plugin. +A blacklist extension for the famous [Statify](https://wordpress.org/plugins/statify/) Wordpress plugin. This plugin adds customizable blacklist to Statify to allow blocking of referer spam or internal interactions. @@ -54,14 +54,14 @@ visitors from search engines, just "false" referers from 301 redirects or you ow No. It only prevent's _Statify_ from tracking, nothing more or less. ### Does live filtering impact performance? ### -Yes, but probalby not noticeable. Checking a single referer string against a (usually small) list should be neglectible compared to the total loading procedure. +Yes, but probalby not noticeable. Checking a single referer string against a (usually small) list should be negligible compared to the total loading procedure. If this still is an issue for you, consider deactivating the filter and only run the one-time-cleanup or activate the cron job. ### Is any personal data collected? ### No. The privacy policy of _Statify_ is untouched. Data is only processed, not stored or exposed to anyone. ### Are regular expression filters possible? ### -Yes, it it. Just select if you want to filter using regular expressions case sensitive or insensitive. +Yes, it is. Just select if you want to filter using regular expressions case sensitive or insensitive. Note, that regular expression matching is significantly slower than the plain domain filter. Hence it is only recommended for asynchronous cron or manual execution and not for live filtering. @@ -78,6 +78,7 @@ Because of this, an IP blacklist can only be applied while processing the reques ### 1.4.0 / work in progress ### * IP blacklist implemented (#7) * Target page blacklist implemented (#8) +* Internal configuration restructured (upgrade on plugin activation) ### 1.3.1 / 09.12.2016 ### * Continue filtering if no filter applies (#6) diff --git a/inc/statifyblacklist.class.php b/inc/statifyblacklist.class.php index 33b1b38..71f4fc1 100644 --- a/inc/statifyblacklist.class.php +++ b/inc/statifyblacklist.class.php @@ -17,7 +17,7 @@ class StatifyBlacklist { * Plugin options * * @var array - * @since 1.0.0 + * @since 1.0.0 */ public static $_options; @@ -25,14 +25,14 @@ class StatifyBlacklist { * Multisite Status * * @var bool - * @since 1.0.0 + * @since 1.0.0 */ public static $multisite; /** * Class self initialize * - * @since 1.0.0 + * @since 1.0.0 */ public static function instance() { new self(); @@ -41,8 +41,7 @@ class StatifyBlacklist { /** * Class constructor * - * @since 1.0.0 - * @changed 1.2.1 + * @since 1.0.0 */ public function __construct() { /* Skip on autosave or AJAX */ @@ -85,7 +84,7 @@ class StatifyBlacklist { /* CronJob to clean up database */ if ( defined( 'DOING_CRON' ) && DOING_CRON ) { - if ( self::$_options['referer']['cron'] == 1 || self::$_options['target']['cron'] == 1 ) { + if ( self::$_options['referer']['cron'] == 1 || self::$_options['target']['cron'] == 1 ) { add_action( 'statify_cleanup', array( 'StatifyBlacklist_Admin', 'cleanup_database' ) ); } } @@ -94,10 +93,10 @@ class StatifyBlacklist { /** * Update options * - * @param $options array New options to save + * @param array $options New options to save * - * @since 1.0.0 - * @changed 1.1.1 + * @since 1.0.0 + * @since 1.2.1 update_options($options = null) Parameter with default value introduced */ public static function update_options( $options = null ) { self::$_options = wp_parse_args( @@ -138,10 +137,9 @@ class StatifyBlacklist { /** * Apply the blacklist filter if active * - * @return TRUE if referer matches blacklist. + * @return bool TRUE if referer matches blacklist. * - * @since 1.0.0 - * @since 1.4.0 Target and IP blacklist + * @since 1.0.0 */ public static function apply_blacklist_filter() { /* Referer blacklist */ @@ -252,8 +250,8 @@ class StatifyBlacklist { /** * Helper function to check if an IP address matches a given subnet. * - * @param $ip string IP address to check - * @param $net string IP address or subnet in CIDR notation + * @param string $ip IP address to check + * @param string $net IP address or subnet in CIDR notation * * @return bool TRUE, if the given IP addresses matches the given subnet */ diff --git a/inc/statifyblacklist_admin.class.php b/inc/statifyblacklist_admin.class.php index f927076..c21d803 100644 --- a/inc/statifyblacklist_admin.class.php +++ b/inc/statifyblacklist_admin.class.php @@ -13,11 +13,10 @@ class StatifyBlacklist_Admin extends StatifyBlacklist { /** * Update options * - * @param $options array New options to save + * @param array $options New options to save * - * @return mixed array of sanitized array on errors, FALSE if there were none - * @since 1.1.1 - * @changed 1.4.0 + * @return array|bool array of sanitized array on errors, FALSE if there were none + * @since 1.1.1 */ public static function update_options( $options = null ) { if ( isset( $options ) && current_user_can( 'manage_options' ) ) { @@ -57,7 +56,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist { /** * Add configuration page to admin menu * - * @since 1.0.0 + * @since 1.0.0 */ public function _add_menu_page() { $title = __( 'Statify Blacklist', 'statify-blacklist' ); @@ -82,12 +81,12 @@ class StatifyBlacklist_Admin extends StatifyBlacklist { /** * Add plugin meta links * - * @param $links - * @param $file + * @param array $links Registered links + * @param string $file The filename * - * @return array + * @return array Merged links * - * @since 1.0.0 + * @since 1.0.0 */ public static function plugin_meta_link( $links, $file ) { if ( $file == STATIFYBLACKLIST_BASE ) { @@ -100,11 +99,12 @@ class StatifyBlacklist_Admin extends StatifyBlacklist { /** * Add plugin action links * - * @param array $input Registered links + * @param array $links Registered links + * @param string $file The filename * - * @return array Merged links + * @return array Merged links * - * @since 1.0.0 + * @since 1.0.0 */ public static function plugin_actions_links( $links, $file ) { $base = self::$multisite ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' ); @@ -122,8 +122,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist { /** * Filter database for cleanup. * - * @since 1.1.0 - * @changed 1.4.0 + * @since 1.1.0 */ public static function cleanup_database() { /* Check user permissions */ @@ -195,12 +194,11 @@ class StatifyBlacklist_Admin extends StatifyBlacklist { /** * Sanitize URLs and remove empty results * - * @param $urls array given array of URLs + * @param array $urls given array of URLs * * @return array sanitized array * - * @since 1.1.1 - * @changed 1.2.0 + * @since 1.1.1 */ private static function sanitizeURLs( $urls ) { return array_flip( @@ -218,11 +216,11 @@ class StatifyBlacklist_Admin extends StatifyBlacklist { /** * Sanitize IP addresses with optional CIDR notation and remove empty results * - * @param $ips array given array of URLs + * @param array $ips given array of URLs * * @return array sanitized array * - * @since 1.4.0 + * @since 1.4.0 */ private static function sanitizeIPs( $ips ) { return array_filter( $ips, function ( $ip ) { diff --git a/inc/statifyblacklist_system.class.php b/inc/statifyblacklist_system.class.php index 832c6ab..861da8e 100644 --- a/inc/statifyblacklist_system.class.php +++ b/inc/statifyblacklist_system.class.php @@ -14,8 +14,7 @@ class StatifyBlacklist_System extends StatifyBlacklist { /** * Plugin install handler. * - * @since 1.0.0 - * @changed 1.4.0 + * @since 1.0.0 * * @param bool $network_wide Whether the plugin was activated network-wide or not. */ @@ -80,8 +79,7 @@ class StatifyBlacklist_System extends StatifyBlacklist { /** * Upgrade plugin options. * - * @since 1.2.0 - * @changed 1.4.0 + * @since 1.2.0 */ public static function upgrade() { self::update_options(); @@ -130,7 +128,7 @@ class StatifyBlacklist_System extends StatifyBlacklist { /* Version older than current major release */ if ( self::$_options['version'] < self::VERSION_MAIN ) { /* Merge default options with current config, assuming only additive changes */ - $options = array_merge( self::defaultOptions(), self::$_options ); + $options = array_merge_recursive( self::defaultOptions(), self::$_options ); $options['version'] = self::VERSION_MAIN; if ( ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) { update_site_option( 'statify-blacklist', $options ); diff --git a/statify-blacklist.php b/statify-blacklist.php index 1c5e575..65dc44c 100644 --- a/statify-blacklist.php +++ b/statify-blacklist.php @@ -35,7 +35,7 @@ spl_autoload_register( 'statifyBlacklist_autoload' ); /** * Autoloader for StatifyBlacklist classes. * - * @param $class + * @param string $class name of the class to load * * @since 1.0.0 */ diff --git a/views/settings_page.php b/views/settings_page.php index bd57901..87eb928 100755 --- a/views/settings_page.php +++ b/views/settings_page.php @@ -141,7 +141,7 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {