Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
012b9a0189 | |||
eb63299dfc | |||
637d5f482c | |||
f061b4c194 | |||
7962d4dbc9 | |||
aa40945ebd | |||
12a7959982 | |||
58ac6e36f1 | |||
bc32bd66db | |||
2b6f892b18 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@ composer.lock
|
||||
/node_modules/
|
||||
/dist/
|
||||
.idea
|
||||
tests-clover.xml
|
||||
tests-junit.xml
|
@ -5,6 +5,7 @@ php:
|
||||
- '5.6'
|
||||
- '7.0'
|
||||
- '7.1'
|
||||
- '7.2'
|
||||
before_script:
|
||||
- composer install --no-interaction
|
||||
- vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs
|
||||
|
119
CONTRIBUTING.md
Normal file
119
CONTRIBUTING.md
Normal file
@ -0,0 +1,119 @@
|
||||
# How to contribute
|
||||
|
||||
As for all great Open Source projects, contributions in form of bug reports and code are welcome and important to keep the project alive.
|
||||
|
||||
In general, this project follows the [Git Flow](https://guides.github.com/introduction/flow/).
|
||||
Fork the project, commit your changes to your branch, open a pull request and it will probably be merged.
|
||||
However, to ensure maintainability and quality of the code, there are some guidelines you might be more or less familiar with.
|
||||
For that purpose, this document describes the important points.
|
||||
|
||||
## Opening an Issue
|
||||
|
||||
If you experience any issues with the plugin or the code, don't hesitate to file an issue.
|
||||
|
||||
### Bug Reports
|
||||
|
||||
Think you found a bug?
|
||||
Please clearly state what happens and describe your environment.
|
||||
|
||||
* Which version of the plugin are you running?
|
||||
* Which version of WordPress?
|
||||
* Which version(s) of related plugin(s) (e.g. Statify)?
|
||||
* Which version of PHP and - if of interest - which webserver are you running?
|
||||
|
||||
### Feature Requests
|
||||
|
||||
Missing a feature or like to have certain functionality enhanced?
|
||||
No problem, please open an issue and describe what and why you think this change is required.
|
||||
|
||||
## Pull Requests
|
||||
|
||||
If you want to contribute your code to solve an issue or implement a desired feature yourself, you might open a pull request.
|
||||
If the changes introduce new functionality or affect major parts of existing code, please consider opening an issue for discussion first.
|
||||
|
||||
For adding new functionality a new test case the corresponding PHPUnit test would be nice (no hard criterion).
|
||||
|
||||
### Branches
|
||||
|
||||
The `master` branch represents the current state of development.
|
||||
Please ensure your initial code is up to date with it at the time you start development.
|
||||
The `master` should also be target for most pull requests.
|
||||
|
||||
In addition, this project features a `develop` branch, which hold cutting edge developments, not necessarily considered stable or even compatible.
|
||||
Do not expect this code to run smoothly, but you might have a look into the history to see if some work on an issue has already been started there.
|
||||
|
||||
For fixes and features, there might be additional branches, likely prefixed by `ft-` (feature) or `hf-` (hotfix) followed by an issue number (if applicable) and/or a title.
|
||||
Feel free to adapt these naming scheme to your forks.
|
||||
|
||||
### Merge Requirements
|
||||
|
||||
To be merged into the master branch, your code has to pass the automated continuous integration tests, to ensure compatibility.
|
||||
In Addition your code has to be approved by a project member.
|
||||
|
||||
#### What if my code fails the tests?
|
||||
|
||||
Don't worry, you can submit your PR anyway.
|
||||
The reviewing process might help you to solve remaining issues.
|
||||
|
||||
### Commit messages
|
||||
|
||||
Please use speaking titles and messages for your commits, to ensure a transparent history.
|
||||
If your patch fixes an issue, reference the ID in the first line.
|
||||
If you feel like you have to _briefly_ explain your changes, do it (for long explanations and discussion, consider opening an issue or describe in the PR).
|
||||
|
||||
**Example commit:**
|
||||
```
|
||||
Fix nasty bug from #1337
|
||||
|
||||
This example commit fixes the issue that some people write non-speaking commit messages like 'done magic'.
|
||||
A short description is helpful sometimes.
|
||||
```
|
||||
|
||||
You might sign your work, although that's no must.
|
||||
|
||||
### When will it be merged?
|
||||
|
||||
Short answer: When it makes sense.
|
||||
|
||||
Bugfixes should be merges in time - assuming they pass the above criteria.
|
||||
New features might be assigned to a certain milestone and as a result of this be scheduled according to the planned release cycle.
|
||||
|
||||
## Compatibility
|
||||
|
||||
To ensure usability for a wide range of users, please take note on the software requirements stated in the `README`.
|
||||
This includes especially the minimum PHP version and also the minimum version of WordPress.
|
||||
|
||||
If you are unsure if your code matches these versions, the test will probably tell you.
|
||||
|
||||
In case you think, your change is more important than maintaining backwards compatibility, please start a discussion to see,
|
||||
if we might increase the minimum version or find a workaround for legacy systems.
|
||||
|
||||
## Unit Tests
|
||||
|
||||
The PHP code is tested by a PHPUnit test.
|
||||
All test files are located in the `test` directory.
|
||||
Files ending with `-test.php` will be automatically included into the test suite.
|
||||
The coverage is not yet perfect, but be invited to write tests for methods not yet covered or newly introduced by your patch.
|
||||
|
||||
## Code Style
|
||||
|
||||
This project, as part of the WordPress ecosystem adheres to the [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards).
|
||||
Please make sure that you are at least roughly familiar with those guidelines.
|
||||
|
||||
The code style is automatically checked for commits (including pull requests) using [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
|
||||
You can check your code against the configured ruleset yourself by running
|
||||
`./vendor/bin/phpcs --standard=phpcs.xml your-edited-file.php` (assuming `composer install` has been executed).
|
||||
|
||||
Please see these standards as guidelines.
|
||||
If code style this is the only test that fails and your code's semantics are fine, don't hesitate to submit your pull request anyway.
|
||||
We probably find a solution for that.
|
||||
|
||||
## Continuous Integration
|
||||
|
||||
Automated tests are run using [Travis CI](https://travis-ci.org/stklcode/statify-blacklist) for every commit including pull requests.
|
||||
They ensure compatibility with the supported PHP versions and the WP Coding Standards.
|
||||
|
||||
## Still Open Questions?
|
||||
|
||||
If anything is still left unanswered and you're unsure if you got it right, don't hesitate to contact a team member.
|
||||
in any case you might submit your request/issue anyway, we won't refuse good code only for formal reasons.
|
@ -47,7 +47,7 @@ gulp.task('test-cs', function (cb) {
|
||||
gulp.task('bundle', ['clean'], function () {
|
||||
console.log('Collecting files for package dist/' + config.name + config.version + ' ...');
|
||||
return gulp.src(['**/*.php', '!test/**', '!vendor/**', 'README.md', 'LICENSE.md'], {base: './'})
|
||||
.pipe(copy('./dist/' + config.name + '.' + config.version));
|
||||
.pipe(copy('./dist/' + config.name + '.' + config.version + '/' + config.name));
|
||||
});
|
||||
|
||||
// Create a ZIP package of the relevant files for plugin distribution.
|
||||
|
13
README.md
13
README.md
@ -1,8 +1,9 @@
|
||||
# Statify Blacklist #
|
||||
* Contributors: Stefan Kalscheuer
|
||||
* Requires at least: 3.9
|
||||
* Tested up to: 4.8
|
||||
* Stable tag: 1.4.1
|
||||
* Requires at least: 4.4
|
||||
* Tested up to: 4.9
|
||||
* Requires PHP: 5.5
|
||||
* Stable tag: 1.4.2
|
||||
* License: GPLv2 or later
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
@ -45,7 +46,7 @@ The plugin is capable of handling multisite installations.
|
||||
|
||||
### Requirements ###
|
||||
* PHP 5.5 or above
|
||||
* WordPress 3.9 or above
|
||||
* WordPress 4.4 or above
|
||||
* Statify plugin installed and activated (tested up to 1.5.1)
|
||||
|
||||
## Frequently Asked Questions ##
|
||||
@ -81,11 +82,15 @@ Because of this, an IP blacklist can only be applied while processing the reques
|
||||
|
||||
## Changelog ##
|
||||
|
||||
### 1.4.2 / 12.11.2017 ###
|
||||
* Minor code fixes
|
||||
|
||||
### 1.4.1 / 16.07.2017 ###
|
||||
* Relicensed to GPLv2 or later
|
||||
* Fix filter hook if referer is disabled (#9)
|
||||
* Fix problem with faulty IPv6 netmask in IP blacklist
|
||||
* Minor changes for WP Coding Standard
|
||||
* Minimum required WordPress version is 4.4 (#10)
|
||||
|
||||
### 1.4.0 / 10.06.2017 ###
|
||||
* IP blacklist implemented (#7)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "stklcode/statify-blacklist",
|
||||
"version": "1.4.1",
|
||||
"version": "1.4.2",
|
||||
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
||||
"keywords": [
|
||||
"wordpress",
|
||||
@ -24,6 +24,7 @@
|
||||
"require-dev": {
|
||||
"php": ">=5.5",
|
||||
"phpunit/phpunit": "*",
|
||||
"wp-coding-standards/wpcs": "~0.11.0"
|
||||
"phpunit/php-code-coverage": "*",
|
||||
"wp-coding-standards/wpcs": "~0.14.0"
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
||||
} elseif ( ! empty( array_diff( $given_ip, $sanitized_ip ) ) ) {
|
||||
return array(
|
||||
'ip' => array_diff( $given_ip, $sanitized_ip ),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
// Update database on success.
|
||||
@ -70,7 +70,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function _add_menu_page() {
|
||||
public static function add_menu_page() {
|
||||
$title = __( 'Statify Blacklist', 'statify-blacklist' );
|
||||
if ( self::$multisite ) {
|
||||
add_submenu_page(
|
||||
|
@ -46,17 +46,28 @@ class StatifyBlacklist {
|
||||
* Class self initialize.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @deprecated 1.4.2 Replaced by init().
|
||||
*/
|
||||
public static function instance() {
|
||||
new self();
|
||||
self::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @deprecated 1.4.2 Replaced by init().
|
||||
*/
|
||||
public function __construct() {
|
||||
self::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin initialization.
|
||||
*
|
||||
* @since 1.4.2
|
||||
*/
|
||||
public static function init() {
|
||||
// Skip on autosave or AJAX.
|
||||
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||
return;
|
||||
@ -84,7 +95,7 @@ class StatifyBlacklist {
|
||||
add_filter( 'plugin_row_meta', array( 'StatifyBlacklist_Admin', 'plugin_meta_link' ), 10, 2 );
|
||||
|
||||
if ( is_multisite() ) {
|
||||
add_action( 'network_admin_menu', array( 'StatifyBlacklist_Admin', '_add_menu_page' ) );
|
||||
add_action( 'network_admin_menu', array( 'StatifyBlacklist_Admin', 'add_menu_page' ) );
|
||||
add_filter(
|
||||
'network_admin_plugin_action_links', array(
|
||||
'StatifyBlacklist_Admin',
|
||||
@ -94,7 +105,7 @@ class StatifyBlacklist {
|
||||
2
|
||||
);
|
||||
} else {
|
||||
add_action( 'admin_menu', array( 'StatifyBlacklist_Admin', '_add_menu_page' ) );
|
||||
add_action( 'admin_menu', array( 'StatifyBlacklist_Admin', 'add_menu_page' ) );
|
||||
add_filter( 'plugin_action_links', array( 'StatifyBlacklist_Admin', 'plugin_actions_links' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
@ -306,7 +317,7 @@ class StatifyBlacklist {
|
||||
}
|
||||
|
||||
$bytes_addr = unpack( 'n*', inet_pton( $base ) );
|
||||
$bytes_est = unpack( 'n*', inet_pton( $ip ) );
|
||||
$bytes_est = unpack( 'n*', inet_pton( $ip ) );
|
||||
|
||||
if ( ! $bytes_addr || ! $bytes_est ) {
|
||||
return false;
|
||||
@ -314,8 +325,8 @@ class StatifyBlacklist {
|
||||
|
||||
$ceil = ceil( $mask / 16 );
|
||||
for ( $i = 1; $i <= $ceil; ++ $i ) {
|
||||
$left = $mask - 16 * ( $i - 1 );
|
||||
$left = ( $left <= 16 ) ? $left : 16;
|
||||
$left = $mask - 16 * ( $i - 1 );
|
||||
$left = ( $left <= 16 ) ? $left : 16;
|
||||
$mask_b = ~( 0xffff >> $left ) & 0xffff;
|
||||
if ( ( $bytes_addr[ $i ] & $mask_b ) !== ( $bytes_est[ $i ] & $mask_b ) ) {
|
||||
return false;
|
||||
|
12
package.json
12
package.json
@ -1,17 +1,17 @@
|
||||
{
|
||||
"name": "statify-blacklist",
|
||||
"version": "1.4.1",
|
||||
"version": "1.4.2",
|
||||
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
||||
"author": "Stefan Kalscheuer",
|
||||
"license": "GPLv2 or later",
|
||||
"license": "GPL-2.0+",
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-clean": "^0.3.2",
|
||||
"gulp-copy": "^1.0.0",
|
||||
"gulp-copy": "^1.0.1",
|
||||
"gulp-zip": "^4.0.0",
|
||||
"gulp-composer": "^0.4.0",
|
||||
"gulp-phpunit": "^0.23.0",
|
||||
"gulp-phpcs": "^2.0.0",
|
||||
"gulp-composer": "^0.4.4",
|
||||
"gulp-phpunit": "^0.24.1",
|
||||
"gulp-phpcs": "^2.1.0",
|
||||
"child_process": "^1.0.2"
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,13 @@
|
||||
<directory suffix="-test.php">./test/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./inc/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="tests-clover.xml"/>
|
||||
<log type="junit" target="tests-junit.xml" logIncompleteSkipped="false"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Plugin Name: Statify Blacklist
|
||||
* Plugin URI: https://wordpress.org/plugins/statify-blacklist/
|
||||
* Description: Extension for the Statify plugin to add a customizable blacklists.
|
||||
* Version: 1.4.1
|
||||
* Version: 1.4.2
|
||||
* Author: Stefan Kalscheuer (@stklcode)
|
||||
* Author URI: https://www.stklcode.de
|
||||
* Text Domain: statify-blacklist
|
||||
@ -40,7 +40,7 @@ define( 'STATIFYBLACKLIST_DIR', dirname( __FILE__ ) );
|
||||
define( 'STATIFYBLACKLIST_BASE', plugin_basename( __FILE__ ) );
|
||||
|
||||
// System Hooks.
|
||||
add_action( 'plugins_loaded', array( 'StatifyBlacklist', 'instance' ) );
|
||||
add_action( 'plugins_loaded', array( 'StatifyBlacklist', 'init' ) );
|
||||
|
||||
register_activation_hook( STATIFYBLACKLIST_FILE, array( 'StatifyBlacklist_System', 'install' ) );
|
||||
|
||||
@ -67,12 +67,10 @@ function statify_blacklist_autoload( $class ) {
|
||||
);
|
||||
|
||||
if ( in_array( $class, $plugin_classes, true ) ) {
|
||||
require_once(
|
||||
sprintf(
|
||||
'%s/inc/class-%s.php',
|
||||
STATIFYBLACKLIST_DIR,
|
||||
strtolower( str_replace( '_', '-', $class ) )
|
||||
)
|
||||
require_once sprintf(
|
||||
'%s/inc/class-%s.php',
|
||||
STATIFYBLACKLIST_DIR,
|
||||
strtolower( str_replace( '_', '-', $class ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user