Making WordPress.org


Ignore:
Timestamp:
08/09/2016 10:52:06 PM (9 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.

File:
1 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>/',
Note: See TracChangeset for help on using the changeset viewer.