Skip to content

Docs: Update WP_HTML_Processor::class_list example to runnable snippet - #13034

Closed
sirreal wants to merge 4 commits into
WordPress:trunkfrom
sirreal:docs/add-runnable-docs-snippet
Closed

Docs: Update WP_HTML_Processor::class_list example to runnable snippet#13034
sirreal wants to merge 4 commits into
WordPress:trunkfrom
sirreal:docs/add-runnable-docs-snippet

Conversation

@sirreal

@sirrealsirreal commented Aug 13, 2026

Copy link
Copy Markdown
Member

The makes the ::class_list methods on WP_HTML_Tag_Processor and WP_HTML_Processor example snippets into runnable PHP snippets thanks to the WordPress PHP Playground.

This is achieved by using PHP interactive code fences:

```php
<?php plain code example
``````php interactive
<?php echo "This is interactive, expected output goes here";
``````expected-outputThis is interactive, expected output goes here```

A following expected-output code fence preloads the expected output so the demo can be viewed without needing to download and run WordPress Playground.

See WordPress/phpdoc-parser#258 and WordPress/wporg-developer#567.

This was discussed on the July 21 2026 dev chat and mentioned in a few relevant Slack channels (#core and #docs) and reception was positive.

Trac ticket: https://core.trac.wordpress.org/ticket/64896

Demo

Before

Static snapshot - including a small typo for the discerning reader!

Screenshot 2026-08-13 at 15 50 45

After

Interactive!

demo-running.mov

Use of AI Tools

None


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

Copy link
Copy Markdown

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

  • 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.

@sirreal
sirreal marked this pull request as ready for review August 13, 2026 11:53
@github-actions

Copy link
Copy Markdown

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 jonsurrell.

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

pento pushed a commit that referenced this pull request Aug 13, 2026
Converts the `WP_HTML_Processor::class_list()` and `WP_HTML_Tag_Processor::class_list()` examples to runnable WordPress Playground snippets. Corrects the encoded closing angle bracket so the expected output matches the parsed class name.
Developed in #13034.
Props jonsurrell.
See #64896.
git-svn-id: https://develop.svn.wordpress.org/trunk@63293 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Aug 13, 2026
Converts the `WP_HTML_Processor::class_list()` and `WP_HTML_Tag_Processor::class_list()` examples to runnable WordPress Playground snippets. Corrects the encoded closing angle bracket so the expected output matches the parsed class name.
Developed in WordPress/wordpress-develop#13034.
Props jonsurrell.
See #64896.
Built from https://develop.svn.wordpress.org/trunk@63293
git-svn-id: http://core.svn.wordpress.org/trunk@62486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@sirreal

Copy link
Copy Markdown
MemberAuthor

Merged in r63293.

@sirreal
sirreal deleted the docs/add-runnable-docs-snippet branch August 13, 2026 15:09
Comment on lines +5435 to +5436
* <?php
* require '/wordpress/wp-load.php';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Sign up for freeto 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.

3 participants

@sirreal@westonruter@adamziel