Skip to content

Commit

Permalink
Merge pull request #5 from sterner-stuff/exclude-locked-plugins-and-t…
Browse files Browse the repository at this point in the history
…hemes

Update Update.php
  • Loading branch information
ethanclevenger91 authored Oct 30, 2024
2 parents 5663d32 + 21ec8f6 commit 007657d
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Commands/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand All @@ -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,
]);
Expand All @@ -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',
Expand Down

0 comments on commit 007657d

Please sign in to comment.