PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 All 36 releases
vikbooking / libraries / adapter / config / config.php

config.php in VikBooking Hotel Booking Engine & PMS trunk, at libraries/adapter/config/config.php

174 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikWP - Libraries
4 * @subpackage adapter.config
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * System configuration class.
16 * This class acts as a bridge between the Joomla configuration and
17 * the settings provided by WordPress. In fact, by requesting "offset"
18 * setting, the class will return the "timezone_string" option.
19 *
20 * @since 10.1.4
21 */
22 class JConfig
23 {
24 /**
25 * Returns a property of the object or the default value if the property is not set.
26 *
27 * @param string $key The name of the property.
28 * @param mixed $def The default value (optional) if none is set.
29 *
30 * @return mixed The value of the configuration.
31 */
32 public function get($key, $def = null)
33 {
34 // check for the global timezone
35 if ($key == 'offset')
36 {
37 $offset = get_option('timezone_string');
38
39 // remove any unwanted char (used to ignore manual offsets)
40 $offset = preg_replace("/[^a-zA-Z_\/]/", "", $offset);
41
42 return $offset ? $offset : $def;
43 }
44
45 // switch $key to check if the name of a Joomla setting
46 // should be changed to be used in wordpress
47 switch ($key)
48 {
49 case 'list_limit':
50 $input = JFactory::getApplication()->input;
51
52 /**
53 * Try to use the list limit that belong to the current plugin.
54 *
55 * @since 10.1.23
56 */
57 $page = $input->get('page');
58
59 if ($page)
60 {
61 // use setting name for current plugin
62 $key = $page . '_list_limit';
63 // access user meta (user ID, setting key, true to return a scalar value)
64 $val = get_user_meta(JFactory::getUser()->id, $key, true);
65
66 if ((int) $val > 0)
67 {
68 // return pagination if higher than 0
69 return $val;
70 }
71 }
72 else
73 {
74 /**
75 * No page set in request, we are probably in the front-end.
76 * Try to look for a global option for the list limit of the current plugin.
77 *
78 * @since 10.1.33
79 */
80 $plugin = preg_replace("/^com_/i", '', $input->get('option', ''));
81 $key = $plugin . '_list_limit';
82 }
83
84 $def = abs(is_null($def) ? 20 : $def);
85 break;
86
87 case 'editor':
88 $key = 'system.editor';
89 $def = is_null($def) ? 'tinymce' : $def;
90 break;
91
92 case 'sitename':
93 $key = 'blogname';
94 break;
95
96 /**
97 * Added support for setting used to fetch the system logging path.
98 *
99 * @since 10.1.35
100 */
101 case 'log_path':
102 if (is_string(WP_DEBUG_LOG))
103 {
104 $log_path = WP_DEBUG_LOG;
105 }
106 else
107 {
108 $log_path = WP_CONTENT_DIR;
109 }
110
111 return $log_path;
112
113 /**
114 * Added support for setting used to fetch the system tmp path.
115 *
116 * @since 10.1.35
117 */
118 case 'tmp_path':
119 return get_temp_dir();
120
121 case 'users.new_usertype':
122 $key = 'default_role';
123 $def = is_int($def) ? 'subscriber' : $def;
124 break;
125
126 /**
127 * Added support for setting used to check whether a user
128 * can register a new account.
129 *
130 * @since 10.1.24
131 */
132 case 'users.allowUserRegistration':
133 $key = 'users_can_register';
134 break;
135
136 case 'languages.admin':
137 case 'languages.site':
138 $lang = get_option('WPLANG');
139
140 if (!$lang)
141 {
142 /**
143 * Attempt to load the default language from WPML configuration.
144 *
145 * @since 10.1.54
146 */
147 $activeLanguages = apply_filters('wpml_active_languages', []);
148 $defaultLanguage = apply_filters('wpml_default_language', '');
149 // convert language (en) into an extended locale (en_US)
150 $lang = $activeLanguages[$defaultLanguage]['default_locale'] ?? null;
151 }
152
153 return str_replace('_', '-', $lang ? $lang : 'en-US');
154 }
155
156 return get_option($key, $def);
157 }
158
159 /**
160 * Magic method used to invoke the get() method
161 * by accessing the property name directly.
162 *
163 * @param string $name The property name.
164 *
165 * @return mixed The configuration value.
166 *
167 * @uses get()
168 */
169 public function __get($name)
170 {
171 return $this->get($name);
172 }
173 }
174