Skip to content

Commit 25bf1ed

Browse files
committed
Updated filter to ensure same folder destination.
1 parent 035fd72 commit 25bf1ed

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

helpers/updater.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public function __construct($file, $prefix, $version, $repo) {
7171
$namespace = explode('\\', __NAMESPACE__);
7272
$this->namespace = strtolower($namespace[0]);
7373

74+
// Set filter options for upgrades
75+
add_filter('upgrader_package_options', [$this, 'upgraderOptions']);
76+
7477
// HTTP Request Args short-circuit
7578
add_filter('http_request_args', [$this, 'httpRequestArgs'], PHP_INT_MAX, 2);
7679

@@ -590,9 +593,6 @@ public function install($upgrade) {
590593
// Update plugins data
591594
wp_update_plugins();
592595

593-
// Set filter options for this upgrade
594-
add_filter('upgrader_package_options', [$this, 'upgraderOptions']);
595-
596596
// Single plugin upgrade
597597
$skin = new \WP_Ajax_Upgrader_Skin();
598598
$upgrader = new \Plugin_Upgrader( $skin );
@@ -723,15 +723,14 @@ public function install($upgrade) {
723723
*/
724724
public function upgraderOptions($options) {
725725

726-
// No multi
727-
$options['multi'] = false;
726+
// Check this plugin update
727+
if (empty($options['hook_extra']['plugin']) || $this->key != $options['hook_extra']['plugin']) {
728+
return $options;
729+
}
728730

729-
// Set destination
731+
// Set same folder destination
730732
$options['destination'] = rtrim($options['destination'], '/').'/'.dirname($this->key);
731733

732-
// No more filters
733-
remove_filter('upgrader_package_options', [$this, 'upgraderOptions']);
734-
735734
// Done
736735
return $options;
737736
}

0 commit comments

Comments
 (0)