Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
075441d6f3 | |||
92f8496926 | |||
66ddada63e | |||
fcba292698 | |||
1e811957f8 | |||
b9017a7b8d | |||
7329574d09 |
@ -2,7 +2,7 @@
|
||||
|
||||
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/).
|
||||
In general, this project follows the [GitHub 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.
|
||||
@ -14,7 +14,7 @@ If you experience any issues with the plugin or the code, don't hesitate to file
|
||||
### Bug Reports
|
||||
|
||||
Think you found a bug?
|
||||
Please clearly state what happens and describe your environment.
|
||||
Please clearly state what happens and describe your environment to help tracking down the issue.
|
||||
|
||||
* Which version of the plugin are you running?
|
||||
* Which version of WordPress?
|
||||
@ -31,7 +31,7 @@ No problem, please open an issue and describe what and why you think this change
|
||||
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).
|
||||
For adding new functionality a new test case the corresponding PHPUnit test would be nice (no hard criterion though).
|
||||
|
||||
### Branches
|
||||
|
||||
@ -39,7 +39,7 @@ 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.
|
||||
In addition, this project features a `develop` branch, which holds bleeding 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.
|
||||
@ -62,7 +62,7 @@ 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:**
|
||||
```
|
||||
```text
|
||||
Fix nasty bug from #1337
|
||||
|
||||
This example commit fixes the issue that some people write non-speaking commit messages like 'done magic'.
|
||||
@ -75,7 +75,7 @@ You might sign your work, although that's no must.
|
||||
|
||||
Short answer: When it makes sense.
|
||||
|
||||
Bugfixes should be merges in time - assuming they pass the above criteria.
|
||||
Bugfixes should be merged 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
|
||||
@ -88,9 +88,17 @@ If you are unsure if your code matches these versions, the test will probably te
|
||||
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.
|
||||
|
||||
## Build Environment
|
||||
|
||||
All you need to start off - besides your favorite IDE of course - is [Composer](https://getcomposer.org).
|
||||
Running `composer install` will fetch all dependencies and build tools required.
|
||||
You might have noticed that this project contains a [Robo](http://robo.li) build script.
|
||||
Running the _build_-task (`./vendor/bin/robo build`) executes the full chain from cleanup over test to bundling the final product in the `dist` directory.
|
||||
A complete list of the available tasks and options can be shown by running `robo list`.
|
||||
|
||||
## Unit Tests
|
||||
|
||||
The PHP code is tested by a PHPUnit test.
|
||||
The PHP code is tested by a PHPUnit tests.
|
||||
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.
|
||||
@ -102,7 +110,7 @@ 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).
|
||||
`./vendor/bin/phpcs --standard=phpcs.xml your-edited-file.php` (assuming `composer install` has been executed) or the Robo task `robo test:cs` for a complete scan.
|
||||
|
||||
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.
|
||||
@ -113,6 +121,9 @@ We probably find a solution for that.
|
||||
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.
|
||||
|
||||
There is also a semi-automated code quality analysis pushing results to [SonarCloud](https://sonarcloud.io/dashboard?id=de.stklcode.web.wordpress.plugins%3Astatify-blacklist).
|
||||
Keep in mind that the ruleset is not yet perfect, so not every minor issue has to be fixed immediately.
|
||||
|
||||
## 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.
|
||||
|
@ -358,4 +358,4 @@ you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use the
|
||||
[GNU Lesser General Public
|
||||
License](http://www.gnu.org/licenses/lgpl.html) instead of this
|
||||
License.
|
||||
License.
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Requires at least: 4.4
|
||||
* Tested up to: 4.9
|
||||
* Requires PHP: 5.5
|
||||
* Stable tag: 1.4.3
|
||||
* Stable tag: 1.4.4
|
||||
* License: GPLv2 or later
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
@ -47,7 +47,7 @@ The plugin is capable of handling multisite installations.
|
||||
### Requirements ###
|
||||
* PHP 5.5 or above
|
||||
* WordPress 4.4 or above
|
||||
* Statify plugin installed and activated (tested up to 1.5.4)
|
||||
* Statify plugin installed and activated (1.5.0 or above)
|
||||
|
||||
## Frequently Asked Questions ##
|
||||
|
||||
@ -82,6 +82,9 @@ Because of this, an IP blacklist can only be applied while processing the reques
|
||||
|
||||
## Changelog ##
|
||||
|
||||
### 1.4.4 / 19.05.2018 ###
|
||||
* Fix live filter chain when regular expressions are active (#12)
|
||||
|
||||
### 1.4.3 / 09.01.2018 ###
|
||||
* Fix issues with multisite installation (#11)
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* @author Stefan Kalscheuer <stefan@stklcode.de>
|
||||
*
|
||||
* @package Statify_Blacklist
|
||||
* @version 1.4.3
|
||||
* @version 1.4.4
|
||||
*/
|
||||
|
||||
use Robo\Exception\TaskException;
|
||||
@ -351,7 +351,7 @@ class RoboFile extends Tasks {
|
||||
*/
|
||||
private function updateVCSreadme() {
|
||||
$trunk_dir = $this->target_dir . '/svn/statify-blacklist/trunk';
|
||||
$this->_copy( $this->target_dir . '/' . $this->final_name . 'README.md', $trunk_dir . 'README.md' );
|
||||
$this->_copy( $this->target_dir . '/' . $this->final_name . '/README.md', $trunk_dir . '/README.md' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "stklcode/statify-blacklist",
|
||||
"version": "1.4.3",
|
||||
"version": "1.4.4",
|
||||
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
||||
"keywords": [
|
||||
"wordpress",
|
||||
@ -8,7 +8,7 @@
|
||||
"statistics",
|
||||
"blacklist"
|
||||
],
|
||||
"license": "GPL-2.0+",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Stefan Kalscheuer",
|
||||
@ -23,7 +23,6 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.4",
|
||||
"php": ">=5.5",
|
||||
"consolidation/robo": "^1.0.0",
|
||||
"phpunit/phpunit": "*",
|
||||
"phpunit/php-code-coverage": "*",
|
||||
|
@ -187,8 +187,10 @@ class StatifyBlacklist {
|
||||
$regexp .= 'i';
|
||||
}
|
||||
|
||||
// Check blacklist (return NULL to continue filtering).
|
||||
return ( 1 === preg_match( $regexp, $referer ) ) ? true : null;
|
||||
// Check blacklist (no return to continue filtering #12).
|
||||
if ( 1 === preg_match( $regexp, $referer ) ) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Extract relevant domain parts.
|
||||
$referer = wp_parse_url( wp_get_raw_referer() );
|
||||
@ -218,8 +220,10 @@ class StatifyBlacklist {
|
||||
$regexp .= 'i';
|
||||
}
|
||||
|
||||
// Check blacklist (return NULL to continue filtering).
|
||||
return ( 1 === preg_match( $regexp, $target ) ) ? true : null;
|
||||
// Check blacklist (no return to continue filtering #12).
|
||||
if ( 1 === preg_match( $regexp, $target ) ) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Extract target page.
|
||||
// @codingStandardsIgnoreStart The globals are checked.
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "statify-blacklist",
|
||||
"version": "1.4.3",
|
||||
"version": "1.4.4",
|
||||
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
||||
"author": "Stefan Kalscheuer",
|
||||
"license": "GPL-2.0+",
|
||||
|
@ -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.3
|
||||
* Version: 1.4.4
|
||||
* Author: Stefan Kalscheuer (@stklcode)
|
||||
* Author URI: https://www.stklcode.de
|
||||
* Text Domain: statify-blacklist
|
||||
|
@ -472,6 +472,86 @@ class StatifyBlacklist_Test extends PHPUnit\Framework\TestCase {
|
||||
}
|
||||
|
||||
// TODO: Test target regex filter.
|
||||
|
||||
|
||||
/**
|
||||
* Test combined filters.
|
||||
*
|
||||
* @since 1.4.4
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_combined_filters() {
|
||||
// Prepare Options: simple referer + simple target + ip.
|
||||
StatifyBlacklist::$_options = array(
|
||||
'referer' => array(
|
||||
'active' => 1,
|
||||
'cron' => 0,
|
||||
'regexp' => 0,
|
||||
'blacklist' => array(
|
||||
'example.com' => 0,
|
||||
),
|
||||
),
|
||||
'target' => array(
|
||||
'active' => 1,
|
||||
'cron' => 0,
|
||||
'regexp' => 0,
|
||||
'blacklist' => array(
|
||||
'/excluded/page/' => 0
|
||||
),
|
||||
),
|
||||
'ip' => array(
|
||||
'active' => 1,
|
||||
'blacklist' => array(
|
||||
'192.0.2.123'
|
||||
),
|
||||
),
|
||||
'version' => StatifyBlacklist::VERSION_MAIN,
|
||||
);
|
||||
|
||||
// No multisite.
|
||||
StatifyBlacklist::$multisite = false;
|
||||
|
||||
// No match.
|
||||
$_SERVER['HTTP_REFERER'] = 'https://example.net';
|
||||
$_SERVER['REQUEST_URI'] = '/normal/page/';
|
||||
$_SERVER['REMOTE_ADDR'] = '192.0.2.234';
|
||||
unset( $_SERVER['HTTP_X_FORWARDED_FOR'] );
|
||||
unset( $_SERVER['HTTP_X_REAL_IP'] );
|
||||
|
||||
// Matching Referer.
|
||||
$_SERVER['HTTP_REFERER'] = 'https://example.com';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
|
||||
// Matching target.
|
||||
$_SERVER['HTTP_REFERER'] = 'https://example.net';
|
||||
$_SERVER['REQUEST_URI'] = '/excluded/page/';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
|
||||
// Matching IP.
|
||||
$_SERVER['REQUEST_URI'] = '/normal/page/';
|
||||
$_SERVER['REMOTE_ADDR'] = '192.0.2.123';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REMOTE_ADDR'] = '192.0.2.234';
|
||||
|
||||
// Same for RegExp filters.
|
||||
StatifyBlacklist::$_options['referer']['regexp'] = 1;
|
||||
StatifyBlacklist::$_options['referer']['blacklist'] = array( 'example\.com' => 0 );
|
||||
StatifyBlacklist::$_options['target']['regexp'] = 1;
|
||||
StatifyBlacklist::$_options['target']['blacklist'] = array( '\/excluded\/.*' => 0 );
|
||||
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['HTTP_REFERER'] = 'https://example.com';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['HTTP_REFERER'] = 'https://example.net';
|
||||
$_SERVER['REQUEST_URI'] = '/excluded/page/';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REQUEST_URI'] = '/normal/page/';
|
||||
$_SERVER['REMOTE_ADDR'] = '192.0.2.123';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REMOTE_ADDR'] = '192.0.2.234';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user