function my_custom_function() { // do something... } add_action( 'wp_head', 'my_custom_function' );
class MyCustomMiddleware { public function handle($request, Closure $next) { // do something... return $next($request); } } Route::middleware([MyCustomMiddleware::class])->get('/my-route', function () { // handle the route... });
function my_custom_filter($value) { // do something... return $value; } add_filter( 'my_filter_hook', 'my_custom_filter' ); $my_value = apply_filters( 'my_filter_hook', 'hello world' );In this example, we use the `add_filter()` function to add a custom callback function called `my_custom_filter()` to a filter hook called `my_filter_hook`. We then use the `apply_filters()` function to execute the filter hook, passing in the initial value of `'hello world'` as a parameter. Our custom function then modifies this value and returns it back to the calling script, allowing us to modify the behavior of the application in real time. Package : Vanilla PHP.