mirror of
https://github.com/inretio/WordPress-Plugin-Boilerplate
synced 2024-12-22 20:03:53 +02:00
adding a priority argument to the loader (defaulting to 10 as per wordpress codex)
This commit is contained in:
parent
b7caa3e958
commit
9f5ffbf597
1 changed files with 9 additions and 8 deletions
|
@ -46,26 +46,27 @@ class Plugin_Name_Loader {
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
public function add_action( $hook, $component, $callback ) {
|
public function add_action( $hook, $component, $callback, $priority = 10 ) {
|
||||||
$this->actions = $this->add( $this->actions, $hook, $component, $callback );
|
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
public function add_filter( $hook, $component, $callback ) {
|
public function add_filter( $hook, $component, $callback, $priority = 10 ) {
|
||||||
$this->filters = $this->add( $this->filters, $hook, $component, $callback );
|
$this->filters = $this->add( $this->filters, $hook, $component, $callback $priority );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
private function add( $hooks, $hook, $component, $callback ) {
|
private function add( $hooks, $hook, $component, $callback, $priority ) {
|
||||||
|
|
||||||
$hooks[] = array(
|
$hooks[] = array(
|
||||||
'hook' => $hook,
|
'hook' => $hook,
|
||||||
'component' => $component,
|
'component' => $component,
|
||||||
'callback' => $callback
|
'callback' => $callback,
|
||||||
|
'priority' => $priority
|
||||||
);
|
);
|
||||||
|
|
||||||
return $hooks;
|
return $hooks;
|
||||||
|
@ -91,11 +92,11 @@ class Plugin_Name_Loader {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
foreach ( $this->filters as $hook ) {
|
foreach ( $this->filters as $hook ) {
|
||||||
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ) );
|
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $this->actions as $hook ) {
|
foreach ( $this->actions as $hook ) {
|
||||||
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ) );
|
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue