PluginProbe
FileBird – WordPress Media Library Folders & File Manager / 6.3.4
FileBird – WordPress Media Library Folders & File Manager v6.3.4
6.5.8 6.5.7 6.5.5 6.5.4 trunk 4.3.1 5.1.6 5.3 5.3.2 5.4.3 5.4.4 5.4.5 5.5 5.5.3 5.5.5 5.5.8 5.5.8.1 5.6 5.6.1 5.6.2 5.6.3 5.6.4 6.2.3 6.2.5 6.3 All 36 releases
filebird / includes / Model / SettingModel.php

SettingModel.php in FileBird – WordPress Media Library Folders & File Manager 6.3.4, at includes/Model/SettingModel.php

89 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace FileBird\Model;
3
4 use FileBird\Utils\Singleton;
5 use FileBird\Admin\Settings;
6
7 defined( 'ABSPATH' ) || exit;
8
9 class SettingModel {
10 use Singleton;
11 private $settings = array();
12 private $config = array();
13
14 public function __construct() {
15 $this->initialize();
16 $this->settings = $this->loadSettings();
17
18 add_filter( 'fbv_data', array( $this, 'addUserSettingsData' ), 10, 1 );
19 }
20
21 public function initialize() {
22 $this->config = array(
23 'USER_MODE' => array(
24 'get' => 'getUserMode',
25 'set' => 'setUserMode',
26 ),
27 'SVG_SUPPORT' => array(
28 'get' => 'getSvgSupport',
29 'set' => 'setSvgSupport',
30 ),
31 'IS_SEARCH_USING_API' => array(
32 'get' => 'getFolderSearchMethod',
33 'set' => 'setFolderSearchMethod',
34 ),
35 );
36 }
37
38 public function addUserSettingsData( $data ) {
39 $data['user_settings'] = array_merge( $data['user_settings'], $this->settings );
40
41 return $data;
42 }
43
44 public function loadSettings() {
45 foreach ( $this->config as $key => $value ) {
46 $this->settings[ $key ] = $this->{$value['get']}();
47 }
48
49 return $this->settings;
50 }
51
52 public function get( $key ) {
53 if ( in_array( $key, array_keys( $this->config ) ) ) {
54 return $this->settings[ $key ];
55 }
56 }
57
58 public function setSettings( $params ) {
59 foreach ( $params as $key => $value ) {
60 if ( isset( $this->config[ $key ] ) ) {
61 $this->{$this->config[ $key ]['set']}( $value );
62 }
63 }
64 }
65
66 public function getUserMode() {
67 return get_option( 'njt_fbv_folder_per_user', '0' ) === '1';
68 }
69
70 public function setUserMode( $value ) {
71 update_option( 'njt_fbv_folder_per_user', $value );
72 }
73
74 public function getSvgSupport() {
75 return get_option( 'njt_fbv_allow_svg_upload', '0' ) === '1';
76 }
77
78 public function setSvgSupport( $value ) {
79 update_option( 'njt_fbv_allow_svg_upload', $value );
80 }
81
82 public function getFolderSearchMethod() {
83 return get_option( 'njt_fbv_is_search_using_api', '0' ) === '1';
84 }
85
86 public function setFolderSearchMethod( $value ) {
87 update_option( 'njt_fbv_is_search_using_api', $value );
88 }
89 }