Skip to content

Fix: The boolean attributes of wp_audio_shortcode#7611

Closed
Debarghya-Banerjee wants to merge 7 commits intoWordPress:trunkfrom
Debarghya-Banerjee:fix/boolean-attributes-of-wp_audio_shortcode
Closed

Fix: The boolean attributes of wp_audio_shortcode#7611
Debarghya-Banerjee wants to merge 7 commits intoWordPress:trunkfrom
Debarghya-Banerjee:fix/boolean-attributes-of-wp_audio_shortcode

Conversation

@Debarghya-Banerjee
Copy link

Trac Ticket : Core-61515

Overview

  • This pull request introduces updates to the wp_audio_shortcode function to enhance the handling of boolean attributes and the preload attribute in accordance with HTML5 standards. These changes aim to ensure that the generated audio elements are more compliant with modern web practices.

Changes Made

  • Boolean Attributes Handling

    • The loop, autoplay, and muted attributes are now output without values when their respective conditions are met. This aligns with HTML5 standards where these attributes can be treated as boolean.
  • Preload Attribute

    • The preload attribute has been updated to accept only specific allowed values: none, metadata, and auto. If a value outside of this list is provided, it will be ignored, preventing invalid attribute outputs.
  • Code Improvements

    • Enhanced readability and maintainability of the code, including better organization of attribute handling and validation.

Benefits

  • Improves compliance with HTML5 standards for audio elements.

  • Ensures cleaner and more efficient HTML output.

  • Enhances user experience by properly managing audio attributes based on their intended use.

Testing:

  • All existing tests related to audio shortcode rendering have been updated to validate the new behavior of boolean attributes and the preload attribute.

  • This pull request aims to improve the functionality and reliability of audio embeds in WordPress while adhering to current web standards.

@github-actions
Copy link

github-actions bot commented Oct 22, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props debarghyabanerjee, joedolson, apermo, audrasjb.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@Debarghya-Banerjee
Copy link
Author

Hi @joedolson , Can you please take a look into this PR. Thanks.

Copy link

@apermo apermo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, besides the suggested improvement for the variable names in the foreach()

@joedolson joedolson self-requested a review January 27, 2025 20:12
Copy link
Contributor

@joedolson joedolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good; one minor tweak to escaping.

@Debarghya-Banerjee
Copy link
Author

Hi @joedolson , I have addressed the feedback.

@audrasjb
Copy link
Contributor

Similarly to ticket 60178, I can confirm this PR also handle well the related attributes when using the [audio] shortcode.

@joedolson joedolson dismissed their stale review March 16, 2025 18:39

Obsolete

@joedolson
Copy link
Contributor

This was fixed in https://core.trac.wordpress.org/changeset/59987

@joedolson joedolson closed this Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants