Title: WP_HTML_Text_Replacement::__construct
Published: March 29, 2023
Last modified: February 24, 2026

---

# WP_HTML_Text_Replacement::__construct( int $start, int $length, string $text )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#wp--skip-link--target)

Constructor.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#parameters)󠁿

 `$start`intrequired

Byte offset into document where replacement span begins.

`$length`intrequired

Byte length of span in document being replaced.

`$text`stringrequired

Span of text to insert in document to replace existing content from start to end.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#source)󠁿

    ```php
    public function __construct( int $start, int $length, string $text ) {
    	$this->start  = $start;
    	$this->length = $length;
    	$this->text   = $text;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/html-api/class-wp-html-text-replacement.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/html-api/class-wp-html-text-replacement.php#L59)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/html-api/class-wp-html-text-replacement.php#L59-L63)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#related)󠁿

| Used by | Description | 
| [class@anonymous::remove()](https://developer.wordpress.org/reference/classes/classanonymous/remove/)`wp-includes/script-loader.php` |

Removes the current token.

  | 
| [class@anonymous::insert_before()](https://developer.wordpress.org/reference/classes/classanonymous/insert_before/)`wp-includes/script-loader.php` |

Inserts text before the current token.

  | 
| [class@anonymous::insert_after()](https://developer.wordpress.org/reference/classes/classanonymous/insert_after/)`wp-includes/script-loader.php` |

Inserts text after the current token.

  | 
| [class@anonymous::replace_rich_text()](https://developer.wordpress.org/reference/classes/classanonymous/replace_rich_text/)`wp-includes/class-wp-block.php` |

Replace the rich text content between a tag opener and matching closer.

  | 
| [WP_HTML_Tag_Processor::set_modifiable_text()](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/set_modifiable_text/)`wp-includes/html-api/class-wp-html-tag-processor.php` |

Sets the modifiable text for the matched token, if matched.

  | 
| [WP_Interactivity_API_Directives_Processor::set_content_between_balanced_tags()](https://developer.wordpress.org/reference/classes/wp_interactivity_api_directives_processor/set_content_between_balanced_tags/)`wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php` |

Sets the content between two balanced tags.

  | 
| [WP_Interactivity_API_Directives_Processor::append_content_after_template_tag_closer()](https://developer.wordpress.org/reference/classes/wp_interactivity_api_directives_processor/append_content_after_template_tag_closer/)`wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php` |

Appends content after the closing tag of a template tag.

  | 
| [WP_HTML_Tag_Processor::set_attribute()](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/set_attribute/)`wp-includes/html-api/class-wp-html-tag-processor.php` |

Updates or creates a new attribute on the currently matched tag with the passed value.

  | 
| [WP_HTML_Tag_Processor::remove_attribute()](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/remove_attribute/)`wp-includes/html-api/class-wp-html-tag-processor.php` |

Remove an attribute from the currently-matched tag.

  |

[Show 4 more](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.2.0](https://developer.wordpress.org/reference/since/6.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_html_text_replacement%2F__construct%2F)
before being able to contribute a note or feedback.