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
- Host: GitHub
- URL: https://github.com/themeplate/hook
- Owner: ThemePlate
- License: gpl-3.0
- Created: 2020-03-29T13:27:46.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-02T16:28:56.000Z (over 1 year ago)
- Last Synced: 2025-03-02T16:35:38.718Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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' ); //
```