Making WordPress.org

Changeset 3796


Ignore:
Timestamp:
08/09/2016 10:52:06 PM (8 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Use a better approach to preventing fix_unintended_markdown() from running against explanations.

  • Revert [1914].
  • In get_explanation_field(), don't run value through 'the_content' filter. It's not applicable for all fields. And post_content is already passed through the filter in the template prior to display (thus this also prevents double-filtering).
  • Temporarily unhook fix_unintended_markdown() from 'the_content' filter when outputting the explanation content.
  • Hook 'the_content' for fix_unintended_markdown() at a priority of 1. Also, it's a filter, not an action.

See #1250.

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

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/formatting.php

    r3785 r3796  
    2222     */
    2323    public static function do_init() {
     24        // NOTE: This filtering is temporarily disabled and then restored in
     25        // reference/template-explanation.php
     26        add_filter( 'the_content', array( __CLASS__, 'fix_unintended_markdown' ), 1 );
     27
    2428        add_filter( 'the_excerpt', array( __CLASS__, 'lowercase_P_dangit_just_once' ) );
    2529        add_filter( 'the_content', array( __CLASS__, 'make_doclink_clickable' ), 10, 5 );
     
    3438
    3539        add_filter( 'devhub-format-description', array( __CLASS__, 'fix_param_hash_formatting' ), 9 );
    36         add_action( 'the_content', array( __CLASS__, 'fix_unintended_markdown' ) );
    3740
    3841        add_filter( 'devhub-function-return-type', array( __CLASS__, 'autolink_references' ) );
     
    205208    public static function fix_unintended_markdown( $content, $post_type = null ) {
    206209        // Only apply to parsed content that have the em tag.
    207         if ( DevHub\is_parsed_post_type( $post_type )
    208             && false !== strpos( $content, '<em>' )
    209             && false === strpos( $content, '<p>' )
    210         ) {
     210        if ( DevHub\is_parsed_post_type( $post_type ) && false !== strpos( $content, '<em>' ) ) {
    211211            $content = preg_replace_callback(
    212212                '/([^\s])<em>(.+)<\/em>/',
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r3753 r3796  
    13281328        }
    13291329
    1330         $post_field = get_post_field( $field, $explanation, $context );
    1331 
    1332         return apply_filters( 'the_content', apply_filters( 'get_the_content', $post_field ) );
     1330        return get_post_field( $field, $explanation, $context );
    13331331    }
    13341332
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/reference/template-explanation.php

    r3660 r3796  
    1717        <?php
    1818        // Output the explanation. Passed through 'the_content' on retrieval, thus no escaping.
     19        remove_filter( 'the_content', array( 'DevHub_Formatting', 'fix_unintended_markdown' ), 1 );
    1920        echo apply_filters( 'the_content', apply_filters( 'get_the_content', $explanation ) );
     21        add_filter( 'the_content', array( 'DevHub_Formatting', 'fix_unintended_markdown' ), 1 );
    2022        ?>
    2123    </section>
Note: See TracChangeset for help on using the changeset viewer.