wpml-tf-settings.php
3.85 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
use WPML\API\Sanitize;
/**
* Class WPML_TF_Settings
*
* @author OnTheGoSystems
*/
class WPML_TF_Settings implements IWPML_TF_Settings {
const BUTTON_MODE_DISABLED = 'disabled';
const BUTTON_MODE_LEFT = 'left';
const BUTTON_MODE_RIGHT = 'right';
const BUTTON_MODE_CUSTOM = 'custom';
const ICON_STYLE_LEGACY = 'translation';
const ICON_STYLE_STAR = 'star';
const ICON_STYLE_THUMBSUP = 'thumbsup';
const ICON_STYLE_BULLHORN = 'bullhorn';
const ICON_STYLE_COMMENT = 'comment';
const ICON_STYLE_QUOTE = 'quote';
const DISPLAY_ALWAYS = 'always';
const DISPLAY_CUSTOM = 'custom';
const EXPIRATION_ON_PUBLISH_OR_UPDATE = 'publish_or_update';
const EXPIRATION_ON_PUBLISH_ONLY = 'publish_only';
const EXPIRATION_ON_UPDATE_ONLY = 'update_only';
const DELAY_DAY = 1;
const DELAY_WEEK = 7;
const DELAY_MONTH = 30;
/** @var bool $enabled */
private $enabled = false;
/** @var string $button_mode */
private $button_mode = self::BUTTON_MODE_LEFT;
/** @var string $icon_style */
private $icon_style = self::ICON_STYLE_LEGACY;
/** @var null|array $languages_to */
private $languages_to = null;
/** @var string $display_mode */
private $display_mode = self::DISPLAY_CUSTOM;
/** @var string $expiration_mode */
private $expiration_mode = self::EXPIRATION_ON_PUBLISH_OR_UPDATE;
/** @var int $expiration_delay_quantity */
private $expiration_delay_quantity = 1;
/** @var int $expiration_delay_unit */
private $expiration_delay_unit = self::DELAY_MONTH;
/**
* @param bool $enabled
*/
public function set_enabled( $enabled ) {
$this->enabled = (bool) $enabled;
}
/**
* @return bool
*/
public function is_enabled() {
return $this->enabled;
}
/**
* @param string $button_mode
*/
public function set_button_mode( $button_mode ) {
$this->button_mode = Sanitize::string( $button_mode );
}
/**
* @return string
*/
public function get_button_mode() {
return $this->button_mode;
}
/** @param string $style */
public function set_icon_style( $style ) {
$this->icon_style = Sanitize::string( $style );
}
/** @return string */
public function get_icon_style() {
return $this->icon_style;
}
/**
* @param array $languages_to
*/
public function set_languages_to( array $languages_to ) {
$this->languages_to = array_map( 'sanitize_title', $languages_to );
}
/**
* @return null|array
*/
public function get_languages_to() {
return $this->languages_to;
}
/**
* @param string $display_mode
*/
public function set_display_mode( $display_mode ) {
$this->display_mode = Sanitize::string( $display_mode );
}
/**
* @return string
*/
public function get_display_mode() {
return $this->display_mode;
}
/**
* @param string $expiration_mode
*/
public function set_expiration_mode( $expiration_mode ) {
$this->expiration_mode = Sanitize::string( $expiration_mode );
}
/**
* @return string
*/
public function get_expiration_mode() {
return $this->expiration_mode;
}
/**
* @param int $expiration_delay_quantity
*/
public function set_expiration_delay_quantity( $expiration_delay_quantity ) {
$this->expiration_delay_quantity = (int) $expiration_delay_quantity;
}
/**
* @return int
*/
public function get_expiration_delay_quantity() {
return $this->expiration_delay_quantity;
}
/**
* @param int $expiration_delay_unit
*/
public function set_expiration_delay_unit( $expiration_delay_unit ) {
$this->expiration_delay_unit = (int) $expiration_delay_unit;
}
/**
* @return int
*/
public function get_expiration_delay_unit() {
return $this->expiration_delay_unit;
}
/**
* @return int delay in days before expiration
*/
public function get_expiration_delay_in_days() {
return $this->expiration_delay_quantity * $this->expiration_delay_unit;
}
/**
* @return array
*/
public function get_properties() {
return get_object_vars( $this );
}
}