Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter to allow ajax calls #355

Merged
merged 4 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
composer.lock
/vendor/
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
script: ./bin/behat.sh
- stage: behat
php: '7.2'
env: WORDPRESS_VERSION=5.4
script: ./bin/behat.sh
- stage: behat
php: '7.0'
env: WORDPRESS_VERSION=5.3
script: ./bin/behat.sh
- stage: behat
Expand Down
8 changes: 7 additions & 1 deletion antispam_bee.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ public static function init() {
)
);

if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ) {
$disallow_ajax = apply_filters( 'antispam_bee_disallow_ajax_calls', true );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer using the positive phrasing: $allow_ajax = apply_filters( 'antispam_bee_allow_ajax_calls', false );

It might be confusing to use true to disable something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was easier to make it this way, but I get your point.

My second thought was, "true" for default seems better than false. But I'm fine with changing the logic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also valid... I approved it, because it is really a personal thing...


if ( defined( 'DOING_AJAX' ) && DOING_AJAX && $disallow_ajax ) {
return;
}

if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
"wp-coding-standards/wpcs": "^0.14.1",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4"
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"composer/package-versions-deprecated": "^1.11"
},
"autoload-dev": {
"classmap": [
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/Behat/filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Feature: Filter settings
Given I am on "/wp-admin/edit-comments.php"
Then I should see "Monty"
Then I check "cb-select-all-1"
Then I select "Mark as Spam" from "bulk-action-selector-top"
Then I select "spam" from "bulk-action-selector-top"
Then I press "doaction"

Given I am an anonymous user
Expand Down