<?php
namespace EPWF\Includes;
use EPWF\PublicFacing\Frontend;
defined('ABSPATH')||exit;
class Hooks {
    private $s,$fe;
    public function __construct(Settings $s,Frontend $fe){$this->s=$s;$this->fe=$fe;}
    public function attach(){
        if(!$this->s->is_enabled())return;
        $h=$this->s->get_hook();
        if(!array_key_exists($h,Settings::$HOOK_LABELS))return;
        add_action($h,[$this->fe,'render'],$this->s->get_priority());
    }
    public function reattach($old,$new){
        foreach(array_keys(Settings::$HOOK_LABELS) as $h)remove_action($h,[$this->fe,'render']);
        $this->s->flush();$this->attach();
    }
}
