Assets.php
6 hours ago
Cache.php
3 weeks ago
Date.php
6 hours ago
Debug.php
5 hours ago
FeedReader.php
6 hours ago
HTML.php
6 hours ago
Helper.php
3 weeks ago
JSON.php
3 weeks ago
Nonce.php
3 weeks ago
Notice.php
6 hours ago
Number.php
3 weeks ago
NumberConverter.php
6 hours ago
Param.php
3 weeks ago
Sanitizing.php
6 hours ago
Strip.php
3 weeks ago
Templates.php
3 weeks ago
User.php
3 weeks ago
Validating.php
3 weeks ago
WooCommerce.php
3 weeks ago
WordPress.php
6 hours ago
Strip.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPParsidate\Helper; |
| 4 | |
| 5 | class Strip { |
| 6 | /** |
| 7 | * Filters text content and strips out disallowed HTML. |
| 8 | * |
| 9 | * @param string $content Text content to filter. |
| 10 | * |
| 11 | * @return string Filtered content containing only the allowed HTML. |
| 12 | */ |
| 13 | public static function kses( string $content ): string { |
| 14 | return wp_kses( stripslashes_deep( $content ), wp_kses_allowed_html( 'post' ) ); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Remove HTML comments |
| 19 | * |
| 20 | * @param string $html |
| 21 | * |
| 22 | * @return string |
| 23 | */ |
| 24 | public static function removeHtmlComments( string $html ): string { |
| 25 | return preg_replace( '~<!--(.*?)-->~s', '', $html ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Remove HTML Document type |
| 30 | * |
| 31 | * @param string $html |
| 32 | * |
| 33 | * @return string |
| 34 | */ |
| 35 | public static function removeHtmlDoctype( string $html ): string { |
| 36 | return preg_replace( '/^<!DOCTYPE.+?>/', '', $html ); |
| 37 | } |
| 38 | } |
| 39 |