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

add_rule() публичный Метод

Add a rewrite rule that dispatches entirely to a plugin hook
public add_rule ( mixed $rule, string $hook, Callback $fn = null )
$rule mixed An old-style rewrite rule string, where quoted segments are literals and unquoted segments are variable names, OR a RewriteRule object
$hook string The suffix of the hook function: action_plugin_act_{$suffix}
$fn Callback A potential function/method to register directly to the newly created hook
    public function add_rule($rule, $hook, $fn = null)
    {
        if (count($this->_new_rules) == 0) {
            Plugins::register(array($this, '_filter_rewrite_rules'), 'filter', 'rewrite_rules', 7);
        }
        if ($rule instanceof RewriteRule) {
            $this->_new_rules[] = $rule;
        } else {
            $this->_new_rules[] = RewriteRule::create_url_rule($rule, 'PluginHandler', $hook);
        }
        if (!is_null($fn)) {
            Plugins::register($fn, 'theme', 'route_' . $hook);
        }
    }