PluginProbe
CatFolders – WordPress Media Library Folders & Categories / trunk
CatFolders – WordPress Media Library Folders & Categories vtrunk
2.5.6 2.5.5 trunk 1.6.1 1.8 1.9 2.0 2.2 2.3.1 2.3.2 2.4.4 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4
catfolders / includes / Models / OptionModel.php

OptionModel.php in CatFolders – WordPress Media Library Folders & Categories trunk, at includes/Models/OptionModel.php

40 lines 943 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace CatFolders\Models;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class OptionModel {
7
8 private static $defaults = array(
9 'userrestriction' => '', // can't use userRestriction due to sanitize_key func
10 'allowsvgupload' => '',
11 );
12
13 public static function update_option( $values = array() ) {
14 $options = get_option( 'catf_settings', array() );
15 if ( ! is_array( $options ) ) {
16 $options = array();
17 }
18 foreach ( $values as $key => $val ) {
19 if ( in_array( $key, array_keys( self::$defaults ), true ) ) {
20 $options[ $key ] = $val;
21 }
22 }
23 update_option( 'catf_settings', $options );
24 }
25
26 public static function get_option( $name = '', $default = '' ) {
27 $options = get_option( 'catf_settings', array() );
28
29 if ( ! is_array( $options ) ) {
30 $options = array();
31 }
32
33 if ( '' === $name ) {
34 return wp_parse_args( $options, self::$defaults );
35 }
36
37 return isset( $options[ $name ] ) ? $options[ $name ] : $default;
38 }
39 }
40