From 9efcb29ab08f0832587316f34c5385fea1b839d7 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Mon, 16 Sep 2019 05:00:01 +0200
Subject: [PATCH] Simplify do_action() / remove PHP 4 code

---
 src/wp-includes/plugin.php | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php
index 3e021bbdd8..1f6cacd5b4 100644
--- a/src/wp-includes/plugin.php
+++ b/src/wp-includes/plugin.php
@@ -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 );
 	}
 
@@ -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 );
-- 
2.23.0.windows.1

