From fcdd54cbcd2540955b591a6cd938b7ef50b4614f Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Thu, 18 Jul 2019 06:18:27 +0200
Subject: [PATCH] Simplify & modernize do_action()

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

diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php
index 1f6cacd5b4..02957ee041 100644
--- a/src/wp-includes/plugin.php
+++ b/src/wp-includes/plugin.php
@@ -439,7 +439,7 @@ function add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1
  * @param mixed  ...$arg Optional. Additional arguments which are passed on to the
  *                       functions hooked to the action. Default empty.
  */
-function do_action( $tag, $arg = '' ) {
+function do_action( $tag, ...$arg ) {
 	global $wp_filter, $wp_actions, $wp_current_filter;
 
 	if ( ! isset( $wp_actions[ $tag ] ) ) {
@@ -448,11 +448,10 @@ 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 );
 	}
 
@@ -467,14 +466,11 @@ function do_action( $tag, $arg = '' ) {
 		$wp_current_filter[] = $tag;
 	}
 
-	$args = $all_args;
-	array_shift( $args );
-
-	if ( empty( $args ) ) {
-		$args = array( '' );
+	if ( empty( $arg ) ) {
+		$arg[] = '';
 	}
 
-	$wp_filter[ $tag ]->do_action( $args );
+	$wp_filter[ $tag ]->do_action( $arg );
 
 	array_pop( $wp_current_filter );
 }
-- 
2.23.0.windows.1

