PHPackages                             wp-php-toolkit/polyfill - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wp-php-toolkit/polyfill

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wp-php-toolkit/polyfill
=======================

Polyfill component for WordPress.

v0.8.1(1mo ago)0129GPL-2.0-or-laterPHPPHP &gt;=7.2

Since May 20Pushed 1mo agoCompare

[ Source](https://github.com/wp-php-toolkit/polyfill)[ Packagist](https://packagist.org/packages/wp-php-toolkit/polyfill)[ Docs](https://wordpress.github.io/php-toolkit/reference/polyfill.html)[ RSS](/packages/wp-php-toolkit-polyfill/feed)WikiDiscussions trunk Synced today

READMEChangelogDependencies (4)Versions (49)Used By (0)

   slug polyfill   title Polyfill   install wp-php-toolkit/polyfill   credit\_title WordPress-shaped compatibility   credit\_body When WordPress is loaded, every function in this component defers to WordPress. Outside WordPress, the standalone implementations cover the subset toolkit components need from &lt;code&gt;esc\_html()&lt;/code&gt;, &lt;code&gt;add\_filter()&lt;/code&gt;, &lt;code&gt;\_\_()&lt;/code&gt;, and related helpers.    see\_also    html | HTML | Run WordPress-shaped escaping and translation helpers beside HTML processors.

 blockparser | BlockParser | Keep standalone block tooling familiar outside WordPress.

    PHP 8 string functions on PHP 7.2+, WordPress hook stubs, and translation/escaping passthroughs so toolkit code runs without booting WordPress.

Why this exists
---------------

[](#why-this-exists)

A lot of WordPress-adjacent code wants to call `esc_html()`, `__()`, or `apply_filters()` without booting WordPress. The polyfill component provides minimal implementations for the subset used by the toolkit, and stays out of the way when WordPress is loaded (every function uses `function_exists()` guards).

PHP 8 string functions on PHP 7.2
---------------------------------

[](#php-8-string-functions-on-php-72)

The polyfills define `str_contains`, `str_starts_with`, `str_ends_with`, and `array_key_first` only when missing.

```
