| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Description of class-wc-brands-expand-loader |
| 5 |
* |
| 6 |
* @author ohad |
| 7 |
*/ |
| 8 |
class OcAcceibility_Loader { |
| 9 |
|
| 10 |
protected $actions; |
| 11 |
protected $filters; |
| 12 |
|
| 13 |
public function __construct() { |
| 14 |
|
| 15 |
$this->actions = array(); |
| 16 |
$this->filters = array(); |
| 17 |
} |
| 18 |
|
| 19 |
public function add_action($hook, $component, $callback) { |
| 20 |
$this->actions = $this->add($this->actions, $hook, $component, $callback); |
| 21 |
} |
| 22 |
|
| 23 |
public function add_filter($hook, $component, $callback) { |
| 24 |
$this->filters = $this->add($this->filters, $hook, $component, $callback); |
| 25 |
} |
| 26 |
|
| 27 |
private function add($hooks, $hook, $component, $callback) { |
| 28 |
|
| 29 |
$hooks[] = array( |
| 30 |
'hook' => $hook, |
| 31 |
'component' => $component, |
| 32 |
'callback' => $callback |
| 33 |
); |
| 34 |
|
| 35 |
return $hooks; |
| 36 |
} |
| 37 |
|
| 38 |
public function run() { |
| 39 |
|
| 40 |
foreach ($this->filters as $hook) { |
| 41 |
add_filter($hook['hook'], array($hook['component'], $hook['callback'])); |
| 42 |
} |
| 43 |
|
| 44 |
foreach ($this->actions as $hook) { |
| 45 |
add_action($hook['hook'], array($hook['component'], $hook['callback'])); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
} |
| 50 |
|