Changeset 59987 for trunk/src/wp-includes/media.php
- Timestamp:
- 03/16/2025 06:49:39 PM (8 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/media.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r59955 r59987 3346 3346 * 3347 3347 * @since 3.6.0 3348 * @since 6.8.0 Added the 'muted' attribute. 3348 3349 * 3349 3350 * @param array $attr { … … 3353 3354 * @type string $loop The 'loop' attribute for the `<audio>` element. Default empty. 3354 3355 * @type string $autoplay The 'autoplay' attribute for the `<audio>` element. Default empty. 3356 * @type string $muted The 'muted' attribute for the `<audio>` element. Default 'false'. 3355 3357 * @type string $preload The 'preload' attribute for the `<audio>` element. Default 'none'. 3356 3358 * @type string $class The 'class' attribute for the `<audio>` element. Default 'wp-audio-shortcode'. … … 3391 3393 'loop' => '', 3392 3394 'autoplay' => '', 3395 'muted' => 'false', 3393 3396 'preload' => 'none', 3394 3397 'class' => 'wp-audio-shortcode', … … 3470 3473 'loop' => wp_validate_boolean( $atts['loop'] ), 3471 3474 'autoplay' => wp_validate_boolean( $atts['autoplay'] ), 3475 'muted' => wp_validate_boolean( $atts['muted'] ), 3472 3476 'preload' => $atts['preload'], 3473 3477 'style' => $atts['style'], … … 3475 3479 3476 3480 // These ones should just be omitted altogether if they are blank. 3477 foreach ( array( 'loop', 'autoplay', 'preload' ) as $a ) {3481 foreach ( array( 'loop', 'autoplay', 'preload', 'muted' ) as $a ) { 3478 3482 if ( empty( $html_atts[ $a ] ) ) { 3479 3483 unset( $html_atts[ $a ] ); … … 3483 3487 $attr_strings = array(); 3484 3488 3485 foreach ( $html_atts as $k => $v ) { 3486 $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; 3489 foreach ( $html_atts as $attribute_name => $attribute_value ) { 3490 if ( in_array( $attribute_name, array( 'loop', 'autoplay', 'muted' ), true ) && true === $attribute_value ) { 3491 // Add boolean attributes without a value. 3492 $attr_strings[] = esc_attr( $attribute_name ); 3493 } elseif ( 'preload' === $attribute_name && ! empty( $attribute_value ) ) { 3494 // Handle the preload attribute with specific allowed values. 3495 $allowed_preload_values = array( 'none', 'metadata', 'auto' ); 3496 if ( in_array( $attribute_value, $allowed_preload_values, true ) ) { 3497 $attr_strings[] = sprintf( '%s="%s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); 3498 } 3499 } else { 3500 // For other attributes, include the value. 3501 $attr_strings[] = sprintf( '%s="%s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); 3502 } 3487 3503 } 3488 3504
Note: See TracChangeset
for help on using the changeset viewer.