Open
Conversation
Reviewer's GuideAdds textarea-aware support to the text formatting helper by introducing a has_textarea option that switches escaping to wp_kses_post and applies wpautop when appropriate, and updates paragraph styles so block-style classes applied on a wrapper div correctly style wpautop-generated tags. Sequence diagram for textarea rendering with has_textarea in the_text helpersequenceDiagram
actor Editor
participant WordPress
participant TextHelper as TextHelper_get_the_text
participant EscapeHelper as escape_content_value
participant wpautop
participant Browser
Editor->>WordPress: Save post with textarea content
WordPress-->>WordPress: Store content in database
Editor->>WordPress: View post on frontend
WordPress->>TextHelper: get_the_text(value, {has_textarea:true, before:"<div>", after:"</div>"})
TextHelper-->>TextHelper: wp_parse_args with defaults
TextHelper-->>TextHelper: apply_filters(bea_theme_framework_text_settings)
alt has_textarea true and escape is esc_html
TextHelper-->>TextHelper: Set escape to wp_kses_post
end
TextHelper->>EscapeHelper: escape_content_value(value, escape)
EscapeHelper-->>TextHelper: escaped_value
alt has_textarea true
TextHelper->>wpautop: wpautop(escaped_value)
wpautop-->>TextHelper: paragraph_wrapped_value
else has_textarea false
TextHelper-->>TextHelper: keep escaped_value
end
TextHelper-->>TextHelper: apply_filters(bea_theme_framework_text_value)
TextHelper-->>WordPress: before + value + after
WordPress-->>Browser: Render HTML
Browser-->>Editor: Display formatted paragraphs without double br
Class diagram for text helper settings with has_textarea supportclassDiagram
class TextHelper {
+the_text(value string, settings array) void
+get_the_text(value string, settings array) string
}
class TextSettings {
+before string
+after string
+escape string
+has_textarea bool
}
class EscapeHelper {
+escape_content_value(value string, escape_callback string) string
}
class WordPressFilters {
+bea_theme_framework_text_settings(settings array, value string) array
+bea_theme_framework_text_value(value string, settings array) string
}
class WordPressFormatting {
+wpautop(value string) string
+wp_kses_post(value string) string
+esc_html(value string) string
}
TextHelper ..> TextSettings : uses
TextHelper ..> EscapeHelper : calls
TextHelper ..> WordPressFilters : applies
TextHelper ..> WordPressFormatting : may call
TextSettings : before = ""
TextSettings : after = ""
TextSettings : escape = "esc_html"
TextSettings : has_textarea = false
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new SCSS rule targets all
div.is-style-*globally; consider scoping this under the relevant block/container (e.g..wp-block-paragraphor a theme wrapper) to avoid unintentionally styling unrelateddivelements elsewhere on the site. - The
$has_textareaflag name doesn’t clearly reflect the behavior (switching escape towp_kses_postand applyingwpautop); consider renaming it to something liketextarea_formatting/use_wpautopto make its effect more self-explanatory at call sites.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new SCSS rule targets all `div.is-style-*` globally; consider scoping this under the relevant block/container (e.g. `.wp-block-paragraph` or a theme wrapper) to avoid unintentionally styling unrelated `div` elements elsewhere on the site.
- The `$has_textarea` flag name doesn’t clearly reflect the behavior (switching escape to `wp_kses_post` and applying `wpautop`); consider renaming it to something like `textarea_formatting` / `use_wpautop` to make its effect more self-explanatory at call sites.
## Individual Comments
### Comment 1
<location path="src/scss/06-blocks/core/_paragraph.scss" line_range="20-16" />
<code_context>
}
+
+// For paragraphs generated by wpautop function (eg. excerpts), paragraphs are wrapped in a div with the class "is-style-large" for example. We need to apply the text style to the p elements inside the div.
+div {
+ @each $style in $paragraphs {
+ &.is-style-#{$style} {
+ & > p:where(:not([class*="is-style-"])) {
+ @include text(#{$style});
+ }
+ }
+ }
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** The global `div` selector may apply paragraph styles far beyond the intended context.
This selector affects every `div.is-style-*` on the page, not just paragraph wrappers, so any container with an `is-style-*` class will style its direct `p` children as paragraphs. Please scope this to the specific block/wrapper you expect (e.g. a particular `.wp-block-*` parent) instead of all `div` elements.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pour faire suite àa la discussion : https://beapi.slack.com/archives/C02UL029WJC/p1772033049807879?thread_ts=1772032428.453569&cid=C02UL029WJC
Ajout du support de
wpautopdans le Helperthe_text(Utilie dans cas d'utilisation des textarea)https://developer.wordpress.org/reference/functions/wpautop/
Son rôle principal : La conversion automatique
L'objectif de
wpautop()dans notre cas est d'éviter les doubles<br>qui provoquerait une non conformité A11Y.Elle analyse une chaîne de caractères et applique ces transformations :
<p>...</p>.<br />.Ajouts :
has_textarea(nom à définir) par défaut àfalsehas_textareaàfalse(défaut) : inchangé —esc_htmlpar défaut, pas dewpautophas_textareaàtrue: si l'escape vaut encoreesc_html(défaut), il est remplacé parwp_kses_post, puiswpautop()sur la chaîne déjà assainiehas_textareaàtrue+ escape personnalisé (ex.wp_kses_postou une autre fonction) : ton escape est respecté, pas de substitution.car nous n'avons pas la main sur les éléments` générés
Exemples pour afficher le texte d'un textarea en conservant les sauts de lignes
Par exemple l'extrait d'une page ou d'un article, ou un champ ACF textarea :
Avec
nl2br:Caution
Non forme au RGAA car nous avons des doubles
<br>.Avec
wpautopet le nouveau paramètre :Note
Conforme au RGAA.
On pourrait très bien écrire comme cela nativement avec la fonction existante :
Summary by Sourcery
Add textarea-aware formatting support to the text helper and align paragraph styles for wpautop-generated content.
New Features:
Enhancements:
Note
Medium Risk
Changes output escaping/markup behavior when
has_textareais enabled, which can affect rendered HTML and sanitization expectations. Also updates paragraph styling selectors to account forwpautop-generated markup, with moderate risk of CSS regressions.Overview
Adds an opt-in
has_textareasetting toget_the_text()/the_text()to better render textarea-like content: if enabled, the helper switches the default escape fromesc_htmltowp_kses_post(only when still default) and runswpautop()after escaping.Updates paragraph SCSS so paragraph text styles also apply when
wpautop()wraps generated<p>tags inside a parentdiv.is-style-*(e.g., excerpts), by targeting childpelements without their ownis-style-*class.Written by Cursor Bugbot for commit 841ae37. This will update automatically on new commits. Configure here.