Skip to content

Commit

Permalink
Tag Processor: Add get_updated_html as a non-toString method of strin…
Browse files Browse the repository at this point in the history
…gifying the markup (#44597)

Adds a get_updated_html as a more WordPress-style way of retrieving the updated markup than (string) $p.

Co-authored-by: Dennis Snell <[email protected]>
  • Loading branch information
adamziel and dmsnell authored Oct 18, 2022
1 parent 963d836 commit d406de5
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 77 deletions.
13 changes: 12 additions & 1 deletion lib/experimental/html/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1267,13 +1267,24 @@ public function remove_class( $class_name ) {

/**
* Returns the string representation of the HTML Tag Processor.
* It closes the HTML Tag Processor and prevents further lookups and modifications.
*
* @since 6.2.0
* @see get_updated_html
*
* @return string The processed HTML.
*/
public function __toString() {
return $this->get_updated_html();
}

/**
* Returns the string representation of the HTML Tag Processor.
*
* @since 6.2.0
*
* @return string The processed HTML.
*/
public function get_updated_html() {
// Short-circuit if there are no updates to apply.
if ( ! count( $this->classname_updates ) && ! count( $this->attribute_updates ) ) {
return $this->updated_html . substr( $this->html, $this->updated_bytes );
Expand Down
Loading

0 comments on commit d406de5

Please sign in to comment.