From 21ec8f677b7fcf4cde65c1284bd5b0d1096fb42c Mon Sep 17 00:00:00 2001 From: mspringer4 <79160593+mspringer4@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:34:32 -0700 Subject: [PATCH] Update Update.php --- src/Commands/Update.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Commands/Update.php b/src/Commands/Update.php index 5b013f3..17bd3e4 100644 --- a/src/Commands/Update.php +++ b/src/Commands/Update.php @@ -68,10 +68,12 @@ private function updateComposer() { } private function updateThemes() { + $exclude = '--exclude=' . $this->getComposerPlugins(); + if (WP_CLI::runcommand('theme list --update=available', [ 'return' => true, ])) { - return WP_CLI::runcommand('theme update --all', [ + return WP_CLI::runcommand('theme update --all ' . $exclude, [ 'return' => true, 'exit_error' => false, ]); @@ -82,10 +84,12 @@ private function updateThemes() { } private function updatePlugins() { + $exclude = '--exclude=' . $this->getComposerPlugins(); + if (WP_CLI::runcommand('plugin list --update=available', [ 'return' => true, ])) { - return WP_CLI::runcommand('plugin update --all', [ + return WP_CLI::runcommand('plugin update --all ' . $exclude, [ 'return' => true, 'exit_error' => false, ]); @@ -95,6 +99,22 @@ private function updatePlugins() { } } + public function getComposerPlugins(){ + $output = shell_exec('composer show --format=json'); + + $dependencies = json_decode($output, true); + + $dependencyNames = []; + if (isset($dependencies['installed'])) { + foreach ($dependencies['installed'] as $dependency) { + $parts = explode('/', $dependency['name']); + $dependencyNames[] = end($parts); + } + } + + return implode(',', $dependencyNames); + } + private function getPlugins() { return WP_CLI::runcommand('plugin list --fields=name,status,update,version,title --format=json', [ 'parse' => 'json',