Making WordPress.org

Changeset 13635


Ignore:
Timestamp:
05/01/2024 12:38:08 AM (5 months ago)
Author:
dd32
Message:

Support Forums: Don't apply the <li> improper HTML fixes to block content.

With support forum posts being written with the block editor, invalid HTML is much less likely now.

This tries removing the list item fixes from block posts.

See #20.
Fixes #7618.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php

    r13608 r13635  
    12011201 */
    12021202function wporg_support_wrap_standalone_li_tags_in_ul( $content ) {
     1203    remove_filter( current_filter(), 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
     1204
    12031205    // No lists? No worries.
    12041206    if ( false === stripos( $content, '<li>' ) ) {
     
    12511253    return $content;
    12521254}
    1253 add_filter( 'bbp_get_topic_content', 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
    1254 add_filter( 'bbp_get_reply_content', 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
     1255
     1256/**
     1257 * Maybe wrap standalone <li> tags in <ul> tags.
     1258 * This only wraps non-block-posts.
     1259 *
     1260 * @see https://meta.trac.wordpress.org/ticket/7618
     1261 */
     1262function wporg_support_maybe_wrap_standalone_li_tags_in_ul( $content ) {
     1263    // If it's not a block post, we'll need to filter it after all transforms.
     1264    if ( ! has_blocks( $content ) ) {
     1265        add_filter( current_filter(), 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
     1266    }
     1267
     1268    return $content;
     1269}
     1270add_filter( 'bbp_get_topic_content', 'wporg_support_maybe_wrap_standalone_li_tags_in_ul', 1 );
     1271add_filter( 'bbp_get_reply_content', 'wporg_support_maybe_wrap_standalone_li_tags_in_ul', 1 );
    12551272
    12561273/**
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

    r13168 r13635  
    863863 */
    864864function wporg_support_wrap_standalone_li_tags_in_ul( $content ) {
     865    remove_filter( current_filter(), 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
     866
    865867    // No lists? No worries.
    866868    if ( false === stripos( $content, '<li>' ) ) {
     
    913915    return $content;
    914916}
    915 add_filter( 'bbp_get_topic_content', 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
    916 add_filter( 'bbp_get_reply_content', 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
     917
     918/**
     919 * Maybe wrap standalone <li> tags in <ul> tags.
     920 * This only wraps non-block-posts.
     921 *
     922 * @see https://meta.trac.wordpress.org/ticket/7618
     923 */
     924function wporg_support_maybe_wrap_standalone_li_tags_in_ul( $content ) {
     925    // If it's not a block post, we'll need to filter it after all transforms.
     926    if ( ! has_blocks( $content ) ) {
     927        add_filter( current_filter(), 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
     928    }
     929
     930    return $content;
     931}
     932add_filter( 'bbp_get_topic_content', 'wporg_support_maybe_wrap_standalone_li_tags_in_ul', 1 );
     933add_filter( 'bbp_get_reply_content', 'wporg_support_maybe_wrap_standalone_li_tags_in_ul', 1 );
    917934
    918935/**
Note: See TracChangeset for help on using the changeset viewer.