EntryQueries.php
1.65 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace WPML\ST\TranslationFile;
class EntryQueries {
/**
* @param string $type
*
* @return \Closure
*/
public static function isType( $type ) {
return function ( \WPML_ST_Translations_File_Entry $entry ) use ( $type ) {
return $entry->get_component_type() === $type;
};
}
/**
* @param string $extension
*
* @return \Closure
*/
public static function isExtension( $extension ) {
return function ( \WPML_ST_Translations_File_Entry $file ) use ( $extension ) {
return $file->get_extension() === $extension;
};
}
/**
* @return \Closure
*/
public static function getResourceName() {
return function ( \WPML_ST_Translations_File_Entry $entry ) {
$function = 'get' . ucfirst( $entry->get_component_type() ) . 'Name';
return self::$function( $entry );
};
}
/**
* @return \Closure
*/
public static function getDomain() {
return function( \WPML_ST_Translations_File_Entry $file ) {
return $file->get_domain();
};
}
/**
* @param \WPML_ST_Translations_File_Entry $entry
*
* @return string
*/
private static function getPluginName( \WPML_ST_Translations_File_Entry $entry ) {
$data = get_plugin_data( WPML_PLUGINS_DIR . '/' . $entry->get_component_id(), false, false );
return $data['Name'];
}
/**
* @param \WPML_ST_Translations_File_Entry $entry
*
* @return string
*/
private static function getThemeName( \WPML_ST_Translations_File_Entry $entry ) {
return $entry->get_component_id();
}
/**
* @param \WPML_ST_Translations_File_Entry $entry
*
* @return mixed|string|void
*/
private static function getOtherName( \WPML_ST_Translations_File_Entry $entry ) {
return 'WordPress';
}
}