From c7695e1c24901b695e1d3af3967e65e22c1e91f9 Mon Sep 17 00:00:00 2001 From: AntonV1211 Date: Fri, 22 May 2026 16:32:07 +0700 Subject: [PATCH] Fix. Code. Bug fixes after WP 7.0 update --- cleantalk.php | 21 ++++++++------------- lib/Cleantalk/Common/Enqueue/Enqueue.php | 3 +++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cleantalk.php b/cleantalk.php index 557a0a248..c2298dd96 100644 --- a/cleantalk.php +++ b/cleantalk.php @@ -2132,18 +2132,11 @@ function apbct_rc__install_plugin($_wp = null, $plugin = null) } else { die('FAIL ' . json_encode(array('error' => $installer->apbct_result))); } - } elseif ( $result instanceof \WP_Error ) { - die( - 'FAIL ' . json_encode(array( - 'error' => 'FAIL_TO_GET_LATEST_VERSION', - 'details' => $result->get_error_message(), - )) - ); } else { die( 'FAIL ' . json_encode(array( 'error' => 'FAIL_TO_GET_LATEST_VERSION', - 'details' => 'Unknown error', + 'details' => $result->get_error_message(), )) ); } @@ -2177,16 +2170,18 @@ function apbct_rc__activate_plugin($plugin) $result = activate_plugins($plugin); $result_array = array('success' => true); - $error_msg = ''; - if ( ! $result || is_wp_error($result) ) { - if ( $result instanceof \WP_Error ) { - $error_msg = ' ' . $result->get_error_message(); - } + if ( is_wp_error($result) ) { + $error_msg = ' ' . $result->get_error_message(); $result_array = array( 'error' => 'FAIL_TO_ACTIVATE', 'details' => $error_msg ); + } elseif ( ! $result ) { + $result_array = array( + 'error' => 'FAIL_TO_ACTIVATE', + 'details' => '' + ); } return $result_array; } else { diff --git a/lib/Cleantalk/Common/Enqueue/Enqueue.php b/lib/Cleantalk/Common/Enqueue/Enqueue.php index 62f839622..3ac0a79e3 100644 --- a/lib/Cleantalk/Common/Enqueue/Enqueue.php +++ b/lib/Cleantalk/Common/Enqueue/Enqueue.php @@ -74,6 +74,9 @@ private function load($data) if (is_null($data)) { throw new \Exception(__('Data DTO is invalid', 'cleantalk-spam-protect')); } + if ($data->handle === '') { + throw new \Exception(__('Script handle is empty.', 'cleantalk-spam-protect')); + } $this->handles_to_register = array_merge($this->handles_to_register, array($data->handle)); // any must have a type if ($this->type === 'css') {