Skip to content

Commit 007657d

Browse files
Merge pull request #5 from sterner-stuff/exclude-locked-plugins-and-themes
Update Update.php
2 parents 5663d32 + 21ec8f6 commit 007657d

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/Commands/Update.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ private function updateComposer() {
6868
}
6969

7070
private function updateThemes() {
71+
$exclude = '--exclude=' . $this->getComposerPlugins();
72+
7173
if (WP_CLI::runcommand('theme list --update=available', [
7274
'return' => true,
7375
])) {
74-
return WP_CLI::runcommand('theme update --all', [
76+
return WP_CLI::runcommand('theme update --all ' . $exclude, [
7577
'return' => true,
7678
'exit_error' => false,
7779
]);
@@ -82,10 +84,12 @@ private function updateThemes() {
8284
}
8385

8486
private function updatePlugins() {
87+
$exclude = '--exclude=' . $this->getComposerPlugins();
88+
8589
if (WP_CLI::runcommand('plugin list --update=available', [
8690
'return' => true,
8791
])) {
88-
return WP_CLI::runcommand('plugin update --all', [
92+
return WP_CLI::runcommand('plugin update --all ' . $exclude, [
8993
'return' => true,
9094
'exit_error' => false,
9195
]);
@@ -95,6 +99,22 @@ private function updatePlugins() {
9599
}
96100
}
97101

102+
public function getComposerPlugins(){
103+
$output = shell_exec('composer show --format=json');
104+
105+
$dependencies = json_decode($output, true);
106+
107+
$dependencyNames = [];
108+
if (isset($dependencies['installed'])) {
109+
foreach ($dependencies['installed'] as $dependency) {
110+
$parts = explode('/', $dependency['name']);
111+
$dependencyNames[] = end($parts);
112+
}
113+
}
114+
115+
return implode(',', $dependencyNames);
116+
}
117+
98118
private function getPlugins() {
99119
return WP_CLI::runcommand('plugin list --fields=name,status,update,version,title --format=json', [
100120
'parse' => 'json',

0 commit comments

Comments
 (0)