WordPress.org

Making WordPress.org

Ticket #20: meta-20.patch

File meta-20.patch, 1.5 KB (added by SergeyBiryukov, 5 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

     
    389389add_filter( 'bbp_get_topic_edit_url', 'wporg_support_fix_pending_posts_reply_url', 10, 2 );
    390390add_filter( 'bbp_get_reply_edit_url', 'wporg_support_fix_pending_posts_reply_url', 10, 2 );
    391391
     392/**
     393 * Prevent standalone <li> tags from breaking the theme layout.
     394 *
     395 * If a <li> tag is not preceded by <ul> or <ol>, prepend it with <ul>
     396 * and let force_balance_tags() do the rest.
     397 *
     398 * @see https://meta.trac.wordpress.org/ticket/20
     399 *
     400 * @param string $content Topic or reply content.
     401 * @return string Filtered content.
     402 */
     403function wporg_support_wrap_standalone_li_tags_in_ul( $content ) {
     404        if ( false !== strpos( $content, '<li>' ) ) {
     405                $content = preg_replace( '#(?<!<ul>\s|<ol>\s)<li>#', '<ul><li>', $content );
     406                $content = force_balance_tags( $content );
     407        }
    392408
     409        return $content;
     410}
     411add_filter( 'bbp_get_topic_content', 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
     412add_filter( 'bbp_get_reply_content', 'wporg_support_wrap_standalone_li_tags_in_ul', 50 );
     413
     414
    393415/** bb Base *******************************************************************/
    394416
    395417function bb_base_search_form() {