Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pressmodo/wp-attributes
An helper library to generate attributes for HTML elements.
https://github.com/pressmodo/wp-attributes
attributes generator html wordpress
Last synced: 4 days ago
JSON representation
An helper library to generate attributes for HTML elements.
- Host: GitHub
- URL: https://github.com/pressmodo/wp-attributes
- Owner: Pressmodo
- License: mit
- Created: 2020-06-22T09:38:58.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-22T10:27:45.000Z (over 4 years ago)
- Last Synced: 2024-04-18T04:22:45.026Z (7 months ago)
- Topics: attributes, generator, html, wordpress
- Language: PHP
- Homepage: https://pressmodo.com
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# WP Attributes
[![Latest Stable Version](https://img.shields.io/packagist/v/pressmodo/wp-attributes.svg)](https://packagist.org/packages/pressmodo/wp-attributes)
[![Total Downloads](https://img.shields.io/packagist/dt/pressmodo/wp-attributes.svg)](https://packagist.org/packages/pressmodo/wp-attributes)
[![Latest Unstable Version](https://img.shields.io/packagist/vpre/pressmodo/wp-attributes.svg)](https://packagist.org/packages/pressmodo/wp-attributes)
[![License](https://img.shields.io/packagist/l/pressmodo/wp-attributes.svg)](https://packagist.org/packages/pressmodo/wp-attributes)
![PHP from Packagist](https://img.shields.io/packagist/php-v/pressmodo/wp-attributes)An helper library to generate attributes for HTML elements.
## Installation
``` bash
composer require pressmodo/wp-attributes
```## Basic usage
```php
use Pressmodo\Attributes\AttributesInterface;$sut = new AttributesInterface();
$sut->add( 'context', [
'class' => 'color-primary',
'id' => 'unique_id',
] );// ' class="color-primary" id="unique_id"'
echo $sut->render( 'context' );$sut->add( 'another_context', [
'class' => '', // This will be skipped because empty
'attr1' => null, // This will be skipped because null
'attr2' => false, // This will be skipped because false
'attr3' => 0, // This will be skipped because 0 is also false
'id' => 'unique_id',
] );
// ' id="unique_id"'
echo $sut->render( 'another_context' );
```## Credits
* [ItalyStrap/html](https://github.com/ItalyStrap/html)