Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/demo.cartinsight.co/Corals/core/Foundation/Classes/Hooks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/demo.cartinsight.co/Corals/core/Foundation/Classes/Hooks/Filters.php
<?php

namespace Corals\Foundation\Classes\Hooks;

class Filters extends AbstractHookEvent
{
    /**
     * @param string $action
     * @param array $args
     * @return mixed|string
     */
    public function dispatch($action, array $args)
    {
        $value = isset($args[0]) ? $args[0] : '';

        if ($this->getListeners()) {
            foreach ($this->getListeners() as $hook => $listeners) {
                if ($hook === $action) {
                    foreach ($listeners as $arguments) {
                        $args[0] = $value;
                        $value = call_user_func_array($this->getFunction($arguments['callback']), $args);
                    }
                }
            }
        }

        return $value;
    }

    /**
     * @param string $hook
     * @param \Closure|string|array|callable $callback
     * @param int $priority
     */
    function add_filter($hook, $callback, $priority = 20)
    {
        self::addListener($hook, $callback, $priority);
    }


    /**
     * Do action then return value
     * @param string $hookName
     * @param array ...$args
     * @return mixed
     */
    function do_filter($hookName, ...$args)
    {
        return self::dispatch($hookName, $args);
    }

    /**
     * @param null $name
     * @return array|null
     */
    function get_filters($name = null)
    {
        $listeners = self::getListeners();

        if (empty($name)) {
            return $listeners;
        }
        return \Arr::get($listeners, $name);
    }
}

Spamworldpro Mini