UntranslatedStrings.php
1.21 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
<?php
namespace WPML\ST\StringsCleanup;
class UntranslatedStrings {
/** @var \wpdb */
private $wpdb;
public function __construct( \wpdb $wpdb ) {
$this->wpdb = $wpdb;
}
/**
* @param string[] $domains
*
* @return int
*/
public function getCountInDomains( $domains ) {
if ( ! $domains ) {
return 0;
}
return (int) $this->wpdb->get_var(
$this->wpdb->prepare(
"SELECT count(id) FROM {$this->wpdb->prefix}icl_strings WHERE status = %d AND context IN ("
. wpml_prepare_in( $domains, '%s' ) . ')',
ICL_TM_NOT_TRANSLATED
)
);
}
/**
* @param string[] $domains
* @param int $batchSize
*
* @return array
*/
public function getFromDomains( $domains, $batchSize ) {
if ( ! $domains ) {
return [];
}
return $this->wpdb->get_results(
$this->wpdb->prepare(
"SELECT id FROM {$this->wpdb->prefix}icl_strings WHERE status = %d AND context IN ("
. wpml_prepare_in( $domains, '%s' ) . ') LIMIT 0, %d',
ICL_TM_NOT_TRANSLATED,
$batchSize
)
);
}
/**
* @param int[] $stringIds
*
* @return int
*/
public function remove( $stringIds ) {
if ( $stringIds ) {
wpml_unregister_string_multi( $stringIds );
}
return count( $stringIds );
}
}