-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wp_audio_shortcode() outputs invalid HTML #6917
base: trunk
Are you sure you want to change the base?
wp_audio_shortcode() outputs invalid HTML #6917
Conversation
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Hi @shubham07kb The PR looks good to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like all this is doing is generating an HTML <audio>
tag. What if instead of sticking with the old pattern and adjusting it for a very specific purpose, we replaced the generation with the use of the HTML API/
Is it correct that these values are the PHP boolean values true
? If so, the HTML API will add them as boolean attributes, or if they are false
, will automatically not add them.
$audio_tag_builder = new WP_HTML_Tag_Processor( '<audio controls>' );
$audio_tag_builder->next_tag();
foreach ( $html_attrs as $name => $value ) {
$audio_tag_builder->set_attribute( $name, $value );
}
$html .= $audio_tag_builder->get_updated_html();
Hi @dmsnell , |
@shubham07kb there are some existing tests for this in I guess it's worth stating that the boolean attributes with a value of |
wp_audio_shortcode() was chaging boolean attributes to 1, as of true === 1, in debug i notice it was directly happening after foreach, not by eascaping, so I have add a if statement to handle boolean attributes and directly pass our key, as Key can be directly work for boolean attributes in HTML.
Trac Ticket: https://core.trac.wordpress.org/ticket/61515