InstalledComponents.php
1.08 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
46
47
<?php
/**
* @author OnTheGo Systems
*/
namespace WPML\ST\MO\Scan\UI;
use WPML\Collect\Support\Collection;
use WPML_ST_Translations_File_Entry;
class InstalledComponents {
/**
* @param Collection $components Collection of WPML_ST_Translations_File_Entry objects.
*
* @return Collection
*/
public static function filter( Collection $components ) {
return $components
->reject( self::isPluginMissing() )
->reject( self::isThemeMissing() );
}
/**
* WPML_ST_Translations_File_Entry -> bool
*
* @return \Closure
*/
public static function isPluginMissing() {
return function( WPML_ST_Translations_File_Entry $entry ) {
return 'plugin' === $entry->get_component_type()
&& ! is_readable( WPML_PLUGINS_DIR . '/' . $entry->get_component_id() );
};
}
/**
* WPML_ST_Translations_File_Entry -> bool
*
* @return \Closure
*/
public static function isThemeMissing() {
return function( WPML_ST_Translations_File_Entry $entry ) {
return 'theme' === $entry->get_component_type()
&& ! wp_get_theme( $entry->get_component_id() )->exists();
};
}
}