Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (42.10%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## fix #842 +/- ##
============================================
+ Coverage 27.67% 27.72% +0.04%
Complexity 5899 5899
============================================
Files 283 283
Lines 24847 24920 +73
============================================
+ Hits 6877 6908 +31
- Misses 17970 18012 +42 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Introduces a new “Protection mode” setting that allows running the plugin in Full mode (assets on all pages) or Lite mode (assets only on a configured set of pages/URL patterns), and wires this into public asset loading and the admin settings UI.
Changes:
- Added new settings/state keys for
data__protection_modeanddata__protection_mode__urls, including UI fields and RemoteCalls labels. - Implemented page-matching logic (
apbct_is_assets_allowed_on_current_page()) and applied it to public script/style enqueueing and localization. - Added admin settings-page JS to show/hide the “Lite mode pages” textarea based on the selected mode (and updated the compiled minified asset).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/Cleantalk/ApbctWP/State.php | Adds default state values for protection mode and URL list. |
| lib/Cleantalk/ApbctWP/RemoteCalls.php | Exposes new settings labels via remote settings retrieval. |
| js/src/cleantalk-admin-settings-page.js | Adds UI behavior to hide/show the Lite-mode URL textarea. |
| js/cleantalk-admin-settings-page.min.js | Updates compiled admin settings JS output. |
| inc/cleantalk-settings.php | Adds settings definitions and sanitization/validation handling for the new URLs list. |
| inc/cleantalk-public.php | Gates public asset loading/localization by the new “assets allowed on current page” logic. |
| inc/cleantalk-common.php | Introduces URL/pattern matching helper to decide whether assets should load on the current page. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
inc/cleantalk-settings.php:2396
apbct_settings__validate()is called in some places with a partial settings array (e.g. onlyapikey, seeinc/cleantalk-admin.php:377). In that case, missing settings are filled from defaults; sincedata__protection_modeis not in$list_of_settings_to_keep, it can be unintentionally reset back to Full mode (0) even if the admin previously set Lite mode.
$list_of_settings_to_keep = array(
'data__email_decoder_encode_email_addresses',
'data__email_decoder_encode_phone_numbers',
'data__email_decoder_obfuscation_mode',
'data__email_decoder_obfuscation_custom_text',
'data__email_decoder_buffer',
'data__protection_mode__urls',
);
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
inc/cleantalk-common.php:582
apbct_protection_mode__pattern_matches()always attemptspreg_match()after the substring check, even for patterns that are clearly plain substrings. Since patterns are user-controlled and this runs on every page load, it’s cheaper to only run regex matching when the pattern actually looks like a regexp (same heuristic you already use during validation).
function apbct_protection_mode__pattern_matches($pattern, $url_haystack)
{
if ( stripos($url_haystack, $pattern) !== false ) {
return true;
}
return @preg_match(apbct_protection_mode__build_regexp($pattern), $url_haystack) === 1;
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
inc/cleantalk-settings.php:2490
- When an invalid regexp-like pattern is detected, the code currently reports an error but still leaves the (sanitized) value in
data__protection_mode__urls, so WordPress will still persist the invalid pattern(s). This differs from the existing exclusions validation (which clears invalid values) and can keep Lite mode broken until the admin manually fixes the field. Consider clearing the setting (or reverting to the previously saved value) when an invalid regexp is found so an invalid value is not stored.
if ( $invalid_pattern !== null ) {
task https://app.doboard.com/1/task/53898