From a8661c77f411e6e5d5edd461ca8050a9a662afac Mon Sep 17 00:00:00 2001 From: Ravinder Kumar Date: Thu, 9 Feb 2023 23:43:29 +0530 Subject: [PATCH] add: allow to merge asset depedencies with custom depdencies --- includes/classes/EnqueueScript.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/classes/EnqueueScript.php b/includes/classes/EnqueueScript.php index e65369156..c81553504 100644 --- a/includes/classes/EnqueueScript.php +++ b/includes/classes/EnqueueScript.php @@ -147,9 +147,14 @@ public function loadInFooter(): EnqueueScript { * * @return $this */ - public function dependencies( array $scriptDependencies ): EnqueueScript { + public function dependencies( array $scriptDependencies, $addDependenciesFromAssets = true ): EnqueueScript { $this->scriptDependencies = $scriptDependencies; + if ( $addDependenciesFromAssets ) { + $assetFileData = $this->getAssetFileData(); + $this->scriptDependencies = array_merge( $this->scriptDependencies, $assetFileData['dependencies'] ); + } + return $this; }