class-wpml-st-icl-strings.php
1.49 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
76
77
78
79
80
81
82
83
<?php
class WPML_ST_ICL_Strings extends WPML_WPDB_User {
private $table = 'icl_strings';
private $string_id = 0;
/**
* WPML_TM_ICL_Strings constructor.
*
* @param wpdb $wpdb
* @param int $string_id
*/
public function __construct( &$wpdb, $string_id ) {
parent::__construct( $wpdb );
$string_id = (int) $string_id;
if ( $string_id > 0 ) {
$this->string_id = $string_id;
} else {
throw new InvalidArgumentException( 'Invalid String ID: ' . $string_id );
}
}
/**
* @param array $args in the same format used by \wpdb::update()
*
* @return $this
*/
public function update( $args ) {
$this->wpdb->update(
$this->wpdb->prefix . $this->table,
$args,
array( 'id' => $this->string_id )
);
return $this;
}
/**
* @return string
*/
public function value() {
return $this->wpdb->get_var(
$this->wpdb->prepare(
" SELECT value
FROM {$this->wpdb->prefix}{$this->table}
WHERE id = %d LIMIT 1",
$this->string_id
)
);
}
/**
* @return string
*/
public function language() {
return $this->wpdb->get_var(
$this->wpdb->prepare(
" SELECT language
FROM {$this->wpdb->prefix}{$this->table}
WHERE id = %d LIMIT 1",
$this->string_id
)
);
}
/**
* @return int
*/
public function status() {
return (int) $this->wpdb->get_var(
$this->wpdb->prepare(
" SELECT status
FROM {$this->wpdb->prefix}{$this->table}
WHERE id = %d LIMIT 1",
$this->string_id
)
);
}
}