DefaultColumnsRepository.php
1.06 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
<?php
namespace AC;
class DefaultColumnsRepository {
private const OPTIONS_KEY = 'cpac_options_';
/**
* @param string $list_screen_key
*
* @return string
*/
private function get_option_name( $list_screen_key ) {
return self::OPTIONS_KEY . $list_screen_key . "__default";
}
/**
* @param string $list_screen_key
* @param array $columns
*
* @return void
*/
public function update( $list_screen_key, array $columns ) {
update_option( $this->get_option_name( $list_screen_key ), $columns, false );
}
/**
* @param string $list_screen_key
*
* @return bool
*/
public function exists( $list_screen_key ) {
return false !== get_option( $this->get_option_name( $list_screen_key ) );
}
/**
* @param string $list_screen_key
*
* @return array
*/
public function get( $list_screen_key ) {
return get_option( $this->get_option_name( $list_screen_key ), [] );
}
/**
* @param string $list_screen_key
*
* @return void
*/
public function delete( $list_screen_key ) {
delete_option( $this->get_option_name( $list_screen_key ) );
}
}