-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path_core-theme-subdir.php
53 lines (43 loc) · 1.07 KB
/
_core-theme-subdir.php
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
46
47
48
49
50
51
52
53
<?php
/*
* Plugin Name: Enable manual installation of themes with theme/ subdirectory
* Plugin URI: https://github.com/szepeviktor/wordpress-website-lifecycle
*/
function _core_theme_subdir_helper($source)
{
static $themePath;
$screen = get_current_screen();
if (!$screen instanceof \WP_Screen || $screen->id !== 'update') {
return $source;
}
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
if ($action !== 'upload-theme') {
return $source;
}
if (is_wp_error($source)) {
if (
$source->get_error_code() === 'incompatible_archive_theme_no_style'
&& isset($themePath)
&& is_dir($themePath . 'theme')
) {
// Run on priority 11.
return $themePath;
}
return $source;
}
// Run on priority 0.
$themePath = $source;
return $source;
}
add_filter(
'upgrader_source_selection',
'_core_theme_subdir_helper',
0,
1
);
add_filter(
'upgrader_source_selection',
'_core_theme_subdir_helper',
11,
1
);