1 | <?php |
||
24 | class WP_Review_Me { |
||
25 | |||
26 | /** |
||
27 | * Library version |
||
28 | * |
||
29 | * @since 1.0 |
||
30 | * @var string |
||
31 | */ |
||
32 | public $version = '2.0.1'; |
||
33 | |||
34 | /** |
||
35 | * Required version of PHP. |
||
36 | * |
||
37 | * @since 1.0 |
||
38 | * @var string |
||
39 | */ |
||
40 | public $php_version_required = '5.5'; |
||
41 | |||
42 | /** |
||
43 | * Minimum version of WordPress required to use the library |
||
44 | * |
||
45 | * @since 1.0 |
||
46 | * @var string |
||
47 | */ |
||
48 | public $wordpress_version_required = '4.2'; |
||
49 | |||
50 | /** |
||
51 | * Holds the unique identifying key for this particular instance |
||
52 | * |
||
53 | * @since 1.0 |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $key; |
||
57 | |||
58 | /** |
||
59 | * Link unique ID |
||
60 | * |
||
61 | * @since 1.0 |
||
62 | * @var string |
||
63 | */ |
||
64 | public $link_id; |
||
65 | |||
66 | /** |
||
67 | * WP_Review_Me constructor. |
||
68 | * |
||
69 | * @since 1.0 |
||
70 | * |
||
71 | * @param array $args Object settings |
||
72 | */ |
||
73 | public function __construct( $args ) { |
||
93 | |||
94 | /** |
||
95 | * Get default object settings |
||
96 | * |
||
97 | * @since 1.0 |
||
98 | * @return array |
||
99 | */ |
||
100 | protected function get_defaults() { |
||
117 | |||
118 | /** |
||
119 | * Initialize the library |
||
120 | * |
||
121 | * @since 1.0 |
||
122 | * @return void |
||
123 | */ |
||
124 | private function init() { |
||
178 | |||
179 | /** |
||
180 | * Check if the current WordPress version fits the requirements |
||
181 | * |
||
182 | * @since 1.0 |
||
183 | * @return boolean |
||
184 | */ |
||
185 | private function is_wp_compatible() { |
||
194 | |||
195 | /** |
||
196 | * Check if the version of PHP is compatible with this library |
||
197 | * |
||
198 | * @since 1.0 |
||
199 | * @return boolean |
||
200 | */ |
||
201 | private function is_php_compatible() { |
||
210 | |||
211 | /** |
||
212 | * Spits an error message at the top of the admin screen |
||
213 | * |
||
214 | * @since 1.0 |
||
215 | * |
||
216 | * @param string $error Error message to spit |
||
217 | * |
||
218 | * @return void |
||
219 | */ |
||
220 | protected function spit_error( $error ) { |
||
227 | |||
228 | /** |
||
229 | * Check if it is time to ask for a review |
||
230 | * |
||
231 | * @since 1.0 |
||
232 | * @return bool |
||
233 | */ |
||
234 | public function is_time() { |
||
250 | |||
251 | /** |
||
252 | * Save the current date as the installation date |
||
253 | * |
||
254 | * @since 1.0 |
||
255 | * @return void |
||
256 | */ |
||
257 | protected function setup_date() { |
||
260 | |||
261 | /** |
||
262 | * Get the review link |
||
263 | * |
||
264 | * @since 1.0 |
||
265 | * @return string |
||
266 | */ |
||
267 | protected function get_review_link() { |
||
290 | |||
291 | /** |
||
292 | * Get the complete link tag |
||
293 | * |
||
294 | * @since 1.0 |
||
295 | * @return string |
||
296 | */ |
||
297 | protected function get_review_link_tag() { |
||
304 | |||
305 | /** |
||
306 | * Trigger the notice if it is time to ask for a review |
||
307 | * |
||
308 | * @since 1.0 |
||
309 | * @return void |
||
310 | */ |
||
311 | protected function maybe_prompt() { |
||
323 | |||
324 | /** |
||
325 | * Echo the JS script in the admin footer |
||
326 | * |
||
327 | * @since 1.0 |
||
328 | * @return void |
||
329 | */ |
||
330 | public function script() { ?> |
||
356 | |||
357 | /** |
||
358 | * Dismiss the notice when the review link is clicked |
||
359 | * |
||
360 | * @since 1.0 |
||
361 | * @return void |
||
362 | */ |
||
363 | public function dismiss_notice() { |
||
402 | |||
403 | /** |
||
404 | * Get the review prompt message |
||
405 | * |
||
406 | * @since 1.0 |
||
407 | * @return string |
||
408 | */ |
||
409 | protected function get_message() { |
||
418 | |||
419 | } |
||
420 | |||
422 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: