class.wdtsettingscontroller.php
4.18 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
defined('ABSPATH') or die('Access denied.');
/**
* Created by PhpStorm.
* User: miljkomilosevic
* Date: 12/2/16
* Time: 4:12 PM
*/
class WDTSettingsController {
public static function sanitizeSettings($settings) {
foreach ($settings as $key=>&$setting) {
if (is_array($setting)) {
foreach ($setting as &$childSetting) {
$childSetting = sanitize_text_field($childSetting);
}
} elseif (function_exists('sanitize_textarea_field') && ($key === "wdtCustomJs" || $key === "wdtCustomCss") ){
$setting = sanitize_textarea_field($setting);
} else {
$setting = sanitize_text_field($setting);
}
}
return $settings;
}
public static function saveSettings( $settings ){
$settings = self::sanitizeSettings( stripslashes_deep( $settings ) );
foreach($settings as $key=>$value) {
update_option($key, $value);
}
do_action('wpdatatables_after_save_settings');
}
public static function getCurrentPluginConfig() {
return array(
'wdtInterfaceLanguage' => get_option('wdtInterfaceLanguage'),
'wdtTablesPerPage' => get_option('wdtTablesPerPage'),
'wdtDateFormat' => get_option('wdtDateFormat'),
'wdtTimeFormat' => get_option('wdtTimeFormat'),
'wdtBaseSkin' => get_option('wdtBaseSkin'),
'wdtNumberFormat' => get_option('wdtNumberFormat'),
'wdtRenderFilter' => get_option('wdtRenderFilter'),
'wdtDecimalPlaces' => get_option('wdtDecimalPlaces'),
'wdtCSVDelimiter' => get_option('wdtCSVDelimiter'),
'wdtTabletWidth' => get_option('wdtTabletWidth'),
'wdtMobileWidth' => get_option('wdtMobileWidth'),
'wdtPurchaseCode' => get_option('wdtPurchaseCode'),
'wdtIncludeBootstrap' => get_option('wdtIncludeBootstrap'),
'wdtIncludeBootstrapBackEnd'=> get_option('wdtIncludeBootstrapBackEnd'),
'wdtParseShortcodes' => get_option('wdtParseShortcodes'),
'wdtNumbersAlign' => get_option('wdtNumbersAlign'),
'wdtBorderRemoval' => get_option('wdtBorderRemoval'),
'wdtBorderRemovalHeader' => get_option('wdtBorderRemovalHeader'),
'wdtUseSeparateCon' => get_option('wdtUseSeparateCon'),
'wdtMySQLHost' => get_option('wdtMySqlHost'),
'wdtMySqlDB' => get_option('wdtMySqlDB'),
'wdtMySqlUser' => get_option('wdtMySqlUser'),
'wdtMySqlPwd' => get_option('wdtMySqlPwd'),
'wdtMySqlPort' => get_option('wdtMySqlPort'),
'wdtCustomCss' => get_option('wdtCustomCss'),
'wdtCustomJs' => get_option('wdtCustomJs'),
'wdtMinifiedJs' => get_option('wdtMinifiedJs'),
'wdtSumFunctionsLabel' => get_option('wdtSumFunctionsLabel'),
'wdtAvgFunctionsLabel' => get_option('wdtAvgFunctionsLabel'),
'wdtMinFunctionsLabel' => get_option('wdtMinFunctionsLabel'),
'wdtMaxFunctionsLabel' => get_option('wdtMaxFunctionsLabel'),
'wdtFontColorSettings' => get_option('wdtFontColorSettings') ? get_option('wdtFontColorSettings') : new stdClass()
);
}
/**
* Returns languages
*/
public static function getInterfaceLanguages(){
$languages = array();
foreach (glob(WDT_ROOT_PATH . 'source/lang/*.inc.php') as $lang_filename) {
$lang_filename = str_replace(WDT_ROOT_PATH . 'source/lang/', '', $lang_filename);
$name = ucwords(str_replace('_', ' ', $lang_filename));
$name = str_replace('.inc.php', '', $name);
$languages[] = array('file' => $lang_filename, 'name' => $name);
}
return $languages;
}
/**
* Returns system fonts
*/
function wdtGetSystemFonts() {
$systemFonts = array(
'Georgia, serif',
'Palatino Linotype, Book Antiqua, Palatino, serif',
'Times New Roman, Times, serif',
'Arial, Helvetica, sans-serif',
'Impact, Charcoal, sans-serif',
'Lucida Sans Unicode, Lucida Grande, sans-serif',
'Tahoma, Geneva, sans-serif',
'Verdana, Geneva, sans-serif',
'Courier New, Courier, monospace',
'Lucida Console, Monaco, monospace'
);
$systemFonts = apply_filters('wpdatatables_get_system_fonts', $systemFonts);
return $systemFonts;
}
}