class-wpml-translate-link-targets-in-posts.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
<?php
/**
* Class WPML_Translate_Link_Targets_In_Posts
*
* @package wpml-tm
*/
class WPML_Translate_Link_Targets_In_Posts extends WPML_Translate_Link_Targets_In_Content {
protected function get_contents_with_links_needing_fix( $start_id = 0, $count = 0 ) {
$this->content_to_fix = $this->wpdb->get_results( $this->get_sql( $start_id, $count, false) );
}
protected function get_content_type() {
return 'post';
}
public function get_number_to_be_fixed( $start_id = 0 ) {
return $this->wpdb->get_var( $this->get_sql( $start_id, 0, true ) );
}
protected function get_sql( $start_id , $count, $return_count_only ) {
$limit = '';
if ( $count > 0 ) {
$limit = " LIMIT " . $count;
}
if ( $return_count_only ) {
$sql = "SELECT COUNT(t.element_id)";
} else {
$sql = "SELECT t.element_id, t.language_code";
}
$sql = $this->wpdb->prepare( $sql .
" FROM {$this->wpdb->prefix}icl_translations AS t
INNER JOIN {$this->wpdb->prefix}icl_translation_status AS ts
ON t.translation_id = ts.translation_id
WHERE ts.links_fixed = 0
AND t.element_id IS NOT NULL
AND t.element_id >= %d
AND t.element_type LIKE 'post_%%'
ORDER BY t.element_id ASC" . $limit,
$start_id
);
return $sql;
}
}