Avoid array push/pops for empty filters and actions. fixes #17110
git-svn-id: http://svn.automattic.com/wordpress/trunk@17638 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8f8b8d16a7
commit
3e77cd18c9
|
@ -135,19 +135,23 @@ function apply_filters($tag, $value) {
|
|||
global $wp_filter, $merged_filters, $wp_current_filter;
|
||||
|
||||
$args = array();
|
||||
$wp_current_filter[] = $tag;
|
||||
|
||||
// Do 'all' actions first
|
||||
if ( isset($wp_filter['all']) ) {
|
||||
$wp_current_filter[] = $tag;
|
||||
$args = func_get_args();
|
||||
_wp_call_all_hook($args);
|
||||
}
|
||||
|
||||
if ( !isset($wp_filter[$tag]) ) {
|
||||
if ( isset($wp_filter['all']) )
|
||||
array_pop($wp_current_filter);
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ( !isset($wp_filter['all']) )
|
||||
$wp_current_filter[] = $tag;
|
||||
|
||||
// Sort
|
||||
if ( !isset( $merged_filters[ $tag ] ) ) {
|
||||
ksort($wp_filter[$tag]);
|
||||
|
@ -193,19 +197,22 @@ function apply_filters($tag, $value) {
|
|||
function apply_filters_ref_array($tag, $args) {
|
||||
global $wp_filter, $merged_filters, $wp_current_filter;
|
||||
|
||||
$wp_current_filter[] = $tag;
|
||||
|
||||
// Do 'all' actions first
|
||||
if ( isset($wp_filter['all']) ) {
|
||||
$wp_current_filter[] = $tag;
|
||||
$all_args = func_get_args();
|
||||
_wp_call_all_hook($all_args);
|
||||
}
|
||||
|
||||
if ( !isset($wp_filter[$tag]) ) {
|
||||
if ( isset($wp_filter['all']) )
|
||||
array_pop($wp_current_filter);
|
||||
return $args[0];
|
||||
}
|
||||
|
||||
if ( !isset($wp_filter['all']) )
|
||||
$wp_current_filter[] = $tag;
|
||||
|
||||
// Sort
|
||||
if ( !isset( $merged_filters[ $tag ] ) ) {
|
||||
ksort($wp_filter[$tag]);
|
||||
|
@ -360,19 +367,22 @@ function do_action($tag, $arg = '') {
|
|||
else
|
||||
++$wp_actions[$tag];
|
||||
|
||||
$wp_current_filter[] = $tag;
|
||||
|
||||
// Do 'all' actions first
|
||||
if ( isset($wp_filter['all']) ) {
|
||||
$wp_current_filter[] = $tag;
|
||||
$all_args = func_get_args();
|
||||
_wp_call_all_hook($all_args);
|
||||
}
|
||||
|
||||
if ( !isset($wp_filter[$tag]) ) {
|
||||
if ( isset($wp_filter['all']) )
|
||||
array_pop($wp_current_filter);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isset($wp_filter['all']) )
|
||||
$wp_current_filter[] = $tag;
|
||||
|
||||
$args = array();
|
||||
if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
|
||||
$args[] =& $arg[0];
|
||||
|
@ -446,19 +456,22 @@ function do_action_ref_array($tag, $args) {
|
|||
else
|
||||
++$wp_actions[$tag];
|
||||
|
||||
$wp_current_filter[] = $tag;
|
||||
|
||||
// Do 'all' actions first
|
||||
if ( isset($wp_filter['all']) ) {
|
||||
$wp_current_filter[] = $tag;
|
||||
$all_args = func_get_args();
|
||||
_wp_call_all_hook($all_args);
|
||||
}
|
||||
|
||||
if ( !isset($wp_filter[$tag]) ) {
|
||||
if ( isset($wp_filter['all']) )
|
||||
array_pop($wp_current_filter);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isset($wp_filter['all']) )
|
||||
$wp_current_filter[] = $tag;
|
||||
|
||||
// Sort
|
||||
if ( !isset( $merged_filters[ $tag ] ) ) {
|
||||
ksort($wp_filter[$tag]);
|
||||
|
|
Loading…
Reference in New Issue