Avoid array push/pops for empty filters and actions. fixes #17110
git-svn-id: https://develop.svn.wordpress.org/trunk@17638 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
95d1619373
commit
61e17b180f
@ -135,19 +135,23 @@ function apply_filters($tag, $value) {
|
|||||||
global $wp_filter, $merged_filters, $wp_current_filter;
|
global $wp_filter, $merged_filters, $wp_current_filter;
|
||||||
|
|
||||||
$args = array();
|
$args = array();
|
||||||
$wp_current_filter[] = $tag;
|
|
||||||
|
|
||||||
// Do 'all' actions first
|
// Do 'all' actions first
|
||||||
if ( isset($wp_filter['all']) ) {
|
if ( isset($wp_filter['all']) ) {
|
||||||
|
$wp_current_filter[] = $tag;
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
_wp_call_all_hook($args);
|
_wp_call_all_hook($args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !isset($wp_filter[$tag]) ) {
|
if ( !isset($wp_filter[$tag]) ) {
|
||||||
|
if ( isset($wp_filter['all']) )
|
||||||
array_pop($wp_current_filter);
|
array_pop($wp_current_filter);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !isset($wp_filter['all']) )
|
||||||
|
$wp_current_filter[] = $tag;
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
if ( !isset( $merged_filters[ $tag ] ) ) {
|
if ( !isset( $merged_filters[ $tag ] ) ) {
|
||||||
ksort($wp_filter[$tag]);
|
ksort($wp_filter[$tag]);
|
||||||
@ -193,19 +197,22 @@ function apply_filters($tag, $value) {
|
|||||||
function apply_filters_ref_array($tag, $args) {
|
function apply_filters_ref_array($tag, $args) {
|
||||||
global $wp_filter, $merged_filters, $wp_current_filter;
|
global $wp_filter, $merged_filters, $wp_current_filter;
|
||||||
|
|
||||||
$wp_current_filter[] = $tag;
|
|
||||||
|
|
||||||
// Do 'all' actions first
|
// Do 'all' actions first
|
||||||
if ( isset($wp_filter['all']) ) {
|
if ( isset($wp_filter['all']) ) {
|
||||||
|
$wp_current_filter[] = $tag;
|
||||||
$all_args = func_get_args();
|
$all_args = func_get_args();
|
||||||
_wp_call_all_hook($all_args);
|
_wp_call_all_hook($all_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !isset($wp_filter[$tag]) ) {
|
if ( !isset($wp_filter[$tag]) ) {
|
||||||
|
if ( isset($wp_filter['all']) )
|
||||||
array_pop($wp_current_filter);
|
array_pop($wp_current_filter);
|
||||||
return $args[0];
|
return $args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !isset($wp_filter['all']) )
|
||||||
|
$wp_current_filter[] = $tag;
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
if ( !isset( $merged_filters[ $tag ] ) ) {
|
if ( !isset( $merged_filters[ $tag ] ) ) {
|
||||||
ksort($wp_filter[$tag]);
|
ksort($wp_filter[$tag]);
|
||||||
@ -360,19 +367,22 @@ function do_action($tag, $arg = '') {
|
|||||||
else
|
else
|
||||||
++$wp_actions[$tag];
|
++$wp_actions[$tag];
|
||||||
|
|
||||||
$wp_current_filter[] = $tag;
|
|
||||||
|
|
||||||
// Do 'all' actions first
|
// Do 'all' actions first
|
||||||
if ( isset($wp_filter['all']) ) {
|
if ( isset($wp_filter['all']) ) {
|
||||||
|
$wp_current_filter[] = $tag;
|
||||||
$all_args = func_get_args();
|
$all_args = func_get_args();
|
||||||
_wp_call_all_hook($all_args);
|
_wp_call_all_hook($all_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !isset($wp_filter[$tag]) ) {
|
if ( !isset($wp_filter[$tag]) ) {
|
||||||
|
if ( isset($wp_filter['all']) )
|
||||||
array_pop($wp_current_filter);
|
array_pop($wp_current_filter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !isset($wp_filter['all']) )
|
||||||
|
$wp_current_filter[] = $tag;
|
||||||
|
|
||||||
$args = array();
|
$args = array();
|
||||||
if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
|
if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
|
||||||
$args[] =& $arg[0];
|
$args[] =& $arg[0];
|
||||||
@ -446,19 +456,22 @@ function do_action_ref_array($tag, $args) {
|
|||||||
else
|
else
|
||||||
++$wp_actions[$tag];
|
++$wp_actions[$tag];
|
||||||
|
|
||||||
$wp_current_filter[] = $tag;
|
|
||||||
|
|
||||||
// Do 'all' actions first
|
// Do 'all' actions first
|
||||||
if ( isset($wp_filter['all']) ) {
|
if ( isset($wp_filter['all']) ) {
|
||||||
|
$wp_current_filter[] = $tag;
|
||||||
$all_args = func_get_args();
|
$all_args = func_get_args();
|
||||||
_wp_call_all_hook($all_args);
|
_wp_call_all_hook($all_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !isset($wp_filter[$tag]) ) {
|
if ( !isset($wp_filter[$tag]) ) {
|
||||||
|
if ( isset($wp_filter['all']) )
|
||||||
array_pop($wp_current_filter);
|
array_pop($wp_current_filter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !isset($wp_filter['all']) )
|
||||||
|
$wp_current_filter[] = $tag;
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
if ( !isset( $merged_filters[ $tag ] ) ) {
|
if ( !isset( $merged_filters[ $tag ] ) ) {
|
||||||
ksort($wp_filter[$tag]);
|
ksort($wp_filter[$tag]);
|
||||||
|
Loading…
Reference in New Issue
Block a user