Skip to content

Commit

Permalink
Code Modernisation: Remove redundant PHP 4 code from do_action().
Browse files Browse the repository at this point in the history
As of PHP 5, objects are always passed by reference, so this has not been needed for quite some time.

Props jrf.
See #47678.

git-svn-id: https://develop.svn.wordpress.org/trunk@46149 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Sep 16, 2019
1 parent ea35099 commit 31fa37f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/wp-includes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,11 @@ function do_action( $tag, $arg = '' ) {
++$wp_actions[ $tag ];
}

$all_args = func_get_args();

// Do 'all' actions first
if ( isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
$all_args = func_get_args();
_wp_call_all_hook( $all_args );
}

Expand All @@ -466,14 +467,11 @@ function do_action( $tag, $arg = '' ) {
$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];
} else {
$args[] = $arg;
}
for ( $a = 2, $num = func_num_args(); $a < $num; $a++ ) {
$args[] = func_get_arg( $a );
$args = $all_args;
array_shift( $args );

if ( empty( $args ) ) {
$args = array( '' );
}

$wp_filter[ $tag ]->do_action( $args );
Expand Down

0 comments on commit 31fa37f

Please sign in to comment.