Whip_WPDismissOption.php
873 Bytes
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
<?php
/**
* WHIP libary file.
*
* @package Yoast\WHIP
*/
/**
* Represents the WordPress option for saving the dismissed messages.
*/
class Whip_WPDismissOption implements Whip_DismissStorage {
/**
* WordPress option name.
*
* @var string
*/
protected $optionName = 'whip_dismiss_timestamp';
/**
* Saves the value to the options.
*
* @param int $dismissedValue The value to save.
*
* @return bool True when successful.
*/
public function set( $dismissedValue ) {
return update_option( $this->optionName, $dismissedValue );
}
/**
* Returns the value of the whip_dismissed option.
*
* @return int Returns the value of the option or an empty string when not set.
*/
public function get() {
$dismissedOption = get_option( $this->optionName );
if ( ! $dismissedOption ) {
return 0;
}
return (int) $dismissedOption;
}
}