Changeset 42704 for trunk/src/wp-includes/media.php
- Timestamp:
- 02/12/2018 09:36:36 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r42697 r42704 1494 1494 * parameter and the content parameter values. 1495 1495 * 1496 * The supported attributes for the shortcode are 'id', ' align', 'width', and1497 * ' caption'.1496 * The supported attributes for the shortcode are 'id', 'caption_id', 'align', 1497 * 'width', 'caption', and 'class'. 1498 1498 * 1499 1499 * @since 2.6.0 1500 * @since 3.9.0 The `class` attribute was added. 1501 * @since 5.0.0 The `caption_id` attribute was added. 1500 1502 * 1501 1503 * @param array $attr { 1502 1504 * Attributes of the caption shortcode. 1503 1505 * 1504 * @type string $id ID of the div element for the caption. 1505 * @type string $align Class name that aligns the caption. Default 'alignnone'. Accepts 'alignleft', 1506 * 'aligncenter', alignright', 'alignnone'. 1507 * @type int $width The width of the caption, in pixels. 1508 * @type string $caption The caption text. 1509 * @type string $class Additional class name(s) added to the caption container. 1506 * @type string $id ID of the image and caption container element, i.e. <figure> or <div>. 1507 * @type string $caption_id ID of the caption element, i.e. <figcaption> or <p>. 1508 * @type string $align Class name that aligns the caption. Default 'alignnone'. Accepts 'alignleft', 1509 * 'aligncenter', alignright', 'alignnone'. 1510 * @type int $width The width of the caption, in pixels. 1511 * @type string $caption The caption text. 1512 * @type string $class Additional class name(s) added to the caption container. 1510 1513 * } 1511 1514 * @param string $content Shortcode content. … … 1559 1562 1560 1563 if ( $atts['id'] ) { 1561 $att_id = esc_attr( sanitize_html_class( $atts['id'] ) ); 1562 $atts['id'] = 'id="' . $att_id . '" '; 1563 1564 if ( ! $atts['caption_id'] ) { 1565 $atts['caption_id'] = 'caption-' . str_replace( '_', '-', $att_id ); 1566 } 1564 $atts['id'] = sanitize_html_class( $atts['id'] ); 1565 $id = 'id="' . esc_attr( $atts['id'] ) . '" '; 1566 } 1567 1568 if ( $atts['caption_id'] ) { 1569 $atts['caption_id'] = sanitize_html_class( $atts['caption_id'] ); 1570 } elseif ( $atts['id'] ) { 1571 $atts['caption_id'] = 'caption-' . str_replace( '_', '-', $atts['id'] ); 1567 1572 } 1568 1573 … … 1570 1575 1571 1576 if ( $atts['caption_id'] ) { 1572 $ describedby = 'aria-describedby="' . $atts['caption_id']. '" ';1573 $ atts['caption_id'] = 'id="' . $atts['caption_id']. '" ';1577 $caption_id = 'id="' . esc_attr( $atts['caption_id'] ) . '" '; 1578 $describedby = 'aria-describedby="' . esc_attr( $atts['caption_id'] ) . '" '; 1574 1579 } 1575 1580 … … 1605 1610 $html = sprintf( 1606 1611 '<figure %s%s%sclass="%s">%s%s</figure>', 1607 $ atts['id'],1612 $id, 1608 1613 $describedby, 1609 1614 $style, … … 1612 1617 sprintf( 1613 1618 '<figcaption %sclass="wp-caption-text">%s</figcaption>', 1614 $ atts['caption_id'],1619 $caption_id, 1615 1620 $atts['caption'] 1616 1621 ) … … 1619 1624 $html = sprintf( 1620 1625 '<div %s%sclass="%s">%s%s</div>', 1621 $ atts['id'],1626 $id, 1622 1627 $style, 1623 1628 esc_attr( $class ), … … 1625 1630 sprintf( 1626 1631 '<p %sclass="wp-caption-text">%s</p>', 1627 $ atts['caption_id'],1632 $caption_id, 1628 1633 $atts['caption'] 1629 1634 )
Note: See TracChangeset
for help on using the changeset viewer.