Make WordPress Core

Ticket #12061: 12061.4.diff

File 12061.4.diff, 1.8 KB (added by aaroncampbell, 9 years ago)
  • src/wp-includes/formatting.php

    diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
    index 44376e5..b1f997f 100644
    function shortcode_unautop( $pee ) { 
    486486                return $pee;
    487487        }
    488488
    489         $tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) );
     489        /**
     490         * Filter the list of shortcodes to run through the 'unautop' routine.
     491         *
     492         * @since 4.1.0
     493         *
     494         * @param array $shortcode_tags Shortcode tags to run through the 'unautop' routine.
     495         */
     496        $unautop_shortcode_tags = apply_filters( 'unautop_shortcodes', array_keys( $shortcode_tags ) );
     497
     498        $tagregexp = join( '|', array_map( 'preg_quote', $unautop_shortcode_tags ) );
    490499        $spaces = wp_spaces_regexp();
    491500
    492501        $pattern =
  • tests/phpunit/tests/shortcode.php

    diff --git tests/phpunit/tests/shortcode.php tests/phpunit/tests/shortcode.php
    index 7e8b971..8ead9f2 100644
    EOF; 
    407407                $this->assertTrue( has_shortcode( $content_nested, 'gallery' ) );
    408408                remove_shortcode( 'foo' );
    409409        }
     410
     411        /**
     412         * @ticket 12061
     413         */
     414        function test_unautop_shortcodes_filter() {
     415                // trim() is necessary because the shortcode_unautop(wpautop()) combo causes whitespace that we don't care about
     416                $this->assertEquals( '_shortcode_hyphen', trim( do_shortcode( shortcode_unautop( wpautop( '[hyphen]' ) ) ) ) );
     417                // Filter 'hyphen' out of the shortcodes that are unautop'd and test again
     418                add_filter( 'unautop_shortcodes', array( $this, '_shortcode_unautop_filter' ) );
     419                $this->assertEquals( '<p>_shortcode_hyphen</p>', trim( do_shortcode( shortcode_unautop( wpautop( '[hyphen]' ) ) ) ) );
     420        }
     421
     422        function _shortcode_unautop_filter( $shortcodes ) {
     423                return array_diff( $shortcodes, array( 'hyphen' ) );
     424        }
    410425}