An open API service indexing awesome lists of open source software.

https://github.com/themeplate/hook

Advanced wrapper for filters
https://github.com/themeplate/hook

Last synced: 4 months ago
JSON representation

Advanced wrapper for filters

Awesome Lists containing this project

README

          

# ThemePlate Hook

## Usage

```php

use ThemePlate\Hook;

// Hook::( , )
Hook::append( 'sample_filter', 'ing' );
Hook::prepend( 'sample_filter', 're-' );
Hook::return( 'sample_filter', 'this!' );
Hook::pluck( 'sample_filter', 'i' );
Hook::replace( 'sample_filter', '!', '...' );
Hook::insert( 'sample_filter', 'u', 2 );
Hook::once( 'sample_filter', array( 'pluck', 'th' ) );
```

> ^Line by line output with initial value **test**

| ACTION | VALUE | RESULT #1 | RESULT #2 |
|---------|----------------|------------|------------|
| append | ing | testing | testing |
| prepend | re- | re-testing | re-testing |
| return | this! | this! | this! |
| pluck | i | ths! | ths! |
| replace | ["!","..."] | ths... | ths... |
| insert | ["u",2] | thus... | thus... |
| once | ["pluck","th"] | us... | thus... |

```php
// apply_filters( , );
apply_filters( 'sample_filter', 'test' ); //
apply_filters( 'sample_filter', 'test' ); //
```