lxbdr/wp-template-helper

There is no license information available for the latest version (1.3.0) of this package.

Data wrapper for easy output with WordPress escaping functions.

1.3.0 2023-12-04 19:45 UTC

This package is auto-updated.

Last update: 2024-06-04 08:57:49 UTC


README

Use it to wrap data and get escaped output automatically checking for existence.

Simple example:

<?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
// ...