Habari\Pluggable::add_rest_rule PHP Метод

add_rest_rule() защищенный статический Метод

Adds a RewriteRule to the REST handler for the rule provided
protected static add_rest_rule ( string $hook, Pluggable $object, Callable $fn )
$hook string The hook name to add a RewriteRule for
$object Pluggable The pluggable object holding the hook
$fn Callable The hook function to use to dispatch the request
    protected static function add_rest_rule($hook, Pluggable $object, $fn)
    {
        $hook_ary = preg_split('#(?<!_)_#', $hook);
        $verb = array_shift($hook_ary);
        $hook_regex = '/^' . implode('\\/', array_map(function ($a) {
            if ($a[0] === '_') {
                return '(?P<' . substr($a, 1) . '>[^\\/]+)';
            }
            return $a;
        }, $hook_ary)) . '\\/?$/i';
        $hook_build = implode('/', array_map(function ($a) {
            if ($a[0] === '_') {
                return '{$' . substr($a, 1) . '}';
            }
            return $a;
        }, $hook_ary));
        $rule = new RewriteRule(array('name' => implode($hook_ary), 'parse_regex' => $hook_regex, 'build_str' => $hook_build, 'handler' => 'RestHandler', 'action' => 'rest', 'priority' => 1, 'is_active' => 1, 'rule_class' => RewriteRule::RULE_CUSTOM, 'description' => 'Rule to dispatch REST hook.', 'parameters' => array('verb' => $verb, 'hook' => array($object, $fn))));
        $object->add_rule($rule, implode($hook_ary));
    }