Upd. ContactEncoder. Improve shortcode flow.#827
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request updates the ContactsEncoder shortcode/buffer pipeline so shortcode placeholders are handled more predictably (including in output-buffer mode), adds a dedicated shortcode-placeholder exclusion path, and expands unit coverage around paragraph wrapper preservation and decoder-pass cookie behavior.
Changes:
- Refactors buffer-mode flow to run shortcode placeholder preparation/finalization around
ContactsEncoder::modifyContent()and adjusts hook registrations/priorities. - Updates shortcode exclusion/encoding logic (including new
doReturnShortcodeContentBeforeModify()and resetting placeholder state after use). - Adds/updates tests for paragraph wrapper preservation, shutdown/buffer behavior, and decoder cookie scenarios.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ApbctWP/ContactsEncoder/TestContactsEncoderShortCodeEncode.php | Adds tests ensuring placeholders are used even when decoder cookie is set / global encoding disabled. |
| tests/ApbctWP/ContactsEncoder/TestContactsEncoder.php | Adds buffer-mode regression tests for <p> wrapper preservation and cookie-based encoding skip. |
| tests/ApbctWP/ContactsEncoder/Shortcodes/ExcludedEncodeContentSCTest.php | Updates tests to reflect shutdown-only behavior in buffer mode and adds coverage for using $apbct->buffer during shutdown. |
| lib/Cleantalk/ApbctWP/ContactsEncoder/Shortcodes/ShortCodesService.php | Adds buffer pre/post helpers and an encode-only “after modify” hook registration method. |
| lib/Cleantalk/ApbctWP/ContactsEncoder/Shortcodes/ExcludedEncodeContentSC.php | Restricts buffer-mode processing to shutdown and only falls back to $apbct->buffer when input content is empty. |
| lib/Cleantalk/ApbctWP/ContactsEncoder/Shortcodes/EncodeContentSC.php | Switches to WP ExclusionsService, uses shortcode-specific exclusions, and resets shortcode replacement state after restoration. |
| lib/Cleantalk/ApbctWP/ContactsEncoder/Exclusions/ExclusionsService.php | Adds decoder-pass cookie exclusion for global encoding and introduces shortcode-placeholder-specific exclusion method. |
| lib/Cleantalk/ApbctWP/ContactsEncoder/ContactsEncoder.php | Reworks buffer-mode hook wiring and routes buffer processing through ShortCodesService pre/post methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #827 +/- ##
============================================
+ Coverage 26.68% 26.97% +0.29%
- Complexity 5683 5820 +137
============================================
Files 270 278 +8
Lines 24260 24606 +346
============================================
+ Hits 6473 6637 +164
- Misses 17787 17969 +182 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
task https://app.doboard.com/1/task/36474