Make WordPress Core

Changeset 42694


Ignore:
Timestamp:
02/11/2018 03:39:20 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Media: After [42693], update HTML4 markup in img_caption_shortcode() to avoid an empty ID attribute as well.

Add a unit test for aria-describedby in img_caption_shortcode().

See #34595.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r42693 r42694  
    16241624            str_replace( '<img ', '<img ' . $describedby, do_shortcode( $content ) ),
    16251625            sprintf(
    1626                 '<p id="%s" class="wp-caption-text">%s</p>',
     1626                '<p %sclass="wp-caption-text">%s</p>',
    16271627                $atts['caption_id'],
    16281628                $atts['caption']
  • trunk/tests/phpunit/tests/media.php

    r42343 r42694  
    213213        $this->assertEquals( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) );
    214214        $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) );
     215    }
     216
     217    /**
     218     * @ticket 34595
     219     */
     220    function test_img_caption_shortcode_has_aria_describedby() {
     221        $result = img_caption_shortcode(
     222            array(
     223                'width' => 20,
     224                'id'    => 'myId',
     225            ),
     226            $this->img_content . $this->html_content
     227        );
     228
     229        $this->assertEquals( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) );
    215230    }
    216231
Note: See TracChangeset for help on using the changeset viewer.