-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[-]: "remove accepted_args option, all arguments are always transmitt…
…ed" - mistic100/PHP-Hooks@16c9d19
- Loading branch information
Lars Moelleken
committed
Jan 28, 2015
1 parent
78edfeb
commit b19f484
Showing
1 changed file
with
12 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,16 @@ | |
* of the code comes from there. | ||
* | ||
* | ||
* @version 0.1.3 | ||
* @copyright 2011 - 2014 | ||
* @version 0.1.5 | ||
* @copyright 2011 - 2015 | ||
* @author Ohad Raz (email: [email protected]) | ||
* @link http://en.bainternet.info | ||
* @author David Miles <[email protected]> | ||
* @link http://github.com/amereservant/PHP-Hooks | ||
* @author Lars Moelleken <[email protected]> | ||
* @link https://github.com/voku/PHP-Hooks/ | ||
* @author Damien "Mistic" Sorel (email: [email protected]) | ||
* @link http://www.strangeplanet.fr | ||
* | ||
* @license GNU General Public License v3.0 - license.txt | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
|
@@ -162,17 +164,15 @@ public static function getInstance() | |
* Lower numbers correspond with earlier execution, | ||
* and functions with the same priority are executed | ||
* in the order in which they were added to the action. | ||
* @param integer $accepted_args (optional) The number of arguments the function accept (default 1). | ||
* | ||
* @return boolean true | ||
*/ | ||
public function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) | ||
public function add_filter($tag, $function_to_add, $priority = 10) | ||
{ | ||
$idx = $this->_filter_build_unique_id($tag, $function_to_add, $priority); | ||
|
||
$this->filters[$tag][$priority][$idx] = array( | ||
'function' => $function_to_add, | ||
'accepted_args' => $accepted_args | ||
'function' => $function_to_add | ||
); | ||
|
||
unset($this->merged_filters[$tag]); | ||
|
@@ -334,7 +334,7 @@ public function apply_filters($tag, $value) | |
|
||
if (!is_null($the_['function'])) { | ||
$args[1] = $value; | ||
$value = call_user_func_array($the_['function'], array_slice($args, 1, (int)$the_['accepted_args'])); | ||
$value = call_user_func_array($the_['function'], array_slice($args, 1)); | ||
} | ||
} | ||
} | ||
|
@@ -390,7 +390,7 @@ public function apply_filters_ref_array($tag, $args) | |
do { | ||
foreach ((array)current($this->filters[$tag]) as $the_) { | ||
if (!is_null($the_['function'])) { | ||
$args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int)$the_['accepted_args'])); | ||
$args[0] = call_user_func_array($the_['function'], $args); | ||
} | ||
} | ||
} | ||
|
@@ -419,15 +419,14 @@ public function apply_filters_ref_array($tag, $args) | |
* Lower numbers correspond with earlier execution, | ||
* and functions with the same priority are executed | ||
* in the order in which they were added to the action. | ||
* @param integer $accepted_args (optional) The number of arguments the function accept (default 1). | ||
* | ||
* @access public | ||
* @since 1.0.0 | ||
* @return bool | ||
*/ | ||
public function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) | ||
public function add_action($tag, $function_to_add, $priority = 10) | ||
{ | ||
return $this->add_filter($tag, $function_to_add, $priority, $accepted_args); | ||
return $this->add_filter($tag, $function_to_add, $priority); | ||
} | ||
|
||
/** | ||
|
@@ -556,7 +555,7 @@ public function do_action($tag, $arg = '') | |
do { | ||
foreach ((array)current($this->filters[$tag]) as $the_) { | ||
if (!is_null($the_['function'])) { | ||
call_user_func_array($the_['function'], array_slice($args, 0, (int)$the_['accepted_args'])); | ||
call_user_func_array($the_['function'], $args); | ||
} | ||
} | ||
} | ||
|
@@ -619,7 +618,7 @@ public function do_action_ref_array($tag, $args) | |
do { | ||
foreach ((array)current($this->filters[$tag]) as $the_) { | ||
if (!is_null($the_['function'])) { | ||
call_user_func_array($the_['function'], array_slice($args, 0, (int)$the_['accepted_args'])); | ||
call_user_func_array($the_['function'], $args); | ||
} | ||
} | ||
} | ||
|