PHPdoc and ReadMe corrections

This commit is contained in:
Stefan Kalscheuer 2017-06-05 14:19:19 +02:00
parent df59e43b29
commit 7929dd66bd
6 changed files with 40 additions and 45 deletions

View File

@ -7,7 +7,7 @@
* License URI: https://www.gnu.org/licenses/gpl-3.0.html * License URI: https://www.gnu.org/licenses/gpl-3.0.html
## Description ## ## 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. 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. No. It only prevent's _Statify_ from tracking, nothing more or less.
### Does live filtering impact performance? ### ### 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. 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? ### ### Is any personal data collected? ###
No. The privacy policy of _Statify_ is untouched. Data is only processed, not stored or exposed to anyone. No. The privacy policy of _Statify_ is untouched. Data is only processed, not stored or exposed to anyone.
### Are regular expression filters possible? ### ### 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. 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 ### ### 1.4.0 / work in progress ###
* IP blacklist implemented (#7) * IP blacklist implemented (#7)
* Target page blacklist implemented (#8) * Target page blacklist implemented (#8)
* Internal configuration restructured (upgrade on plugin activation)
### 1.3.1 / 09.12.2016 ### ### 1.3.1 / 09.12.2016 ###
* Continue filtering if no filter applies (#6) * Continue filtering if no filter applies (#6)

View File

@ -42,7 +42,6 @@ class StatifyBlacklist {
* Class constructor * Class constructor
* *
* @since 1.0.0 * @since 1.0.0
* @changed 1.2.1
*/ */
public function __construct() { public function __construct() {
/* Skip on autosave or AJAX */ /* Skip on autosave or AJAX */
@ -94,10 +93,10 @@ class StatifyBlacklist {
/** /**
* Update options * Update options
* *
* @param $options array New options to save * @param array $options New options to save
* *
* @since 1.0.0 * @since 1.0.0
* @changed 1.1.1 * @since 1.2.1 update_options($options = null) Parameter with default value introduced
*/ */
public static function update_options( $options = null ) { public static function update_options( $options = null ) {
self::$_options = wp_parse_args( self::$_options = wp_parse_args(
@ -138,10 +137,9 @@ class StatifyBlacklist {
/** /**
* Apply the blacklist filter if active * 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.0.0
* @since 1.4.0 Target and IP blacklist
*/ */
public static function apply_blacklist_filter() { public static function apply_blacklist_filter() {
/* Referer blacklist */ /* Referer blacklist */
@ -252,8 +250,8 @@ class StatifyBlacklist {
/** /**
* Helper function to check if an IP address matches a given subnet. * Helper function to check if an IP address matches a given subnet.
* *
* @param $ip string IP address to check * @param string $ip IP address to check
* @param $net string IP address or subnet in CIDR notation * @param string $net IP address or subnet in CIDR notation
* *
* @return bool TRUE, if the given IP addresses matches the given subnet * @return bool TRUE, if the given IP addresses matches the given subnet
*/ */

View File

@ -13,11 +13,10 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
/** /**
* Update options * 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 * @return array|bool array of sanitized array on errors, FALSE if there were none
* @since 1.1.1 * @since 1.1.1
* @changed 1.4.0
*/ */
public static function update_options( $options = null ) { public static function update_options( $options = null ) {
if ( isset( $options ) && current_user_can( 'manage_options' ) ) { if ( isset( $options ) && current_user_can( 'manage_options' ) ) {
@ -82,10 +81,10 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
/** /**
* Add plugin meta links * Add plugin meta links
* *
* @param $links * @param array $links Registered links
* @param $file * @param string $file The filename
* *
* @return array * @return array Merged links
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -100,7 +99,8 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
/** /**
* Add plugin action links * 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
* *
@ -123,7 +123,6 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
* Filter database for cleanup. * Filter database for cleanup.
* *
* @since 1.1.0 * @since 1.1.0
* @changed 1.4.0
*/ */
public static function cleanup_database() { public static function cleanup_database() {
/* Check user permissions */ /* Check user permissions */
@ -195,12 +194,11 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
/** /**
* Sanitize URLs and remove empty results * Sanitize URLs and remove empty results
* *
* @param $urls array given array of URLs * @param array $urls given array of URLs
* *
* @return array sanitized array * @return array sanitized array
* *
* @since 1.1.1 * @since 1.1.1
* @changed 1.2.0
*/ */
private static function sanitizeURLs( $urls ) { private static function sanitizeURLs( $urls ) {
return array_flip( return array_flip(
@ -218,7 +216,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
/** /**
* Sanitize IP addresses with optional CIDR notation and remove empty results * 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 * @return array sanitized array
* *

View File

@ -15,7 +15,6 @@ class StatifyBlacklist_System extends StatifyBlacklist {
* Plugin install handler. * Plugin install handler.
* *
* @since 1.0.0 * @since 1.0.0
* @changed 1.4.0
* *
* @param bool $network_wide Whether the plugin was activated network-wide or not. * @param bool $network_wide Whether the plugin was activated network-wide or not.
*/ */
@ -81,7 +80,6 @@ class StatifyBlacklist_System extends StatifyBlacklist {
* Upgrade plugin options. * Upgrade plugin options.
* *
* @since 1.2.0 * @since 1.2.0
* @changed 1.4.0
*/ */
public static function upgrade() { public static function upgrade() {
self::update_options(); self::update_options();
@ -130,7 +128,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
/* Version older than current major release */ /* Version older than current major release */
if ( self::$_options['version'] < self::VERSION_MAIN ) { if ( self::$_options['version'] < self::VERSION_MAIN ) {
/* Merge default options with current config, assuming only additive changes */ /* 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; $options['version'] = self::VERSION_MAIN;
if ( ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) { if ( ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
update_site_option( 'statify-blacklist', $options ); update_site_option( 'statify-blacklist', $options );

View File

@ -35,7 +35,7 @@ spl_autoload_register( 'statifyBlacklist_autoload' );
/** /**
* Autoloader for StatifyBlacklist classes. * Autoloader for StatifyBlacklist classes.
* *
* @param $class * @param string $class name of the class to load
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -141,7 +141,7 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
</li> </li>
<li> <li>
<label for="statify-blacklist_referer"> <label for="statify-blacklist_referer">
<?php esc_html_e( 'Referer blacklist:', 'statify-blacklist' ); ?><br/> <?php esc_html_e( 'Referer blacklist', 'statify-blacklist' ); ?>:<br/>
<textarea cols="40" rows="5" name="statifyblacklist[referer][blacklist]" id="statify-blacklist_referer"><?php <textarea cols="40" rows="5" name="statifyblacklist[referer][blacklist]" id="statify-blacklist_referer"><?php
if ( isset( $statifyBlacklistUpdateResult['referer'] ) ) { if ( isset( $statifyBlacklistUpdateResult['referer'] ) ) {
print esc_html( implode( "\r\n", array_keys( $statifyBlacklistUpdateResult['referer'] ) ) ); print esc_html( implode( "\r\n", array_keys( $statifyBlacklistUpdateResult['referer'] ) ) );
@ -203,7 +203,7 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
</li> </li>
<li> <li>
<label for="statify-blacklist_target"> <label for="statify-blacklist_target">
<?php esc_html_e( 'Target blacklist:', 'statify-blacklist' ); ?><br/> <?php esc_html_e( 'Target blacklist', 'statify-blacklist' ); ?>:<br/>
<textarea cols="40" rows="5" name="statifyblacklist[target][blacklist]" id="statify-blacklist_target"><?php <textarea cols="40" rows="5" name="statifyblacklist[target][blacklist]" id="statify-blacklist_target"><?php
if ( isset( $statifyBlacklistUpdateResult['target'] ) ) { if ( isset( $statifyBlacklistUpdateResult['target'] ) ) {
print esc_html( implode( "\r\n", array_keys( $statifyBlacklistUpdateResult['target'] ) ) ); print esc_html( implode( "\r\n", array_keys( $statifyBlacklistUpdateResult['target'] ) ) );
@ -240,7 +240,7 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
</li> </li>
<li> <li>
<label for="statify-blacklist_ip"> <label for="statify-blacklist_ip">
<?php esc_html_e( 'IP blacklist:', 'statify-blacklist' ); ?><br/> <?php esc_html_e( 'IP blacklist', 'statify-blacklist' ); ?>:<br/>
<textarea cols="40" rows="5" name="statifyblacklist[ip][blacklist]" id="statify-blacklist_ip"><?php <textarea cols="40" rows="5" name="statifyblacklist[ip][blacklist]" id="statify-blacklist_ip"><?php
if ( isset( $statifyBlacklistUpdateResult['ip'] ) ) { if ( isset( $statifyBlacklistUpdateResult['ip'] ) ) {
print esc_html( $_POST['statifyblacklist']['ip']['blacklist'] ); print esc_html( $_POST['statifyblacklist']['ip']['blacklist'] );