From 9f5ffbf597ba07ceecf0c2420b562de5eb679677 Mon Sep 17 00:00:00 2001 From: Tom McFarlin Date: Thu, 26 Jun 2014 15:43:18 -0400 Subject: [PATCH] adding a priority argument to the loader (defaulting to 10 as per wordpress codex) --- .../trunk/includes/class-plugin-name-loader.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugin-name/trunk/includes/class-plugin-name-loader.php b/plugin-name/trunk/includes/class-plugin-name-loader.php index f279e4b..9baceac 100644 --- a/plugin-name/trunk/includes/class-plugin-name-loader.php +++ b/plugin-name/trunk/includes/class-plugin-name-loader.php @@ -46,26 +46,27 @@ class Plugin_Name_Loader { /** * TODO */ - public function add_action( $hook, $component, $callback ) { - $this->actions = $this->add( $this->actions, $hook, $component, $callback ); + public function add_action( $hook, $component, $callback, $priority = 10 ) { + $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority ); } /** * TODO */ - public function add_filter( $hook, $component, $callback ) { - $this->filters = $this->add( $this->filters, $hook, $component, $callback ); + public function add_filter( $hook, $component, $callback, $priority = 10 ) { + $this->filters = $this->add( $this->filters, $hook, $component, $callback $priority ); } /** * TODO */ - private function add( $hooks, $hook, $component, $callback ) { + private function add( $hooks, $hook, $component, $callback, $priority ) { $hooks[] = array( 'hook' => $hook, 'component' => $component, - 'callback' => $callback + 'callback' => $callback, + 'priority' => $priority ); return $hooks; @@ -91,11 +92,11 @@ class Plugin_Name_Loader { */ 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 ) { - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ) ); + add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'] ); } }