Skip to:
Content

bbPress.org

Changeset 4640


Ignore:
Timestamp:
12/23/2012 01:44:46 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Improve the output of code between pre and code HTML tags. Fixes #1967.

Location:
trunk/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/common/kses.php

    r4606 r4640  
    8989    return wp_kses( $data , bbp_kses_allowed_tags() );
    9090}
     91
     92/** Formatting ****************************************************************/
     93
     94/**
     95 * Filter the content of topics and replies, and turn the value of pre and code
     96 * tags into entities where appropriate.
     97 *
     98 * @since bbPress (r4639)
     99 *
     100 * @param string $content
     101 * @return string
     102 */
     103function bbp_pre_code_tags( $content = '' ) {
     104    return preg_replace_callback( '/<pre.*?>(.*?)<\/pre>/imsu', '_bbp_pre_entities_callback', $content );
     105}
     106
     107/**
     108 * Callback used by bbp_pre_code_tags()
     109 *
     110 * @since bbPress (r4639)
     111 *
     112 * @internal Used by bbp_improve_pre_code_tags() to make code into entities
     113 *
     114 * @param string $matches
     115 * @return string
     116 */
     117function _bbp_pre_entities_callback( $matches = array() ) {
     118    return str_replace( $matches[1], htmlentities( $matches[1] ), $matches[0] );
     119}
  • trunk/includes/core/filters.php

    r4636 r4640  
    125125add_filter( 'bbp_get_reply_content', 'make_clickable',     9    );
    126126add_filter( 'bbp_get_reply_content', 'capital_P_dangit',   10   );
     127add_filter( 'bbp_get_reply_content', 'convert_smilies',    20   );
     128add_filter( 'bbp_get_reply_content', 'bbp_pre_code_tags',  25   );
    127129add_filter( 'bbp_get_reply_content', 'force_balance_tags', 25   );
    128 add_filter( 'bbp_get_reply_content', 'convert_smilies',    20   );
    129130add_filter( 'bbp_get_reply_content', 'wpautop',            30   );
    130131add_filter( 'bbp_get_reply_content', 'bbp_mention_filter', 40   );
     
    135136add_filter( 'bbp_get_topic_content', 'make_clickable',     9    );
    136137add_filter( 'bbp_get_topic_content', 'capital_P_dangit',   10   );
     138add_filter( 'bbp_get_topic_content', 'convert_smilies',    20   );
     139add_filter( 'bbp_get_topic_content', 'bbp_pre_code_tags',  25   );
    137140add_filter( 'bbp_get_topic_content', 'force_balance_tags', 25   );
    138 add_filter( 'bbp_get_topic_content', 'convert_smilies',    20   );
    139141add_filter( 'bbp_get_topic_content', 'wpautop',            30   );
    140142add_filter( 'bbp_get_topic_content', 'bbp_mention_filter', 40   );
Note: See TracChangeset for help on using the changeset viewer.