lxbdr / wp-template-helper
此包最新版本(2.0.0)没有可用的许可证信息。
WordPress 转义函数的简单数据包装器。
2.0.0
2024-09-12 07:46 UTC
Requires
- php: >=7.4
Requires (Dev)
- 10up/wp_mock: dev-trunk
- phpunit/phpunit: ^9
README
使用它来包装数据,并自动检查是否存在以获取转义输出。
简单示例
<?php $data = [ 'foo' => 'bar', 'foo_url' => 'https://example.com', 'style' => 'color: red; font-weight: bold', 'img' => 'https://picsum.photos/100/100' ]; $t = new \Lxbdr\WpTemplateHelper\WpTemplateHelper($data); ?> <div class="card"> <?php if ($t->notEmpty('img')): ?> <img src="<?php $t->url('img'); ?>" alt="Beautiful picture"> <?php endif; ?> <h1 class="card-title"><?php $t('foo'); ?></h1> <p style="<?php $t->attr('style'); ?>">lorem ipsum</p> <a href="<?php $t->url('foo_url'); ?>">Read more</a> </div> <?php // ...