Skip to content

Commit

Permalink
fix: add manually marked reason again
Browse files Browse the repository at this point in the history
  • Loading branch information
florianbrinkmann committed Jul 23, 2023
1 parent c3f760b commit 7a1e0ed
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Handlers/PluginUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private static function maybe_update_database() {
'<'
) ) {
// Update options (we migrate to a new option name `antispam_bee_options` in this release).
$options = get_option( 'antispam_bee' );
$options = get_option( 'antispam_bee', [] );

$allowed_languages = self::convert_multiselect_values( $options['translate_lang'] ?? [] );

Expand Down
6 changes: 4 additions & 2 deletions src/Handlers/Reaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ public static function init() {
1
);

add_action( 'transition_comment_status', [ __CLASS__, 'handle_comment_status_changes' ], 10, 3 );

// Add our manual spam reason to the list of reasons.
add_filter( 'antispam_bee_additional_spam_reasons', function ( $reasons ) {
$reasons['asb-marked-manually'] = __( 'Manually', 'antispam-bee' );
return $reasons;
} );
}

public static function always_init() {
add_action( 'transition_comment_status', [ __CLASS__, 'handle_comment_status_changes' ], 10, 3 );
}

public static function process( $reaction ) {
// phpcs:enable WordPress.Security.NonceVerification.Missing
$rules = new Rules( static::$type );
Expand Down
31 changes: 18 additions & 13 deletions src/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use AntispamBee\GeneralOptions\Uninstall;
use AntispamBee\Handlers\Comment;
use AntispamBee\Handlers\PluginStateChangeHandler;
use AntispamBee\Handlers\PluginUpdate;
use AntispamBee\Handlers\Linkback;
use AntispamBee\Helpers\Settings;
use AntispamBee\Helpers\SpamReasonTextHelper;
Expand All @@ -43,18 +42,8 @@
* Init function of the plugin
*/
function init() {
$disallow_ajax = apply_filters( 'antispam_bee_disallow_ajax_calls', true );

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

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

// Construct all modules to initialize.
$modules = array(
$modules = [
DashboardWidgets::class,
new SettingsPage(),
CommentsColumns::class,
Expand Down Expand Up @@ -88,10 +77,26 @@ function init() {
LinkbackFromMyself::class,
LinkbackPostTitleIsBlogName::class,
ValidGravatar::class,
);
];

$disallow_ajax = apply_filters( 'antispam_bee_disallow_ajax_calls', true );

$is_ajax_call = defined( 'DOING_AJAX' ) && DOING_AJAX;

// Initialize all modules.
foreach ( $modules as $module ) {
if ( is_callable( [ $module, 'always_init' ] ) ) {
call_user_func( [ $module, 'always_init' ] );
}

if ( $is_ajax_call && $disallow_ajax ) {
continue;
}

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

if ( is_callable( [ $module, 'init' ] ) ) {
call_user_func( [ $module, 'init' ] );
}
Expand Down

0 comments on commit 7a1e0ed

Please sign in to comment.