Analytics.php
2 years ago
Assets.php
1 year ago
Filters.php
7 months ago
Functions.php
2 months ago
Handlebars.php
1 year ago
I18n.php
1 month ago
index.php
3 years ago
Filters.php
50 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Twig; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\WP\Functions as WPFunctions; |
| 9 | use MailPoetVendor\Twig\Extension\AbstractExtension; |
| 10 | use MailPoetVendor\Twig\TwigFilter; |
| 11 | |
| 12 | class Filters extends AbstractExtension { |
| 13 | public function getName() { |
| 14 | return 'filters'; |
| 15 | } |
| 16 | |
| 17 | public function getFilters() { |
| 18 | return [ |
| 19 | new TwigFilter( |
| 20 | 'intval', |
| 21 | 'intval' |
| 22 | ), |
| 23 | new TwigFilter( |
| 24 | 'replaceLinkTags', |
| 25 | 'MailPoet\Util\Helpers::replaceLinkTags' |
| 26 | ), |
| 27 | new TwigFilter( |
| 28 | 'wpKses', |
| 29 | [$this, 'wpKses'], |
| 30 | ['is_safe' => ['html']] |
| 31 | ), |
| 32 | new TwigFilter( |
| 33 | 'wp_json_encode', |
| 34 | [$this, 'wpJsonEncode'], |
| 35 | ['is_safe' => ['js']] |
| 36 | ), |
| 37 | ]; |
| 38 | } |
| 39 | |
| 40 | public function wpKses($content, $allowedHtml) { |
| 41 | $wp = WPFunctions::get(); |
| 42 | return $wp->wpKses($content, $allowedHtml); |
| 43 | } |
| 44 | |
| 45 | public function wpJsonEncode($data) { |
| 46 | $wp = WPFunctions::get(); |
| 47 | return $wp->wpJsonEncode($data); |
| 48 | } |
| 49 | } |
| 50 |