Skip to content

Commit

Permalink
fix(cloudflare): fixing bad calls to some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarshall511 committed Mar 7, 2024
1 parent 649bf3b commit d07c9d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions core/class-access.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ public function __construct() {
}

/**
* Fires after WordPress has finished loading but before any headers are sent.
* Initializes the class by setting up hooks and actions.
*
* This method is called during the WordPress initialization process. It
* registers the 'template_redirect' action to perform access checks and
* adds a filter for 'zerospam_access_checks' to determine if the current
* request should be blocked.
*/
public function init() {
if ( ! is_admin() && is_main_query() && self::process() ) {
Expand All @@ -48,7 +53,7 @@ public function init() {
* @param int $code Optional. The HTTP status code to be sent in the header.
* Defaults to 403 to indicate a Forbidden error.
*/
public static function die( $title, $message, $code = 403 ) {
public static function terminate_execution( $title, $message, $code = 403 ) {
header( 'Cache-Control: no-store, no-cache, must-revalidate, max-age=0' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
Expand Down Expand Up @@ -118,19 +123,12 @@ public function access_check() {
if ( ! empty( $settings['block_handler']['value'] ) ) {
switch ( $settings['block_handler']['value'] ) {
case 403:
add_action( 'send_headers', [ $this, 'prevent_cache_on_error_condition' ] );

$message = __( 'Your IP address has been blocked due to detected spam/malicious activity.', 'zero-spam' );
if ( ! empty( $settings['blocked_message']['value'] ) ) {
$message = $settings['blocked_message']['value'];
}
wp_die(
$message,
__( 'Blocked', 'zero-spam' ),
array(
'response' => 403,
)
);

self::terminate_execution( __( 'Blocked', 'zero-spam' ), $message );
break;
case 'redirect':
$url = 'https://wordpress.org/plugins/zero-spam/';
Expand Down
2 changes: 1 addition & 1 deletion modules/comments/class-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function preprocess_comments( $commentdata ) {
}
}

\ZeroSpam\Core\Access::die(
\ZeroSpam\Core\Access::terminate_execution(
\ZeroSpam\Core\Utilities::detection_title( 'comment_spam_message' ),
$error_message
);
Expand Down

0 comments on commit d07c9d0

Please sign in to comment.