Make WordPress Core

Opened 3 months ago

Closed 3 months ago

Last modified 3 months ago

#59891 closed defect (bug) (fixed)

Incorrect example for WP_HTML_Tag_Processor class

Reported by: atachibana's profile atachibana Owned by: bernhard-reiter's profile Bernhard Reiter
Milestone: 6.4.2 Priority: normal
Severity: minor Version: 6.4
Component: HTML API Keywords: has-patch fixed-major
Focuses: docs Cc:

Description (last modified by sabernhardt)

This issue was originally reported as https://github.com/WordPress/Documentation-Issue-Tracker/issues/1362.

The examples in the documentation reference:
https://developer.wordpress.org/reference/classes/wp_html_tag_processor/#modifying-html-attributes-for-a-found-tag
using the class parameter to query for an existing class on a tag. But the source code and code function documentation actually only support the class_name property:
The example under Modifying HTML attributes for a found tag should be:

if ( $tags->next_tag( array( 'class_name' => 'wp-group-block' ) ) ) {

At least for me in WP 6.3.

Reported by @gaambo via User Contributed Notes.

Change History (10)

#1 @sabernhardt
3 months ago

  • Description modified (diff)
  • Focuses docs added

This ticket was mentioned in PR #5661 on WordPress/wordpress-develop by @dmsnell.


3 months ago
#2

  • Keywords has-patch added

Trac ticket: Core-59891
Resolves: https://github.com/WordPress/Documentation-Issue-Tracker/issues/1362

The example code in the PHPDoc comment for the HTML Tag Processor class previously showed calling next_tag() with an array containing a class key, which should have been class_name. This patch fixes this by using the appropriate class_name key.

Props: @gaambo, @crstauf, @atachibana

As a documentation change this should have no impact on any code and should need no testing.

#3 @audrasjb
3 months ago

  • Milestone changed from Awaiting Review to 6.5
  • Owner set to audrasjb
  • Status changed from new to accepted

Thanks for the report and PR. Self assigning for commit consideration.

#4 @Bernhard Reiter
3 months ago

  • Owner changed from audrasjb to Bernhard Reiter

Since this has been sitting for a while and I'm committing a few things right now anyway, I'm taking this over. Hope that's okay @audrasjb -- otherwise kindly let me know if I'm overstepping :)

#5 @Bernhard Reiter
3 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 57116:

HTML API: Fix typo in documentation example.

The example code in the PHPDoc comment for the HTML Tag Processor class
previously showed calling next_tag() with an array containing a class
key, which should have been class_name. This patch fixes this by using
the appropriate class_name key.

Props dmsnell, gaambo, crstauf, atachibana, audrasjb, krupalpanchal.
Fixes #59891.

#7 @Bernhard Reiter
3 months ago

  • Keywords fixed-major added
  • Milestone changed from 6.5 to 6.4.2
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backporting to the 6.4 branch.

This is a (minor) doc fix that seems to make sense to have in 6.4.x, as it might otherwise continue to throw people off while they're using the HTML API (potentially causing them to re-report the issue).

#8 @Bernhard Reiter
3 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 57117:

HTML API: Fix typo in documentation example.

The example code in the PHPDoc comment for the HTML Tag Processor class
previously showed calling next_tag() with an array containing a class
key, which should have been class_name. This patch fixes this by using
the appropriate class_name key.

Merges [57116] to the 6.4 branch.

Props dmsnell, gaambo, crstauf, atachibana, audrasjb, krupalpanchal.
Fixes #59891.

@Bernhard Reiter commented on PR #5661:


3 months ago
#9

Backported to Core's 6.4 branch in https://core.trac.wordpress.org/changeset/57117.

This ticket was mentioned in Slack in #core by jorbin. View the logs.


3 months ago

Note: See TracTickets for help on using tickets.