1
0
Fork 0
mirror of https://github.com/inretio/WordPress-Plugin-Boilerplate synced 2024-05-12 16:22:10 +03:00

adding a priority argument to the loader (defaulting to 10 as per wordpress codex)

This commit is contained in:
Tom McFarlin 2014-06-26 15:43:18 -04:00
parent b7caa3e958
commit 9f5ffbf597

View file

@ -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'] );
} }
} }