class-otgs-installer-wp-share-local-components-setting.php
912 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
<?php
class OTGS_Installer_WP_Share_Local_Components_Setting {
const OPTION_KEY = 'otgs_share_local_components';
public function save( array $repos ) {
$settings = array_merge( $this->get(), $repos );
update_option( self::OPTION_KEY, $settings );
}
/**
* @param string $repo
*
* @return bool
*/
public function is_repo_allowed( $repo ) {
$allowed_repos = $this->get();
return isset( $allowed_repos[ $repo ] ) && $allowed_repos[ $repo ];
}
public function has_setting( $repo ) {
$current_value = self::get();
return $current_value
&& array_key_exists( $repo, $current_value );
}
public static function get_setting ( $repo) {
$current_value = self::get();
return array_key_exists( $repo, $current_value ) ? $current_value[$repo] : null;
}
private static function get() {
$setting = get_option( self::OPTION_KEY );
return $setting ? $setting : array();
}
}