PHPdoc and ReadMe corrections

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

View File

@ -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
*/

View File

@ -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 ) {

View File

@ -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 );