-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathThemeUpgrader.php
More file actions
45 lines (35 loc) · 1.03 KB
/
ThemeUpgrader.php
File metadata and controls
45 lines (35 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace WP_CLI;
/**
* A theme upgrader class that tracks changed files.
*/
class ThemeUpgrader extends \Theme_Upgrader {
/**
* List of files that were changed during the update process.
*
* @var array<string>
*/
private $changed_files = [];
public function install_package( $args = array() ) {
parent::upgrade_strings(); // Needed for the 'remove_old' string.
$track_files = function ( $will_invalidate, $filepath ) {
$this->changed_files[] = $filepath;
return $will_invalidate;
};
add_filter( 'wp_opcache_invalidate_file', $track_files, 10, 2 );
$result = parent::install_package( $args );
remove_filter( 'wp_opcache_invalidate_file', $track_files );
// Remove duplicates and sort files.
$this->changed_files = array_unique( $this->changed_files );
sort( $this->changed_files );
return $result;
}
/**
* Returns a list of files that were changed during the update process.
*
* @return array<string> Changed files.
*/
public function get_changed_files() {
return $this->changed_files;
}
}