@@ -27,329 +27,329 @@ |
||
27 | 27 | class CoreAssetManager extends AssetManager |
28 | 28 | { |
29 | 29 | |
30 | - // WordPress core / Third party JS asset handles |
|
31 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
32 | - |
|
33 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
34 | - |
|
35 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
36 | - |
|
37 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
38 | - |
|
39 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
40 | - |
|
41 | - // EE JS assets handles |
|
42 | - const JS_HANDLE_EE_MANIFEST = 'ee-manifest'; |
|
43 | - |
|
44 | - const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
|
45 | - |
|
46 | - const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor'; |
|
47 | - |
|
48 | - const JS_HANDLE_EE_JS_API = 'eejs-api'; |
|
49 | - |
|
50 | - const JS_HANDLE_EE_CORE = 'espresso_core'; |
|
51 | - |
|
52 | - const JS_HANDLE_EE_I18N = 'eei18n'; |
|
53 | - |
|
54 | - const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting'; |
|
55 | - |
|
56 | - const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
57 | - |
|
58 | - // EE CSS assets handles |
|
59 | - const CSS_HANDLE_EE_DEFAULT = 'espresso_default'; |
|
60 | - |
|
61 | - const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css'; |
|
62 | - |
|
63 | - /** |
|
64 | - * @var EE_Currency_Config $currency_config |
|
65 | - */ |
|
66 | - protected $currency_config; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var EE_Template_Config $template_config |
|
70 | - */ |
|
71 | - protected $template_config; |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * CoreAssetRegister constructor. |
|
76 | - * |
|
77 | - * @param AssetCollection $assets |
|
78 | - * @param EE_Currency_Config $currency_config |
|
79 | - * @param EE_Template_Config $template_config |
|
80 | - * @param DomainInterface $domain |
|
81 | - * @param Registry $registry |
|
82 | - */ |
|
83 | - public function __construct( |
|
84 | - AssetCollection $assets, |
|
85 | - EE_Currency_Config $currency_config, |
|
86 | - EE_Template_Config $template_config, |
|
87 | - DomainInterface $domain, |
|
88 | - Registry $registry |
|
89 | - ) { |
|
90 | - $this->currency_config = $currency_config; |
|
91 | - $this->template_config = $template_config; |
|
92 | - parent::__construct($domain, $assets, $registry); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @since 4.9.62.p |
|
98 | - * @throws DuplicateCollectionIdentifierException |
|
99 | - * @throws InvalidArgumentException |
|
100 | - * @throws InvalidDataTypeException |
|
101 | - * @throws InvalidEntityException |
|
102 | - */ |
|
103 | - public function addAssets() |
|
104 | - { |
|
105 | - $this->addJavascriptFiles(); |
|
106 | - $this->addStylesheetFiles(); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @since 4.9.62.p |
|
112 | - * @throws DuplicateCollectionIdentifierException |
|
113 | - * @throws InvalidArgumentException |
|
114 | - * @throws InvalidDataTypeException |
|
115 | - * @throws InvalidEntityException |
|
116 | - */ |
|
117 | - public function addJavascriptFiles() |
|
118 | - { |
|
119 | - $this->loadCoreJs(); |
|
120 | - $this->loadJqueryValidate(); |
|
121 | - $this->loadAccountingJs(); |
|
122 | - add_action( |
|
123 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
124 | - array($this, 'loadQtipJs') |
|
125 | - ); |
|
126 | - $this->registerAdminAssets(); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * @since 4.9.62.p |
|
132 | - * @throws DuplicateCollectionIdentifierException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidEntityException |
|
135 | - */ |
|
136 | - public function addStylesheetFiles() |
|
137 | - { |
|
138 | - $this->loadCoreCss(); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * core default javascript |
|
144 | - * |
|
145 | - * @since 4.9.62.p |
|
146 | - * @throws DuplicateCollectionIdentifierException |
|
147 | - * @throws InvalidArgumentException |
|
148 | - * @throws InvalidDataTypeException |
|
149 | - * @throws InvalidEntityException |
|
150 | - */ |
|
151 | - private function loadCoreJs() |
|
152 | - { |
|
153 | - $this->addJavascript( |
|
154 | - CoreAssetManager::JS_HANDLE_EE_MANIFEST, |
|
155 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
156 | - ); |
|
157 | - |
|
158 | - $this->addJavascript( |
|
159 | - CoreAssetManager::JS_HANDLE_EE_JS_CORE, |
|
160 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
161 | - array(CoreAssetManager::JS_HANDLE_EE_MANIFEST) |
|
162 | - ) |
|
163 | - ->setHasInlineData(); |
|
164 | - |
|
165 | - $this->addJavascript( |
|
166 | - CoreAssetManager::JS_HANDLE_EE_VENDOR, |
|
167 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
168 | - array(CoreAssetManager::JS_HANDLE_EE_JS_CORE) |
|
169 | - ); |
|
170 | - |
|
171 | - global $wp_version; |
|
172 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
173 | - //js.api |
|
174 | - $this->addJavascript( |
|
175 | - CoreAssetManager::JS_HANDLE_EE_JS_API, |
|
176 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
177 | - array( |
|
178 | - CoreAssetManager::JS_HANDLE_UNDERSCORE, |
|
179 | - CoreAssetManager::JS_HANDLE_EE_JS_CORE |
|
180 | - ) |
|
181 | - ); |
|
182 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
183 | - $this->registry->addData('paths', array('rest_route' => rest_url('ee/v4.8.36/'))); |
|
184 | - } |
|
185 | - |
|
186 | - $this->addJavascript( |
|
187 | - CoreAssetManager::JS_HANDLE_EE_CORE, |
|
188 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
189 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
190 | - ) |
|
191 | - ->setInlineDataCallback( |
|
192 | - function () { |
|
193 | - wp_localize_script( |
|
194 | - CoreAssetManager::JS_HANDLE_EE_CORE, |
|
195 | - CoreAssetManager::JS_HANDLE_EE_I18N, |
|
196 | - EE_Registry::$i18n_js_strings |
|
197 | - ); |
|
198 | - } |
|
199 | - ); |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * @since 4.9.62.p |
|
205 | - * @throws DuplicateCollectionIdentifierException |
|
206 | - * @throws InvalidDataTypeException |
|
207 | - * @throws InvalidEntityException |
|
208 | - */ |
|
209 | - private function loadCoreCss() |
|
210 | - { |
|
211 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
212 | - $this->addStylesheet( |
|
213 | - CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
|
214 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
215 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
216 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
217 | - array('dashicons') |
|
218 | - ); |
|
219 | - //Load custom style sheet if available |
|
220 | - if ($this->template_config->custom_style_sheet !== null) { |
|
221 | - $this->addStylesheet( |
|
222 | - CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
|
223 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
224 | - array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
|
225 | - ); |
|
226 | - } |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * jQuery Validate for form validation |
|
233 | - * |
|
234 | - * @since 4.9.62.p |
|
235 | - * @throws DuplicateCollectionIdentifierException |
|
236 | - * @throws InvalidDataTypeException |
|
237 | - * @throws InvalidEntityException |
|
238 | - */ |
|
239 | - private function loadJqueryValidate() |
|
240 | - { |
|
241 | - $this->addJavascript( |
|
242 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
243 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
244 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
245 | - ) |
|
246 | - ->setVersion('1.15.0'); |
|
247 | - |
|
248 | - $this->addJavascript( |
|
249 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
250 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
251 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
252 | - ) |
|
253 | - ->setVersion('1.15.0'); |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * accounting.js for performing client-side calculations |
|
259 | - * |
|
260 | - * @since 4.9.62.p |
|
261 | - * @throws DuplicateCollectionIdentifierException |
|
262 | - * @throws InvalidDataTypeException |
|
263 | - * @throws InvalidEntityException |
|
264 | - */ |
|
265 | - private function loadAccountingJs() |
|
266 | - { |
|
267 | - //accounting.js library |
|
268 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
269 | - $this->addJavascript( |
|
270 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
271 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
272 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
273 | - ) |
|
274 | - ->setVersion('0.3.2'); |
|
275 | - |
|
276 | - $currency_config = $this->currency_config; |
|
277 | - $this->addJavascript( |
|
278 | - CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
279 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
280 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
281 | - ) |
|
282 | - ->setInlineDataCallback( |
|
283 | - function () use ($currency_config) { |
|
284 | - wp_localize_script( |
|
285 | - CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
286 | - 'EE_ACCOUNTING_CFG', |
|
287 | - array( |
|
288 | - 'currency' => array( |
|
289 | - 'symbol' => $currency_config->sign, |
|
290 | - 'format' => array( |
|
291 | - 'pos' => $currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
292 | - 'neg' => $currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
293 | - 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s', |
|
294 | - ), |
|
295 | - 'decimal' => $currency_config->dec_mrk, |
|
296 | - 'thousand' => $currency_config->thsnds, |
|
297 | - 'precision' => $currency_config->dec_plc, |
|
298 | - ), |
|
299 | - 'number' => array( |
|
300 | - 'precision' => $currency_config->dec_plc, |
|
301 | - 'thousand' => $currency_config->thsnds, |
|
302 | - 'decimal' => $currency_config->dec_mrk, |
|
303 | - ), |
|
304 | - ) |
|
305 | - ); |
|
306 | - } |
|
307 | - ) |
|
308 | - ->setVersion(); |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * registers assets for cleaning your ears |
|
314 | - * |
|
315 | - * @param JavascriptAsset $script |
|
316 | - */ |
|
317 | - public function loadQtipJs(JavascriptAsset $script) |
|
318 | - { |
|
319 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
320 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
321 | - if ( |
|
322 | - $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE |
|
323 | - && apply_filters('FHEE_load_qtip', false) |
|
324 | - ) { |
|
325 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
326 | - } |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * assets that are used in the WordPress admin |
|
332 | - * |
|
333 | - * @since 4.9.62.p |
|
334 | - * @throws DuplicateCollectionIdentifierException |
|
335 | - * @throws InvalidDataTypeException |
|
336 | - * @throws InvalidEntityException |
|
337 | - */ |
|
338 | - private function registerAdminAssets() |
|
339 | - { |
|
340 | - $this->addJavascript( |
|
341 | - CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
342 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
343 | - array( |
|
344 | - CoreAssetManager::JS_HANDLE_JQUERY, |
|
345 | - CoreAssetManager::JS_HANDLE_EE_VENDOR, |
|
346 | - ) |
|
347 | - ) |
|
348 | - ->setRequiresTranslation(); |
|
349 | - |
|
350 | - $this->addStylesheet( |
|
351 | - CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
352 | - $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
353 | - ); |
|
354 | - } |
|
30 | + // WordPress core / Third party JS asset handles |
|
31 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
32 | + |
|
33 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
34 | + |
|
35 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
36 | + |
|
37 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
38 | + |
|
39 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
40 | + |
|
41 | + // EE JS assets handles |
|
42 | + const JS_HANDLE_EE_MANIFEST = 'ee-manifest'; |
|
43 | + |
|
44 | + const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
|
45 | + |
|
46 | + const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor'; |
|
47 | + |
|
48 | + const JS_HANDLE_EE_JS_API = 'eejs-api'; |
|
49 | + |
|
50 | + const JS_HANDLE_EE_CORE = 'espresso_core'; |
|
51 | + |
|
52 | + const JS_HANDLE_EE_I18N = 'eei18n'; |
|
53 | + |
|
54 | + const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting'; |
|
55 | + |
|
56 | + const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
57 | + |
|
58 | + // EE CSS assets handles |
|
59 | + const CSS_HANDLE_EE_DEFAULT = 'espresso_default'; |
|
60 | + |
|
61 | + const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css'; |
|
62 | + |
|
63 | + /** |
|
64 | + * @var EE_Currency_Config $currency_config |
|
65 | + */ |
|
66 | + protected $currency_config; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var EE_Template_Config $template_config |
|
70 | + */ |
|
71 | + protected $template_config; |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * CoreAssetRegister constructor. |
|
76 | + * |
|
77 | + * @param AssetCollection $assets |
|
78 | + * @param EE_Currency_Config $currency_config |
|
79 | + * @param EE_Template_Config $template_config |
|
80 | + * @param DomainInterface $domain |
|
81 | + * @param Registry $registry |
|
82 | + */ |
|
83 | + public function __construct( |
|
84 | + AssetCollection $assets, |
|
85 | + EE_Currency_Config $currency_config, |
|
86 | + EE_Template_Config $template_config, |
|
87 | + DomainInterface $domain, |
|
88 | + Registry $registry |
|
89 | + ) { |
|
90 | + $this->currency_config = $currency_config; |
|
91 | + $this->template_config = $template_config; |
|
92 | + parent::__construct($domain, $assets, $registry); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @since 4.9.62.p |
|
98 | + * @throws DuplicateCollectionIdentifierException |
|
99 | + * @throws InvalidArgumentException |
|
100 | + * @throws InvalidDataTypeException |
|
101 | + * @throws InvalidEntityException |
|
102 | + */ |
|
103 | + public function addAssets() |
|
104 | + { |
|
105 | + $this->addJavascriptFiles(); |
|
106 | + $this->addStylesheetFiles(); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @since 4.9.62.p |
|
112 | + * @throws DuplicateCollectionIdentifierException |
|
113 | + * @throws InvalidArgumentException |
|
114 | + * @throws InvalidDataTypeException |
|
115 | + * @throws InvalidEntityException |
|
116 | + */ |
|
117 | + public function addJavascriptFiles() |
|
118 | + { |
|
119 | + $this->loadCoreJs(); |
|
120 | + $this->loadJqueryValidate(); |
|
121 | + $this->loadAccountingJs(); |
|
122 | + add_action( |
|
123 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
124 | + array($this, 'loadQtipJs') |
|
125 | + ); |
|
126 | + $this->registerAdminAssets(); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * @since 4.9.62.p |
|
132 | + * @throws DuplicateCollectionIdentifierException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidEntityException |
|
135 | + */ |
|
136 | + public function addStylesheetFiles() |
|
137 | + { |
|
138 | + $this->loadCoreCss(); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * core default javascript |
|
144 | + * |
|
145 | + * @since 4.9.62.p |
|
146 | + * @throws DuplicateCollectionIdentifierException |
|
147 | + * @throws InvalidArgumentException |
|
148 | + * @throws InvalidDataTypeException |
|
149 | + * @throws InvalidEntityException |
|
150 | + */ |
|
151 | + private function loadCoreJs() |
|
152 | + { |
|
153 | + $this->addJavascript( |
|
154 | + CoreAssetManager::JS_HANDLE_EE_MANIFEST, |
|
155 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
156 | + ); |
|
157 | + |
|
158 | + $this->addJavascript( |
|
159 | + CoreAssetManager::JS_HANDLE_EE_JS_CORE, |
|
160 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
161 | + array(CoreAssetManager::JS_HANDLE_EE_MANIFEST) |
|
162 | + ) |
|
163 | + ->setHasInlineData(); |
|
164 | + |
|
165 | + $this->addJavascript( |
|
166 | + CoreAssetManager::JS_HANDLE_EE_VENDOR, |
|
167 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
168 | + array(CoreAssetManager::JS_HANDLE_EE_JS_CORE) |
|
169 | + ); |
|
170 | + |
|
171 | + global $wp_version; |
|
172 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
173 | + //js.api |
|
174 | + $this->addJavascript( |
|
175 | + CoreAssetManager::JS_HANDLE_EE_JS_API, |
|
176 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
177 | + array( |
|
178 | + CoreAssetManager::JS_HANDLE_UNDERSCORE, |
|
179 | + CoreAssetManager::JS_HANDLE_EE_JS_CORE |
|
180 | + ) |
|
181 | + ); |
|
182 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
183 | + $this->registry->addData('paths', array('rest_route' => rest_url('ee/v4.8.36/'))); |
|
184 | + } |
|
185 | + |
|
186 | + $this->addJavascript( |
|
187 | + CoreAssetManager::JS_HANDLE_EE_CORE, |
|
188 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
189 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
190 | + ) |
|
191 | + ->setInlineDataCallback( |
|
192 | + function () { |
|
193 | + wp_localize_script( |
|
194 | + CoreAssetManager::JS_HANDLE_EE_CORE, |
|
195 | + CoreAssetManager::JS_HANDLE_EE_I18N, |
|
196 | + EE_Registry::$i18n_js_strings |
|
197 | + ); |
|
198 | + } |
|
199 | + ); |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * @since 4.9.62.p |
|
205 | + * @throws DuplicateCollectionIdentifierException |
|
206 | + * @throws InvalidDataTypeException |
|
207 | + * @throws InvalidEntityException |
|
208 | + */ |
|
209 | + private function loadCoreCss() |
|
210 | + { |
|
211 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
212 | + $this->addStylesheet( |
|
213 | + CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
|
214 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
215 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
216 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
217 | + array('dashicons') |
|
218 | + ); |
|
219 | + //Load custom style sheet if available |
|
220 | + if ($this->template_config->custom_style_sheet !== null) { |
|
221 | + $this->addStylesheet( |
|
222 | + CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
|
223 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
224 | + array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
|
225 | + ); |
|
226 | + } |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * jQuery Validate for form validation |
|
233 | + * |
|
234 | + * @since 4.9.62.p |
|
235 | + * @throws DuplicateCollectionIdentifierException |
|
236 | + * @throws InvalidDataTypeException |
|
237 | + * @throws InvalidEntityException |
|
238 | + */ |
|
239 | + private function loadJqueryValidate() |
|
240 | + { |
|
241 | + $this->addJavascript( |
|
242 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
243 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
244 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
245 | + ) |
|
246 | + ->setVersion('1.15.0'); |
|
247 | + |
|
248 | + $this->addJavascript( |
|
249 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
250 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
251 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
252 | + ) |
|
253 | + ->setVersion('1.15.0'); |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * accounting.js for performing client-side calculations |
|
259 | + * |
|
260 | + * @since 4.9.62.p |
|
261 | + * @throws DuplicateCollectionIdentifierException |
|
262 | + * @throws InvalidDataTypeException |
|
263 | + * @throws InvalidEntityException |
|
264 | + */ |
|
265 | + private function loadAccountingJs() |
|
266 | + { |
|
267 | + //accounting.js library |
|
268 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
269 | + $this->addJavascript( |
|
270 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
271 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
272 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
273 | + ) |
|
274 | + ->setVersion('0.3.2'); |
|
275 | + |
|
276 | + $currency_config = $this->currency_config; |
|
277 | + $this->addJavascript( |
|
278 | + CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
279 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
280 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
281 | + ) |
|
282 | + ->setInlineDataCallback( |
|
283 | + function () use ($currency_config) { |
|
284 | + wp_localize_script( |
|
285 | + CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
286 | + 'EE_ACCOUNTING_CFG', |
|
287 | + array( |
|
288 | + 'currency' => array( |
|
289 | + 'symbol' => $currency_config->sign, |
|
290 | + 'format' => array( |
|
291 | + 'pos' => $currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
292 | + 'neg' => $currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
293 | + 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s', |
|
294 | + ), |
|
295 | + 'decimal' => $currency_config->dec_mrk, |
|
296 | + 'thousand' => $currency_config->thsnds, |
|
297 | + 'precision' => $currency_config->dec_plc, |
|
298 | + ), |
|
299 | + 'number' => array( |
|
300 | + 'precision' => $currency_config->dec_plc, |
|
301 | + 'thousand' => $currency_config->thsnds, |
|
302 | + 'decimal' => $currency_config->dec_mrk, |
|
303 | + ), |
|
304 | + ) |
|
305 | + ); |
|
306 | + } |
|
307 | + ) |
|
308 | + ->setVersion(); |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * registers assets for cleaning your ears |
|
314 | + * |
|
315 | + * @param JavascriptAsset $script |
|
316 | + */ |
|
317 | + public function loadQtipJs(JavascriptAsset $script) |
|
318 | + { |
|
319 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
320 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
321 | + if ( |
|
322 | + $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE |
|
323 | + && apply_filters('FHEE_load_qtip', false) |
|
324 | + ) { |
|
325 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
326 | + } |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * assets that are used in the WordPress admin |
|
332 | + * |
|
333 | + * @since 4.9.62.p |
|
334 | + * @throws DuplicateCollectionIdentifierException |
|
335 | + * @throws InvalidDataTypeException |
|
336 | + * @throws InvalidEntityException |
|
337 | + */ |
|
338 | + private function registerAdminAssets() |
|
339 | + { |
|
340 | + $this->addJavascript( |
|
341 | + CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
342 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
343 | + array( |
|
344 | + CoreAssetManager::JS_HANDLE_JQUERY, |
|
345 | + CoreAssetManager::JS_HANDLE_EE_VENDOR, |
|
346 | + ) |
|
347 | + ) |
|
348 | + ->setRequiresTranslation(); |
|
349 | + |
|
350 | + $this->addStylesheet( |
|
351 | + CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
352 | + $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
353 | + ); |
|
354 | + } |
|
355 | 355 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
45 | 45 | |
46 | - const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor'; |
|
46 | + const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor'; |
|
47 | 47 | |
48 | 48 | const JS_HANDLE_EE_JS_API = 'eejs-api'; |
49 | 49 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | //js.api |
174 | 174 | $this->addJavascript( |
175 | 175 | CoreAssetManager::JS_HANDLE_EE_JS_API, |
176 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
176 | + EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js', |
|
177 | 177 | array( |
178 | 178 | CoreAssetManager::JS_HANDLE_UNDERSCORE, |
179 | 179 | CoreAssetManager::JS_HANDLE_EE_JS_CORE |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | |
186 | 186 | $this->addJavascript( |
187 | 187 | CoreAssetManager::JS_HANDLE_EE_CORE, |
188 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
188 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
189 | 189 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
190 | 190 | ) |
191 | 191 | ->setInlineDataCallback( |
192 | - function () { |
|
192 | + function() { |
|
193 | 193 | wp_localize_script( |
194 | 194 | CoreAssetManager::JS_HANDLE_EE_CORE, |
195 | 195 | CoreAssetManager::JS_HANDLE_EE_I18N, |
@@ -211,16 +211,16 @@ discard block |
||
211 | 211 | if ($this->template_config->enable_default_style && ! is_admin()) { |
212 | 212 | $this->addStylesheet( |
213 | 213 | CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
214 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
214 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
215 | 215 | ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
216 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
216 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
217 | 217 | array('dashicons') |
218 | 218 | ); |
219 | 219 | //Load custom style sheet if available |
220 | 220 | if ($this->template_config->custom_style_sheet !== null) { |
221 | 221 | $this->addStylesheet( |
222 | 222 | CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
223 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
223 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
224 | 224 | array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
225 | 225 | ); |
226 | 226 | } |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | { |
241 | 241 | $this->addJavascript( |
242 | 242 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
243 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
243 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
244 | 244 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
245 | 245 | ) |
246 | 246 | ->setVersion('1.15.0'); |
247 | 247 | |
248 | 248 | $this->addJavascript( |
249 | 249 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
250 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
250 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
251 | 251 | array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
252 | 252 | ) |
253 | 253 | ->setVersion('1.15.0'); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | // @link http://josscrowcroft.github.io/accounting.js/ |
269 | 269 | $this->addJavascript( |
270 | 270 | CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
271 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
271 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
272 | 272 | array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
273 | 273 | ) |
274 | 274 | ->setVersion('0.3.2'); |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | $currency_config = $this->currency_config; |
277 | 277 | $this->addJavascript( |
278 | 278 | CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
279 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
279 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
280 | 280 | array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
281 | 281 | ) |
282 | 282 | ->setInlineDataCallback( |
283 | - function () use ($currency_config) { |
|
283 | + function() use ($currency_config) { |
|
284 | 284 | wp_localize_script( |
285 | 285 | CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
286 | 286 | 'EE_ACCOUNTING_CFG', |
@@ -23,492 +23,492 @@ |
||
23 | 23 | */ |
24 | 24 | abstract class EE_Gateway |
25 | 25 | { |
26 | - /** |
|
27 | - * a constant used as a possible value for $_currencies_supported to indicate |
|
28 | - * that ALL currencies are supported by this gateway |
|
29 | - */ |
|
30 | - const all_currencies_supported = 'all_currencies_supported'; |
|
31 | - /** |
|
32 | - * Where values are 3-letter currency codes |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - protected $_currencies_supported = array(); |
|
37 | - /** |
|
38 | - * Whether or not this gateway can support SENDING a refund request (ie, initiated by |
|
39 | - * admin in EE's wp-admin page) |
|
40 | - * |
|
41 | - * @var boolean |
|
42 | - */ |
|
43 | - protected $_supports_sending_refunds = false; |
|
44 | - |
|
45 | - /** |
|
46 | - * Whether or not this gateway can support RECEIVING a refund request from the payment |
|
47 | - * provider (ie, initiated by admin on the payment prover's website who sends an IPN to EE) |
|
48 | - * |
|
49 | - * @var boolean |
|
50 | - */ |
|
51 | - protected $_supports_receiving_refunds = false; |
|
52 | - /** |
|
53 | - * Model for querying for existing payments |
|
54 | - * |
|
55 | - * @var EEMI_Payment |
|
56 | - */ |
|
57 | - protected $_pay_model; |
|
58 | - |
|
59 | - /** |
|
60 | - * Model used for adding to the payments log |
|
61 | - * |
|
62 | - * @var EEMI_Payment_Log |
|
63 | - */ |
|
64 | - protected $_pay_log; |
|
65 | - |
|
66 | - /** |
|
67 | - * Used for formatting some input to gateways |
|
68 | - * |
|
69 | - * @var EEHI_Template |
|
70 | - */ |
|
71 | - protected $_template; |
|
72 | - |
|
73 | - /** |
|
74 | - * Concrete class that implements EEHI_Money, used by most gateways |
|
75 | - * |
|
76 | - * @var EEHI_Money |
|
77 | - */ |
|
78 | - protected $_money; |
|
79 | - |
|
80 | - /** |
|
81 | - * Concrete class that implements EEHI_Line_Item, used for manipulating the line item tree |
|
82 | - * |
|
83 | - * @var EEHI_Line_Item |
|
84 | - */ |
|
85 | - protected $_line_item; |
|
86 | - |
|
87 | - /** |
|
88 | - * @var GatewayDataFormatterInterface |
|
89 | - */ |
|
90 | - protected $_gateway_data_formatter; |
|
91 | - |
|
92 | - /** |
|
93 | - * @var FormatterInterface |
|
94 | - */ |
|
95 | - protected $_unsupported_character_remover; |
|
96 | - |
|
97 | - /** |
|
98 | - * The ID of the payment method using this gateway |
|
99 | - * |
|
100 | - * @var int |
|
101 | - */ |
|
102 | - protected $_ID; |
|
103 | - |
|
104 | - /** |
|
105 | - * @var $_debug_mode boolean whether to send requests to teh sandbox site or not |
|
106 | - */ |
|
107 | - protected $_debug_mode; |
|
108 | - /** |
|
109 | - * |
|
110 | - * @var string $_name name to show for this payment method |
|
111 | - */ |
|
112 | - protected $_name; |
|
113 | - /** |
|
114 | - * |
|
115 | - * @var string name to show fir this payment method to admin-type users |
|
116 | - */ |
|
117 | - protected $_admin_name; |
|
118 | - |
|
119 | - /** |
|
120 | - * @return EE_Gateway |
|
121 | - */ |
|
122 | - public function __construct() |
|
123 | - { |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * We don't want to serialize models as they often have circular structures |
|
128 | - * (eg a payment model has a reference to each payment model object; and most |
|
129 | - * payments have a transaction, most transactions have a payment method; |
|
130 | - * most payment methods have a payment method type; most payment method types |
|
131 | - * have a gateway. And if a gateway serializes its models, we start at the |
|
132 | - * beginning again) |
|
133 | - * |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - public function __sleep() |
|
137 | - { |
|
138 | - $properties = get_object_vars($this); |
|
139 | - unset($properties['_pay_model'], $properties['_pay_log']); |
|
140 | - return array_keys($properties); |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Returns whether or not this gateway should support SENDING refunds |
|
145 | - * see $_supports_sending_refunds |
|
146 | - * |
|
147 | - * @return boolean |
|
148 | - */ |
|
149 | - public function supports_sending_refunds() |
|
150 | - { |
|
151 | - return $this->_supports_sending_refunds; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Returns whether or not this gateway should support RECEIVING refunds |
|
156 | - * see $_supports_receiving_refunds |
|
157 | - * |
|
158 | - * @return boolean |
|
159 | - */ |
|
160 | - public function supports_receiving_refunds() |
|
161 | - { |
|
162 | - return $this->_supports_receiving_refunds; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * Tries to refund the payment specified, taking into account the extra |
|
168 | - * refund info. Note that if the gateway's _supports_sending_refunds is false, |
|
169 | - * this should just throw an exception. |
|
170 | - * |
|
171 | - * @param EE_Payment $payment |
|
172 | - * @param array $refund_info |
|
173 | - * @return EE_Payment for the refund |
|
174 | - * @throws EE_Error |
|
175 | - */ |
|
176 | - public function do_direct_refund(EE_Payment $payment, $refund_info = null) |
|
177 | - { |
|
178 | - return null; |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * Sets the payment method's settings so the gateway knows where to send the request |
|
184 | - * etc |
|
185 | - * |
|
186 | - * @param array $settings_array |
|
187 | - */ |
|
188 | - public function set_settings($settings_array) |
|
189 | - { |
|
190 | - foreach ($settings_array as $name => $value) { |
|
191 | - $property_name = "_" . $name; |
|
192 | - $this->{$property_name} = $value; |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * See this class description |
|
198 | - * |
|
199 | - * @param EEMI_Payment $payment_model |
|
200 | - */ |
|
201 | - public function set_payment_model($payment_model) |
|
202 | - { |
|
203 | - $this->_pay_model = $payment_model; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * See this class description |
|
208 | - * |
|
209 | - * @param EEMI_Payment_Log $payment_log_model |
|
210 | - */ |
|
211 | - public function set_payment_log($payment_log_model) |
|
212 | - { |
|
213 | - $this->_pay_log = $payment_log_model; |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * See this class description |
|
218 | - * |
|
219 | - * @param EEHI_Template $template_helper |
|
220 | - */ |
|
221 | - public function set_template_helper($template_helper) |
|
222 | - { |
|
223 | - $this->_template = $template_helper; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * See this class description |
|
228 | - * |
|
229 | - * @param EEHI_Line_Item $line_item_helper |
|
230 | - */ |
|
231 | - public function set_line_item_helper($line_item_helper) |
|
232 | - { |
|
233 | - $this->_line_item = $line_item_helper; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * See this class description |
|
238 | - * |
|
239 | - * @param EEHI_Money $money_helper |
|
240 | - */ |
|
241 | - public function set_money_helper($money_helper) |
|
242 | - { |
|
243 | - $this->_money = $money_helper; |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * Sets the gateway data formatter helper |
|
249 | - * |
|
250 | - * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
251 | - * @throws InvalidEntityException if it's not set properly |
|
252 | - */ |
|
253 | - public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) |
|
254 | - { |
|
255 | - if (! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
256 | - throw new InvalidEntityException( |
|
257 | - is_object($gateway_data_formatter) |
|
258 | - ? get_class($gateway_data_formatter) |
|
259 | - : esc_html__('Not an object', 'event_espresso'), |
|
260 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
261 | - ); |
|
262 | - } |
|
263 | - $this->_gateway_data_formatter = $gateway_data_formatter; |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * Gets the gateway data formatter |
|
268 | - * |
|
269 | - * @return GatewayDataFormatterInterface |
|
270 | - * @throws InvalidEntityException if it's not set properly |
|
271 | - */ |
|
272 | - protected function _get_gateway_formatter() |
|
273 | - { |
|
274 | - if (! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
275 | - throw new InvalidEntityException( |
|
276 | - is_object($this->_gateway_data_formatter) |
|
277 | - ? get_class($this->_gateway_data_formatter) |
|
278 | - : esc_html__('Not an object', 'event_espresso'), |
|
279 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
280 | - ); |
|
281 | - } |
|
282 | - return $this->_gateway_data_formatter; |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * Sets the helper which will remove unsupported characters for most gateways |
|
288 | - * |
|
289 | - * @param FormatterInterface $formatter |
|
290 | - * @return FormatterInterface |
|
291 | - * @throws InvalidEntityException |
|
292 | - */ |
|
293 | - public function set_unsupported_character_remover(FormatterInterface $formatter) |
|
294 | - { |
|
295 | - if (! $formatter instanceof FormatterInterface) { |
|
296 | - throw new InvalidEntityException( |
|
297 | - is_object($formatter) |
|
298 | - ? get_class($formatter) |
|
299 | - : esc_html__('Not an object', 'event_espresso'), |
|
300 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
301 | - ); |
|
302 | - } |
|
303 | - $this->_unsupported_character_remover = $formatter; |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
308 | - * |
|
309 | - * @return FormatterInterface |
|
310 | - * @throws InvalidEntityException |
|
311 | - */ |
|
312 | - protected function _get_unsupported_character_remover() |
|
313 | - { |
|
314 | - if (! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
315 | - throw new InvalidEntityException( |
|
316 | - is_object($this->_unsupported_character_remover) |
|
317 | - ? get_class($this->_unsupported_character_remover) |
|
318 | - : esc_html__('Not an object', 'event_espresso'), |
|
319 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
320 | - ); |
|
321 | - } |
|
322 | - return $this->_unsupported_character_remover; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @param $message |
|
328 | - * @param $payment |
|
329 | - */ |
|
330 | - public function log($message, $payment) |
|
331 | - { |
|
332 | - if ($payment instanceof EEI_Payment) { |
|
333 | - $type = 'Payment'; |
|
334 | - $id = $payment->ID(); |
|
335 | - } else { |
|
336 | - $type = 'Payment_Method'; |
|
337 | - $id = $this->_ID; |
|
338 | - } |
|
339 | - // only log if we're going to store it for longer than the minimum time |
|
340 | - $reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config'); |
|
341 | - if ($reg_config->gateway_log_lifespan !== '1 second') { |
|
342 | - $this->_pay_log->gateway_log($message, $id, $type); |
|
343 | - } |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Formats the amount so it can generally be sent to gateways |
|
348 | - * |
|
349 | - * @param float $amount |
|
350 | - * @return string |
|
351 | - * @deprecated since 4.9.31 insetad use |
|
352 | - * EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
353 | - */ |
|
354 | - public function format_currency($amount) |
|
355 | - { |
|
356 | - return $this->_get_gateway_formatter()->formatCurrency($amount); |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Returns either an array of all the currency codes supported, |
|
361 | - * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
|
362 | - * |
|
363 | - * @return mixed array or string |
|
364 | - */ |
|
365 | - public function currencies_supported() |
|
366 | - { |
|
367 | - return $this->_currencies_supported; |
|
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * Returns what a simple summing of items and taxes for this transaction. This |
|
372 | - * can be used to determine if some more complex line items, like promotions, |
|
373 | - * surcharges, or cancellations occurred (in which case we might want to forget |
|
374 | - * about creating an itemized list of purchases and instead only send the total due) |
|
375 | - * |
|
376 | - * @param EE_Transaction $transaction |
|
377 | - * @return float |
|
378 | - */ |
|
379 | - protected function _sum_items_and_taxes(EE_Transaction $transaction) |
|
380 | - { |
|
381 | - $total_line_item = $transaction->total_line_item(); |
|
382 | - $total = 0; |
|
383 | - foreach ($total_line_item->get_items() as $item_line_item) { |
|
384 | - $total += max($item_line_item->total(), 0); |
|
385 | - } |
|
386 | - foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
387 | - $total += max($tax_line_item->total(), 0); |
|
388 | - } |
|
389 | - return $total; |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * Determines whether or not we can easily itemize the transaction using only |
|
394 | - * items and taxes (ie, no promotions or surcharges or cancellations needed) |
|
395 | - * |
|
396 | - * @param EEI_Payment $payment |
|
397 | - * @return boolean |
|
398 | - */ |
|
399 | - protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) |
|
400 | - { |
|
401 | - return $this->_money->compare_floats( |
|
402 | - $this->_sum_items_and_taxes($payment->transaction()), |
|
403 | - $payment->transaction()->total() |
|
404 | - ) |
|
405 | - && $this->_money->compare_floats( |
|
406 | - $payment->amount(), |
|
407 | - $payment->transaction()->total() |
|
408 | - ); |
|
409 | - } |
|
410 | - |
|
411 | - /** |
|
412 | - * Handles updating the transaction and any other related data based on the payment. |
|
413 | - * You may be tempted to do this as part of do_direct_payment or handle_payment_update, |
|
414 | - * but doing so on those functions might be too early. It's possible that the changes |
|
415 | - * you make to teh transaction or registration or line items may just get overwritten |
|
416 | - * at that point. Instead, you should store any info you need on the payment during those |
|
417 | - * functions, and use that information at this step, which client code will decide |
|
418 | - * for you when it should be called. |
|
419 | - * |
|
420 | - * @param EE_Payment $payment |
|
421 | - * @return void |
|
422 | - */ |
|
423 | - public function update_txn_based_on_payment($payment) |
|
424 | - { |
|
425 | - // maybe update the transaction or line items or registrations |
|
426 | - // but most gateways don't need to do this, because they only update the payment |
|
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * Gets the first event for this payment (it's possible that it could be for multiple) |
|
431 | - * |
|
432 | - * @param EEI_Payment $payment |
|
433 | - * @return EEI_Event|null |
|
434 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
435 | - */ |
|
436 | - protected function _get_first_event_for_payment(EEI_Payment $payment) |
|
437 | - { |
|
438 | - return $payment->get_first_event(); |
|
439 | - } |
|
440 | - |
|
441 | - /** |
|
442 | - * Gets the name of the first event for which is being paid |
|
443 | - * |
|
444 | - * @param EEI_Payment $payment |
|
445 | - * @return string |
|
446 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
447 | - */ |
|
448 | - protected function _get_first_event_name_for_payment(EEI_Payment $payment) |
|
449 | - { |
|
450 | - return $payment->get_first_event_name(); |
|
451 | - } |
|
452 | - |
|
453 | - /** |
|
454 | - * Gets the text to use for a gateway's line item name when this is a partial payment |
|
455 | - * |
|
456 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
457 | - * @param EE_Payment $payment |
|
458 | - * @return string |
|
459 | - */ |
|
460 | - protected function _format_partial_payment_line_item_name(EEI_Payment $payment) |
|
461 | - { |
|
462 | - return $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment); |
|
463 | - } |
|
464 | - |
|
465 | - /** |
|
466 | - * Gets the text to use for a gateway's line item description when this is a partial payment |
|
467 | - * |
|
468 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
469 | - * @param EEI_Payment $payment |
|
470 | - * @return string |
|
471 | - */ |
|
472 | - protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) |
|
473 | - { |
|
474 | - return $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc($payment); |
|
475 | - } |
|
476 | - |
|
477 | - /** |
|
478 | - * Gets the name to use for a line item when sending line items to the gateway |
|
479 | - * |
|
480 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
481 | - * @param EEI_Line_Item $line_item |
|
482 | - * @param EEI_Payment $payment |
|
483 | - * @return string |
|
484 | - */ |
|
485 | - protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
486 | - { |
|
487 | - return $this->_get_gateway_formatter()->formatLineItemName($line_item, $payment); |
|
488 | - } |
|
489 | - |
|
490 | - /** |
|
491 | - * Gets the description to use for a line item when sending line items to the gateway |
|
492 | - * |
|
493 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
494 | - * @param EEI_Line_Item $line_item |
|
495 | - * @param EEI_Payment $payment |
|
496 | - * @return string |
|
497 | - */ |
|
498 | - protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
499 | - { |
|
500 | - return $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment); |
|
501 | - } |
|
502 | - |
|
503 | - /** |
|
504 | - * Gets the order description that should generlly be sent to gateways |
|
505 | - * |
|
506 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
507 | - * @param EEI_Payment $payment |
|
508 | - * @return type |
|
509 | - */ |
|
510 | - protected function _format_order_description(EEI_Payment $payment) |
|
511 | - { |
|
512 | - return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
|
513 | - } |
|
26 | + /** |
|
27 | + * a constant used as a possible value for $_currencies_supported to indicate |
|
28 | + * that ALL currencies are supported by this gateway |
|
29 | + */ |
|
30 | + const all_currencies_supported = 'all_currencies_supported'; |
|
31 | + /** |
|
32 | + * Where values are 3-letter currency codes |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + protected $_currencies_supported = array(); |
|
37 | + /** |
|
38 | + * Whether or not this gateway can support SENDING a refund request (ie, initiated by |
|
39 | + * admin in EE's wp-admin page) |
|
40 | + * |
|
41 | + * @var boolean |
|
42 | + */ |
|
43 | + protected $_supports_sending_refunds = false; |
|
44 | + |
|
45 | + /** |
|
46 | + * Whether or not this gateway can support RECEIVING a refund request from the payment |
|
47 | + * provider (ie, initiated by admin on the payment prover's website who sends an IPN to EE) |
|
48 | + * |
|
49 | + * @var boolean |
|
50 | + */ |
|
51 | + protected $_supports_receiving_refunds = false; |
|
52 | + /** |
|
53 | + * Model for querying for existing payments |
|
54 | + * |
|
55 | + * @var EEMI_Payment |
|
56 | + */ |
|
57 | + protected $_pay_model; |
|
58 | + |
|
59 | + /** |
|
60 | + * Model used for adding to the payments log |
|
61 | + * |
|
62 | + * @var EEMI_Payment_Log |
|
63 | + */ |
|
64 | + protected $_pay_log; |
|
65 | + |
|
66 | + /** |
|
67 | + * Used for formatting some input to gateways |
|
68 | + * |
|
69 | + * @var EEHI_Template |
|
70 | + */ |
|
71 | + protected $_template; |
|
72 | + |
|
73 | + /** |
|
74 | + * Concrete class that implements EEHI_Money, used by most gateways |
|
75 | + * |
|
76 | + * @var EEHI_Money |
|
77 | + */ |
|
78 | + protected $_money; |
|
79 | + |
|
80 | + /** |
|
81 | + * Concrete class that implements EEHI_Line_Item, used for manipulating the line item tree |
|
82 | + * |
|
83 | + * @var EEHI_Line_Item |
|
84 | + */ |
|
85 | + protected $_line_item; |
|
86 | + |
|
87 | + /** |
|
88 | + * @var GatewayDataFormatterInterface |
|
89 | + */ |
|
90 | + protected $_gateway_data_formatter; |
|
91 | + |
|
92 | + /** |
|
93 | + * @var FormatterInterface |
|
94 | + */ |
|
95 | + protected $_unsupported_character_remover; |
|
96 | + |
|
97 | + /** |
|
98 | + * The ID of the payment method using this gateway |
|
99 | + * |
|
100 | + * @var int |
|
101 | + */ |
|
102 | + protected $_ID; |
|
103 | + |
|
104 | + /** |
|
105 | + * @var $_debug_mode boolean whether to send requests to teh sandbox site or not |
|
106 | + */ |
|
107 | + protected $_debug_mode; |
|
108 | + /** |
|
109 | + * |
|
110 | + * @var string $_name name to show for this payment method |
|
111 | + */ |
|
112 | + protected $_name; |
|
113 | + /** |
|
114 | + * |
|
115 | + * @var string name to show fir this payment method to admin-type users |
|
116 | + */ |
|
117 | + protected $_admin_name; |
|
118 | + |
|
119 | + /** |
|
120 | + * @return EE_Gateway |
|
121 | + */ |
|
122 | + public function __construct() |
|
123 | + { |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * We don't want to serialize models as they often have circular structures |
|
128 | + * (eg a payment model has a reference to each payment model object; and most |
|
129 | + * payments have a transaction, most transactions have a payment method; |
|
130 | + * most payment methods have a payment method type; most payment method types |
|
131 | + * have a gateway. And if a gateway serializes its models, we start at the |
|
132 | + * beginning again) |
|
133 | + * |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + public function __sleep() |
|
137 | + { |
|
138 | + $properties = get_object_vars($this); |
|
139 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
140 | + return array_keys($properties); |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Returns whether or not this gateway should support SENDING refunds |
|
145 | + * see $_supports_sending_refunds |
|
146 | + * |
|
147 | + * @return boolean |
|
148 | + */ |
|
149 | + public function supports_sending_refunds() |
|
150 | + { |
|
151 | + return $this->_supports_sending_refunds; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Returns whether or not this gateway should support RECEIVING refunds |
|
156 | + * see $_supports_receiving_refunds |
|
157 | + * |
|
158 | + * @return boolean |
|
159 | + */ |
|
160 | + public function supports_receiving_refunds() |
|
161 | + { |
|
162 | + return $this->_supports_receiving_refunds; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * Tries to refund the payment specified, taking into account the extra |
|
168 | + * refund info. Note that if the gateway's _supports_sending_refunds is false, |
|
169 | + * this should just throw an exception. |
|
170 | + * |
|
171 | + * @param EE_Payment $payment |
|
172 | + * @param array $refund_info |
|
173 | + * @return EE_Payment for the refund |
|
174 | + * @throws EE_Error |
|
175 | + */ |
|
176 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) |
|
177 | + { |
|
178 | + return null; |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * Sets the payment method's settings so the gateway knows where to send the request |
|
184 | + * etc |
|
185 | + * |
|
186 | + * @param array $settings_array |
|
187 | + */ |
|
188 | + public function set_settings($settings_array) |
|
189 | + { |
|
190 | + foreach ($settings_array as $name => $value) { |
|
191 | + $property_name = "_" . $name; |
|
192 | + $this->{$property_name} = $value; |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * See this class description |
|
198 | + * |
|
199 | + * @param EEMI_Payment $payment_model |
|
200 | + */ |
|
201 | + public function set_payment_model($payment_model) |
|
202 | + { |
|
203 | + $this->_pay_model = $payment_model; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * See this class description |
|
208 | + * |
|
209 | + * @param EEMI_Payment_Log $payment_log_model |
|
210 | + */ |
|
211 | + public function set_payment_log($payment_log_model) |
|
212 | + { |
|
213 | + $this->_pay_log = $payment_log_model; |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * See this class description |
|
218 | + * |
|
219 | + * @param EEHI_Template $template_helper |
|
220 | + */ |
|
221 | + public function set_template_helper($template_helper) |
|
222 | + { |
|
223 | + $this->_template = $template_helper; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * See this class description |
|
228 | + * |
|
229 | + * @param EEHI_Line_Item $line_item_helper |
|
230 | + */ |
|
231 | + public function set_line_item_helper($line_item_helper) |
|
232 | + { |
|
233 | + $this->_line_item = $line_item_helper; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * See this class description |
|
238 | + * |
|
239 | + * @param EEHI_Money $money_helper |
|
240 | + */ |
|
241 | + public function set_money_helper($money_helper) |
|
242 | + { |
|
243 | + $this->_money = $money_helper; |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * Sets the gateway data formatter helper |
|
249 | + * |
|
250 | + * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
251 | + * @throws InvalidEntityException if it's not set properly |
|
252 | + */ |
|
253 | + public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) |
|
254 | + { |
|
255 | + if (! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
256 | + throw new InvalidEntityException( |
|
257 | + is_object($gateway_data_formatter) |
|
258 | + ? get_class($gateway_data_formatter) |
|
259 | + : esc_html__('Not an object', 'event_espresso'), |
|
260 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
261 | + ); |
|
262 | + } |
|
263 | + $this->_gateway_data_formatter = $gateway_data_formatter; |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * Gets the gateway data formatter |
|
268 | + * |
|
269 | + * @return GatewayDataFormatterInterface |
|
270 | + * @throws InvalidEntityException if it's not set properly |
|
271 | + */ |
|
272 | + protected function _get_gateway_formatter() |
|
273 | + { |
|
274 | + if (! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
275 | + throw new InvalidEntityException( |
|
276 | + is_object($this->_gateway_data_formatter) |
|
277 | + ? get_class($this->_gateway_data_formatter) |
|
278 | + : esc_html__('Not an object', 'event_espresso'), |
|
279 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
280 | + ); |
|
281 | + } |
|
282 | + return $this->_gateway_data_formatter; |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * Sets the helper which will remove unsupported characters for most gateways |
|
288 | + * |
|
289 | + * @param FormatterInterface $formatter |
|
290 | + * @return FormatterInterface |
|
291 | + * @throws InvalidEntityException |
|
292 | + */ |
|
293 | + public function set_unsupported_character_remover(FormatterInterface $formatter) |
|
294 | + { |
|
295 | + if (! $formatter instanceof FormatterInterface) { |
|
296 | + throw new InvalidEntityException( |
|
297 | + is_object($formatter) |
|
298 | + ? get_class($formatter) |
|
299 | + : esc_html__('Not an object', 'event_espresso'), |
|
300 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
301 | + ); |
|
302 | + } |
|
303 | + $this->_unsupported_character_remover = $formatter; |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
308 | + * |
|
309 | + * @return FormatterInterface |
|
310 | + * @throws InvalidEntityException |
|
311 | + */ |
|
312 | + protected function _get_unsupported_character_remover() |
|
313 | + { |
|
314 | + if (! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
315 | + throw new InvalidEntityException( |
|
316 | + is_object($this->_unsupported_character_remover) |
|
317 | + ? get_class($this->_unsupported_character_remover) |
|
318 | + : esc_html__('Not an object', 'event_espresso'), |
|
319 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
320 | + ); |
|
321 | + } |
|
322 | + return $this->_unsupported_character_remover; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @param $message |
|
328 | + * @param $payment |
|
329 | + */ |
|
330 | + public function log($message, $payment) |
|
331 | + { |
|
332 | + if ($payment instanceof EEI_Payment) { |
|
333 | + $type = 'Payment'; |
|
334 | + $id = $payment->ID(); |
|
335 | + } else { |
|
336 | + $type = 'Payment_Method'; |
|
337 | + $id = $this->_ID; |
|
338 | + } |
|
339 | + // only log if we're going to store it for longer than the minimum time |
|
340 | + $reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config'); |
|
341 | + if ($reg_config->gateway_log_lifespan !== '1 second') { |
|
342 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
343 | + } |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Formats the amount so it can generally be sent to gateways |
|
348 | + * |
|
349 | + * @param float $amount |
|
350 | + * @return string |
|
351 | + * @deprecated since 4.9.31 insetad use |
|
352 | + * EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
353 | + */ |
|
354 | + public function format_currency($amount) |
|
355 | + { |
|
356 | + return $this->_get_gateway_formatter()->formatCurrency($amount); |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Returns either an array of all the currency codes supported, |
|
361 | + * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
|
362 | + * |
|
363 | + * @return mixed array or string |
|
364 | + */ |
|
365 | + public function currencies_supported() |
|
366 | + { |
|
367 | + return $this->_currencies_supported; |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * Returns what a simple summing of items and taxes for this transaction. This |
|
372 | + * can be used to determine if some more complex line items, like promotions, |
|
373 | + * surcharges, or cancellations occurred (in which case we might want to forget |
|
374 | + * about creating an itemized list of purchases and instead only send the total due) |
|
375 | + * |
|
376 | + * @param EE_Transaction $transaction |
|
377 | + * @return float |
|
378 | + */ |
|
379 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) |
|
380 | + { |
|
381 | + $total_line_item = $transaction->total_line_item(); |
|
382 | + $total = 0; |
|
383 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
384 | + $total += max($item_line_item->total(), 0); |
|
385 | + } |
|
386 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
387 | + $total += max($tax_line_item->total(), 0); |
|
388 | + } |
|
389 | + return $total; |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * Determines whether or not we can easily itemize the transaction using only |
|
394 | + * items and taxes (ie, no promotions or surcharges or cancellations needed) |
|
395 | + * |
|
396 | + * @param EEI_Payment $payment |
|
397 | + * @return boolean |
|
398 | + */ |
|
399 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) |
|
400 | + { |
|
401 | + return $this->_money->compare_floats( |
|
402 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
403 | + $payment->transaction()->total() |
|
404 | + ) |
|
405 | + && $this->_money->compare_floats( |
|
406 | + $payment->amount(), |
|
407 | + $payment->transaction()->total() |
|
408 | + ); |
|
409 | + } |
|
410 | + |
|
411 | + /** |
|
412 | + * Handles updating the transaction and any other related data based on the payment. |
|
413 | + * You may be tempted to do this as part of do_direct_payment or handle_payment_update, |
|
414 | + * but doing so on those functions might be too early. It's possible that the changes |
|
415 | + * you make to teh transaction or registration or line items may just get overwritten |
|
416 | + * at that point. Instead, you should store any info you need on the payment during those |
|
417 | + * functions, and use that information at this step, which client code will decide |
|
418 | + * for you when it should be called. |
|
419 | + * |
|
420 | + * @param EE_Payment $payment |
|
421 | + * @return void |
|
422 | + */ |
|
423 | + public function update_txn_based_on_payment($payment) |
|
424 | + { |
|
425 | + // maybe update the transaction or line items or registrations |
|
426 | + // but most gateways don't need to do this, because they only update the payment |
|
427 | + } |
|
428 | + |
|
429 | + /** |
|
430 | + * Gets the first event for this payment (it's possible that it could be for multiple) |
|
431 | + * |
|
432 | + * @param EEI_Payment $payment |
|
433 | + * @return EEI_Event|null |
|
434 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
435 | + */ |
|
436 | + protected function _get_first_event_for_payment(EEI_Payment $payment) |
|
437 | + { |
|
438 | + return $payment->get_first_event(); |
|
439 | + } |
|
440 | + |
|
441 | + /** |
|
442 | + * Gets the name of the first event for which is being paid |
|
443 | + * |
|
444 | + * @param EEI_Payment $payment |
|
445 | + * @return string |
|
446 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
447 | + */ |
|
448 | + protected function _get_first_event_name_for_payment(EEI_Payment $payment) |
|
449 | + { |
|
450 | + return $payment->get_first_event_name(); |
|
451 | + } |
|
452 | + |
|
453 | + /** |
|
454 | + * Gets the text to use for a gateway's line item name when this is a partial payment |
|
455 | + * |
|
456 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
457 | + * @param EE_Payment $payment |
|
458 | + * @return string |
|
459 | + */ |
|
460 | + protected function _format_partial_payment_line_item_name(EEI_Payment $payment) |
|
461 | + { |
|
462 | + return $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment); |
|
463 | + } |
|
464 | + |
|
465 | + /** |
|
466 | + * Gets the text to use for a gateway's line item description when this is a partial payment |
|
467 | + * |
|
468 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
469 | + * @param EEI_Payment $payment |
|
470 | + * @return string |
|
471 | + */ |
|
472 | + protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) |
|
473 | + { |
|
474 | + return $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc($payment); |
|
475 | + } |
|
476 | + |
|
477 | + /** |
|
478 | + * Gets the name to use for a line item when sending line items to the gateway |
|
479 | + * |
|
480 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
481 | + * @param EEI_Line_Item $line_item |
|
482 | + * @param EEI_Payment $payment |
|
483 | + * @return string |
|
484 | + */ |
|
485 | + protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
486 | + { |
|
487 | + return $this->_get_gateway_formatter()->formatLineItemName($line_item, $payment); |
|
488 | + } |
|
489 | + |
|
490 | + /** |
|
491 | + * Gets the description to use for a line item when sending line items to the gateway |
|
492 | + * |
|
493 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
494 | + * @param EEI_Line_Item $line_item |
|
495 | + * @param EEI_Payment $payment |
|
496 | + * @return string |
|
497 | + */ |
|
498 | + protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
499 | + { |
|
500 | + return $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment); |
|
501 | + } |
|
502 | + |
|
503 | + /** |
|
504 | + * Gets the order description that should generlly be sent to gateways |
|
505 | + * |
|
506 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
507 | + * @param EEI_Payment $payment |
|
508 | + * @return type |
|
509 | + */ |
|
510 | + protected function _format_order_description(EEI_Payment $payment) |
|
511 | + { |
|
512 | + return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
|
513 | + } |
|
514 | 514 | } |
@@ -14,1125 +14,1125 @@ |
||
14 | 14 | class Payments_Admin_Page extends EE_Admin_Page |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Variables used for when we're re-sorting the logs results, in case |
|
19 | - * we needed to do two queries and we need to resort |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - private $_sort_logs_again_direction; |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * @Constructor |
|
28 | - * @access public |
|
29 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
30 | - * @return \Payments_Admin_Page |
|
31 | - */ |
|
32 | - public function __construct($routing = true) |
|
33 | - { |
|
34 | - parent::__construct($routing); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - protected function _init_page_props() |
|
39 | - { |
|
40 | - $this->page_slug = EE_PAYMENTS_PG_SLUG; |
|
41 | - $this->page_label = __('Payment Methods', 'event_espresso'); |
|
42 | - $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL; |
|
43 | - $this->_admin_base_path = EE_PAYMENTS_ADMIN; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - protected function _ajax_hooks() |
|
48 | - { |
|
49 | - // todo: all hooks for ajax goes here. |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - protected function _define_page_props() |
|
54 | - { |
|
55 | - $this->_admin_page_title = $this->page_label; |
|
56 | - $this->_labels = array( |
|
57 | - 'publishbox' => __('Update Settings', 'event_espresso'), |
|
58 | - ); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - protected function _set_page_routes() |
|
63 | - { |
|
64 | - /** |
|
65 | - * note that with payment method capabilities, although we've implemented |
|
66 | - * capability mapping which will be used for accessing payment methods owned by |
|
67 | - * other users. This is not fully implemented yet in the payment method ui. |
|
68 | - * Currently only the "plural" caps are in active use. |
|
69 | - * When cap mapping is implemented, some routes will need to use the singular form of |
|
70 | - * capability method and also include the $id of the payment method for the route. |
|
71 | - **/ |
|
72 | - $this->_page_routes = array( |
|
73 | - 'default' => array( |
|
74 | - 'func' => '_payment_methods_list', |
|
75 | - 'capability' => 'ee_edit_payment_methods', |
|
76 | - ), |
|
77 | - 'payment_settings' => array( |
|
78 | - 'func' => '_payment_settings', |
|
79 | - 'capability' => 'ee_manage_gateways', |
|
80 | - ), |
|
81 | - 'activate_payment_method' => array( |
|
82 | - 'func' => '_activate_payment_method', |
|
83 | - 'noheader' => true, |
|
84 | - 'capability' => 'ee_edit_payment_methods', |
|
85 | - ), |
|
86 | - 'deactivate_payment_method' => array( |
|
87 | - 'func' => '_deactivate_payment_method', |
|
88 | - 'noheader' => true, |
|
89 | - 'capability' => 'ee_delete_payment_methods', |
|
90 | - ), |
|
91 | - 'update_payment_method' => array( |
|
92 | - 'func' => '_update_payment_method', |
|
93 | - 'noheader' => true, |
|
94 | - 'headers_sent_route' => 'default', |
|
95 | - 'capability' => 'ee_edit_payment_methods', |
|
96 | - ), |
|
97 | - 'update_payment_settings' => array( |
|
98 | - 'func' => '_update_payment_settings', |
|
99 | - 'noheader' => true, |
|
100 | - 'capability' => 'ee_manage_gateways', |
|
101 | - ), |
|
102 | - 'payment_log' => array( |
|
103 | - 'func' => '_payment_log_overview_list_table', |
|
104 | - 'capability' => 'ee_read_payment_methods', |
|
105 | - ), |
|
106 | - 'payment_log_details' => array( |
|
107 | - 'func' => '_payment_log_details', |
|
108 | - 'capability' => 'ee_read_payment_methods', |
|
109 | - ), |
|
110 | - ); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - protected function _set_page_config() |
|
115 | - { |
|
116 | - $payment_method_list_config = array( |
|
117 | - 'nav' => array( |
|
118 | - 'label' => __('Payment Methods', 'event_espresso'), |
|
119 | - 'order' => 10, |
|
120 | - ), |
|
121 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
122 | - 'help_tabs' => array_merge( |
|
123 | - array( |
|
124 | - 'payment_methods_overview_help_tab' => array( |
|
125 | - 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
126 | - 'filename' => 'payment_methods_overview', |
|
127 | - ), |
|
128 | - ), |
|
129 | - $this->_add_payment_method_help_tabs() |
|
130 | - ), |
|
131 | - 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
132 | - 'require_nonce' => false, |
|
133 | - ); |
|
134 | - $this->_page_config = array( |
|
135 | - 'default' => $payment_method_list_config, |
|
136 | - 'payment_settings' => array( |
|
137 | - 'nav' => array( |
|
138 | - 'label' => __('Settings', 'event_espresso'), |
|
139 | - 'order' => 20, |
|
140 | - ), |
|
141 | - 'help_tabs' => array( |
|
142 | - 'payment_methods_settings_help_tab' => array( |
|
143 | - 'title' => __('Payment Method Settings', 'event_espresso'), |
|
144 | - 'filename' => 'payment_methods_settings', |
|
145 | - ), |
|
146 | - ), |
|
147 | - // 'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
|
148 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
149 | - 'require_nonce' => false, |
|
150 | - ), |
|
151 | - 'payment_log' => array( |
|
152 | - 'nav' => array( |
|
153 | - 'label' => __("Logs", 'event_espresso'), |
|
154 | - 'order' => 30, |
|
155 | - ), |
|
156 | - 'list_table' => 'Payment_Log_Admin_List_Table', |
|
157 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
158 | - 'require_nonce' => false, |
|
159 | - ), |
|
160 | - ); |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @return array |
|
166 | - */ |
|
167 | - protected function _add_payment_method_help_tabs() |
|
168 | - { |
|
169 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
170 | - $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
|
171 | - $all_pmt_help_tabs_config = array(); |
|
172 | - foreach ($payment_method_types as $payment_method_type) { |
|
173 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
174 | - $payment_method_type->cap_name(), |
|
175 | - 'specific_payment_method_type_access' |
|
176 | - ) |
|
177 | - ) { |
|
178 | - continue; |
|
179 | - } |
|
180 | - foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
181 | - $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
182 | - $template_args['admin_page_obj'] = $this; |
|
183 | - $all_pmt_help_tabs_config[ $help_tab_name ] = array( |
|
184 | - 'title' => $config['title'], |
|
185 | - 'content' => EEH_Template::display_template( |
|
186 | - $payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php', |
|
187 | - $template_args, |
|
188 | - true |
|
189 | - ), |
|
190 | - ); |
|
191 | - } |
|
192 | - } |
|
193 | - return $all_pmt_help_tabs_config; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - // none of the below group are currently used for Gateway Settings |
|
198 | - protected function _add_screen_options() |
|
199 | - { |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - protected function _add_feature_pointers() |
|
204 | - { |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - public function admin_init() |
|
209 | - { |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - public function admin_notices() |
|
214 | - { |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - public function admin_footer_scripts() |
|
219 | - { |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - public function load_scripts_styles() |
|
224 | - { |
|
225 | - wp_enqueue_script('ee_admin_js'); |
|
226 | - wp_enqueue_script('ee-text-links'); |
|
227 | - wp_enqueue_script( |
|
228 | - 'espresso_payments', |
|
229 | - EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', |
|
230 | - array('espresso-ui-theme', 'ee-datepicker'), |
|
231 | - EVENT_ESPRESSO_VERSION, |
|
232 | - true |
|
233 | - ); |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - public function load_scripts_styles_default() |
|
238 | - { |
|
239 | - // styles |
|
240 | - wp_register_style( |
|
241 | - 'espresso_payments', |
|
242 | - EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', |
|
243 | - array(), |
|
244 | - EVENT_ESPRESSO_VERSION |
|
245 | - ); |
|
246 | - wp_enqueue_style('espresso_payments'); |
|
247 | - wp_enqueue_style('ee-text-links'); |
|
248 | - // scripts |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - protected function _payment_methods_list() |
|
253 | - { |
|
254 | - /** |
|
255 | - * first let's ensure payment methods have been setup. We do this here because when people activate a |
|
256 | - * payment method for the first time (as an addon), it may not setup its capabilities or get registered correctly due |
|
257 | - * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
|
258 | - * recheck here. |
|
259 | - */ |
|
260 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
261 | - EEM_Payment_Method::instance()->verify_button_urls(); |
|
262 | - // setup tabs, one for each payment method type |
|
263 | - $tabs = array(); |
|
264 | - $payment_methods = array(); |
|
265 | - foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
266 | - // we don't want to show admin-only PMTs for now |
|
267 | - if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
268 | - continue; |
|
269 | - } |
|
270 | - // check access |
|
271 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
272 | - $pmt_obj->cap_name(), |
|
273 | - 'specific_payment_method_type_access' |
|
274 | - ) |
|
275 | - ) { |
|
276 | - continue; |
|
277 | - } |
|
278 | - // check for any active pms of that type |
|
279 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
280 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
281 | - $payment_method = EE_Payment_Method::new_instance( |
|
282 | - array( |
|
283 | - 'PMD_slug' => sanitize_key($pmt_obj->system_name()), |
|
284 | - 'PMD_type' => $pmt_obj->system_name(), |
|
285 | - 'PMD_name' => $pmt_obj->pretty_name(), |
|
286 | - 'PMD_admin_name' => $pmt_obj->pretty_name(), |
|
287 | - ) |
|
288 | - ); |
|
289 | - } |
|
290 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
291 | - } |
|
292 | - $payment_methods = apply_filters( |
|
293 | - 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', |
|
294 | - $payment_methods |
|
295 | - ); |
|
296 | - foreach ($payment_methods as $payment_method) { |
|
297 | - if ($payment_method instanceof EE_Payment_Method) { |
|
298 | - add_meta_box( |
|
299 | - // html id |
|
300 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
301 | - // title |
|
302 | - sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
303 | - // callback |
|
304 | - array($this, 'payment_method_settings_meta_box'), |
|
305 | - // post type |
|
306 | - null, |
|
307 | - // context |
|
308 | - 'normal', |
|
309 | - // priority |
|
310 | - 'default', |
|
311 | - // callback args |
|
312 | - array('payment_method' => $payment_method) |
|
313 | - ); |
|
314 | - // setup for tabbed content |
|
315 | - $tabs[ $payment_method->slug() ] = array( |
|
316 | - 'label' => $payment_method->admin_name(), |
|
317 | - 'class' => $payment_method->active() ? 'gateway-active' : '', |
|
318 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
319 | - 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
320 | - 'slug' => $payment_method->slug(), |
|
321 | - ); |
|
322 | - } |
|
323 | - } |
|
324 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( |
|
325 | - $tabs, |
|
326 | - 'payment_method_links', |
|
327 | - '|', |
|
328 | - $this->_get_active_payment_method_slug() |
|
329 | - ); |
|
330 | - $this->display_admin_page_with_sidebar(); |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - /** |
|
335 | - * _get_active_payment_method_slug |
|
336 | - * |
|
337 | - * @return string |
|
338 | - */ |
|
339 | - protected function _get_active_payment_method_slug() |
|
340 | - { |
|
341 | - $payment_method_slug = false; |
|
342 | - // decide which payment method tab to open first, as dictated by the request's 'payment_method' |
|
343 | - if (isset($this->_req_data['payment_method'])) { |
|
344 | - // if they provided the current payment method, use it |
|
345 | - $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
346 | - } |
|
347 | - $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
348 | - // if that didn't work or wasn't provided, find another way to select the current pm |
|
349 | - if (! $this->_verify_payment_method($payment_method)) { |
|
350 | - // like, looking for an active one |
|
351 | - $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
352 | - // test that one as well |
|
353 | - if ($this->_verify_payment_method($payment_method)) { |
|
354 | - $payment_method_slug = $payment_method->slug(); |
|
355 | - } else { |
|
356 | - $payment_method_slug = 'paypal_standard'; |
|
357 | - } |
|
358 | - } |
|
359 | - return $payment_method_slug; |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - /** |
|
364 | - * payment_method_settings_meta_box |
|
365 | - * returns TRUE if the passed payment method is properly constructed and the logged in user has the correct |
|
366 | - * capabilities to access it |
|
367 | - * |
|
368 | - * @param \EE_Payment_Method $payment_method |
|
369 | - * @return boolean |
|
370 | - */ |
|
371 | - protected function _verify_payment_method($payment_method) |
|
372 | - { |
|
373 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base |
|
374 | - && EE_Registry::instance()->CAP->current_user_can( |
|
375 | - $payment_method->type_obj()->cap_name(), |
|
376 | - 'specific_payment_method_type_access' |
|
377 | - ) |
|
378 | - ) { |
|
379 | - return true; |
|
380 | - } |
|
381 | - return false; |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * payment_method_settings_meta_box |
|
387 | - * |
|
388 | - * @param NULL $post_obj_which_is_null is an object containing the current post (as a $post object) |
|
389 | - * @param array $metabox is an array with metabox id, title, callback, and args elements. the value |
|
390 | - * at 'args' has key 'payment_method', as set within _payment_methods_list |
|
391 | - * @return string |
|
392 | - * @throws EE_Error |
|
393 | - */ |
|
394 | - public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) |
|
395 | - { |
|
396 | - $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) |
|
397 | - ? $metabox['args']['payment_method'] : null; |
|
398 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
399 | - throw new EE_Error( |
|
400 | - sprintf( |
|
401 | - __( |
|
402 | - 'Payment method metabox setup incorrectly. No Payment method object was supplied', |
|
403 | - 'event_espresso' |
|
404 | - ) |
|
405 | - ) |
|
406 | - ); |
|
407 | - } |
|
408 | - $payment_method_scopes = $payment_method->active(); |
|
409 | - // if the payment method really exists show its form, otherwise the activation template |
|
410 | - if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
411 | - $form = $this->_generate_payment_method_settings_form($payment_method); |
|
412 | - if ($form->form_data_present_in($this->_req_data)) { |
|
413 | - $form->receive_form_submission($this->_req_data); |
|
414 | - } |
|
415 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
416 | - } else { |
|
417 | - echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
418 | - } |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * Gets the form for all the settings related to this payment method type |
|
424 | - * |
|
425 | - * @access protected |
|
426 | - * @param \EE_Payment_Method $payment_method |
|
427 | - * @return \EE_Form_Section_Proper |
|
428 | - */ |
|
429 | - protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) |
|
430 | - { |
|
431 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
432 | - return new EE_Form_Section_Proper(); |
|
433 | - } |
|
434 | - return new EE_Form_Section_Proper( |
|
435 | - array( |
|
436 | - 'name' => $payment_method->slug() . '_settings_form', |
|
437 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
438 | - 'action' => EE_Admin_Page::add_query_args_and_nonce( |
|
439 | - array( |
|
440 | - 'action' => 'update_payment_method', |
|
441 | - 'payment_method' => $payment_method->slug(), |
|
442 | - ), |
|
443 | - EE_PAYMENTS_ADMIN_URL |
|
444 | - ), |
|
445 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
446 | - 'subsections' => apply_filters( |
|
447 | - 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
|
448 | - array( |
|
449 | - 'pci_dss_compliance' => $this->_pci_dss_compliance($payment_method), |
|
450 | - 'currency_support' => $this->_currency_support($payment_method), |
|
451 | - 'payment_method_settings' => $this->_payment_method_settings($payment_method), |
|
452 | - 'update' => $this->_update_payment_method_button($payment_method), |
|
453 | - 'deactivate' => $this->_deactivate_payment_method_button($payment_method), |
|
454 | - 'fine_print' => $this->_fine_print(), |
|
455 | - ), |
|
456 | - $payment_method |
|
457 | - ), |
|
458 | - ) |
|
459 | - ); |
|
460 | - } |
|
461 | - |
|
462 | - |
|
463 | - /** |
|
464 | - * _pci_dss_compliance |
|
465 | - * |
|
466 | - * @access protected |
|
467 | - * @param \EE_Payment_Method $payment_method |
|
468 | - * @return \EE_Form_Section_Proper |
|
469 | - */ |
|
470 | - protected function _pci_dss_compliance(EE_Payment_Method $payment_method) |
|
471 | - { |
|
472 | - if ($payment_method->type_obj()->requires_https()) { |
|
473 | - return new EE_Form_Section_HTML( |
|
474 | - EEH_HTML::tr( |
|
475 | - EEH_HTML::th( |
|
476 | - EEH_HTML::label( |
|
477 | - EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
478 | - ) |
|
479 | - ) . |
|
480 | - EEH_HTML::td( |
|
481 | - EEH_HTML::strong( |
|
482 | - __( |
|
483 | - 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', |
|
484 | - 'event_espresso' |
|
485 | - ) |
|
486 | - ) |
|
487 | - . |
|
488 | - EEH_HTML::br() |
|
489 | - . |
|
490 | - __('Learn more about ', 'event_espresso') |
|
491 | - . EEH_HTML::link( |
|
492 | - 'https://www.pcisecuritystandards.org/merchants/index.php', |
|
493 | - __('PCI DSS compliance', 'event_espresso') |
|
494 | - ) |
|
495 | - ) |
|
496 | - ) |
|
497 | - ); |
|
498 | - } else { |
|
499 | - return new EE_Form_Section_HTML(''); |
|
500 | - } |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * _currency_support |
|
506 | - * |
|
507 | - * @access protected |
|
508 | - * @param \EE_Payment_Method $payment_method |
|
509 | - * @return \EE_Form_Section_Proper |
|
510 | - */ |
|
511 | - protected function _currency_support(EE_Payment_Method $payment_method) |
|
512 | - { |
|
513 | - if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
514 | - return new EE_Form_Section_HTML( |
|
515 | - EEH_HTML::tr( |
|
516 | - EEH_HTML::th( |
|
517 | - EEH_HTML::label( |
|
518 | - EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
519 | - ) |
|
520 | - ) . |
|
521 | - EEH_HTML::td( |
|
522 | - EEH_HTML::strong( |
|
523 | - sprintf( |
|
524 | - __( |
|
525 | - 'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.', |
|
526 | - 'event_espresso' |
|
527 | - ), |
|
528 | - EE_Config::instance()->currency->code |
|
529 | - ) |
|
530 | - ) |
|
531 | - ) |
|
532 | - ) |
|
533 | - ); |
|
534 | - } else { |
|
535 | - return new EE_Form_Section_HTML(''); |
|
536 | - } |
|
537 | - } |
|
538 | - |
|
539 | - |
|
540 | - /** |
|
541 | - * _update_payment_method_button |
|
542 | - * |
|
543 | - * @access protected |
|
544 | - * @param \EE_Payment_Method $payment_method |
|
545 | - * @return \EE_Form_Section_HTML |
|
546 | - */ |
|
547 | - protected function _payment_method_settings(EE_Payment_Method $payment_method) |
|
548 | - { |
|
549 | - // modify the form so we only have/show fields that will be implemented for this version |
|
550 | - return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
551 | - } |
|
552 | - |
|
553 | - |
|
554 | - /** |
|
555 | - * Simplifies the form to merely reproduce 4.1's gateway settings functionality |
|
556 | - * |
|
557 | - * @param EE_Form_Section_Proper $form_section |
|
558 | - * @param string $payment_method_name |
|
559 | - * @return \EE_Payment_Method_Form |
|
560 | - * @throws \EE_Error |
|
561 | - */ |
|
562 | - protected function _simplify_form($form_section, $payment_method_name = '') |
|
563 | - { |
|
564 | - if ($form_section instanceof EE_Payment_Method_Form) { |
|
565 | - $form_section->exclude( |
|
566 | - array( |
|
567 | - 'PMD_type', // dont want them changing the type |
|
568 | - 'PMD_slug', // or the slug (probably never) |
|
569 | - 'PMD_wp_user', // or the user's ID |
|
570 | - 'Currency' // or the currency, until the rest of EE supports simultaneous currencies |
|
571 | - ) |
|
572 | - ); |
|
573 | - return $form_section; |
|
574 | - } else { |
|
575 | - throw new EE_Error( |
|
576 | - sprintf( |
|
577 | - __( |
|
578 | - 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', |
|
579 | - 'event_espresso' |
|
580 | - ), |
|
581 | - $payment_method_name |
|
582 | - ) |
|
583 | - ); |
|
584 | - } |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - /** |
|
589 | - * _update_payment_method_button |
|
590 | - * |
|
591 | - * @access protected |
|
592 | - * @param \EE_Payment_Method $payment_method |
|
593 | - * @return \EE_Form_Section_HTML |
|
594 | - */ |
|
595 | - protected function _update_payment_method_button(EE_Payment_Method $payment_method) |
|
596 | - { |
|
597 | - $update_button = new EE_Submit_Input( |
|
598 | - array( |
|
599 | - 'name' => 'submit', |
|
600 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
601 | - 'default' => sprintf( |
|
602 | - __('Update %s Payment Settings', 'event_espresso'), |
|
603 | - $payment_method->admin_name() |
|
604 | - ), |
|
605 | - 'html_label' => EEH_HTML::nbsp(), |
|
606 | - ) |
|
607 | - ); |
|
608 | - return new EE_Form_Section_HTML( |
|
609 | - EEH_HTML::no_row(EEH_HTML::br(2)) . |
|
610 | - EEH_HTML::tr( |
|
611 | - EEH_HTML::th(__('Update Settings', 'event_espresso')) . |
|
612 | - EEH_HTML::td( |
|
613 | - $update_button->get_html_for_input() |
|
614 | - ) |
|
615 | - ) |
|
616 | - ); |
|
617 | - } |
|
618 | - |
|
619 | - |
|
620 | - /** |
|
621 | - * _deactivate_payment_method_button |
|
622 | - * |
|
623 | - * @access protected |
|
624 | - * @param \EE_Payment_Method $payment_method |
|
625 | - * @return \EE_Form_Section_Proper |
|
626 | - */ |
|
627 | - protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) |
|
628 | - { |
|
629 | - $link_text_and_title = sprintf( |
|
630 | - __('Deactivate %1$s Payments?', 'event_espresso'), |
|
631 | - $payment_method->admin_name() |
|
632 | - ); |
|
633 | - return new EE_Form_Section_HTML( |
|
634 | - EEH_HTML::tr( |
|
635 | - EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) . |
|
636 | - EEH_HTML::td( |
|
637 | - EEH_HTML::link( |
|
638 | - EE_Admin_Page::add_query_args_and_nonce( |
|
639 | - array( |
|
640 | - 'action' => 'deactivate_payment_method', |
|
641 | - 'payment_method' => $payment_method->slug(), |
|
642 | - ), |
|
643 | - EE_PAYMENTS_ADMIN_URL |
|
644 | - ), |
|
645 | - $link_text_and_title, |
|
646 | - $link_text_and_title, |
|
647 | - 'deactivate_' . $payment_method->slug(), |
|
648 | - 'espresso-button button-secondary' |
|
649 | - ) |
|
650 | - ) |
|
651 | - ) |
|
652 | - ); |
|
653 | - } |
|
654 | - |
|
655 | - |
|
656 | - /** |
|
657 | - * _activate_payment_method_button |
|
658 | - * |
|
659 | - * @access protected |
|
660 | - * @param \EE_Payment_Method $payment_method |
|
661 | - * @return \EE_Form_Section_Proper |
|
662 | - */ |
|
663 | - protected function _activate_payment_method_button(EE_Payment_Method $payment_method) |
|
664 | - { |
|
665 | - $link_text_and_title = sprintf( |
|
666 | - __('Activate %1$s Payment Method?', 'event_espresso'), |
|
667 | - $payment_method->admin_name() |
|
668 | - ); |
|
669 | - return new EE_Form_Section_Proper( |
|
670 | - array( |
|
671 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
672 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
673 | - 'action' => '#', |
|
674 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
675 | - 'subsections' => apply_filters( |
|
676 | - 'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections', |
|
677 | - array( |
|
678 | - new EE_Form_Section_HTML( |
|
679 | - EEH_HTML::tr( |
|
680 | - EEH_HTML::td( |
|
681 | - $payment_method->type_obj()->introductory_html(), |
|
682 | - '', |
|
683 | - '', |
|
684 | - '', |
|
685 | - 'colspan="2"' |
|
686 | - ) |
|
687 | - ) . |
|
688 | - EEH_HTML::tr( |
|
689 | - EEH_HTML::th( |
|
690 | - EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
691 | - ) . |
|
692 | - EEH_HTML::td( |
|
693 | - EEH_HTML::link( |
|
694 | - EE_Admin_Page::add_query_args_and_nonce( |
|
695 | - array( |
|
696 | - 'action' => 'activate_payment_method', |
|
697 | - 'payment_method_type' => $payment_method->type(), |
|
698 | - ), |
|
699 | - EE_PAYMENTS_ADMIN_URL |
|
700 | - ), |
|
701 | - $link_text_and_title, |
|
702 | - $link_text_and_title, |
|
703 | - 'activate_' . $payment_method->slug(), |
|
704 | - 'espresso-button-green button-primary' |
|
705 | - ) |
|
706 | - ) |
|
707 | - ) |
|
708 | - ), |
|
709 | - ), |
|
710 | - $payment_method |
|
711 | - ), |
|
712 | - ) |
|
713 | - ); |
|
714 | - } |
|
715 | - |
|
716 | - |
|
717 | - /** |
|
718 | - * _fine_print |
|
719 | - * |
|
720 | - * @access protected |
|
721 | - * @return \EE_Form_Section_HTML |
|
722 | - */ |
|
723 | - protected function _fine_print() |
|
724 | - { |
|
725 | - return new EE_Form_Section_HTML( |
|
726 | - EEH_HTML::tr( |
|
727 | - EEH_HTML::th() . |
|
728 | - EEH_HTML::td( |
|
729 | - EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
730 | - ) |
|
731 | - ) |
|
732 | - ); |
|
733 | - } |
|
734 | - |
|
735 | - |
|
736 | - /** |
|
737 | - * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
|
738 | - * |
|
739 | - * @global WP_User $current_user |
|
740 | - */ |
|
741 | - protected function _activate_payment_method() |
|
742 | - { |
|
743 | - if (isset($this->_req_data['payment_method_type'])) { |
|
744 | - $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
|
745 | - // see if one exists |
|
746 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
747 | - $payment_method = EE_Payment_Method_Manager::instance() |
|
748 | - ->activate_a_payment_method_of_type($payment_method_type); |
|
749 | - $this->_redirect_after_action( |
|
750 | - 1, |
|
751 | - 'Payment Method', |
|
752 | - 'activated', |
|
753 | - array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
754 | - ); |
|
755 | - } else { |
|
756 | - $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
757 | - } |
|
758 | - } |
|
759 | - |
|
760 | - |
|
761 | - /** |
|
762 | - * Deactivates the payment method with the specified slug, and redirects. |
|
763 | - */ |
|
764 | - protected function _deactivate_payment_method() |
|
765 | - { |
|
766 | - if (isset($this->_req_data['payment_method'])) { |
|
767 | - $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
768 | - // deactivate it |
|
769 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
770 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
771 | - $this->_redirect_after_action( |
|
772 | - $count_updated, |
|
773 | - 'Payment Method', |
|
774 | - 'deactivated', |
|
775 | - array('action' => 'default', 'payment_method' => $payment_method_slug) |
|
776 | - ); |
|
777 | - } else { |
|
778 | - $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default')); |
|
779 | - } |
|
780 | - } |
|
781 | - |
|
782 | - |
|
783 | - /** |
|
784 | - * Processes the payment method form that was submitted. This is slightly trickier than usual form |
|
785 | - * processing because we first need to identify WHICH form was processed and which payment method |
|
786 | - * it corresponds to. Once we have done that, we see if the form is valid. If it is, the |
|
787 | - * form's data is saved and we redirect to the default payment methods page, setting the updated payment method |
|
788 | - * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the |
|
789 | - * subsequently called 'headers_sent_func' which is _payment_methods_list) |
|
790 | - * |
|
791 | - * @return void |
|
792 | - */ |
|
793 | - protected function _update_payment_method() |
|
794 | - { |
|
795 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
796 | - // ok let's find which gateway form to use based on the form input |
|
797 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
798 | - /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
|
799 | - $correct_pmt_form_to_use = null; |
|
800 | - $payment_method = null; |
|
801 | - foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
802 | - // get the form and simplify it, like what we do when we display it |
|
803 | - $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
804 | - if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
805 | - $correct_pmt_form_to_use = $pmt_form; |
|
806 | - break; |
|
807 | - } |
|
808 | - } |
|
809 | - // if we couldn't find the correct payment method type... |
|
810 | - if (! $correct_pmt_form_to_use) { |
|
811 | - EE_Error::add_error( |
|
812 | - __( |
|
813 | - "We could not find which payment method type your form submission related to. Please contact support", |
|
814 | - 'event_espresso' |
|
815 | - ), |
|
816 | - __FILE__, |
|
817 | - __FUNCTION__, |
|
818 | - __LINE__ |
|
819 | - ); |
|
820 | - $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
821 | - } |
|
822 | - $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
|
823 | - if ($correct_pmt_form_to_use->is_valid()) { |
|
824 | - $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings'); |
|
825 | - if (! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
826 | - throw new EE_Error( |
|
827 | - sprintf( |
|
828 | - __( |
|
829 | - 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', |
|
830 | - 'event_espresso' |
|
831 | - ), |
|
832 | - 'payment_method_settings' |
|
833 | - ) |
|
834 | - ); |
|
835 | - } |
|
836 | - $payment_settings_subform->save(); |
|
837 | - /** @var $pm EE_Payment_Method */ |
|
838 | - $this->_redirect_after_action( |
|
839 | - true, |
|
840 | - 'Payment Method', |
|
841 | - 'updated', |
|
842 | - array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
843 | - ); |
|
844 | - } else { |
|
845 | - EE_Error::add_error( |
|
846 | - sprintf( |
|
847 | - __( |
|
848 | - 'Payment method of type %s was not saved because there were validation errors. They have been marked in the form', |
|
849 | - 'event_espresso' |
|
850 | - ), |
|
851 | - $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name() |
|
852 | - : __('"(unknown)"', 'event_espresso') |
|
853 | - ), |
|
854 | - __FILE__, |
|
855 | - __FUNCTION__, |
|
856 | - __LINE__ |
|
857 | - ); |
|
858 | - } |
|
859 | - } |
|
860 | - return; |
|
861 | - } |
|
862 | - |
|
863 | - |
|
864 | - /** |
|
865 | - * Displays payment settings (not payment METHOD settings, that's _payment_method_settings) |
|
866 | - * @throws DomainException |
|
867 | - * @throws EE_Error |
|
868 | - * @throws InvalidArgumentException |
|
869 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
870 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
871 | - */ |
|
872 | - protected function _payment_settings() |
|
873 | - { |
|
874 | - $form = $this->getPaymentSettingsForm(); |
|
875 | - $this->_set_add_edit_form_tags('update_payment_settings'); |
|
876 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
877 | - $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
878 | - $this->display_admin_page_with_sidebar(); |
|
879 | - } |
|
880 | - |
|
881 | - |
|
882 | - /** |
|
883 | - * _update_payment_settings |
|
884 | - * |
|
885 | - * @access protected |
|
886 | - * @return void |
|
887 | - * @throws EE_Error |
|
888 | - * @throws InvalidArgumentException |
|
889 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
890 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
891 | - */ |
|
892 | - protected function _update_payment_settings() |
|
893 | - { |
|
894 | - $form = $this->getPaymentSettingsForm(); |
|
895 | - if ($form->was_submitted($this->_req_data)) { |
|
896 | - $form->receive_form_submission($this->_req_data); |
|
897 | - if ($form->is_valid()) { |
|
898 | - /** |
|
899 | - * @var $reg_config EE_Registration_Config |
|
900 | - */ |
|
901 | - $loader = LoaderFactory::getLoader(); |
|
902 | - $reg_config = $loader->getShared('EE_Registration_Config'); |
|
903 | - $valid_data = $form->valid_data(); |
|
904 | - $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options']; |
|
905 | - $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan']; |
|
906 | - } |
|
907 | - } |
|
908 | - EE_Registry::instance()->CFG = apply_filters( |
|
909 | - 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', |
|
910 | - EE_Registry::instance()->CFG |
|
911 | - ); |
|
912 | - |
|
913 | - $cfg = EE_Registry::instance()->CFG ; |
|
914 | - |
|
915 | - $what = __('Payment Settings', 'event_espresso'); |
|
916 | - $success = $this->_update_espresso_configuration( |
|
917 | - $what, |
|
918 | - EE_Registry::instance()->CFG, |
|
919 | - __FILE__, |
|
920 | - __FUNCTION__, |
|
921 | - __LINE__ |
|
922 | - ); |
|
923 | - $this->_redirect_after_action( |
|
924 | - $success, |
|
925 | - $what, |
|
926 | - __('updated', 'event_espresso'), |
|
927 | - array('action' => 'payment_settings') |
|
928 | - ); |
|
929 | - } |
|
930 | - |
|
931 | - |
|
932 | - /** |
|
933 | - * Gets the form used for updating payment settings |
|
934 | - * |
|
935 | - * @return EE_Form_Section_Proper |
|
936 | - * @throws EE_Error |
|
937 | - * @throws InvalidArgumentException |
|
938 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
939 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
940 | - */ |
|
941 | - protected function getPaymentSettingsForm() |
|
942 | - { |
|
943 | - /** |
|
944 | - * @var $reg_config EE_Registration_Config |
|
945 | - */ |
|
946 | - $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
947 | - return new EE_Form_Section_Proper( |
|
948 | - array( |
|
949 | - 'name' => 'payment-settings', |
|
950 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
951 | - 'subsections' => array( |
|
952 | - 'show_pending_payment_options' => new EE_Yes_No_Input( |
|
953 | - array( |
|
954 | - 'html_name' => 'show_pending_payment_options', |
|
955 | - 'default' => $reg_config->show_pending_payment_options, |
|
956 | - 'html_help_text' => esc_html__( |
|
957 | - "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ", |
|
958 | - 'event_espresso' |
|
959 | - ) |
|
960 | - ) |
|
961 | - ), |
|
962 | - 'gateway_log_lifespan' => new \EE_Select_Input( |
|
963 | - $reg_config->gatewayLogLifespanOptions(), |
|
964 | - array( |
|
965 | - 'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'), |
|
966 | - 'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'), |
|
967 | - 'default' => $reg_config->gateway_log_lifespan, |
|
968 | - ) |
|
969 | - ) |
|
970 | - ) |
|
971 | - ) |
|
972 | - ); |
|
973 | - } |
|
974 | - |
|
975 | - |
|
976 | - protected function _payment_log_overview_list_table() |
|
977 | - { |
|
978 | - $this->display_admin_list_table_page_with_sidebar(); |
|
979 | - } |
|
980 | - |
|
981 | - |
|
982 | - protected function _set_list_table_views_payment_log() |
|
983 | - { |
|
984 | - $this->_views = array( |
|
985 | - 'all' => array( |
|
986 | - 'slug' => 'all', |
|
987 | - 'label' => __('View All Logs', 'event_espresso'), |
|
988 | - 'count' => 0, |
|
989 | - ), |
|
990 | - ); |
|
991 | - } |
|
992 | - |
|
993 | - |
|
994 | - /** |
|
995 | - * @param int $per_page |
|
996 | - * @param int $current_page |
|
997 | - * @param bool $count |
|
998 | - * @return array |
|
999 | - */ |
|
1000 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) |
|
1001 | - { |
|
1002 | - EE_Registry::instance()->load_model('Change_Log'); |
|
1003 | - // we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
|
1004 | - $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway)); |
|
1005 | - // check if they've selected a specific payment method |
|
1006 | - if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
1007 | - $query_params[0]['OR*pm_or_pay_pm'] = array( |
|
1008 | - 'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1009 | - 'Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1010 | - ); |
|
1011 | - } |
|
1012 | - // take into account search |
|
1013 | - if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
1014 | - $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'); |
|
1015 | - $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
|
1016 | - $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
|
1017 | - $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
|
1018 | - $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string; |
|
1019 | - $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1020 | - $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string; |
|
1021 | - $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1022 | - $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string; |
|
1023 | - $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1024 | - $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string; |
|
1025 | - $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1026 | - } |
|
1027 | - if (isset($this->_req_data['payment-filter-start-date']) |
|
1028 | - && isset($this->_req_data['payment-filter-end-date']) |
|
1029 | - ) { |
|
1030 | - // add date |
|
1031 | - $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
1032 | - $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
1033 | - // make sure our timestamps start and end right at the boundaries for each day |
|
1034 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1035 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1036 | - // convert to timestamps |
|
1037 | - $start_date = strtotime($start_date); |
|
1038 | - $end_date = strtotime($end_date); |
|
1039 | - // makes sure start date is the lowest value and vice versa |
|
1040 | - $start_date = min($start_date, $end_date); |
|
1041 | - $end_date = max($start_date, $end_date); |
|
1042 | - // convert for query |
|
1043 | - $start_date = EEM_Change_Log::instance() |
|
1044 | - ->convert_datetime_for_query( |
|
1045 | - 'LOG_time', |
|
1046 | - date('Y-m-d H:i:s', $start_date), |
|
1047 | - 'Y-m-d H:i:s' |
|
1048 | - ); |
|
1049 | - $end_date = EEM_Change_Log::instance() |
|
1050 | - ->convert_datetime_for_query( |
|
1051 | - 'LOG_time', |
|
1052 | - date('Y-m-d H:i:s', $end_date), |
|
1053 | - 'Y-m-d H:i:s' |
|
1054 | - ); |
|
1055 | - $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
1056 | - } |
|
1057 | - if ($count) { |
|
1058 | - return EEM_Change_Log::instance()->count($query_params); |
|
1059 | - } |
|
1060 | - if (isset($this->_req_data['order'])) { |
|
1061 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
1062 | - : 'DESC'; |
|
1063 | - $query_params['order_by'] = array('LOG_time' => $sort); |
|
1064 | - } else { |
|
1065 | - $query_params['order_by'] = array('LOG_time' => 'DESC'); |
|
1066 | - } |
|
1067 | - $offset = ($current_page - 1) * $per_page; |
|
1068 | - if (! isset($this->_req_data['download_results'])) { |
|
1069 | - $query_params['limit'] = array($offset, $per_page); |
|
1070 | - } |
|
1071 | - // now they've requested to instead just download the file instead of viewing it. |
|
1072 | - if (isset($this->_req_data['download_results'])) { |
|
1073 | - $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
|
1074 | - header('Content-Disposition: attachment'); |
|
1075 | - header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url())); |
|
1076 | - echo "<h1>Payment Logs for " . site_url() . "</h1>"; |
|
1077 | - echo "<h3>Query:</h3>"; |
|
1078 | - var_dump($query_params); |
|
1079 | - echo "<h3>Results:</h3>"; |
|
1080 | - var_dump($wpdb_results); |
|
1081 | - die; |
|
1082 | - } |
|
1083 | - $results = EEM_Change_Log::instance()->get_all($query_params); |
|
1084 | - return $results; |
|
1085 | - } |
|
1086 | - |
|
1087 | - |
|
1088 | - /** |
|
1089 | - * Used by usort to RE-sort log query results, because we lose the ordering |
|
1090 | - * because we're possibly combining the results from two queries |
|
1091 | - * |
|
1092 | - * @param EE_Change_Log $logA |
|
1093 | - * @param EE_Change_Log $logB |
|
1094 | - * @return int |
|
1095 | - */ |
|
1096 | - protected function _sort_logs_again($logA, $logB) |
|
1097 | - { |
|
1098 | - $timeA = $logA->get_raw('LOG_time'); |
|
1099 | - $timeB = $logB->get_raw('LOG_time'); |
|
1100 | - if ($timeA == $timeB) { |
|
1101 | - return 0; |
|
1102 | - } |
|
1103 | - $comparison = $timeA < $timeB ? -1 : 1; |
|
1104 | - if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
1105 | - return $comparison * -1; |
|
1106 | - } else { |
|
1107 | - return $comparison; |
|
1108 | - } |
|
1109 | - } |
|
1110 | - |
|
1111 | - |
|
1112 | - protected function _payment_log_details() |
|
1113 | - { |
|
1114 | - EE_Registry::instance()->load_model('Change_Log'); |
|
1115 | - /** @var $payment_log EE_Change_Log */ |
|
1116 | - $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
|
1117 | - $payment_method = null; |
|
1118 | - $transaction = null; |
|
1119 | - if ($payment_log instanceof EE_Change_Log) { |
|
1120 | - if ($payment_log->object() instanceof EE_Payment) { |
|
1121 | - $payment_method = $payment_log->object()->payment_method(); |
|
1122 | - $transaction = $payment_log->object()->transaction(); |
|
1123 | - } elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
1124 | - $payment_method = $payment_log->object(); |
|
1125 | - } |
|
1126 | - } |
|
1127 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1128 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
1129 | - array( |
|
1130 | - 'payment_log' => $payment_log, |
|
1131 | - 'payment_method' => $payment_method, |
|
1132 | - 'transaction' => $transaction, |
|
1133 | - ), |
|
1134 | - true |
|
1135 | - ); |
|
1136 | - $this->display_admin_page_with_sidebar(); |
|
1137 | - } |
|
17 | + /** |
|
18 | + * Variables used for when we're re-sorting the logs results, in case |
|
19 | + * we needed to do two queries and we need to resort |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + private $_sort_logs_again_direction; |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * @Constructor |
|
28 | + * @access public |
|
29 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
30 | + * @return \Payments_Admin_Page |
|
31 | + */ |
|
32 | + public function __construct($routing = true) |
|
33 | + { |
|
34 | + parent::__construct($routing); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + protected function _init_page_props() |
|
39 | + { |
|
40 | + $this->page_slug = EE_PAYMENTS_PG_SLUG; |
|
41 | + $this->page_label = __('Payment Methods', 'event_espresso'); |
|
42 | + $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL; |
|
43 | + $this->_admin_base_path = EE_PAYMENTS_ADMIN; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + protected function _ajax_hooks() |
|
48 | + { |
|
49 | + // todo: all hooks for ajax goes here. |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + protected function _define_page_props() |
|
54 | + { |
|
55 | + $this->_admin_page_title = $this->page_label; |
|
56 | + $this->_labels = array( |
|
57 | + 'publishbox' => __('Update Settings', 'event_espresso'), |
|
58 | + ); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + protected function _set_page_routes() |
|
63 | + { |
|
64 | + /** |
|
65 | + * note that with payment method capabilities, although we've implemented |
|
66 | + * capability mapping which will be used for accessing payment methods owned by |
|
67 | + * other users. This is not fully implemented yet in the payment method ui. |
|
68 | + * Currently only the "plural" caps are in active use. |
|
69 | + * When cap mapping is implemented, some routes will need to use the singular form of |
|
70 | + * capability method and also include the $id of the payment method for the route. |
|
71 | + **/ |
|
72 | + $this->_page_routes = array( |
|
73 | + 'default' => array( |
|
74 | + 'func' => '_payment_methods_list', |
|
75 | + 'capability' => 'ee_edit_payment_methods', |
|
76 | + ), |
|
77 | + 'payment_settings' => array( |
|
78 | + 'func' => '_payment_settings', |
|
79 | + 'capability' => 'ee_manage_gateways', |
|
80 | + ), |
|
81 | + 'activate_payment_method' => array( |
|
82 | + 'func' => '_activate_payment_method', |
|
83 | + 'noheader' => true, |
|
84 | + 'capability' => 'ee_edit_payment_methods', |
|
85 | + ), |
|
86 | + 'deactivate_payment_method' => array( |
|
87 | + 'func' => '_deactivate_payment_method', |
|
88 | + 'noheader' => true, |
|
89 | + 'capability' => 'ee_delete_payment_methods', |
|
90 | + ), |
|
91 | + 'update_payment_method' => array( |
|
92 | + 'func' => '_update_payment_method', |
|
93 | + 'noheader' => true, |
|
94 | + 'headers_sent_route' => 'default', |
|
95 | + 'capability' => 'ee_edit_payment_methods', |
|
96 | + ), |
|
97 | + 'update_payment_settings' => array( |
|
98 | + 'func' => '_update_payment_settings', |
|
99 | + 'noheader' => true, |
|
100 | + 'capability' => 'ee_manage_gateways', |
|
101 | + ), |
|
102 | + 'payment_log' => array( |
|
103 | + 'func' => '_payment_log_overview_list_table', |
|
104 | + 'capability' => 'ee_read_payment_methods', |
|
105 | + ), |
|
106 | + 'payment_log_details' => array( |
|
107 | + 'func' => '_payment_log_details', |
|
108 | + 'capability' => 'ee_read_payment_methods', |
|
109 | + ), |
|
110 | + ); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + protected function _set_page_config() |
|
115 | + { |
|
116 | + $payment_method_list_config = array( |
|
117 | + 'nav' => array( |
|
118 | + 'label' => __('Payment Methods', 'event_espresso'), |
|
119 | + 'order' => 10, |
|
120 | + ), |
|
121 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
122 | + 'help_tabs' => array_merge( |
|
123 | + array( |
|
124 | + 'payment_methods_overview_help_tab' => array( |
|
125 | + 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
126 | + 'filename' => 'payment_methods_overview', |
|
127 | + ), |
|
128 | + ), |
|
129 | + $this->_add_payment_method_help_tabs() |
|
130 | + ), |
|
131 | + 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
132 | + 'require_nonce' => false, |
|
133 | + ); |
|
134 | + $this->_page_config = array( |
|
135 | + 'default' => $payment_method_list_config, |
|
136 | + 'payment_settings' => array( |
|
137 | + 'nav' => array( |
|
138 | + 'label' => __('Settings', 'event_espresso'), |
|
139 | + 'order' => 20, |
|
140 | + ), |
|
141 | + 'help_tabs' => array( |
|
142 | + 'payment_methods_settings_help_tab' => array( |
|
143 | + 'title' => __('Payment Method Settings', 'event_espresso'), |
|
144 | + 'filename' => 'payment_methods_settings', |
|
145 | + ), |
|
146 | + ), |
|
147 | + // 'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
|
148 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
149 | + 'require_nonce' => false, |
|
150 | + ), |
|
151 | + 'payment_log' => array( |
|
152 | + 'nav' => array( |
|
153 | + 'label' => __("Logs", 'event_espresso'), |
|
154 | + 'order' => 30, |
|
155 | + ), |
|
156 | + 'list_table' => 'Payment_Log_Admin_List_Table', |
|
157 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
158 | + 'require_nonce' => false, |
|
159 | + ), |
|
160 | + ); |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @return array |
|
166 | + */ |
|
167 | + protected function _add_payment_method_help_tabs() |
|
168 | + { |
|
169 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
170 | + $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
|
171 | + $all_pmt_help_tabs_config = array(); |
|
172 | + foreach ($payment_method_types as $payment_method_type) { |
|
173 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
174 | + $payment_method_type->cap_name(), |
|
175 | + 'specific_payment_method_type_access' |
|
176 | + ) |
|
177 | + ) { |
|
178 | + continue; |
|
179 | + } |
|
180 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
181 | + $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
182 | + $template_args['admin_page_obj'] = $this; |
|
183 | + $all_pmt_help_tabs_config[ $help_tab_name ] = array( |
|
184 | + 'title' => $config['title'], |
|
185 | + 'content' => EEH_Template::display_template( |
|
186 | + $payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php', |
|
187 | + $template_args, |
|
188 | + true |
|
189 | + ), |
|
190 | + ); |
|
191 | + } |
|
192 | + } |
|
193 | + return $all_pmt_help_tabs_config; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + // none of the below group are currently used for Gateway Settings |
|
198 | + protected function _add_screen_options() |
|
199 | + { |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + protected function _add_feature_pointers() |
|
204 | + { |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + public function admin_init() |
|
209 | + { |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + public function admin_notices() |
|
214 | + { |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + public function admin_footer_scripts() |
|
219 | + { |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + public function load_scripts_styles() |
|
224 | + { |
|
225 | + wp_enqueue_script('ee_admin_js'); |
|
226 | + wp_enqueue_script('ee-text-links'); |
|
227 | + wp_enqueue_script( |
|
228 | + 'espresso_payments', |
|
229 | + EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', |
|
230 | + array('espresso-ui-theme', 'ee-datepicker'), |
|
231 | + EVENT_ESPRESSO_VERSION, |
|
232 | + true |
|
233 | + ); |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + public function load_scripts_styles_default() |
|
238 | + { |
|
239 | + // styles |
|
240 | + wp_register_style( |
|
241 | + 'espresso_payments', |
|
242 | + EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', |
|
243 | + array(), |
|
244 | + EVENT_ESPRESSO_VERSION |
|
245 | + ); |
|
246 | + wp_enqueue_style('espresso_payments'); |
|
247 | + wp_enqueue_style('ee-text-links'); |
|
248 | + // scripts |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + protected function _payment_methods_list() |
|
253 | + { |
|
254 | + /** |
|
255 | + * first let's ensure payment methods have been setup. We do this here because when people activate a |
|
256 | + * payment method for the first time (as an addon), it may not setup its capabilities or get registered correctly due |
|
257 | + * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
|
258 | + * recheck here. |
|
259 | + */ |
|
260 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
261 | + EEM_Payment_Method::instance()->verify_button_urls(); |
|
262 | + // setup tabs, one for each payment method type |
|
263 | + $tabs = array(); |
|
264 | + $payment_methods = array(); |
|
265 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
266 | + // we don't want to show admin-only PMTs for now |
|
267 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
268 | + continue; |
|
269 | + } |
|
270 | + // check access |
|
271 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
272 | + $pmt_obj->cap_name(), |
|
273 | + 'specific_payment_method_type_access' |
|
274 | + ) |
|
275 | + ) { |
|
276 | + continue; |
|
277 | + } |
|
278 | + // check for any active pms of that type |
|
279 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
280 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
281 | + $payment_method = EE_Payment_Method::new_instance( |
|
282 | + array( |
|
283 | + 'PMD_slug' => sanitize_key($pmt_obj->system_name()), |
|
284 | + 'PMD_type' => $pmt_obj->system_name(), |
|
285 | + 'PMD_name' => $pmt_obj->pretty_name(), |
|
286 | + 'PMD_admin_name' => $pmt_obj->pretty_name(), |
|
287 | + ) |
|
288 | + ); |
|
289 | + } |
|
290 | + $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
291 | + } |
|
292 | + $payment_methods = apply_filters( |
|
293 | + 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', |
|
294 | + $payment_methods |
|
295 | + ); |
|
296 | + foreach ($payment_methods as $payment_method) { |
|
297 | + if ($payment_method instanceof EE_Payment_Method) { |
|
298 | + add_meta_box( |
|
299 | + // html id |
|
300 | + 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
301 | + // title |
|
302 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
303 | + // callback |
|
304 | + array($this, 'payment_method_settings_meta_box'), |
|
305 | + // post type |
|
306 | + null, |
|
307 | + // context |
|
308 | + 'normal', |
|
309 | + // priority |
|
310 | + 'default', |
|
311 | + // callback args |
|
312 | + array('payment_method' => $payment_method) |
|
313 | + ); |
|
314 | + // setup for tabbed content |
|
315 | + $tabs[ $payment_method->slug() ] = array( |
|
316 | + 'label' => $payment_method->admin_name(), |
|
317 | + 'class' => $payment_method->active() ? 'gateway-active' : '', |
|
318 | + 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
319 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
320 | + 'slug' => $payment_method->slug(), |
|
321 | + ); |
|
322 | + } |
|
323 | + } |
|
324 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( |
|
325 | + $tabs, |
|
326 | + 'payment_method_links', |
|
327 | + '|', |
|
328 | + $this->_get_active_payment_method_slug() |
|
329 | + ); |
|
330 | + $this->display_admin_page_with_sidebar(); |
|
331 | + } |
|
332 | + |
|
333 | + |
|
334 | + /** |
|
335 | + * _get_active_payment_method_slug |
|
336 | + * |
|
337 | + * @return string |
|
338 | + */ |
|
339 | + protected function _get_active_payment_method_slug() |
|
340 | + { |
|
341 | + $payment_method_slug = false; |
|
342 | + // decide which payment method tab to open first, as dictated by the request's 'payment_method' |
|
343 | + if (isset($this->_req_data['payment_method'])) { |
|
344 | + // if they provided the current payment method, use it |
|
345 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
346 | + } |
|
347 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
348 | + // if that didn't work or wasn't provided, find another way to select the current pm |
|
349 | + if (! $this->_verify_payment_method($payment_method)) { |
|
350 | + // like, looking for an active one |
|
351 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
352 | + // test that one as well |
|
353 | + if ($this->_verify_payment_method($payment_method)) { |
|
354 | + $payment_method_slug = $payment_method->slug(); |
|
355 | + } else { |
|
356 | + $payment_method_slug = 'paypal_standard'; |
|
357 | + } |
|
358 | + } |
|
359 | + return $payment_method_slug; |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + /** |
|
364 | + * payment_method_settings_meta_box |
|
365 | + * returns TRUE if the passed payment method is properly constructed and the logged in user has the correct |
|
366 | + * capabilities to access it |
|
367 | + * |
|
368 | + * @param \EE_Payment_Method $payment_method |
|
369 | + * @return boolean |
|
370 | + */ |
|
371 | + protected function _verify_payment_method($payment_method) |
|
372 | + { |
|
373 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base |
|
374 | + && EE_Registry::instance()->CAP->current_user_can( |
|
375 | + $payment_method->type_obj()->cap_name(), |
|
376 | + 'specific_payment_method_type_access' |
|
377 | + ) |
|
378 | + ) { |
|
379 | + return true; |
|
380 | + } |
|
381 | + return false; |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * payment_method_settings_meta_box |
|
387 | + * |
|
388 | + * @param NULL $post_obj_which_is_null is an object containing the current post (as a $post object) |
|
389 | + * @param array $metabox is an array with metabox id, title, callback, and args elements. the value |
|
390 | + * at 'args' has key 'payment_method', as set within _payment_methods_list |
|
391 | + * @return string |
|
392 | + * @throws EE_Error |
|
393 | + */ |
|
394 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) |
|
395 | + { |
|
396 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) |
|
397 | + ? $metabox['args']['payment_method'] : null; |
|
398 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
399 | + throw new EE_Error( |
|
400 | + sprintf( |
|
401 | + __( |
|
402 | + 'Payment method metabox setup incorrectly. No Payment method object was supplied', |
|
403 | + 'event_espresso' |
|
404 | + ) |
|
405 | + ) |
|
406 | + ); |
|
407 | + } |
|
408 | + $payment_method_scopes = $payment_method->active(); |
|
409 | + // if the payment method really exists show its form, otherwise the activation template |
|
410 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
411 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
412 | + if ($form->form_data_present_in($this->_req_data)) { |
|
413 | + $form->receive_form_submission($this->_req_data); |
|
414 | + } |
|
415 | + echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
416 | + } else { |
|
417 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
418 | + } |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * Gets the form for all the settings related to this payment method type |
|
424 | + * |
|
425 | + * @access protected |
|
426 | + * @param \EE_Payment_Method $payment_method |
|
427 | + * @return \EE_Form_Section_Proper |
|
428 | + */ |
|
429 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) |
|
430 | + { |
|
431 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
432 | + return new EE_Form_Section_Proper(); |
|
433 | + } |
|
434 | + return new EE_Form_Section_Proper( |
|
435 | + array( |
|
436 | + 'name' => $payment_method->slug() . '_settings_form', |
|
437 | + 'html_id' => $payment_method->slug() . '_settings_form', |
|
438 | + 'action' => EE_Admin_Page::add_query_args_and_nonce( |
|
439 | + array( |
|
440 | + 'action' => 'update_payment_method', |
|
441 | + 'payment_method' => $payment_method->slug(), |
|
442 | + ), |
|
443 | + EE_PAYMENTS_ADMIN_URL |
|
444 | + ), |
|
445 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
446 | + 'subsections' => apply_filters( |
|
447 | + 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
|
448 | + array( |
|
449 | + 'pci_dss_compliance' => $this->_pci_dss_compliance($payment_method), |
|
450 | + 'currency_support' => $this->_currency_support($payment_method), |
|
451 | + 'payment_method_settings' => $this->_payment_method_settings($payment_method), |
|
452 | + 'update' => $this->_update_payment_method_button($payment_method), |
|
453 | + 'deactivate' => $this->_deactivate_payment_method_button($payment_method), |
|
454 | + 'fine_print' => $this->_fine_print(), |
|
455 | + ), |
|
456 | + $payment_method |
|
457 | + ), |
|
458 | + ) |
|
459 | + ); |
|
460 | + } |
|
461 | + |
|
462 | + |
|
463 | + /** |
|
464 | + * _pci_dss_compliance |
|
465 | + * |
|
466 | + * @access protected |
|
467 | + * @param \EE_Payment_Method $payment_method |
|
468 | + * @return \EE_Form_Section_Proper |
|
469 | + */ |
|
470 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) |
|
471 | + { |
|
472 | + if ($payment_method->type_obj()->requires_https()) { |
|
473 | + return new EE_Form_Section_HTML( |
|
474 | + EEH_HTML::tr( |
|
475 | + EEH_HTML::th( |
|
476 | + EEH_HTML::label( |
|
477 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
478 | + ) |
|
479 | + ) . |
|
480 | + EEH_HTML::td( |
|
481 | + EEH_HTML::strong( |
|
482 | + __( |
|
483 | + 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', |
|
484 | + 'event_espresso' |
|
485 | + ) |
|
486 | + ) |
|
487 | + . |
|
488 | + EEH_HTML::br() |
|
489 | + . |
|
490 | + __('Learn more about ', 'event_espresso') |
|
491 | + . EEH_HTML::link( |
|
492 | + 'https://www.pcisecuritystandards.org/merchants/index.php', |
|
493 | + __('PCI DSS compliance', 'event_espresso') |
|
494 | + ) |
|
495 | + ) |
|
496 | + ) |
|
497 | + ); |
|
498 | + } else { |
|
499 | + return new EE_Form_Section_HTML(''); |
|
500 | + } |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * _currency_support |
|
506 | + * |
|
507 | + * @access protected |
|
508 | + * @param \EE_Payment_Method $payment_method |
|
509 | + * @return \EE_Form_Section_Proper |
|
510 | + */ |
|
511 | + protected function _currency_support(EE_Payment_Method $payment_method) |
|
512 | + { |
|
513 | + if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
514 | + return new EE_Form_Section_HTML( |
|
515 | + EEH_HTML::tr( |
|
516 | + EEH_HTML::th( |
|
517 | + EEH_HTML::label( |
|
518 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
519 | + ) |
|
520 | + ) . |
|
521 | + EEH_HTML::td( |
|
522 | + EEH_HTML::strong( |
|
523 | + sprintf( |
|
524 | + __( |
|
525 | + 'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.', |
|
526 | + 'event_espresso' |
|
527 | + ), |
|
528 | + EE_Config::instance()->currency->code |
|
529 | + ) |
|
530 | + ) |
|
531 | + ) |
|
532 | + ) |
|
533 | + ); |
|
534 | + } else { |
|
535 | + return new EE_Form_Section_HTML(''); |
|
536 | + } |
|
537 | + } |
|
538 | + |
|
539 | + |
|
540 | + /** |
|
541 | + * _update_payment_method_button |
|
542 | + * |
|
543 | + * @access protected |
|
544 | + * @param \EE_Payment_Method $payment_method |
|
545 | + * @return \EE_Form_Section_HTML |
|
546 | + */ |
|
547 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) |
|
548 | + { |
|
549 | + // modify the form so we only have/show fields that will be implemented for this version |
|
550 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
551 | + } |
|
552 | + |
|
553 | + |
|
554 | + /** |
|
555 | + * Simplifies the form to merely reproduce 4.1's gateway settings functionality |
|
556 | + * |
|
557 | + * @param EE_Form_Section_Proper $form_section |
|
558 | + * @param string $payment_method_name |
|
559 | + * @return \EE_Payment_Method_Form |
|
560 | + * @throws \EE_Error |
|
561 | + */ |
|
562 | + protected function _simplify_form($form_section, $payment_method_name = '') |
|
563 | + { |
|
564 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
565 | + $form_section->exclude( |
|
566 | + array( |
|
567 | + 'PMD_type', // dont want them changing the type |
|
568 | + 'PMD_slug', // or the slug (probably never) |
|
569 | + 'PMD_wp_user', // or the user's ID |
|
570 | + 'Currency' // or the currency, until the rest of EE supports simultaneous currencies |
|
571 | + ) |
|
572 | + ); |
|
573 | + return $form_section; |
|
574 | + } else { |
|
575 | + throw new EE_Error( |
|
576 | + sprintf( |
|
577 | + __( |
|
578 | + 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', |
|
579 | + 'event_espresso' |
|
580 | + ), |
|
581 | + $payment_method_name |
|
582 | + ) |
|
583 | + ); |
|
584 | + } |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + /** |
|
589 | + * _update_payment_method_button |
|
590 | + * |
|
591 | + * @access protected |
|
592 | + * @param \EE_Payment_Method $payment_method |
|
593 | + * @return \EE_Form_Section_HTML |
|
594 | + */ |
|
595 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) |
|
596 | + { |
|
597 | + $update_button = new EE_Submit_Input( |
|
598 | + array( |
|
599 | + 'name' => 'submit', |
|
600 | + 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
601 | + 'default' => sprintf( |
|
602 | + __('Update %s Payment Settings', 'event_espresso'), |
|
603 | + $payment_method->admin_name() |
|
604 | + ), |
|
605 | + 'html_label' => EEH_HTML::nbsp(), |
|
606 | + ) |
|
607 | + ); |
|
608 | + return new EE_Form_Section_HTML( |
|
609 | + EEH_HTML::no_row(EEH_HTML::br(2)) . |
|
610 | + EEH_HTML::tr( |
|
611 | + EEH_HTML::th(__('Update Settings', 'event_espresso')) . |
|
612 | + EEH_HTML::td( |
|
613 | + $update_button->get_html_for_input() |
|
614 | + ) |
|
615 | + ) |
|
616 | + ); |
|
617 | + } |
|
618 | + |
|
619 | + |
|
620 | + /** |
|
621 | + * _deactivate_payment_method_button |
|
622 | + * |
|
623 | + * @access protected |
|
624 | + * @param \EE_Payment_Method $payment_method |
|
625 | + * @return \EE_Form_Section_Proper |
|
626 | + */ |
|
627 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) |
|
628 | + { |
|
629 | + $link_text_and_title = sprintf( |
|
630 | + __('Deactivate %1$s Payments?', 'event_espresso'), |
|
631 | + $payment_method->admin_name() |
|
632 | + ); |
|
633 | + return new EE_Form_Section_HTML( |
|
634 | + EEH_HTML::tr( |
|
635 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) . |
|
636 | + EEH_HTML::td( |
|
637 | + EEH_HTML::link( |
|
638 | + EE_Admin_Page::add_query_args_and_nonce( |
|
639 | + array( |
|
640 | + 'action' => 'deactivate_payment_method', |
|
641 | + 'payment_method' => $payment_method->slug(), |
|
642 | + ), |
|
643 | + EE_PAYMENTS_ADMIN_URL |
|
644 | + ), |
|
645 | + $link_text_and_title, |
|
646 | + $link_text_and_title, |
|
647 | + 'deactivate_' . $payment_method->slug(), |
|
648 | + 'espresso-button button-secondary' |
|
649 | + ) |
|
650 | + ) |
|
651 | + ) |
|
652 | + ); |
|
653 | + } |
|
654 | + |
|
655 | + |
|
656 | + /** |
|
657 | + * _activate_payment_method_button |
|
658 | + * |
|
659 | + * @access protected |
|
660 | + * @param \EE_Payment_Method $payment_method |
|
661 | + * @return \EE_Form_Section_Proper |
|
662 | + */ |
|
663 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) |
|
664 | + { |
|
665 | + $link_text_and_title = sprintf( |
|
666 | + __('Activate %1$s Payment Method?', 'event_espresso'), |
|
667 | + $payment_method->admin_name() |
|
668 | + ); |
|
669 | + return new EE_Form_Section_Proper( |
|
670 | + array( |
|
671 | + 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
672 | + 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
673 | + 'action' => '#', |
|
674 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
675 | + 'subsections' => apply_filters( |
|
676 | + 'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections', |
|
677 | + array( |
|
678 | + new EE_Form_Section_HTML( |
|
679 | + EEH_HTML::tr( |
|
680 | + EEH_HTML::td( |
|
681 | + $payment_method->type_obj()->introductory_html(), |
|
682 | + '', |
|
683 | + '', |
|
684 | + '', |
|
685 | + 'colspan="2"' |
|
686 | + ) |
|
687 | + ) . |
|
688 | + EEH_HTML::tr( |
|
689 | + EEH_HTML::th( |
|
690 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
691 | + ) . |
|
692 | + EEH_HTML::td( |
|
693 | + EEH_HTML::link( |
|
694 | + EE_Admin_Page::add_query_args_and_nonce( |
|
695 | + array( |
|
696 | + 'action' => 'activate_payment_method', |
|
697 | + 'payment_method_type' => $payment_method->type(), |
|
698 | + ), |
|
699 | + EE_PAYMENTS_ADMIN_URL |
|
700 | + ), |
|
701 | + $link_text_and_title, |
|
702 | + $link_text_and_title, |
|
703 | + 'activate_' . $payment_method->slug(), |
|
704 | + 'espresso-button-green button-primary' |
|
705 | + ) |
|
706 | + ) |
|
707 | + ) |
|
708 | + ), |
|
709 | + ), |
|
710 | + $payment_method |
|
711 | + ), |
|
712 | + ) |
|
713 | + ); |
|
714 | + } |
|
715 | + |
|
716 | + |
|
717 | + /** |
|
718 | + * _fine_print |
|
719 | + * |
|
720 | + * @access protected |
|
721 | + * @return \EE_Form_Section_HTML |
|
722 | + */ |
|
723 | + protected function _fine_print() |
|
724 | + { |
|
725 | + return new EE_Form_Section_HTML( |
|
726 | + EEH_HTML::tr( |
|
727 | + EEH_HTML::th() . |
|
728 | + EEH_HTML::td( |
|
729 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
730 | + ) |
|
731 | + ) |
|
732 | + ); |
|
733 | + } |
|
734 | + |
|
735 | + |
|
736 | + /** |
|
737 | + * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
|
738 | + * |
|
739 | + * @global WP_User $current_user |
|
740 | + */ |
|
741 | + protected function _activate_payment_method() |
|
742 | + { |
|
743 | + if (isset($this->_req_data['payment_method_type'])) { |
|
744 | + $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
|
745 | + // see if one exists |
|
746 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
747 | + $payment_method = EE_Payment_Method_Manager::instance() |
|
748 | + ->activate_a_payment_method_of_type($payment_method_type); |
|
749 | + $this->_redirect_after_action( |
|
750 | + 1, |
|
751 | + 'Payment Method', |
|
752 | + 'activated', |
|
753 | + array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
754 | + ); |
|
755 | + } else { |
|
756 | + $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
757 | + } |
|
758 | + } |
|
759 | + |
|
760 | + |
|
761 | + /** |
|
762 | + * Deactivates the payment method with the specified slug, and redirects. |
|
763 | + */ |
|
764 | + protected function _deactivate_payment_method() |
|
765 | + { |
|
766 | + if (isset($this->_req_data['payment_method'])) { |
|
767 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
768 | + // deactivate it |
|
769 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
770 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
771 | + $this->_redirect_after_action( |
|
772 | + $count_updated, |
|
773 | + 'Payment Method', |
|
774 | + 'deactivated', |
|
775 | + array('action' => 'default', 'payment_method' => $payment_method_slug) |
|
776 | + ); |
|
777 | + } else { |
|
778 | + $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default')); |
|
779 | + } |
|
780 | + } |
|
781 | + |
|
782 | + |
|
783 | + /** |
|
784 | + * Processes the payment method form that was submitted. This is slightly trickier than usual form |
|
785 | + * processing because we first need to identify WHICH form was processed and which payment method |
|
786 | + * it corresponds to. Once we have done that, we see if the form is valid. If it is, the |
|
787 | + * form's data is saved and we redirect to the default payment methods page, setting the updated payment method |
|
788 | + * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the |
|
789 | + * subsequently called 'headers_sent_func' which is _payment_methods_list) |
|
790 | + * |
|
791 | + * @return void |
|
792 | + */ |
|
793 | + protected function _update_payment_method() |
|
794 | + { |
|
795 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
796 | + // ok let's find which gateway form to use based on the form input |
|
797 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
798 | + /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
|
799 | + $correct_pmt_form_to_use = null; |
|
800 | + $payment_method = null; |
|
801 | + foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
802 | + // get the form and simplify it, like what we do when we display it |
|
803 | + $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
804 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
805 | + $correct_pmt_form_to_use = $pmt_form; |
|
806 | + break; |
|
807 | + } |
|
808 | + } |
|
809 | + // if we couldn't find the correct payment method type... |
|
810 | + if (! $correct_pmt_form_to_use) { |
|
811 | + EE_Error::add_error( |
|
812 | + __( |
|
813 | + "We could not find which payment method type your form submission related to. Please contact support", |
|
814 | + 'event_espresso' |
|
815 | + ), |
|
816 | + __FILE__, |
|
817 | + __FUNCTION__, |
|
818 | + __LINE__ |
|
819 | + ); |
|
820 | + $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
821 | + } |
|
822 | + $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
|
823 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
824 | + $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings'); |
|
825 | + if (! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
826 | + throw new EE_Error( |
|
827 | + sprintf( |
|
828 | + __( |
|
829 | + 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', |
|
830 | + 'event_espresso' |
|
831 | + ), |
|
832 | + 'payment_method_settings' |
|
833 | + ) |
|
834 | + ); |
|
835 | + } |
|
836 | + $payment_settings_subform->save(); |
|
837 | + /** @var $pm EE_Payment_Method */ |
|
838 | + $this->_redirect_after_action( |
|
839 | + true, |
|
840 | + 'Payment Method', |
|
841 | + 'updated', |
|
842 | + array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
843 | + ); |
|
844 | + } else { |
|
845 | + EE_Error::add_error( |
|
846 | + sprintf( |
|
847 | + __( |
|
848 | + 'Payment method of type %s was not saved because there were validation errors. They have been marked in the form', |
|
849 | + 'event_espresso' |
|
850 | + ), |
|
851 | + $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name() |
|
852 | + : __('"(unknown)"', 'event_espresso') |
|
853 | + ), |
|
854 | + __FILE__, |
|
855 | + __FUNCTION__, |
|
856 | + __LINE__ |
|
857 | + ); |
|
858 | + } |
|
859 | + } |
|
860 | + return; |
|
861 | + } |
|
862 | + |
|
863 | + |
|
864 | + /** |
|
865 | + * Displays payment settings (not payment METHOD settings, that's _payment_method_settings) |
|
866 | + * @throws DomainException |
|
867 | + * @throws EE_Error |
|
868 | + * @throws InvalidArgumentException |
|
869 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
870 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
871 | + */ |
|
872 | + protected function _payment_settings() |
|
873 | + { |
|
874 | + $form = $this->getPaymentSettingsForm(); |
|
875 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
876 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
877 | + $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
878 | + $this->display_admin_page_with_sidebar(); |
|
879 | + } |
|
880 | + |
|
881 | + |
|
882 | + /** |
|
883 | + * _update_payment_settings |
|
884 | + * |
|
885 | + * @access protected |
|
886 | + * @return void |
|
887 | + * @throws EE_Error |
|
888 | + * @throws InvalidArgumentException |
|
889 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
890 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
891 | + */ |
|
892 | + protected function _update_payment_settings() |
|
893 | + { |
|
894 | + $form = $this->getPaymentSettingsForm(); |
|
895 | + if ($form->was_submitted($this->_req_data)) { |
|
896 | + $form->receive_form_submission($this->_req_data); |
|
897 | + if ($form->is_valid()) { |
|
898 | + /** |
|
899 | + * @var $reg_config EE_Registration_Config |
|
900 | + */ |
|
901 | + $loader = LoaderFactory::getLoader(); |
|
902 | + $reg_config = $loader->getShared('EE_Registration_Config'); |
|
903 | + $valid_data = $form->valid_data(); |
|
904 | + $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options']; |
|
905 | + $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan']; |
|
906 | + } |
|
907 | + } |
|
908 | + EE_Registry::instance()->CFG = apply_filters( |
|
909 | + 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', |
|
910 | + EE_Registry::instance()->CFG |
|
911 | + ); |
|
912 | + |
|
913 | + $cfg = EE_Registry::instance()->CFG ; |
|
914 | + |
|
915 | + $what = __('Payment Settings', 'event_espresso'); |
|
916 | + $success = $this->_update_espresso_configuration( |
|
917 | + $what, |
|
918 | + EE_Registry::instance()->CFG, |
|
919 | + __FILE__, |
|
920 | + __FUNCTION__, |
|
921 | + __LINE__ |
|
922 | + ); |
|
923 | + $this->_redirect_after_action( |
|
924 | + $success, |
|
925 | + $what, |
|
926 | + __('updated', 'event_espresso'), |
|
927 | + array('action' => 'payment_settings') |
|
928 | + ); |
|
929 | + } |
|
930 | + |
|
931 | + |
|
932 | + /** |
|
933 | + * Gets the form used for updating payment settings |
|
934 | + * |
|
935 | + * @return EE_Form_Section_Proper |
|
936 | + * @throws EE_Error |
|
937 | + * @throws InvalidArgumentException |
|
938 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
939 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
940 | + */ |
|
941 | + protected function getPaymentSettingsForm() |
|
942 | + { |
|
943 | + /** |
|
944 | + * @var $reg_config EE_Registration_Config |
|
945 | + */ |
|
946 | + $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
947 | + return new EE_Form_Section_Proper( |
|
948 | + array( |
|
949 | + 'name' => 'payment-settings', |
|
950 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
951 | + 'subsections' => array( |
|
952 | + 'show_pending_payment_options' => new EE_Yes_No_Input( |
|
953 | + array( |
|
954 | + 'html_name' => 'show_pending_payment_options', |
|
955 | + 'default' => $reg_config->show_pending_payment_options, |
|
956 | + 'html_help_text' => esc_html__( |
|
957 | + "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ", |
|
958 | + 'event_espresso' |
|
959 | + ) |
|
960 | + ) |
|
961 | + ), |
|
962 | + 'gateway_log_lifespan' => new \EE_Select_Input( |
|
963 | + $reg_config->gatewayLogLifespanOptions(), |
|
964 | + array( |
|
965 | + 'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'), |
|
966 | + 'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'), |
|
967 | + 'default' => $reg_config->gateway_log_lifespan, |
|
968 | + ) |
|
969 | + ) |
|
970 | + ) |
|
971 | + ) |
|
972 | + ); |
|
973 | + } |
|
974 | + |
|
975 | + |
|
976 | + protected function _payment_log_overview_list_table() |
|
977 | + { |
|
978 | + $this->display_admin_list_table_page_with_sidebar(); |
|
979 | + } |
|
980 | + |
|
981 | + |
|
982 | + protected function _set_list_table_views_payment_log() |
|
983 | + { |
|
984 | + $this->_views = array( |
|
985 | + 'all' => array( |
|
986 | + 'slug' => 'all', |
|
987 | + 'label' => __('View All Logs', 'event_espresso'), |
|
988 | + 'count' => 0, |
|
989 | + ), |
|
990 | + ); |
|
991 | + } |
|
992 | + |
|
993 | + |
|
994 | + /** |
|
995 | + * @param int $per_page |
|
996 | + * @param int $current_page |
|
997 | + * @param bool $count |
|
998 | + * @return array |
|
999 | + */ |
|
1000 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) |
|
1001 | + { |
|
1002 | + EE_Registry::instance()->load_model('Change_Log'); |
|
1003 | + // we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
|
1004 | + $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway)); |
|
1005 | + // check if they've selected a specific payment method |
|
1006 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
1007 | + $query_params[0]['OR*pm_or_pay_pm'] = array( |
|
1008 | + 'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1009 | + 'Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1010 | + ); |
|
1011 | + } |
|
1012 | + // take into account search |
|
1013 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
1014 | + $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'); |
|
1015 | + $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
|
1016 | + $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
|
1017 | + $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
|
1018 | + $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string; |
|
1019 | + $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1020 | + $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string; |
|
1021 | + $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1022 | + $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string; |
|
1023 | + $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1024 | + $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string; |
|
1025 | + $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1026 | + } |
|
1027 | + if (isset($this->_req_data['payment-filter-start-date']) |
|
1028 | + && isset($this->_req_data['payment-filter-end-date']) |
|
1029 | + ) { |
|
1030 | + // add date |
|
1031 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
1032 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
1033 | + // make sure our timestamps start and end right at the boundaries for each day |
|
1034 | + $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1035 | + $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1036 | + // convert to timestamps |
|
1037 | + $start_date = strtotime($start_date); |
|
1038 | + $end_date = strtotime($end_date); |
|
1039 | + // makes sure start date is the lowest value and vice versa |
|
1040 | + $start_date = min($start_date, $end_date); |
|
1041 | + $end_date = max($start_date, $end_date); |
|
1042 | + // convert for query |
|
1043 | + $start_date = EEM_Change_Log::instance() |
|
1044 | + ->convert_datetime_for_query( |
|
1045 | + 'LOG_time', |
|
1046 | + date('Y-m-d H:i:s', $start_date), |
|
1047 | + 'Y-m-d H:i:s' |
|
1048 | + ); |
|
1049 | + $end_date = EEM_Change_Log::instance() |
|
1050 | + ->convert_datetime_for_query( |
|
1051 | + 'LOG_time', |
|
1052 | + date('Y-m-d H:i:s', $end_date), |
|
1053 | + 'Y-m-d H:i:s' |
|
1054 | + ); |
|
1055 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
1056 | + } |
|
1057 | + if ($count) { |
|
1058 | + return EEM_Change_Log::instance()->count($query_params); |
|
1059 | + } |
|
1060 | + if (isset($this->_req_data['order'])) { |
|
1061 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
1062 | + : 'DESC'; |
|
1063 | + $query_params['order_by'] = array('LOG_time' => $sort); |
|
1064 | + } else { |
|
1065 | + $query_params['order_by'] = array('LOG_time' => 'DESC'); |
|
1066 | + } |
|
1067 | + $offset = ($current_page - 1) * $per_page; |
|
1068 | + if (! isset($this->_req_data['download_results'])) { |
|
1069 | + $query_params['limit'] = array($offset, $per_page); |
|
1070 | + } |
|
1071 | + // now they've requested to instead just download the file instead of viewing it. |
|
1072 | + if (isset($this->_req_data['download_results'])) { |
|
1073 | + $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
|
1074 | + header('Content-Disposition: attachment'); |
|
1075 | + header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url())); |
|
1076 | + echo "<h1>Payment Logs for " . site_url() . "</h1>"; |
|
1077 | + echo "<h3>Query:</h3>"; |
|
1078 | + var_dump($query_params); |
|
1079 | + echo "<h3>Results:</h3>"; |
|
1080 | + var_dump($wpdb_results); |
|
1081 | + die; |
|
1082 | + } |
|
1083 | + $results = EEM_Change_Log::instance()->get_all($query_params); |
|
1084 | + return $results; |
|
1085 | + } |
|
1086 | + |
|
1087 | + |
|
1088 | + /** |
|
1089 | + * Used by usort to RE-sort log query results, because we lose the ordering |
|
1090 | + * because we're possibly combining the results from two queries |
|
1091 | + * |
|
1092 | + * @param EE_Change_Log $logA |
|
1093 | + * @param EE_Change_Log $logB |
|
1094 | + * @return int |
|
1095 | + */ |
|
1096 | + protected function _sort_logs_again($logA, $logB) |
|
1097 | + { |
|
1098 | + $timeA = $logA->get_raw('LOG_time'); |
|
1099 | + $timeB = $logB->get_raw('LOG_time'); |
|
1100 | + if ($timeA == $timeB) { |
|
1101 | + return 0; |
|
1102 | + } |
|
1103 | + $comparison = $timeA < $timeB ? -1 : 1; |
|
1104 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
1105 | + return $comparison * -1; |
|
1106 | + } else { |
|
1107 | + return $comparison; |
|
1108 | + } |
|
1109 | + } |
|
1110 | + |
|
1111 | + |
|
1112 | + protected function _payment_log_details() |
|
1113 | + { |
|
1114 | + EE_Registry::instance()->load_model('Change_Log'); |
|
1115 | + /** @var $payment_log EE_Change_Log */ |
|
1116 | + $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
|
1117 | + $payment_method = null; |
|
1118 | + $transaction = null; |
|
1119 | + if ($payment_log instanceof EE_Change_Log) { |
|
1120 | + if ($payment_log->object() instanceof EE_Payment) { |
|
1121 | + $payment_method = $payment_log->object()->payment_method(); |
|
1122 | + $transaction = $payment_log->object()->transaction(); |
|
1123 | + } elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
1124 | + $payment_method = $payment_log->object(); |
|
1125 | + } |
|
1126 | + } |
|
1127 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1128 | + EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
1129 | + array( |
|
1130 | + 'payment_log' => $payment_log, |
|
1131 | + 'payment_method' => $payment_method, |
|
1132 | + 'transaction' => $transaction, |
|
1133 | + ), |
|
1134 | + true |
|
1135 | + ); |
|
1136 | + $this->display_admin_page_with_sidebar(); |
|
1137 | + } |
|
1138 | 1138 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
171 | 171 | $all_pmt_help_tabs_config = array(); |
172 | 172 | foreach ($payment_method_types as $payment_method_type) { |
173 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
173 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
174 | 174 | $payment_method_type->cap_name(), |
175 | 175 | 'specific_payment_method_type_access' |
176 | 176 | ) |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
181 | 181 | $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
182 | 182 | $template_args['admin_page_obj'] = $this; |
183 | - $all_pmt_help_tabs_config[ $help_tab_name ] = array( |
|
183 | + $all_pmt_help_tabs_config[$help_tab_name] = array( |
|
184 | 184 | 'title' => $config['title'], |
185 | 185 | 'content' => EEH_Template::display_template( |
186 | - $payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php', |
|
186 | + $payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', |
|
187 | 187 | $template_args, |
188 | 188 | true |
189 | 189 | ), |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | wp_enqueue_script('ee-text-links'); |
227 | 227 | wp_enqueue_script( |
228 | 228 | 'espresso_payments', |
229 | - EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', |
|
229 | + EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', |
|
230 | 230 | array('espresso-ui-theme', 'ee-datepicker'), |
231 | 231 | EVENT_ESPRESSO_VERSION, |
232 | 232 | true |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | // styles |
240 | 240 | wp_register_style( |
241 | 241 | 'espresso_payments', |
242 | - EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', |
|
242 | + EE_PAYMENTS_ASSETS_URL.'ee-payments.css', |
|
243 | 243 | array(), |
244 | 244 | EVENT_ESPRESSO_VERSION |
245 | 245 | ); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | continue; |
269 | 269 | } |
270 | 270 | // check access |
271 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
271 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
272 | 272 | $pmt_obj->cap_name(), |
273 | 273 | 'specific_payment_method_type_access' |
274 | 274 | ) |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | } |
278 | 278 | // check for any active pms of that type |
279 | 279 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
280 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
280 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
281 | 281 | $payment_method = EE_Payment_Method::new_instance( |
282 | 282 | array( |
283 | 283 | 'PMD_slug' => sanitize_key($pmt_obj->system_name()), |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | ) |
288 | 288 | ); |
289 | 289 | } |
290 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
290 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
291 | 291 | } |
292 | 292 | $payment_methods = apply_filters( |
293 | 293 | 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | if ($payment_method instanceof EE_Payment_Method) { |
298 | 298 | add_meta_box( |
299 | 299 | // html id |
300 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
300 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
301 | 301 | // title |
302 | 302 | sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
303 | 303 | // callback |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | array('payment_method' => $payment_method) |
313 | 313 | ); |
314 | 314 | // setup for tabbed content |
315 | - $tabs[ $payment_method->slug() ] = array( |
|
315 | + $tabs[$payment_method->slug()] = array( |
|
316 | 316 | 'label' => $payment_method->admin_name(), |
317 | 317 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
318 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
318 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
319 | 319 | 'title' => __('Modify this Payment Method', 'event_espresso'), |
320 | 320 | 'slug' => $payment_method->slug(), |
321 | 321 | ); |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | } |
347 | 347 | $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
348 | 348 | // if that didn't work or wasn't provided, find another way to select the current pm |
349 | - if (! $this->_verify_payment_method($payment_method)) { |
|
349 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
350 | 350 | // like, looking for an active one |
351 | 351 | $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
352 | 352 | // test that one as well |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | { |
396 | 396 | $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) |
397 | 397 | ? $metabox['args']['payment_method'] : null; |
398 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
398 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
399 | 399 | throw new EE_Error( |
400 | 400 | sprintf( |
401 | 401 | __( |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | if ($form->form_data_present_in($this->_req_data)) { |
413 | 413 | $form->receive_form_submission($this->_req_data); |
414 | 414 | } |
415 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
415 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
416 | 416 | } else { |
417 | 417 | echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
418 | 418 | } |
@@ -428,13 +428,13 @@ discard block |
||
428 | 428 | */ |
429 | 429 | protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) |
430 | 430 | { |
431 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
431 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
432 | 432 | return new EE_Form_Section_Proper(); |
433 | 433 | } |
434 | 434 | return new EE_Form_Section_Proper( |
435 | 435 | array( |
436 | - 'name' => $payment_method->slug() . '_settings_form', |
|
437 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
436 | + 'name' => $payment_method->slug().'_settings_form', |
|
437 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
438 | 438 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
439 | 439 | array( |
440 | 440 | 'action' => 'update_payment_method', |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | EEH_HTML::label( |
477 | 477 | EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
478 | 478 | ) |
479 | - ) . |
|
479 | + ). |
|
480 | 480 | EEH_HTML::td( |
481 | 481 | EEH_HTML::strong( |
482 | 482 | __( |
@@ -510,14 +510,14 @@ discard block |
||
510 | 510 | */ |
511 | 511 | protected function _currency_support(EE_Payment_Method $payment_method) |
512 | 512 | { |
513 | - if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
513 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
514 | 514 | return new EE_Form_Section_HTML( |
515 | 515 | EEH_HTML::tr( |
516 | 516 | EEH_HTML::th( |
517 | 517 | EEH_HTML::label( |
518 | 518 | EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
519 | 519 | ) |
520 | - ) . |
|
520 | + ). |
|
521 | 521 | EEH_HTML::td( |
522 | 522 | EEH_HTML::strong( |
523 | 523 | sprintf( |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | $update_button = new EE_Submit_Input( |
598 | 598 | array( |
599 | 599 | 'name' => 'submit', |
600 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
600 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
601 | 601 | 'default' => sprintf( |
602 | 602 | __('Update %s Payment Settings', 'event_espresso'), |
603 | 603 | $payment_method->admin_name() |
@@ -606,9 +606,9 @@ discard block |
||
606 | 606 | ) |
607 | 607 | ); |
608 | 608 | return new EE_Form_Section_HTML( |
609 | - EEH_HTML::no_row(EEH_HTML::br(2)) . |
|
609 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
610 | 610 | EEH_HTML::tr( |
611 | - EEH_HTML::th(__('Update Settings', 'event_espresso')) . |
|
611 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
612 | 612 | EEH_HTML::td( |
613 | 613 | $update_button->get_html_for_input() |
614 | 614 | ) |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | ); |
633 | 633 | return new EE_Form_Section_HTML( |
634 | 634 | EEH_HTML::tr( |
635 | - EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) . |
|
635 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
636 | 636 | EEH_HTML::td( |
637 | 637 | EEH_HTML::link( |
638 | 638 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | ), |
645 | 645 | $link_text_and_title, |
646 | 646 | $link_text_and_title, |
647 | - 'deactivate_' . $payment_method->slug(), |
|
647 | + 'deactivate_'.$payment_method->slug(), |
|
648 | 648 | 'espresso-button button-secondary' |
649 | 649 | ) |
650 | 650 | ) |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | ); |
669 | 669 | return new EE_Form_Section_Proper( |
670 | 670 | array( |
671 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
672 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
671 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
672 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
673 | 673 | 'action' => '#', |
674 | 674 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
675 | 675 | 'subsections' => apply_filters( |
@@ -684,11 +684,11 @@ discard block |
||
684 | 684 | '', |
685 | 685 | 'colspan="2"' |
686 | 686 | ) |
687 | - ) . |
|
687 | + ). |
|
688 | 688 | EEH_HTML::tr( |
689 | 689 | EEH_HTML::th( |
690 | 690 | EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
691 | - ) . |
|
691 | + ). |
|
692 | 692 | EEH_HTML::td( |
693 | 693 | EEH_HTML::link( |
694 | 694 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | ), |
701 | 701 | $link_text_and_title, |
702 | 702 | $link_text_and_title, |
703 | - 'activate_' . $payment_method->slug(), |
|
703 | + 'activate_'.$payment_method->slug(), |
|
704 | 704 | 'espresso-button-green button-primary' |
705 | 705 | ) |
706 | 706 | ) |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | { |
725 | 725 | return new EE_Form_Section_HTML( |
726 | 726 | EEH_HTML::tr( |
727 | - EEH_HTML::th() . |
|
727 | + EEH_HTML::th(). |
|
728 | 728 | EEH_HTML::td( |
729 | 729 | EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
730 | 730 | ) |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | } |
808 | 808 | } |
809 | 809 | // if we couldn't find the correct payment method type... |
810 | - if (! $correct_pmt_form_to_use) { |
|
810 | + if ( ! $correct_pmt_form_to_use) { |
|
811 | 811 | EE_Error::add_error( |
812 | 812 | __( |
813 | 813 | "We could not find which payment method type your form submission related to. Please contact support", |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
823 | 823 | if ($correct_pmt_form_to_use->is_valid()) { |
824 | 824 | $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings'); |
825 | - if (! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
825 | + if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
826 | 826 | throw new EE_Error( |
827 | 827 | sprintf( |
828 | 828 | __( |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | $form = $this->getPaymentSettingsForm(); |
875 | 875 | $this->_set_add_edit_form_tags('update_payment_settings'); |
876 | 876 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
877 | - $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
877 | + $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
878 | 878 | $this->display_admin_page_with_sidebar(); |
879 | 879 | } |
880 | 880 | |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | EE_Registry::instance()->CFG |
911 | 911 | ); |
912 | 912 | |
913 | - $cfg = EE_Registry::instance()->CFG ; |
|
913 | + $cfg = EE_Registry::instance()->CFG; |
|
914 | 914 | |
915 | 915 | $what = __('Payment Settings', 'event_espresso'); |
916 | 916 | $success = $this->_update_espresso_configuration( |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | } |
1012 | 1012 | // take into account search |
1013 | 1013 | if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
1014 | - $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'); |
|
1014 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
1015 | 1015 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
1016 | 1016 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
1017 | 1017 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -1031,8 +1031,8 @@ discard block |
||
1031 | 1031 | $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
1032 | 1032 | $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
1033 | 1033 | // make sure our timestamps start and end right at the boundaries for each day |
1034 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1035 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1034 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
1035 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
1036 | 1036 | // convert to timestamps |
1037 | 1037 | $start_date = strtotime($start_date); |
1038 | 1038 | $end_date = strtotime($end_date); |
@@ -1065,15 +1065,15 @@ discard block |
||
1065 | 1065 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
1066 | 1066 | } |
1067 | 1067 | $offset = ($current_page - 1) * $per_page; |
1068 | - if (! isset($this->_req_data['download_results'])) { |
|
1068 | + if ( ! isset($this->_req_data['download_results'])) { |
|
1069 | 1069 | $query_params['limit'] = array($offset, $per_page); |
1070 | 1070 | } |
1071 | 1071 | // now they've requested to instead just download the file instead of viewing it. |
1072 | 1072 | if (isset($this->_req_data['download_results'])) { |
1073 | 1073 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
1074 | 1074 | header('Content-Disposition: attachment'); |
1075 | - header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url())); |
|
1076 | - echo "<h1>Payment Logs for " . site_url() . "</h1>"; |
|
1075 | + header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
|
1076 | + echo "<h1>Payment Logs for ".site_url()."</h1>"; |
|
1077 | 1077 | echo "<h3>Query:</h3>"; |
1078 | 1078 | var_dump($query_params); |
1079 | 1079 | echo "<h3>Results:</h3>"; |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | } |
1126 | 1126 | } |
1127 | 1127 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
1128 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
1128 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
1129 | 1129 | array( |
1130 | 1130 | 'payment_log' => $payment_log, |
1131 | 1131 | 'payment_method' => $payment_method, |
@@ -13,2438 +13,2438 @@ discard block |
||
13 | 13 | final class EE_Config implements ResettableInterface |
14 | 14 | { |
15 | 15 | |
16 | - const OPTION_NAME = 'ee_config'; |
|
17 | - |
|
18 | - const LOG_NAME = 'ee_config_log'; |
|
19 | - |
|
20 | - const LOG_LENGTH = 100; |
|
21 | - |
|
22 | - const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * instance of the EE_Config object |
|
27 | - * |
|
28 | - * @var EE_Config $_instance |
|
29 | - * @access private |
|
30 | - */ |
|
31 | - private static $_instance; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var boolean $_logging_enabled |
|
35 | - */ |
|
36 | - private static $_logging_enabled = false; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
40 | - */ |
|
41 | - private $legacy_shortcodes_manager; |
|
42 | - |
|
43 | - /** |
|
44 | - * An StdClass whose property names are addon slugs, |
|
45 | - * and values are their config classes |
|
46 | - * |
|
47 | - * @var StdClass |
|
48 | - */ |
|
49 | - public $addons; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var EE_Admin_Config |
|
53 | - */ |
|
54 | - public $admin; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var EE_Core_Config |
|
58 | - */ |
|
59 | - public $core; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var EE_Currency_Config |
|
63 | - */ |
|
64 | - public $currency; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var EE_Organization_Config |
|
68 | - */ |
|
69 | - public $organization; |
|
70 | - |
|
71 | - /** |
|
72 | - * @var EE_Registration_Config |
|
73 | - */ |
|
74 | - public $registration; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var EE_Template_Config |
|
78 | - */ |
|
79 | - public $template_settings; |
|
80 | - |
|
81 | - /** |
|
82 | - * Holds EE environment values. |
|
83 | - * |
|
84 | - * @var EE_Environment_Config |
|
85 | - */ |
|
86 | - public $environment; |
|
87 | - |
|
88 | - /** |
|
89 | - * settings pertaining to Google maps |
|
90 | - * |
|
91 | - * @var EE_Map_Config |
|
92 | - */ |
|
93 | - public $map_settings; |
|
94 | - |
|
95 | - /** |
|
96 | - * settings pertaining to Taxes |
|
97 | - * |
|
98 | - * @var EE_Tax_Config |
|
99 | - */ |
|
100 | - public $tax_settings; |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * Settings pertaining to global messages settings. |
|
105 | - * |
|
106 | - * @var EE_Messages_Config |
|
107 | - */ |
|
108 | - public $messages; |
|
109 | - |
|
110 | - /** |
|
111 | - * @deprecated |
|
112 | - * @var EE_Gateway_Config |
|
113 | - */ |
|
114 | - public $gateway; |
|
115 | - |
|
116 | - /** |
|
117 | - * @var array $_addon_option_names |
|
118 | - * @access private |
|
119 | - */ |
|
120 | - private $_addon_option_names = array(); |
|
121 | - |
|
122 | - /** |
|
123 | - * @var array $_module_route_map |
|
124 | - * @access private |
|
125 | - */ |
|
126 | - private static $_module_route_map = array(); |
|
127 | - |
|
128 | - /** |
|
129 | - * @var array $_module_forward_map |
|
130 | - * @access private |
|
131 | - */ |
|
132 | - private static $_module_forward_map = array(); |
|
133 | - |
|
134 | - /** |
|
135 | - * @var array $_module_view_map |
|
136 | - * @access private |
|
137 | - */ |
|
138 | - private static $_module_view_map = array(); |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @singleton method used to instantiate class object |
|
143 | - * @access public |
|
144 | - * @return EE_Config instance |
|
145 | - */ |
|
146 | - public static function instance() |
|
147 | - { |
|
148 | - // check if class object is instantiated, and instantiated properly |
|
149 | - if (! self::$_instance instanceof EE_Config) { |
|
150 | - self::$_instance = new self(); |
|
151 | - } |
|
152 | - return self::$_instance; |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * Resets the config |
|
158 | - * |
|
159 | - * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
160 | - * (default) leaves the database alone, and merely resets the EE_Config object to |
|
161 | - * reflect its state in the database |
|
162 | - * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
163 | - * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
164 | - * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
165 | - * site was put into maintenance mode) |
|
166 | - * @return EE_Config |
|
167 | - */ |
|
168 | - public static function reset($hard_reset = false, $reinstantiate = true) |
|
169 | - { |
|
170 | - if (self::$_instance instanceof EE_Config) { |
|
171 | - if ($hard_reset) { |
|
172 | - self::$_instance->legacy_shortcodes_manager = null; |
|
173 | - self::$_instance->_addon_option_names = array(); |
|
174 | - self::$_instance->_initialize_config(); |
|
175 | - self::$_instance->update_espresso_config(); |
|
176 | - } |
|
177 | - self::$_instance->update_addon_option_names(); |
|
178 | - } |
|
179 | - self::$_instance = null; |
|
180 | - // we don't need to reset the static properties imo because those should |
|
181 | - // only change when a module is added or removed. Currently we don't |
|
182 | - // support removing a module during a request when it previously existed |
|
183 | - if ($reinstantiate) { |
|
184 | - return self::instance(); |
|
185 | - } else { |
|
186 | - return null; |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * class constructor |
|
193 | - * |
|
194 | - * @access private |
|
195 | - */ |
|
196 | - private function __construct() |
|
197 | - { |
|
198 | - do_action('AHEE__EE_Config__construct__begin', $this); |
|
199 | - EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
200 | - // setup empty config classes |
|
201 | - $this->_initialize_config(); |
|
202 | - // load existing EE site settings |
|
203 | - $this->_load_core_config(); |
|
204 | - // confirm everything loaded correctly and set filtered defaults if not |
|
205 | - $this->_verify_config(); |
|
206 | - // register shortcodes and modules |
|
207 | - add_action( |
|
208 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
209 | - array($this, 'register_shortcodes_and_modules'), |
|
210 | - 999 |
|
211 | - ); |
|
212 | - // initialize shortcodes and modules |
|
213 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
214 | - // register widgets |
|
215 | - add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
216 | - // shutdown |
|
217 | - add_action('shutdown', array($this, 'shutdown'), 10); |
|
218 | - // construct__end hook |
|
219 | - do_action('AHEE__EE_Config__construct__end', $this); |
|
220 | - // hardcoded hack |
|
221 | - $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - /** |
|
226 | - * @return boolean |
|
227 | - */ |
|
228 | - public static function logging_enabled() |
|
229 | - { |
|
230 | - return self::$_logging_enabled; |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * use to get the current theme if needed from static context |
|
236 | - * |
|
237 | - * @return string current theme set. |
|
238 | - */ |
|
239 | - public static function get_current_theme() |
|
240 | - { |
|
241 | - return isset(self::$_instance->template_settings->current_espresso_theme) |
|
242 | - ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * _initialize_config |
|
248 | - * |
|
249 | - * @access private |
|
250 | - * @return void |
|
251 | - */ |
|
252 | - private function _initialize_config() |
|
253 | - { |
|
254 | - EE_Config::trim_log(); |
|
255 | - // set defaults |
|
256 | - $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
257 | - $this->addons = new stdClass(); |
|
258 | - // set _module_route_map |
|
259 | - EE_Config::$_module_route_map = array(); |
|
260 | - // set _module_forward_map |
|
261 | - EE_Config::$_module_forward_map = array(); |
|
262 | - // set _module_view_map |
|
263 | - EE_Config::$_module_view_map = array(); |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * load core plugin configuration |
|
269 | - * |
|
270 | - * @access private |
|
271 | - * @return void |
|
272 | - */ |
|
273 | - private function _load_core_config() |
|
274 | - { |
|
275 | - // load_core_config__start hook |
|
276 | - do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
277 | - $espresso_config = $this->get_espresso_config(); |
|
278 | - foreach ($espresso_config as $config => $settings) { |
|
279 | - // load_core_config__start hook |
|
280 | - $settings = apply_filters( |
|
281 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
282 | - $settings, |
|
283 | - $config, |
|
284 | - $this |
|
285 | - ); |
|
286 | - if (is_object($settings) && property_exists($this, $config)) { |
|
287 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
288 | - // call configs populate method to ensure any defaults are set for empty values. |
|
289 | - if (method_exists($settings, 'populate')) { |
|
290 | - $this->{$config}->populate(); |
|
291 | - } |
|
292 | - if (method_exists($settings, 'do_hooks')) { |
|
293 | - $this->{$config}->do_hooks(); |
|
294 | - } |
|
295 | - } |
|
296 | - } |
|
297 | - if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
298 | - $this->update_espresso_config(); |
|
299 | - } |
|
300 | - // load_core_config__end hook |
|
301 | - do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * _verify_config |
|
307 | - * |
|
308 | - * @access protected |
|
309 | - * @return void |
|
310 | - */ |
|
311 | - protected function _verify_config() |
|
312 | - { |
|
313 | - $this->core = $this->core instanceof EE_Core_Config |
|
314 | - ? $this->core |
|
315 | - : new EE_Core_Config(); |
|
316 | - $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
317 | - $this->organization = $this->organization instanceof EE_Organization_Config |
|
318 | - ? $this->organization |
|
319 | - : new EE_Organization_Config(); |
|
320 | - $this->organization = apply_filters( |
|
321 | - 'FHEE__EE_Config___initialize_config__organization', |
|
322 | - $this->organization |
|
323 | - ); |
|
324 | - $this->currency = $this->currency instanceof EE_Currency_Config |
|
325 | - ? $this->currency |
|
326 | - : new EE_Currency_Config(); |
|
327 | - $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
328 | - $this->registration = $this->registration instanceof EE_Registration_Config |
|
329 | - ? $this->registration |
|
330 | - : new EE_Registration_Config(); |
|
331 | - $this->registration = apply_filters( |
|
332 | - 'FHEE__EE_Config___initialize_config__registration', |
|
333 | - $this->registration |
|
334 | - ); |
|
335 | - $this->admin = $this->admin instanceof EE_Admin_Config |
|
336 | - ? $this->admin |
|
337 | - : new EE_Admin_Config(); |
|
338 | - $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
339 | - $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
340 | - ? $this->template_settings |
|
341 | - : new EE_Template_Config(); |
|
342 | - $this->template_settings = apply_filters( |
|
343 | - 'FHEE__EE_Config___initialize_config__template_settings', |
|
344 | - $this->template_settings |
|
345 | - ); |
|
346 | - $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
347 | - ? $this->map_settings |
|
348 | - : new EE_Map_Config(); |
|
349 | - $this->map_settings = apply_filters( |
|
350 | - 'FHEE__EE_Config___initialize_config__map_settings', |
|
351 | - $this->map_settings |
|
352 | - ); |
|
353 | - $this->environment = $this->environment instanceof EE_Environment_Config |
|
354 | - ? $this->environment |
|
355 | - : new EE_Environment_Config(); |
|
356 | - $this->environment = apply_filters( |
|
357 | - 'FHEE__EE_Config___initialize_config__environment', |
|
358 | - $this->environment |
|
359 | - ); |
|
360 | - $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
361 | - ? $this->tax_settings |
|
362 | - : new EE_Tax_Config(); |
|
363 | - $this->tax_settings = apply_filters( |
|
364 | - 'FHEE__EE_Config___initialize_config__tax_settings', |
|
365 | - $this->tax_settings |
|
366 | - ); |
|
367 | - $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
368 | - $this->messages = $this->messages instanceof EE_Messages_Config |
|
369 | - ? $this->messages |
|
370 | - : new EE_Messages_Config(); |
|
371 | - $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
372 | - ? $this->gateway |
|
373 | - : new EE_Gateway_Config(); |
|
374 | - $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
375 | - $this->legacy_shortcodes_manager = null; |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * get_espresso_config |
|
381 | - * |
|
382 | - * @access public |
|
383 | - * @return array of espresso config stuff |
|
384 | - */ |
|
385 | - public function get_espresso_config() |
|
386 | - { |
|
387 | - // grab espresso configuration |
|
388 | - return apply_filters( |
|
389 | - 'FHEE__EE_Config__get_espresso_config__CFG', |
|
390 | - get_option(EE_Config::OPTION_NAME, array()) |
|
391 | - ); |
|
392 | - } |
|
393 | - |
|
394 | - |
|
395 | - /** |
|
396 | - * double_check_config_comparison |
|
397 | - * |
|
398 | - * @access public |
|
399 | - * @param string $option |
|
400 | - * @param $old_value |
|
401 | - * @param $value |
|
402 | - */ |
|
403 | - public function double_check_config_comparison($option = '', $old_value, $value) |
|
404 | - { |
|
405 | - // make sure we're checking the ee config |
|
406 | - if ($option === EE_Config::OPTION_NAME) { |
|
407 | - // run a loose comparison of the old value against the new value for type and properties, |
|
408 | - // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
409 | - if ($value != $old_value) { |
|
410 | - // if they are NOT the same, then remove the hook, |
|
411 | - // which means the subsequent update results will be based solely on the update query results |
|
412 | - // the reason we do this is because, as stated above, |
|
413 | - // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
414 | - // this happens PRIOR to serialization and any subsequent update. |
|
415 | - // If values are found to match their previous old value, |
|
416 | - // then WP bails before performing any update. |
|
417 | - // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
418 | - // it just pulled from the db, with the one being passed to it (which will not match). |
|
419 | - // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
420 | - // MySQL MAY ALSO NOT perform the update because |
|
421 | - // the string it sees in the db looks the same as the new one it has been passed!!! |
|
422 | - // This results in the query returning an "affected rows" value of ZERO, |
|
423 | - // which gets returned immediately by WP update_option and looks like an error. |
|
424 | - remove_action('update_option', array($this, 'check_config_updated')); |
|
425 | - } |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * update_espresso_config |
|
432 | - * |
|
433 | - * @access public |
|
434 | - */ |
|
435 | - protected function _reset_espresso_addon_config() |
|
436 | - { |
|
437 | - $this->_addon_option_names = array(); |
|
438 | - foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
439 | - $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
440 | - if ($addon_config_obj instanceof EE_Config_Base) { |
|
441 | - $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
442 | - } |
|
443 | - $this->addons->{$addon_name} = null; |
|
444 | - } |
|
445 | - } |
|
446 | - |
|
447 | - |
|
448 | - /** |
|
449 | - * update_espresso_config |
|
450 | - * |
|
451 | - * @access public |
|
452 | - * @param bool $add_success |
|
453 | - * @param bool $add_error |
|
454 | - * @return bool |
|
455 | - */ |
|
456 | - public function update_espresso_config($add_success = false, $add_error = true) |
|
457 | - { |
|
458 | - // don't allow config updates during WP heartbeats |
|
459 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
460 | - return false; |
|
461 | - } |
|
462 | - // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
463 | - // $clone = clone( self::$_instance ); |
|
464 | - // self::$_instance = NULL; |
|
465 | - do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
466 | - $this->_reset_espresso_addon_config(); |
|
467 | - // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
468 | - // but BEFORE the actual update occurs |
|
469 | - add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
470 | - // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
471 | - $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
472 | - $this->legacy_shortcodes_manager = null; |
|
473 | - // now update "ee_config" |
|
474 | - $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
475 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
476 | - EE_Config::log(EE_Config::OPTION_NAME); |
|
477 | - // if not saved... check if the hook we just added still exists; |
|
478 | - // if it does, it means one of two things: |
|
479 | - // that update_option bailed at the($value === $old_value) conditional, |
|
480 | - // or... |
|
481 | - // the db update query returned 0 rows affected |
|
482 | - // (probably because the data value was the same from it's perspective) |
|
483 | - // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
484 | - // but just means no update occurred, so don't display an error to the user. |
|
485 | - // BUT... if update_option returns FALSE, AND the hook is missing, |
|
486 | - // then it means that something truly went wrong |
|
487 | - $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
488 | - // remove our action since we don't want it in the system anymore |
|
489 | - remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
490 | - do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
491 | - // self::$_instance = $clone; |
|
492 | - // unset( $clone ); |
|
493 | - // if config remains the same or was updated successfully |
|
494 | - if ($saved) { |
|
495 | - if ($add_success) { |
|
496 | - EE_Error::add_success( |
|
497 | - __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
498 | - __FILE__, |
|
499 | - __FUNCTION__, |
|
500 | - __LINE__ |
|
501 | - ); |
|
502 | - } |
|
503 | - return true; |
|
504 | - } else { |
|
505 | - if ($add_error) { |
|
506 | - EE_Error::add_error( |
|
507 | - __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
508 | - __FILE__, |
|
509 | - __FUNCTION__, |
|
510 | - __LINE__ |
|
511 | - ); |
|
512 | - } |
|
513 | - return false; |
|
514 | - } |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * _verify_config_params |
|
520 | - * |
|
521 | - * @access private |
|
522 | - * @param string $section |
|
523 | - * @param string $name |
|
524 | - * @param string $config_class |
|
525 | - * @param EE_Config_Base $config_obj |
|
526 | - * @param array $tests_to_run |
|
527 | - * @param bool $display_errors |
|
528 | - * @return bool TRUE on success, FALSE on fail |
|
529 | - */ |
|
530 | - private function _verify_config_params( |
|
531 | - $section = '', |
|
532 | - $name = '', |
|
533 | - $config_class = '', |
|
534 | - $config_obj = null, |
|
535 | - $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
536 | - $display_errors = true |
|
537 | - ) { |
|
538 | - try { |
|
539 | - foreach ($tests_to_run as $test) { |
|
540 | - switch ($test) { |
|
541 | - // TEST #1 : check that section was set |
|
542 | - case 1: |
|
543 | - if (empty($section)) { |
|
544 | - if ($display_errors) { |
|
545 | - throw new EE_Error( |
|
546 | - sprintf( |
|
547 | - __( |
|
548 | - 'No configuration section has been provided while attempting to save "%s".', |
|
549 | - 'event_espresso' |
|
550 | - ), |
|
551 | - $config_class |
|
552 | - ) |
|
553 | - ); |
|
554 | - } |
|
555 | - return false; |
|
556 | - } |
|
557 | - break; |
|
558 | - // TEST #2 : check that settings section exists |
|
559 | - case 2: |
|
560 | - if (! isset($this->{$section})) { |
|
561 | - if ($display_errors) { |
|
562 | - throw new EE_Error( |
|
563 | - sprintf( |
|
564 | - __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
565 | - $section |
|
566 | - ) |
|
567 | - ); |
|
568 | - } |
|
569 | - return false; |
|
570 | - } |
|
571 | - break; |
|
572 | - // TEST #3 : check that section is the proper format |
|
573 | - case 3: |
|
574 | - if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
575 | - ) { |
|
576 | - if ($display_errors) { |
|
577 | - throw new EE_Error( |
|
578 | - sprintf( |
|
579 | - __( |
|
580 | - 'The "%s" configuration settings have not been formatted correctly.', |
|
581 | - 'event_espresso' |
|
582 | - ), |
|
583 | - $section |
|
584 | - ) |
|
585 | - ); |
|
586 | - } |
|
587 | - return false; |
|
588 | - } |
|
589 | - break; |
|
590 | - // TEST #4 : check that config section name has been set |
|
591 | - case 4: |
|
592 | - if (empty($name)) { |
|
593 | - if ($display_errors) { |
|
594 | - throw new EE_Error( |
|
595 | - __( |
|
596 | - 'No name has been provided for the specific configuration section.', |
|
597 | - 'event_espresso' |
|
598 | - ) |
|
599 | - ); |
|
600 | - } |
|
601 | - return false; |
|
602 | - } |
|
603 | - break; |
|
604 | - // TEST #5 : check that a config class name has been set |
|
605 | - case 5: |
|
606 | - if (empty($config_class)) { |
|
607 | - if ($display_errors) { |
|
608 | - throw new EE_Error( |
|
609 | - __( |
|
610 | - 'No class name has been provided for the specific configuration section.', |
|
611 | - 'event_espresso' |
|
612 | - ) |
|
613 | - ); |
|
614 | - } |
|
615 | - return false; |
|
616 | - } |
|
617 | - break; |
|
618 | - // TEST #6 : verify config class is accessible |
|
619 | - case 6: |
|
620 | - if (! class_exists($config_class)) { |
|
621 | - if ($display_errors) { |
|
622 | - throw new EE_Error( |
|
623 | - sprintf( |
|
624 | - __( |
|
625 | - 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
626 | - 'event_espresso' |
|
627 | - ), |
|
628 | - $config_class |
|
629 | - ) |
|
630 | - ); |
|
631 | - } |
|
632 | - return false; |
|
633 | - } |
|
634 | - break; |
|
635 | - // TEST #7 : check that config has even been set |
|
636 | - case 7: |
|
637 | - if (! isset($this->{$section}->{$name})) { |
|
638 | - if ($display_errors) { |
|
639 | - throw new EE_Error( |
|
640 | - sprintf( |
|
641 | - __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
642 | - $section, |
|
643 | - $name |
|
644 | - ) |
|
645 | - ); |
|
646 | - } |
|
647 | - return false; |
|
648 | - } else { |
|
649 | - // and make sure it's not serialized |
|
650 | - $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
651 | - } |
|
652 | - break; |
|
653 | - // TEST #8 : check that config is the requested type |
|
654 | - case 8: |
|
655 | - if (! $this->{$section}->{$name} instanceof $config_class) { |
|
656 | - if ($display_errors) { |
|
657 | - throw new EE_Error( |
|
658 | - sprintf( |
|
659 | - __( |
|
660 | - 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
661 | - 'event_espresso' |
|
662 | - ), |
|
663 | - $section, |
|
664 | - $name, |
|
665 | - $config_class |
|
666 | - ) |
|
667 | - ); |
|
668 | - } |
|
669 | - return false; |
|
670 | - } |
|
671 | - break; |
|
672 | - // TEST #9 : verify config object |
|
673 | - case 9: |
|
674 | - if (! $config_obj instanceof EE_Config_Base) { |
|
675 | - if ($display_errors) { |
|
676 | - throw new EE_Error( |
|
677 | - sprintf( |
|
678 | - __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
679 | - print_r($config_obj, true) |
|
680 | - ) |
|
681 | - ); |
|
682 | - } |
|
683 | - return false; |
|
684 | - } |
|
685 | - break; |
|
686 | - } |
|
687 | - } |
|
688 | - } catch (EE_Error $e) { |
|
689 | - $e->get_error(); |
|
690 | - } |
|
691 | - // you have successfully run the gauntlet |
|
692 | - return true; |
|
693 | - } |
|
694 | - |
|
695 | - |
|
696 | - /** |
|
697 | - * _generate_config_option_name |
|
698 | - * |
|
699 | - * @access protected |
|
700 | - * @param string $section |
|
701 | - * @param string $name |
|
702 | - * @return string |
|
703 | - */ |
|
704 | - private function _generate_config_option_name($section = '', $name = '') |
|
705 | - { |
|
706 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
707 | - } |
|
708 | - |
|
709 | - |
|
710 | - /** |
|
711 | - * _set_config_class |
|
712 | - * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
713 | - * |
|
714 | - * @access private |
|
715 | - * @param string $config_class |
|
716 | - * @param string $name |
|
717 | - * @return string |
|
718 | - */ |
|
719 | - private function _set_config_class($config_class = '', $name = '') |
|
720 | - { |
|
721 | - return ! empty($config_class) |
|
722 | - ? $config_class |
|
723 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
724 | - } |
|
725 | - |
|
726 | - |
|
727 | - /** |
|
728 | - * set_config |
|
729 | - * |
|
730 | - * @access protected |
|
731 | - * @param string $section |
|
732 | - * @param string $name |
|
733 | - * @param string $config_class |
|
734 | - * @param EE_Config_Base $config_obj |
|
735 | - * @return EE_Config_Base |
|
736 | - */ |
|
737 | - public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
738 | - { |
|
739 | - // ensure config class is set to something |
|
740 | - $config_class = $this->_set_config_class($config_class, $name); |
|
741 | - // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
742 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
743 | - return null; |
|
744 | - } |
|
745 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
746 | - // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
747 | - if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
748 | - $this->_addon_option_names[ $config_option_name ] = $config_class; |
|
749 | - $this->update_addon_option_names(); |
|
750 | - } |
|
751 | - // verify the incoming config object but suppress errors |
|
752 | - if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
753 | - $config_obj = new $config_class(); |
|
754 | - } |
|
755 | - if (get_option($config_option_name)) { |
|
756 | - EE_Config::log($config_option_name); |
|
757 | - update_option($config_option_name, $config_obj); |
|
758 | - $this->{$section}->{$name} = $config_obj; |
|
759 | - return $this->{$section}->{$name}; |
|
760 | - } else { |
|
761 | - // create a wp-option for this config |
|
762 | - if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
763 | - $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
764 | - return $this->{$section}->{$name}; |
|
765 | - } else { |
|
766 | - EE_Error::add_error( |
|
767 | - sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
768 | - __FILE__, |
|
769 | - __FUNCTION__, |
|
770 | - __LINE__ |
|
771 | - ); |
|
772 | - return null; |
|
773 | - } |
|
774 | - } |
|
775 | - } |
|
776 | - |
|
777 | - |
|
778 | - /** |
|
779 | - * update_config |
|
780 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
781 | - * |
|
782 | - * @access public |
|
783 | - * @param string $section |
|
784 | - * @param string $name |
|
785 | - * @param EE_Config_Base|string $config_obj |
|
786 | - * @param bool $throw_errors |
|
787 | - * @return bool |
|
788 | - */ |
|
789 | - public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
790 | - { |
|
791 | - // don't allow config updates during WP heartbeats |
|
792 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
793 | - return false; |
|
794 | - } |
|
795 | - $config_obj = maybe_unserialize($config_obj); |
|
796 | - // get class name of the incoming object |
|
797 | - $config_class = get_class($config_obj); |
|
798 | - // run tests 1-5 and 9 to verify config |
|
799 | - if (! $this->_verify_config_params( |
|
800 | - $section, |
|
801 | - $name, |
|
802 | - $config_class, |
|
803 | - $config_obj, |
|
804 | - array(1, 2, 3, 4, 7, 9) |
|
805 | - ) |
|
806 | - ) { |
|
807 | - return false; |
|
808 | - } |
|
809 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
810 | - // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
811 | - if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
812 | - // save new config to db |
|
813 | - if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
814 | - return true; |
|
815 | - } |
|
816 | - } else { |
|
817 | - // first check if the record already exists |
|
818 | - $existing_config = get_option($config_option_name); |
|
819 | - $config_obj = serialize($config_obj); |
|
820 | - // just return if db record is already up to date (NOT type safe comparison) |
|
821 | - if ($existing_config == $config_obj) { |
|
822 | - $this->{$section}->{$name} = $config_obj; |
|
823 | - return true; |
|
824 | - } elseif (update_option($config_option_name, $config_obj)) { |
|
825 | - EE_Config::log($config_option_name); |
|
826 | - // update wp-option for this config class |
|
827 | - $this->{$section}->{$name} = $config_obj; |
|
828 | - return true; |
|
829 | - } elseif ($throw_errors) { |
|
830 | - EE_Error::add_error( |
|
831 | - sprintf( |
|
832 | - __( |
|
833 | - 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
834 | - 'event_espresso' |
|
835 | - ), |
|
836 | - $config_class, |
|
837 | - 'EE_Config->' . $section . '->' . $name |
|
838 | - ), |
|
839 | - __FILE__, |
|
840 | - __FUNCTION__, |
|
841 | - __LINE__ |
|
842 | - ); |
|
843 | - } |
|
844 | - } |
|
845 | - return false; |
|
846 | - } |
|
847 | - |
|
848 | - |
|
849 | - /** |
|
850 | - * get_config |
|
851 | - * |
|
852 | - * @access public |
|
853 | - * @param string $section |
|
854 | - * @param string $name |
|
855 | - * @param string $config_class |
|
856 | - * @return mixed EE_Config_Base | NULL |
|
857 | - */ |
|
858 | - public function get_config($section = '', $name = '', $config_class = '') |
|
859 | - { |
|
860 | - // ensure config class is set to something |
|
861 | - $config_class = $this->_set_config_class($config_class, $name); |
|
862 | - // run tests 1-4, 6 and 7 to verify that all params have been set |
|
863 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
864 | - return null; |
|
865 | - } |
|
866 | - // now test if the requested config object exists, but suppress errors |
|
867 | - if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
868 | - // config already exists, so pass it back |
|
869 | - return $this->{$section}->{$name}; |
|
870 | - } |
|
871 | - // load config option from db if it exists |
|
872 | - $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
873 | - // verify the newly retrieved config object, but suppress errors |
|
874 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
875 | - // config is good, so set it and pass it back |
|
876 | - $this->{$section}->{$name} = $config_obj; |
|
877 | - return $this->{$section}->{$name}; |
|
878 | - } |
|
879 | - // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
880 | - $config_obj = $this->set_config($section, $name, $config_class); |
|
881 | - // verify the newly created config object |
|
882 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
883 | - return $this->{$section}->{$name}; |
|
884 | - } else { |
|
885 | - EE_Error::add_error( |
|
886 | - sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
887 | - __FILE__, |
|
888 | - __FUNCTION__, |
|
889 | - __LINE__ |
|
890 | - ); |
|
891 | - } |
|
892 | - return null; |
|
893 | - } |
|
894 | - |
|
895 | - |
|
896 | - /** |
|
897 | - * get_config_option |
|
898 | - * |
|
899 | - * @access public |
|
900 | - * @param string $config_option_name |
|
901 | - * @return mixed EE_Config_Base | FALSE |
|
902 | - */ |
|
903 | - public function get_config_option($config_option_name = '') |
|
904 | - { |
|
905 | - // retrieve the wp-option for this config class. |
|
906 | - $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
907 | - if (empty($config_option)) { |
|
908 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
909 | - } |
|
910 | - return $config_option; |
|
911 | - } |
|
912 | - |
|
913 | - |
|
914 | - /** |
|
915 | - * log |
|
916 | - * |
|
917 | - * @param string $config_option_name |
|
918 | - */ |
|
919 | - public static function log($config_option_name = '') |
|
920 | - { |
|
921 | - if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
922 | - $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
923 | - // copy incoming $_REQUEST and sanitize it so we can save it |
|
924 | - $_request = $_REQUEST; |
|
925 | - array_walk_recursive($_request, 'sanitize_text_field'); |
|
926 | - $config_log[ (string) microtime(true) ] = array( |
|
927 | - 'config_name' => $config_option_name, |
|
928 | - 'request' => $_request, |
|
929 | - ); |
|
930 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
931 | - } |
|
932 | - } |
|
933 | - |
|
934 | - |
|
935 | - /** |
|
936 | - * trim_log |
|
937 | - * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
938 | - */ |
|
939 | - public static function trim_log() |
|
940 | - { |
|
941 | - if (! EE_Config::logging_enabled()) { |
|
942 | - return; |
|
943 | - } |
|
944 | - $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
945 | - $log_length = count($config_log); |
|
946 | - if ($log_length > EE_Config::LOG_LENGTH) { |
|
947 | - ksort($config_log); |
|
948 | - $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
949 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
950 | - } |
|
951 | - } |
|
952 | - |
|
953 | - |
|
954 | - /** |
|
955 | - * get_page_for_posts |
|
956 | - * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
957 | - * wp-option "page_for_posts", or "posts" if no page is selected |
|
958 | - * |
|
959 | - * @access public |
|
960 | - * @return string |
|
961 | - */ |
|
962 | - public static function get_page_for_posts() |
|
963 | - { |
|
964 | - $page_for_posts = get_option('page_for_posts'); |
|
965 | - if (! $page_for_posts) { |
|
966 | - return 'posts'; |
|
967 | - } |
|
968 | - /** @type WPDB $wpdb */ |
|
969 | - global $wpdb; |
|
970 | - $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
971 | - return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
972 | - } |
|
973 | - |
|
974 | - |
|
975 | - /** |
|
976 | - * register_shortcodes_and_modules. |
|
977 | - * At this point, it's too early to tell if we're maintenance mode or not. |
|
978 | - * In fact, this is where we give modules a chance to let core know they exist |
|
979 | - * so they can help trigger maintenance mode if it's needed |
|
980 | - * |
|
981 | - * @access public |
|
982 | - * @return void |
|
983 | - */ |
|
984 | - public function register_shortcodes_and_modules() |
|
985 | - { |
|
986 | - // allow modules to set hooks for the rest of the system |
|
987 | - EE_Registry::instance()->modules = $this->_register_modules(); |
|
988 | - } |
|
989 | - |
|
990 | - |
|
991 | - /** |
|
992 | - * initialize_shortcodes_and_modules |
|
993 | - * meaning they can start adding their hooks to get stuff done |
|
994 | - * |
|
995 | - * @access public |
|
996 | - * @return void |
|
997 | - */ |
|
998 | - public function initialize_shortcodes_and_modules() |
|
999 | - { |
|
1000 | - // allow modules to set hooks for the rest of the system |
|
1001 | - $this->_initialize_modules(); |
|
1002 | - } |
|
1003 | - |
|
1004 | - |
|
1005 | - /** |
|
1006 | - * widgets_init |
|
1007 | - * |
|
1008 | - * @access private |
|
1009 | - * @return void |
|
1010 | - */ |
|
1011 | - public function widgets_init() |
|
1012 | - { |
|
1013 | - // only init widgets on admin pages when not in complete maintenance, and |
|
1014 | - // on frontend when not in any maintenance mode |
|
1015 | - if (! EE_Maintenance_Mode::instance()->level() |
|
1016 | - || ( |
|
1017 | - is_admin() |
|
1018 | - && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1019 | - ) |
|
1020 | - ) { |
|
1021 | - // grab list of installed widgets |
|
1022 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1023 | - // filter list of modules to register |
|
1024 | - $widgets_to_register = apply_filters( |
|
1025 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1026 | - $widgets_to_register |
|
1027 | - ); |
|
1028 | - if (! empty($widgets_to_register)) { |
|
1029 | - // cycle thru widget folders |
|
1030 | - foreach ($widgets_to_register as $widget_path) { |
|
1031 | - // add to list of installed widget modules |
|
1032 | - EE_Config::register_ee_widget($widget_path); |
|
1033 | - } |
|
1034 | - } |
|
1035 | - // filter list of installed modules |
|
1036 | - EE_Registry::instance()->widgets = apply_filters( |
|
1037 | - 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1038 | - EE_Registry::instance()->widgets |
|
1039 | - ); |
|
1040 | - } |
|
1041 | - } |
|
1042 | - |
|
1043 | - |
|
1044 | - /** |
|
1045 | - * register_ee_widget - makes core aware of this widget |
|
1046 | - * |
|
1047 | - * @access public |
|
1048 | - * @param string $widget_path - full path up to and including widget folder |
|
1049 | - * @return void |
|
1050 | - */ |
|
1051 | - public static function register_ee_widget($widget_path = null) |
|
1052 | - { |
|
1053 | - do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1054 | - $widget_ext = '.widget.php'; |
|
1055 | - // make all separators match |
|
1056 | - $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1057 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1058 | - if (strpos($widget_path, $widget_ext) !== false) { |
|
1059 | - // grab and shortcode file name from directory name and break apart at dots |
|
1060 | - $file_name = explode('.', basename($widget_path)); |
|
1061 | - // take first segment from file name pieces and remove class prefix if it exists |
|
1062 | - $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1063 | - // sanitize shortcode directory name |
|
1064 | - $widget = sanitize_key($widget); |
|
1065 | - // now we need to rebuild the shortcode path |
|
1066 | - $widget_path = explode(DS, $widget_path); |
|
1067 | - // remove last segment |
|
1068 | - array_pop($widget_path); |
|
1069 | - // glue it back together |
|
1070 | - $widget_path = implode(DS, $widget_path); |
|
1071 | - } else { |
|
1072 | - // grab and sanitize widget directory name |
|
1073 | - $widget = sanitize_key(basename($widget_path)); |
|
1074 | - } |
|
1075 | - // create classname from widget directory name |
|
1076 | - $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1077 | - // add class prefix |
|
1078 | - $widget_class = 'EEW_' . $widget; |
|
1079 | - // does the widget exist ? |
|
1080 | - if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1081 | - $msg = sprintf( |
|
1082 | - __( |
|
1083 | - 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1084 | - 'event_espresso' |
|
1085 | - ), |
|
1086 | - $widget_class, |
|
1087 | - $widget_path . DS . $widget_class . $widget_ext |
|
1088 | - ); |
|
1089 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1090 | - return; |
|
1091 | - } |
|
1092 | - // load the widget class file |
|
1093 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1094 | - // verify that class exists |
|
1095 | - if (! class_exists($widget_class)) { |
|
1096 | - $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1097 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1098 | - return; |
|
1099 | - } |
|
1100 | - register_widget($widget_class); |
|
1101 | - // add to array of registered widgets |
|
1102 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1103 | - } |
|
1104 | - |
|
1105 | - |
|
1106 | - /** |
|
1107 | - * _register_modules |
|
1108 | - * |
|
1109 | - * @access private |
|
1110 | - * @return array |
|
1111 | - */ |
|
1112 | - private function _register_modules() |
|
1113 | - { |
|
1114 | - // grab list of installed modules |
|
1115 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1116 | - // filter list of modules to register |
|
1117 | - $modules_to_register = apply_filters( |
|
1118 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1119 | - $modules_to_register |
|
1120 | - ); |
|
1121 | - if (! empty($modules_to_register)) { |
|
1122 | - // loop through folders |
|
1123 | - foreach ($modules_to_register as $module_path) { |
|
1124 | - /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1125 | - if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1126 | - && $module_path !== EE_MODULES . 'gateways' |
|
1127 | - ) { |
|
1128 | - // add to list of installed modules |
|
1129 | - EE_Config::register_module($module_path); |
|
1130 | - } |
|
1131 | - } |
|
1132 | - } |
|
1133 | - // filter list of installed modules |
|
1134 | - return apply_filters( |
|
1135 | - 'FHEE__EE_Config___register_modules__installed_modules', |
|
1136 | - EE_Registry::instance()->modules |
|
1137 | - ); |
|
1138 | - } |
|
1139 | - |
|
1140 | - |
|
1141 | - /** |
|
1142 | - * register_module - makes core aware of this module |
|
1143 | - * |
|
1144 | - * @access public |
|
1145 | - * @param string $module_path - full path up to and including module folder |
|
1146 | - * @return bool |
|
1147 | - */ |
|
1148 | - public static function register_module($module_path = null) |
|
1149 | - { |
|
1150 | - do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1151 | - $module_ext = '.module.php'; |
|
1152 | - // make all separators match |
|
1153 | - $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1154 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1155 | - if (strpos($module_path, $module_ext) !== false) { |
|
1156 | - // grab and shortcode file name from directory name and break apart at dots |
|
1157 | - $module_file = explode('.', basename($module_path)); |
|
1158 | - // now we need to rebuild the shortcode path |
|
1159 | - $module_path = explode(DS, $module_path); |
|
1160 | - // remove last segment |
|
1161 | - array_pop($module_path); |
|
1162 | - // glue it back together |
|
1163 | - $module_path = implode(DS, $module_path) . DS; |
|
1164 | - // take first segment from file name pieces and sanitize it |
|
1165 | - $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1166 | - // ensure class prefix is added |
|
1167 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1168 | - } else { |
|
1169 | - // we need to generate the filename based off of the folder name |
|
1170 | - // grab and sanitize module name |
|
1171 | - $module = strtolower(basename($module_path)); |
|
1172 | - $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1173 | - // like trailingslashit() |
|
1174 | - $module_path = rtrim($module_path, DS) . DS; |
|
1175 | - // create classname from module directory name |
|
1176 | - $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1177 | - // add class prefix |
|
1178 | - $module_class = 'EED_' . $module; |
|
1179 | - } |
|
1180 | - // does the module exist ? |
|
1181 | - if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1182 | - $msg = sprintf( |
|
1183 | - __( |
|
1184 | - 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1185 | - 'event_espresso' |
|
1186 | - ), |
|
1187 | - $module |
|
1188 | - ); |
|
1189 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1190 | - return false; |
|
1191 | - } |
|
1192 | - // load the module class file |
|
1193 | - require_once($module_path . $module_class . $module_ext); |
|
1194 | - // verify that class exists |
|
1195 | - if (! class_exists($module_class)) { |
|
1196 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1197 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1198 | - return false; |
|
1199 | - } |
|
1200 | - // add to array of registered modules |
|
1201 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1202 | - do_action( |
|
1203 | - 'AHEE__EE_Config__register_module__complete', |
|
1204 | - $module_class, |
|
1205 | - EE_Registry::instance()->modules->{$module_class} |
|
1206 | - ); |
|
1207 | - return true; |
|
1208 | - } |
|
1209 | - |
|
1210 | - |
|
1211 | - /** |
|
1212 | - * _initialize_modules |
|
1213 | - * allow modules to set hooks for the rest of the system |
|
1214 | - * |
|
1215 | - * @access private |
|
1216 | - * @return void |
|
1217 | - */ |
|
1218 | - private function _initialize_modules() |
|
1219 | - { |
|
1220 | - // cycle thru shortcode folders |
|
1221 | - foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1222 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1223 | - // which set hooks ? |
|
1224 | - if (is_admin()) { |
|
1225 | - // fire immediately |
|
1226 | - call_user_func(array($module_class, 'set_hooks_admin')); |
|
1227 | - } else { |
|
1228 | - // delay until other systems are online |
|
1229 | - add_action( |
|
1230 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1231 | - array($module_class, 'set_hooks') |
|
1232 | - ); |
|
1233 | - } |
|
1234 | - } |
|
1235 | - } |
|
1236 | - |
|
1237 | - |
|
1238 | - /** |
|
1239 | - * register_route - adds module method routes to route_map |
|
1240 | - * |
|
1241 | - * @access public |
|
1242 | - * @param string $route - "pretty" public alias for module method |
|
1243 | - * @param string $module - module name (classname without EED_ prefix) |
|
1244 | - * @param string $method_name - the actual module method to be routed to |
|
1245 | - * @param string $key - url param key indicating a route is being called |
|
1246 | - * @return bool |
|
1247 | - */ |
|
1248 | - public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1249 | - { |
|
1250 | - do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1251 | - $module = str_replace('EED_', '', $module); |
|
1252 | - $module_class = 'EED_' . $module; |
|
1253 | - if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1254 | - $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1255 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1256 | - return false; |
|
1257 | - } |
|
1258 | - if (empty($route)) { |
|
1259 | - $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1260 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1261 | - return false; |
|
1262 | - } |
|
1263 | - if (! method_exists('EED_' . $module, $method_name)) { |
|
1264 | - $msg = sprintf( |
|
1265 | - __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1266 | - $route |
|
1267 | - ); |
|
1268 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1269 | - return false; |
|
1270 | - } |
|
1271 | - EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name); |
|
1272 | - return true; |
|
1273 | - } |
|
1274 | - |
|
1275 | - |
|
1276 | - /** |
|
1277 | - * get_route - get module method route |
|
1278 | - * |
|
1279 | - * @access public |
|
1280 | - * @param string $route - "pretty" public alias for module method |
|
1281 | - * @param string $key - url param key indicating a route is being called |
|
1282 | - * @return string |
|
1283 | - */ |
|
1284 | - public static function get_route($route = null, $key = 'ee') |
|
1285 | - { |
|
1286 | - do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1287 | - $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
1288 | - if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) { |
|
1289 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1290 | - } |
|
1291 | - return null; |
|
1292 | - } |
|
1293 | - |
|
1294 | - |
|
1295 | - /** |
|
1296 | - * get_routes - get ALL module method routes |
|
1297 | - * |
|
1298 | - * @access public |
|
1299 | - * @return array |
|
1300 | - */ |
|
1301 | - public static function get_routes() |
|
1302 | - { |
|
1303 | - return EE_Config::$_module_route_map; |
|
1304 | - } |
|
1305 | - |
|
1306 | - |
|
1307 | - /** |
|
1308 | - * register_forward - allows modules to forward request to another module for further processing |
|
1309 | - * |
|
1310 | - * @access public |
|
1311 | - * @param string $route - "pretty" public alias for module method |
|
1312 | - * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1313 | - * class, allows different forwards to be served based on status |
|
1314 | - * @param array|string $forward - function name or array( class, method ) |
|
1315 | - * @param string $key - url param key indicating a route is being called |
|
1316 | - * @return bool |
|
1317 | - */ |
|
1318 | - public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1319 | - { |
|
1320 | - do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1321 | - if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1322 | - $msg = sprintf( |
|
1323 | - __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1324 | - $route |
|
1325 | - ); |
|
1326 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1327 | - return false; |
|
1328 | - } |
|
1329 | - if (empty($forward)) { |
|
1330 | - $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1331 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1332 | - return false; |
|
1333 | - } |
|
1334 | - if (is_array($forward)) { |
|
1335 | - if (! isset($forward[1])) { |
|
1336 | - $msg = sprintf( |
|
1337 | - __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1338 | - $route |
|
1339 | - ); |
|
1340 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1341 | - return false; |
|
1342 | - } |
|
1343 | - if (! method_exists($forward[0], $forward[1])) { |
|
1344 | - $msg = sprintf( |
|
1345 | - __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1346 | - $forward[1], |
|
1347 | - $route |
|
1348 | - ); |
|
1349 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1350 | - return false; |
|
1351 | - } |
|
1352 | - } elseif (! function_exists($forward)) { |
|
1353 | - $msg = sprintf( |
|
1354 | - __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1355 | - $forward, |
|
1356 | - $route |
|
1357 | - ); |
|
1358 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1359 | - return false; |
|
1360 | - } |
|
1361 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward; |
|
1362 | - return true; |
|
1363 | - } |
|
1364 | - |
|
1365 | - |
|
1366 | - /** |
|
1367 | - * get_forward - get forwarding route |
|
1368 | - * |
|
1369 | - * @access public |
|
1370 | - * @param string $route - "pretty" public alias for module method |
|
1371 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1372 | - * allows different forwards to be served based on status |
|
1373 | - * @param string $key - url param key indicating a route is being called |
|
1374 | - * @return string |
|
1375 | - */ |
|
1376 | - public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1377 | - { |
|
1378 | - do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1379 | - if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) { |
|
1380 | - return apply_filters( |
|
1381 | - 'FHEE__EE_Config__get_forward', |
|
1382 | - EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], |
|
1383 | - $route, |
|
1384 | - $status |
|
1385 | - ); |
|
1386 | - } |
|
1387 | - return null; |
|
1388 | - } |
|
1389 | - |
|
1390 | - |
|
1391 | - /** |
|
1392 | - * register_forward - allows modules to specify different view templates for different method routes and status |
|
1393 | - * results |
|
1394 | - * |
|
1395 | - * @access public |
|
1396 | - * @param string $route - "pretty" public alias for module method |
|
1397 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1398 | - * allows different views to be served based on status |
|
1399 | - * @param string $view |
|
1400 | - * @param string $key - url param key indicating a route is being called |
|
1401 | - * @return bool |
|
1402 | - */ |
|
1403 | - public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1404 | - { |
|
1405 | - do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1406 | - if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1407 | - $msg = sprintf( |
|
1408 | - __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1409 | - $route |
|
1410 | - ); |
|
1411 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1412 | - return false; |
|
1413 | - } |
|
1414 | - if (! is_readable($view)) { |
|
1415 | - $msg = sprintf( |
|
1416 | - __( |
|
1417 | - 'The %s view file could not be found or is not readable due to file permissions.', |
|
1418 | - 'event_espresso' |
|
1419 | - ), |
|
1420 | - $view |
|
1421 | - ); |
|
1422 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1423 | - return false; |
|
1424 | - } |
|
1425 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view; |
|
1426 | - return true; |
|
1427 | - } |
|
1428 | - |
|
1429 | - |
|
1430 | - /** |
|
1431 | - * get_view - get view for route and status |
|
1432 | - * |
|
1433 | - * @access public |
|
1434 | - * @param string $route - "pretty" public alias for module method |
|
1435 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1436 | - * allows different views to be served based on status |
|
1437 | - * @param string $key - url param key indicating a route is being called |
|
1438 | - * @return string |
|
1439 | - */ |
|
1440 | - public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1441 | - { |
|
1442 | - do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1443 | - if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) { |
|
1444 | - return apply_filters( |
|
1445 | - 'FHEE__EE_Config__get_view', |
|
1446 | - EE_Config::$_module_view_map[ $key ][ $route ][ $status ], |
|
1447 | - $route, |
|
1448 | - $status |
|
1449 | - ); |
|
1450 | - } |
|
1451 | - return null; |
|
1452 | - } |
|
1453 | - |
|
1454 | - |
|
1455 | - public function update_addon_option_names() |
|
1456 | - { |
|
1457 | - update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1458 | - } |
|
1459 | - |
|
1460 | - |
|
1461 | - public function shutdown() |
|
1462 | - { |
|
1463 | - $this->update_addon_option_names(); |
|
1464 | - } |
|
1465 | - |
|
1466 | - |
|
1467 | - /** |
|
1468 | - * @return LegacyShortcodesManager |
|
1469 | - */ |
|
1470 | - public static function getLegacyShortcodesManager() |
|
1471 | - { |
|
1472 | - |
|
1473 | - if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1474 | - EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
1475 | - EE_Registry::instance() |
|
1476 | - ); |
|
1477 | - } |
|
1478 | - return EE_Config::instance()->legacy_shortcodes_manager; |
|
1479 | - } |
|
1480 | - |
|
1481 | - |
|
1482 | - /** |
|
1483 | - * register_shortcode - makes core aware of this shortcode |
|
1484 | - * |
|
1485 | - * @deprecated 4.9.26 |
|
1486 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
1487 | - * @return bool |
|
1488 | - */ |
|
1489 | - public static function register_shortcode($shortcode_path = null) |
|
1490 | - { |
|
1491 | - EE_Error::doing_it_wrong( |
|
1492 | - __METHOD__, |
|
1493 | - __( |
|
1494 | - 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
1495 | - 'event_espresso' |
|
1496 | - ), |
|
1497 | - '4.9.26' |
|
1498 | - ); |
|
1499 | - return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
1500 | - } |
|
1501 | -} |
|
1502 | - |
|
1503 | -/** |
|
1504 | - * Base class used for config classes. These classes should generally not have |
|
1505 | - * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1506 | - * basically, they should just be well-defined stdClasses |
|
1507 | - */ |
|
1508 | -class EE_Config_Base |
|
1509 | -{ |
|
1510 | - |
|
1511 | - /** |
|
1512 | - * Utility function for escaping the value of a property and returning. |
|
1513 | - * |
|
1514 | - * @param string $property property name (checks to see if exists). |
|
1515 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1516 | - * @throws \EE_Error |
|
1517 | - */ |
|
1518 | - public function get_pretty($property) |
|
1519 | - { |
|
1520 | - if (! property_exists($this, $property)) { |
|
1521 | - throw new EE_Error( |
|
1522 | - sprintf( |
|
1523 | - __( |
|
1524 | - '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1525 | - 'event_espresso' |
|
1526 | - ), |
|
1527 | - get_class($this), |
|
1528 | - $property |
|
1529 | - ) |
|
1530 | - ); |
|
1531 | - } |
|
1532 | - // just handling escaping of strings for now. |
|
1533 | - if (is_string($this->{$property})) { |
|
1534 | - return stripslashes($this->{$property}); |
|
1535 | - } |
|
1536 | - return $this->{$property}; |
|
1537 | - } |
|
1538 | - |
|
1539 | - |
|
1540 | - public function populate() |
|
1541 | - { |
|
1542 | - // grab defaults via a new instance of this class. |
|
1543 | - $class_name = get_class($this); |
|
1544 | - $defaults = new $class_name; |
|
1545 | - // loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1546 | - // default from our $defaults object. |
|
1547 | - foreach (get_object_vars($defaults) as $property => $value) { |
|
1548 | - if ($this->{$property} === null) { |
|
1549 | - $this->{$property} = $value; |
|
1550 | - } |
|
1551 | - } |
|
1552 | - // cleanup |
|
1553 | - unset($defaults); |
|
1554 | - } |
|
1555 | - |
|
1556 | - |
|
1557 | - /** |
|
1558 | - * __isset |
|
1559 | - * |
|
1560 | - * @param $a |
|
1561 | - * @return bool |
|
1562 | - */ |
|
1563 | - public function __isset($a) |
|
1564 | - { |
|
1565 | - return false; |
|
1566 | - } |
|
1567 | - |
|
1568 | - |
|
1569 | - /** |
|
1570 | - * __unset |
|
1571 | - * |
|
1572 | - * @param $a |
|
1573 | - * @return bool |
|
1574 | - */ |
|
1575 | - public function __unset($a) |
|
1576 | - { |
|
1577 | - return false; |
|
1578 | - } |
|
1579 | - |
|
1580 | - |
|
1581 | - /** |
|
1582 | - * __clone |
|
1583 | - */ |
|
1584 | - public function __clone() |
|
1585 | - { |
|
1586 | - } |
|
1587 | - |
|
1588 | - |
|
1589 | - /** |
|
1590 | - * __wakeup |
|
1591 | - */ |
|
1592 | - public function __wakeup() |
|
1593 | - { |
|
1594 | - } |
|
1595 | - |
|
1596 | - |
|
1597 | - /** |
|
1598 | - * __destruct |
|
1599 | - */ |
|
1600 | - public function __destruct() |
|
1601 | - { |
|
1602 | - } |
|
1603 | -} |
|
1604 | - |
|
1605 | - |
|
1606 | -/** |
|
1607 | - * Class for defining what's in the EE_Config relating to registration settings |
|
1608 | - */ |
|
1609 | -class EE_Core_Config extends EE_Config_Base |
|
1610 | -{ |
|
1611 | - |
|
1612 | - public $current_blog_id; |
|
1613 | - |
|
1614 | - public $ee_ueip_optin; |
|
1615 | - |
|
1616 | - public $ee_ueip_has_notified; |
|
1617 | - |
|
1618 | - /** |
|
1619 | - * Not to be confused with the 4 critical page variables (See |
|
1620 | - * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1621 | - * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1622 | - * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1623 | - * |
|
1624 | - * @var array |
|
1625 | - */ |
|
1626 | - public $post_shortcodes; |
|
1627 | - |
|
1628 | - public $module_route_map; |
|
1629 | - |
|
1630 | - public $module_forward_map; |
|
1631 | - |
|
1632 | - public $module_view_map; |
|
1633 | - |
|
1634 | - /** |
|
1635 | - * The next 4 vars are the IDs of critical EE pages. |
|
1636 | - * |
|
1637 | - * @var int |
|
1638 | - */ |
|
1639 | - public $reg_page_id; |
|
1640 | - |
|
1641 | - public $txn_page_id; |
|
1642 | - |
|
1643 | - public $thank_you_page_id; |
|
1644 | - |
|
1645 | - public $cancel_page_id; |
|
1646 | - |
|
1647 | - /** |
|
1648 | - * The next 4 vars are the URLs of critical EE pages. |
|
1649 | - * |
|
1650 | - * @var int |
|
1651 | - */ |
|
1652 | - public $reg_page_url; |
|
1653 | - |
|
1654 | - public $txn_page_url; |
|
1655 | - |
|
1656 | - public $thank_you_page_url; |
|
1657 | - |
|
1658 | - public $cancel_page_url; |
|
1659 | - |
|
1660 | - /** |
|
1661 | - * The next vars relate to the custom slugs for EE CPT routes |
|
1662 | - */ |
|
1663 | - public $event_cpt_slug; |
|
1664 | - |
|
1665 | - |
|
1666 | - /** |
|
1667 | - * This caches the _ee_ueip_option in case this config is reset in the same |
|
1668 | - * request across blog switches in a multisite context. |
|
1669 | - * Avoids extra queries to the db for this option. |
|
1670 | - * |
|
1671 | - * @var bool |
|
1672 | - */ |
|
1673 | - public static $ee_ueip_option; |
|
1674 | - |
|
1675 | - |
|
1676 | - /** |
|
1677 | - * class constructor |
|
1678 | - * |
|
1679 | - * @access public |
|
1680 | - */ |
|
1681 | - public function __construct() |
|
1682 | - { |
|
1683 | - // set default organization settings |
|
1684 | - $this->current_blog_id = get_current_blog_id(); |
|
1685 | - $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1686 | - $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1687 | - $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1688 | - $this->post_shortcodes = array(); |
|
1689 | - $this->module_route_map = array(); |
|
1690 | - $this->module_forward_map = array(); |
|
1691 | - $this->module_view_map = array(); |
|
1692 | - // critical EE page IDs |
|
1693 | - $this->reg_page_id = 0; |
|
1694 | - $this->txn_page_id = 0; |
|
1695 | - $this->thank_you_page_id = 0; |
|
1696 | - $this->cancel_page_id = 0; |
|
1697 | - // critical EE page URLs |
|
1698 | - $this->reg_page_url = ''; |
|
1699 | - $this->txn_page_url = ''; |
|
1700 | - $this->thank_you_page_url = ''; |
|
1701 | - $this->cancel_page_url = ''; |
|
1702 | - // cpt slugs |
|
1703 | - $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1704 | - // ueip constant check |
|
1705 | - if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1706 | - $this->ee_ueip_optin = false; |
|
1707 | - $this->ee_ueip_has_notified = true; |
|
1708 | - } |
|
1709 | - } |
|
1710 | - |
|
1711 | - |
|
1712 | - /** |
|
1713 | - * @return array |
|
1714 | - */ |
|
1715 | - public function get_critical_pages_array() |
|
1716 | - { |
|
1717 | - return array( |
|
1718 | - $this->reg_page_id, |
|
1719 | - $this->txn_page_id, |
|
1720 | - $this->thank_you_page_id, |
|
1721 | - $this->cancel_page_id, |
|
1722 | - ); |
|
1723 | - } |
|
1724 | - |
|
1725 | - |
|
1726 | - /** |
|
1727 | - * @return array |
|
1728 | - */ |
|
1729 | - public function get_critical_pages_shortcodes_array() |
|
1730 | - { |
|
1731 | - return array( |
|
1732 | - $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1733 | - $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1734 | - $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1735 | - $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1736 | - ); |
|
1737 | - } |
|
1738 | - |
|
1739 | - |
|
1740 | - /** |
|
1741 | - * gets/returns URL for EE reg_page |
|
1742 | - * |
|
1743 | - * @access public |
|
1744 | - * @return string |
|
1745 | - */ |
|
1746 | - public function reg_page_url() |
|
1747 | - { |
|
1748 | - if (! $this->reg_page_url) { |
|
1749 | - $this->reg_page_url = add_query_arg( |
|
1750 | - array('uts' => time()), |
|
1751 | - get_permalink($this->reg_page_id) |
|
1752 | - ) . '#checkout'; |
|
1753 | - } |
|
1754 | - return $this->reg_page_url; |
|
1755 | - } |
|
1756 | - |
|
1757 | - |
|
1758 | - /** |
|
1759 | - * gets/returns URL for EE txn_page |
|
1760 | - * |
|
1761 | - * @param array $query_args like what gets passed to |
|
1762 | - * add_query_arg() as the first argument |
|
1763 | - * @access public |
|
1764 | - * @return string |
|
1765 | - */ |
|
1766 | - public function txn_page_url($query_args = array()) |
|
1767 | - { |
|
1768 | - if (! $this->txn_page_url) { |
|
1769 | - $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1770 | - } |
|
1771 | - if ($query_args) { |
|
1772 | - return add_query_arg($query_args, $this->txn_page_url); |
|
1773 | - } else { |
|
1774 | - return $this->txn_page_url; |
|
1775 | - } |
|
1776 | - } |
|
1777 | - |
|
1778 | - |
|
1779 | - /** |
|
1780 | - * gets/returns URL for EE thank_you_page |
|
1781 | - * |
|
1782 | - * @param array $query_args like what gets passed to |
|
1783 | - * add_query_arg() as the first argument |
|
1784 | - * @access public |
|
1785 | - * @return string |
|
1786 | - */ |
|
1787 | - public function thank_you_page_url($query_args = array()) |
|
1788 | - { |
|
1789 | - if (! $this->thank_you_page_url) { |
|
1790 | - $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1791 | - } |
|
1792 | - if ($query_args) { |
|
1793 | - return add_query_arg($query_args, $this->thank_you_page_url); |
|
1794 | - } else { |
|
1795 | - return $this->thank_you_page_url; |
|
1796 | - } |
|
1797 | - } |
|
1798 | - |
|
1799 | - |
|
1800 | - /** |
|
1801 | - * gets/returns URL for EE cancel_page |
|
1802 | - * |
|
1803 | - * @access public |
|
1804 | - * @return string |
|
1805 | - */ |
|
1806 | - public function cancel_page_url() |
|
1807 | - { |
|
1808 | - if (! $this->cancel_page_url) { |
|
1809 | - $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1810 | - } |
|
1811 | - return $this->cancel_page_url; |
|
1812 | - } |
|
1813 | - |
|
1814 | - |
|
1815 | - /** |
|
1816 | - * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1817 | - * |
|
1818 | - * @since 4.7.5 |
|
1819 | - */ |
|
1820 | - protected function _reset_urls() |
|
1821 | - { |
|
1822 | - $this->reg_page_url = ''; |
|
1823 | - $this->txn_page_url = ''; |
|
1824 | - $this->cancel_page_url = ''; |
|
1825 | - $this->thank_you_page_url = ''; |
|
1826 | - } |
|
1827 | - |
|
1828 | - |
|
1829 | - /** |
|
1830 | - * Used to return what the optin value is set for the EE User Experience Program. |
|
1831 | - * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1832 | - * on the main site only. |
|
1833 | - * |
|
1834 | - * @return mixed|void |
|
1835 | - */ |
|
1836 | - protected function _get_main_ee_ueip_optin() |
|
1837 | - { |
|
1838 | - // if this is the main site then we can just bypass our direct query. |
|
1839 | - if (is_main_site()) { |
|
1840 | - return get_option('ee_ueip_optin', false); |
|
1841 | - } |
|
1842 | - // is this already cached for this request? If so use it. |
|
1843 | - if (! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1844 | - return EE_Core_Config::$ee_ueip_option; |
|
1845 | - } |
|
1846 | - global $wpdb; |
|
1847 | - $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1848 | - $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1849 | - $option = 'ee_ueip_optin'; |
|
1850 | - // set correct table for query |
|
1851 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1852 | - // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1853 | - // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1854 | - // re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1855 | - // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1856 | - // for the purpose of caching. |
|
1857 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1858 | - if (false !== $pre) { |
|
1859 | - EE_Core_Config::$ee_ueip_option = $pre; |
|
1860 | - return EE_Core_Config::$ee_ueip_option; |
|
1861 | - } |
|
1862 | - $row = $wpdb->get_row( |
|
1863 | - $wpdb->prepare( |
|
1864 | - "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
1865 | - $option |
|
1866 | - ) |
|
1867 | - ); |
|
1868 | - if (is_object($row)) { |
|
1869 | - $value = $row->option_value; |
|
1870 | - } else { // option does not exist so use default. |
|
1871 | - return apply_filters('default_option_' . $option, false, $option); |
|
1872 | - } |
|
1873 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1874 | - return EE_Core_Config::$ee_ueip_option; |
|
1875 | - } |
|
1876 | - |
|
1877 | - /** |
|
1878 | - * Utility function for escaping the value of a property and returning. |
|
1879 | - * |
|
1880 | - * @param string $property property name (checks to see if exists). |
|
1881 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1882 | - * @throws \EE_Error |
|
1883 | - */ |
|
1884 | - public function get_pretty($property) |
|
1885 | - { |
|
1886 | - if ($property === 'ee_ueip_optin') { |
|
1887 | - return $this->ee_ueip_optin ? 'yes' : 'no'; |
|
1888 | - } |
|
1889 | - return parent::get_pretty($property); |
|
1890 | - } |
|
1891 | - |
|
1892 | - |
|
1893 | - /** |
|
1894 | - * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
1895 | - * on the object. |
|
1896 | - * |
|
1897 | - * @return array |
|
1898 | - */ |
|
1899 | - public function __sleep() |
|
1900 | - { |
|
1901 | - // reset all url properties |
|
1902 | - $this->_reset_urls(); |
|
1903 | - // return what to save to db |
|
1904 | - return array_keys(get_object_vars($this)); |
|
1905 | - } |
|
1906 | -} |
|
1907 | - |
|
1908 | - |
|
1909 | -/** |
|
1910 | - * Config class for storing info on the Organization |
|
1911 | - */ |
|
1912 | -class EE_Organization_Config extends EE_Config_Base |
|
1913 | -{ |
|
1914 | - |
|
1915 | - /** |
|
1916 | - * @var string $name |
|
1917 | - * eg EE4.1 |
|
1918 | - */ |
|
1919 | - public $name; |
|
1920 | - |
|
1921 | - /** |
|
1922 | - * @var string $address_1 |
|
1923 | - * eg 123 Onna Road |
|
1924 | - */ |
|
1925 | - public $address_1; |
|
1926 | - |
|
1927 | - /** |
|
1928 | - * @var string $address_2 |
|
1929 | - * eg PO Box 123 |
|
1930 | - */ |
|
1931 | - public $address_2; |
|
1932 | - |
|
1933 | - /** |
|
1934 | - * @var string $city |
|
1935 | - * eg Inna City |
|
1936 | - */ |
|
1937 | - public $city; |
|
1938 | - |
|
1939 | - /** |
|
1940 | - * @var int $STA_ID |
|
1941 | - * eg 4 |
|
1942 | - */ |
|
1943 | - public $STA_ID; |
|
1944 | - |
|
1945 | - /** |
|
1946 | - * @var string $CNT_ISO |
|
1947 | - * eg US |
|
1948 | - */ |
|
1949 | - public $CNT_ISO; |
|
1950 | - |
|
1951 | - /** |
|
1952 | - * @var string $zip |
|
1953 | - * eg 12345 or V1A 2B3 |
|
1954 | - */ |
|
1955 | - public $zip; |
|
1956 | - |
|
1957 | - /** |
|
1958 | - * @var string $email |
|
1959 | - * eg [email protected] |
|
1960 | - */ |
|
1961 | - public $email; |
|
1962 | - |
|
1963 | - |
|
1964 | - /** |
|
1965 | - * @var string $phone |
|
1966 | - * eg. 111-111-1111 |
|
1967 | - */ |
|
1968 | - public $phone; |
|
1969 | - |
|
1970 | - |
|
1971 | - /** |
|
1972 | - * @var string $vat |
|
1973 | - * VAT/Tax Number |
|
1974 | - */ |
|
1975 | - public $vat; |
|
1976 | - |
|
1977 | - /** |
|
1978 | - * @var string $logo_url |
|
1979 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
1980 | - */ |
|
1981 | - public $logo_url; |
|
1982 | - |
|
1983 | - |
|
1984 | - /** |
|
1985 | - * The below are all various properties for holding links to organization social network profiles |
|
1986 | - * |
|
1987 | - * @var string |
|
1988 | - */ |
|
1989 | - /** |
|
1990 | - * facebook (facebook.com/profile.name) |
|
1991 | - * |
|
1992 | - * @var string |
|
1993 | - */ |
|
1994 | - public $facebook; |
|
1995 | - |
|
1996 | - |
|
1997 | - /** |
|
1998 | - * twitter (twitter.com/twitter_handle) |
|
1999 | - * |
|
2000 | - * @var string |
|
2001 | - */ |
|
2002 | - public $twitter; |
|
2003 | - |
|
2004 | - |
|
2005 | - /** |
|
2006 | - * linkedin (linkedin.com/in/profile_name) |
|
2007 | - * |
|
2008 | - * @var string |
|
2009 | - */ |
|
2010 | - public $linkedin; |
|
2011 | - |
|
2012 | - |
|
2013 | - /** |
|
2014 | - * pinterest (www.pinterest.com/profile_name) |
|
2015 | - * |
|
2016 | - * @var string |
|
2017 | - */ |
|
2018 | - public $pinterest; |
|
2019 | - |
|
2020 | - |
|
2021 | - /** |
|
2022 | - * google+ (google.com/+profileName) |
|
2023 | - * |
|
2024 | - * @var string |
|
2025 | - */ |
|
2026 | - public $google; |
|
2027 | - |
|
2028 | - |
|
2029 | - /** |
|
2030 | - * instagram (instagram.com/handle) |
|
2031 | - * |
|
2032 | - * @var string |
|
2033 | - */ |
|
2034 | - public $instagram; |
|
2035 | - |
|
2036 | - |
|
2037 | - /** |
|
2038 | - * class constructor |
|
2039 | - * |
|
2040 | - * @access public |
|
2041 | - */ |
|
2042 | - public function __construct() |
|
2043 | - { |
|
2044 | - // set default organization settings |
|
2045 | - // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
2046 | - $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
2047 | - $this->address_1 = '123 Onna Road'; |
|
2048 | - $this->address_2 = 'PO Box 123'; |
|
2049 | - $this->city = 'Inna City'; |
|
2050 | - $this->STA_ID = 4; |
|
2051 | - $this->CNT_ISO = 'US'; |
|
2052 | - $this->zip = '12345'; |
|
2053 | - $this->email = get_bloginfo('admin_email'); |
|
2054 | - $this->phone = ''; |
|
2055 | - $this->vat = '123456789'; |
|
2056 | - $this->logo_url = ''; |
|
2057 | - $this->facebook = ''; |
|
2058 | - $this->twitter = ''; |
|
2059 | - $this->linkedin = ''; |
|
2060 | - $this->pinterest = ''; |
|
2061 | - $this->google = ''; |
|
2062 | - $this->instagram = ''; |
|
2063 | - } |
|
2064 | -} |
|
2065 | - |
|
2066 | - |
|
2067 | -/** |
|
2068 | - * Class for defining what's in the EE_Config relating to currency |
|
2069 | - */ |
|
2070 | -class EE_Currency_Config extends EE_Config_Base |
|
2071 | -{ |
|
2072 | - |
|
2073 | - /** |
|
2074 | - * @var string $code |
|
2075 | - * eg 'US' |
|
2076 | - */ |
|
2077 | - public $code; |
|
2078 | - |
|
2079 | - /** |
|
2080 | - * @var string $name |
|
2081 | - * eg 'Dollar' |
|
2082 | - */ |
|
2083 | - public $name; |
|
2084 | - |
|
2085 | - /** |
|
2086 | - * plural name |
|
2087 | - * |
|
2088 | - * @var string $plural |
|
2089 | - * eg 'Dollars' |
|
2090 | - */ |
|
2091 | - public $plural; |
|
2092 | - |
|
2093 | - /** |
|
2094 | - * currency sign |
|
2095 | - * |
|
2096 | - * @var string $sign |
|
2097 | - * eg '$' |
|
2098 | - */ |
|
2099 | - public $sign; |
|
2100 | - |
|
2101 | - /** |
|
2102 | - * Whether the currency sign should come before the number or not |
|
2103 | - * |
|
2104 | - * @var boolean $sign_b4 |
|
2105 | - */ |
|
2106 | - public $sign_b4; |
|
2107 | - |
|
2108 | - /** |
|
2109 | - * How many digits should come after the decimal place |
|
2110 | - * |
|
2111 | - * @var int $dec_plc |
|
2112 | - */ |
|
2113 | - public $dec_plc; |
|
2114 | - |
|
2115 | - /** |
|
2116 | - * Symbol to use for decimal mark |
|
2117 | - * |
|
2118 | - * @var string $dec_mrk |
|
2119 | - * eg '.' |
|
2120 | - */ |
|
2121 | - public $dec_mrk; |
|
2122 | - |
|
2123 | - /** |
|
2124 | - * Symbol to use for thousands |
|
2125 | - * |
|
2126 | - * @var string $thsnds |
|
2127 | - * eg ',' |
|
2128 | - */ |
|
2129 | - public $thsnds; |
|
16 | + const OPTION_NAME = 'ee_config'; |
|
17 | + |
|
18 | + const LOG_NAME = 'ee_config_log'; |
|
19 | + |
|
20 | + const LOG_LENGTH = 100; |
|
21 | + |
|
22 | + const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * instance of the EE_Config object |
|
27 | + * |
|
28 | + * @var EE_Config $_instance |
|
29 | + * @access private |
|
30 | + */ |
|
31 | + private static $_instance; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var boolean $_logging_enabled |
|
35 | + */ |
|
36 | + private static $_logging_enabled = false; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
40 | + */ |
|
41 | + private $legacy_shortcodes_manager; |
|
42 | + |
|
43 | + /** |
|
44 | + * An StdClass whose property names are addon slugs, |
|
45 | + * and values are their config classes |
|
46 | + * |
|
47 | + * @var StdClass |
|
48 | + */ |
|
49 | + public $addons; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var EE_Admin_Config |
|
53 | + */ |
|
54 | + public $admin; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var EE_Core_Config |
|
58 | + */ |
|
59 | + public $core; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var EE_Currency_Config |
|
63 | + */ |
|
64 | + public $currency; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var EE_Organization_Config |
|
68 | + */ |
|
69 | + public $organization; |
|
70 | + |
|
71 | + /** |
|
72 | + * @var EE_Registration_Config |
|
73 | + */ |
|
74 | + public $registration; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var EE_Template_Config |
|
78 | + */ |
|
79 | + public $template_settings; |
|
80 | + |
|
81 | + /** |
|
82 | + * Holds EE environment values. |
|
83 | + * |
|
84 | + * @var EE_Environment_Config |
|
85 | + */ |
|
86 | + public $environment; |
|
87 | + |
|
88 | + /** |
|
89 | + * settings pertaining to Google maps |
|
90 | + * |
|
91 | + * @var EE_Map_Config |
|
92 | + */ |
|
93 | + public $map_settings; |
|
94 | + |
|
95 | + /** |
|
96 | + * settings pertaining to Taxes |
|
97 | + * |
|
98 | + * @var EE_Tax_Config |
|
99 | + */ |
|
100 | + public $tax_settings; |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * Settings pertaining to global messages settings. |
|
105 | + * |
|
106 | + * @var EE_Messages_Config |
|
107 | + */ |
|
108 | + public $messages; |
|
109 | + |
|
110 | + /** |
|
111 | + * @deprecated |
|
112 | + * @var EE_Gateway_Config |
|
113 | + */ |
|
114 | + public $gateway; |
|
115 | + |
|
116 | + /** |
|
117 | + * @var array $_addon_option_names |
|
118 | + * @access private |
|
119 | + */ |
|
120 | + private $_addon_option_names = array(); |
|
121 | + |
|
122 | + /** |
|
123 | + * @var array $_module_route_map |
|
124 | + * @access private |
|
125 | + */ |
|
126 | + private static $_module_route_map = array(); |
|
127 | + |
|
128 | + /** |
|
129 | + * @var array $_module_forward_map |
|
130 | + * @access private |
|
131 | + */ |
|
132 | + private static $_module_forward_map = array(); |
|
133 | + |
|
134 | + /** |
|
135 | + * @var array $_module_view_map |
|
136 | + * @access private |
|
137 | + */ |
|
138 | + private static $_module_view_map = array(); |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @singleton method used to instantiate class object |
|
143 | + * @access public |
|
144 | + * @return EE_Config instance |
|
145 | + */ |
|
146 | + public static function instance() |
|
147 | + { |
|
148 | + // check if class object is instantiated, and instantiated properly |
|
149 | + if (! self::$_instance instanceof EE_Config) { |
|
150 | + self::$_instance = new self(); |
|
151 | + } |
|
152 | + return self::$_instance; |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * Resets the config |
|
158 | + * |
|
159 | + * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
160 | + * (default) leaves the database alone, and merely resets the EE_Config object to |
|
161 | + * reflect its state in the database |
|
162 | + * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
163 | + * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
164 | + * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
165 | + * site was put into maintenance mode) |
|
166 | + * @return EE_Config |
|
167 | + */ |
|
168 | + public static function reset($hard_reset = false, $reinstantiate = true) |
|
169 | + { |
|
170 | + if (self::$_instance instanceof EE_Config) { |
|
171 | + if ($hard_reset) { |
|
172 | + self::$_instance->legacy_shortcodes_manager = null; |
|
173 | + self::$_instance->_addon_option_names = array(); |
|
174 | + self::$_instance->_initialize_config(); |
|
175 | + self::$_instance->update_espresso_config(); |
|
176 | + } |
|
177 | + self::$_instance->update_addon_option_names(); |
|
178 | + } |
|
179 | + self::$_instance = null; |
|
180 | + // we don't need to reset the static properties imo because those should |
|
181 | + // only change when a module is added or removed. Currently we don't |
|
182 | + // support removing a module during a request when it previously existed |
|
183 | + if ($reinstantiate) { |
|
184 | + return self::instance(); |
|
185 | + } else { |
|
186 | + return null; |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * class constructor |
|
193 | + * |
|
194 | + * @access private |
|
195 | + */ |
|
196 | + private function __construct() |
|
197 | + { |
|
198 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
199 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
200 | + // setup empty config classes |
|
201 | + $this->_initialize_config(); |
|
202 | + // load existing EE site settings |
|
203 | + $this->_load_core_config(); |
|
204 | + // confirm everything loaded correctly and set filtered defaults if not |
|
205 | + $this->_verify_config(); |
|
206 | + // register shortcodes and modules |
|
207 | + add_action( |
|
208 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
209 | + array($this, 'register_shortcodes_and_modules'), |
|
210 | + 999 |
|
211 | + ); |
|
212 | + // initialize shortcodes and modules |
|
213 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
214 | + // register widgets |
|
215 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
216 | + // shutdown |
|
217 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
218 | + // construct__end hook |
|
219 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
220 | + // hardcoded hack |
|
221 | + $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + /** |
|
226 | + * @return boolean |
|
227 | + */ |
|
228 | + public static function logging_enabled() |
|
229 | + { |
|
230 | + return self::$_logging_enabled; |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * use to get the current theme if needed from static context |
|
236 | + * |
|
237 | + * @return string current theme set. |
|
238 | + */ |
|
239 | + public static function get_current_theme() |
|
240 | + { |
|
241 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
242 | + ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * _initialize_config |
|
248 | + * |
|
249 | + * @access private |
|
250 | + * @return void |
|
251 | + */ |
|
252 | + private function _initialize_config() |
|
253 | + { |
|
254 | + EE_Config::trim_log(); |
|
255 | + // set defaults |
|
256 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
257 | + $this->addons = new stdClass(); |
|
258 | + // set _module_route_map |
|
259 | + EE_Config::$_module_route_map = array(); |
|
260 | + // set _module_forward_map |
|
261 | + EE_Config::$_module_forward_map = array(); |
|
262 | + // set _module_view_map |
|
263 | + EE_Config::$_module_view_map = array(); |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * load core plugin configuration |
|
269 | + * |
|
270 | + * @access private |
|
271 | + * @return void |
|
272 | + */ |
|
273 | + private function _load_core_config() |
|
274 | + { |
|
275 | + // load_core_config__start hook |
|
276 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
277 | + $espresso_config = $this->get_espresso_config(); |
|
278 | + foreach ($espresso_config as $config => $settings) { |
|
279 | + // load_core_config__start hook |
|
280 | + $settings = apply_filters( |
|
281 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
282 | + $settings, |
|
283 | + $config, |
|
284 | + $this |
|
285 | + ); |
|
286 | + if (is_object($settings) && property_exists($this, $config)) { |
|
287 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
288 | + // call configs populate method to ensure any defaults are set for empty values. |
|
289 | + if (method_exists($settings, 'populate')) { |
|
290 | + $this->{$config}->populate(); |
|
291 | + } |
|
292 | + if (method_exists($settings, 'do_hooks')) { |
|
293 | + $this->{$config}->do_hooks(); |
|
294 | + } |
|
295 | + } |
|
296 | + } |
|
297 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
298 | + $this->update_espresso_config(); |
|
299 | + } |
|
300 | + // load_core_config__end hook |
|
301 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * _verify_config |
|
307 | + * |
|
308 | + * @access protected |
|
309 | + * @return void |
|
310 | + */ |
|
311 | + protected function _verify_config() |
|
312 | + { |
|
313 | + $this->core = $this->core instanceof EE_Core_Config |
|
314 | + ? $this->core |
|
315 | + : new EE_Core_Config(); |
|
316 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
317 | + $this->organization = $this->organization instanceof EE_Organization_Config |
|
318 | + ? $this->organization |
|
319 | + : new EE_Organization_Config(); |
|
320 | + $this->organization = apply_filters( |
|
321 | + 'FHEE__EE_Config___initialize_config__organization', |
|
322 | + $this->organization |
|
323 | + ); |
|
324 | + $this->currency = $this->currency instanceof EE_Currency_Config |
|
325 | + ? $this->currency |
|
326 | + : new EE_Currency_Config(); |
|
327 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
328 | + $this->registration = $this->registration instanceof EE_Registration_Config |
|
329 | + ? $this->registration |
|
330 | + : new EE_Registration_Config(); |
|
331 | + $this->registration = apply_filters( |
|
332 | + 'FHEE__EE_Config___initialize_config__registration', |
|
333 | + $this->registration |
|
334 | + ); |
|
335 | + $this->admin = $this->admin instanceof EE_Admin_Config |
|
336 | + ? $this->admin |
|
337 | + : new EE_Admin_Config(); |
|
338 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
339 | + $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
340 | + ? $this->template_settings |
|
341 | + : new EE_Template_Config(); |
|
342 | + $this->template_settings = apply_filters( |
|
343 | + 'FHEE__EE_Config___initialize_config__template_settings', |
|
344 | + $this->template_settings |
|
345 | + ); |
|
346 | + $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
347 | + ? $this->map_settings |
|
348 | + : new EE_Map_Config(); |
|
349 | + $this->map_settings = apply_filters( |
|
350 | + 'FHEE__EE_Config___initialize_config__map_settings', |
|
351 | + $this->map_settings |
|
352 | + ); |
|
353 | + $this->environment = $this->environment instanceof EE_Environment_Config |
|
354 | + ? $this->environment |
|
355 | + : new EE_Environment_Config(); |
|
356 | + $this->environment = apply_filters( |
|
357 | + 'FHEE__EE_Config___initialize_config__environment', |
|
358 | + $this->environment |
|
359 | + ); |
|
360 | + $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
361 | + ? $this->tax_settings |
|
362 | + : new EE_Tax_Config(); |
|
363 | + $this->tax_settings = apply_filters( |
|
364 | + 'FHEE__EE_Config___initialize_config__tax_settings', |
|
365 | + $this->tax_settings |
|
366 | + ); |
|
367 | + $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
368 | + $this->messages = $this->messages instanceof EE_Messages_Config |
|
369 | + ? $this->messages |
|
370 | + : new EE_Messages_Config(); |
|
371 | + $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
372 | + ? $this->gateway |
|
373 | + : new EE_Gateway_Config(); |
|
374 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
375 | + $this->legacy_shortcodes_manager = null; |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * get_espresso_config |
|
381 | + * |
|
382 | + * @access public |
|
383 | + * @return array of espresso config stuff |
|
384 | + */ |
|
385 | + public function get_espresso_config() |
|
386 | + { |
|
387 | + // grab espresso configuration |
|
388 | + return apply_filters( |
|
389 | + 'FHEE__EE_Config__get_espresso_config__CFG', |
|
390 | + get_option(EE_Config::OPTION_NAME, array()) |
|
391 | + ); |
|
392 | + } |
|
393 | + |
|
394 | + |
|
395 | + /** |
|
396 | + * double_check_config_comparison |
|
397 | + * |
|
398 | + * @access public |
|
399 | + * @param string $option |
|
400 | + * @param $old_value |
|
401 | + * @param $value |
|
402 | + */ |
|
403 | + public function double_check_config_comparison($option = '', $old_value, $value) |
|
404 | + { |
|
405 | + // make sure we're checking the ee config |
|
406 | + if ($option === EE_Config::OPTION_NAME) { |
|
407 | + // run a loose comparison of the old value against the new value for type and properties, |
|
408 | + // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
409 | + if ($value != $old_value) { |
|
410 | + // if they are NOT the same, then remove the hook, |
|
411 | + // which means the subsequent update results will be based solely on the update query results |
|
412 | + // the reason we do this is because, as stated above, |
|
413 | + // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
414 | + // this happens PRIOR to serialization and any subsequent update. |
|
415 | + // If values are found to match their previous old value, |
|
416 | + // then WP bails before performing any update. |
|
417 | + // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
418 | + // it just pulled from the db, with the one being passed to it (which will not match). |
|
419 | + // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
420 | + // MySQL MAY ALSO NOT perform the update because |
|
421 | + // the string it sees in the db looks the same as the new one it has been passed!!! |
|
422 | + // This results in the query returning an "affected rows" value of ZERO, |
|
423 | + // which gets returned immediately by WP update_option and looks like an error. |
|
424 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
425 | + } |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * update_espresso_config |
|
432 | + * |
|
433 | + * @access public |
|
434 | + */ |
|
435 | + protected function _reset_espresso_addon_config() |
|
436 | + { |
|
437 | + $this->_addon_option_names = array(); |
|
438 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
439 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
440 | + if ($addon_config_obj instanceof EE_Config_Base) { |
|
441 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
442 | + } |
|
443 | + $this->addons->{$addon_name} = null; |
|
444 | + } |
|
445 | + } |
|
446 | + |
|
447 | + |
|
448 | + /** |
|
449 | + * update_espresso_config |
|
450 | + * |
|
451 | + * @access public |
|
452 | + * @param bool $add_success |
|
453 | + * @param bool $add_error |
|
454 | + * @return bool |
|
455 | + */ |
|
456 | + public function update_espresso_config($add_success = false, $add_error = true) |
|
457 | + { |
|
458 | + // don't allow config updates during WP heartbeats |
|
459 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
460 | + return false; |
|
461 | + } |
|
462 | + // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
463 | + // $clone = clone( self::$_instance ); |
|
464 | + // self::$_instance = NULL; |
|
465 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
466 | + $this->_reset_espresso_addon_config(); |
|
467 | + // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
468 | + // but BEFORE the actual update occurs |
|
469 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
470 | + // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
471 | + $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
472 | + $this->legacy_shortcodes_manager = null; |
|
473 | + // now update "ee_config" |
|
474 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
475 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
476 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
477 | + // if not saved... check if the hook we just added still exists; |
|
478 | + // if it does, it means one of two things: |
|
479 | + // that update_option bailed at the($value === $old_value) conditional, |
|
480 | + // or... |
|
481 | + // the db update query returned 0 rows affected |
|
482 | + // (probably because the data value was the same from it's perspective) |
|
483 | + // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
484 | + // but just means no update occurred, so don't display an error to the user. |
|
485 | + // BUT... if update_option returns FALSE, AND the hook is missing, |
|
486 | + // then it means that something truly went wrong |
|
487 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
488 | + // remove our action since we don't want it in the system anymore |
|
489 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
490 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
491 | + // self::$_instance = $clone; |
|
492 | + // unset( $clone ); |
|
493 | + // if config remains the same or was updated successfully |
|
494 | + if ($saved) { |
|
495 | + if ($add_success) { |
|
496 | + EE_Error::add_success( |
|
497 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
498 | + __FILE__, |
|
499 | + __FUNCTION__, |
|
500 | + __LINE__ |
|
501 | + ); |
|
502 | + } |
|
503 | + return true; |
|
504 | + } else { |
|
505 | + if ($add_error) { |
|
506 | + EE_Error::add_error( |
|
507 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
508 | + __FILE__, |
|
509 | + __FUNCTION__, |
|
510 | + __LINE__ |
|
511 | + ); |
|
512 | + } |
|
513 | + return false; |
|
514 | + } |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * _verify_config_params |
|
520 | + * |
|
521 | + * @access private |
|
522 | + * @param string $section |
|
523 | + * @param string $name |
|
524 | + * @param string $config_class |
|
525 | + * @param EE_Config_Base $config_obj |
|
526 | + * @param array $tests_to_run |
|
527 | + * @param bool $display_errors |
|
528 | + * @return bool TRUE on success, FALSE on fail |
|
529 | + */ |
|
530 | + private function _verify_config_params( |
|
531 | + $section = '', |
|
532 | + $name = '', |
|
533 | + $config_class = '', |
|
534 | + $config_obj = null, |
|
535 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
536 | + $display_errors = true |
|
537 | + ) { |
|
538 | + try { |
|
539 | + foreach ($tests_to_run as $test) { |
|
540 | + switch ($test) { |
|
541 | + // TEST #1 : check that section was set |
|
542 | + case 1: |
|
543 | + if (empty($section)) { |
|
544 | + if ($display_errors) { |
|
545 | + throw new EE_Error( |
|
546 | + sprintf( |
|
547 | + __( |
|
548 | + 'No configuration section has been provided while attempting to save "%s".', |
|
549 | + 'event_espresso' |
|
550 | + ), |
|
551 | + $config_class |
|
552 | + ) |
|
553 | + ); |
|
554 | + } |
|
555 | + return false; |
|
556 | + } |
|
557 | + break; |
|
558 | + // TEST #2 : check that settings section exists |
|
559 | + case 2: |
|
560 | + if (! isset($this->{$section})) { |
|
561 | + if ($display_errors) { |
|
562 | + throw new EE_Error( |
|
563 | + sprintf( |
|
564 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
565 | + $section |
|
566 | + ) |
|
567 | + ); |
|
568 | + } |
|
569 | + return false; |
|
570 | + } |
|
571 | + break; |
|
572 | + // TEST #3 : check that section is the proper format |
|
573 | + case 3: |
|
574 | + if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
575 | + ) { |
|
576 | + if ($display_errors) { |
|
577 | + throw new EE_Error( |
|
578 | + sprintf( |
|
579 | + __( |
|
580 | + 'The "%s" configuration settings have not been formatted correctly.', |
|
581 | + 'event_espresso' |
|
582 | + ), |
|
583 | + $section |
|
584 | + ) |
|
585 | + ); |
|
586 | + } |
|
587 | + return false; |
|
588 | + } |
|
589 | + break; |
|
590 | + // TEST #4 : check that config section name has been set |
|
591 | + case 4: |
|
592 | + if (empty($name)) { |
|
593 | + if ($display_errors) { |
|
594 | + throw new EE_Error( |
|
595 | + __( |
|
596 | + 'No name has been provided for the specific configuration section.', |
|
597 | + 'event_espresso' |
|
598 | + ) |
|
599 | + ); |
|
600 | + } |
|
601 | + return false; |
|
602 | + } |
|
603 | + break; |
|
604 | + // TEST #5 : check that a config class name has been set |
|
605 | + case 5: |
|
606 | + if (empty($config_class)) { |
|
607 | + if ($display_errors) { |
|
608 | + throw new EE_Error( |
|
609 | + __( |
|
610 | + 'No class name has been provided for the specific configuration section.', |
|
611 | + 'event_espresso' |
|
612 | + ) |
|
613 | + ); |
|
614 | + } |
|
615 | + return false; |
|
616 | + } |
|
617 | + break; |
|
618 | + // TEST #6 : verify config class is accessible |
|
619 | + case 6: |
|
620 | + if (! class_exists($config_class)) { |
|
621 | + if ($display_errors) { |
|
622 | + throw new EE_Error( |
|
623 | + sprintf( |
|
624 | + __( |
|
625 | + 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
626 | + 'event_espresso' |
|
627 | + ), |
|
628 | + $config_class |
|
629 | + ) |
|
630 | + ); |
|
631 | + } |
|
632 | + return false; |
|
633 | + } |
|
634 | + break; |
|
635 | + // TEST #7 : check that config has even been set |
|
636 | + case 7: |
|
637 | + if (! isset($this->{$section}->{$name})) { |
|
638 | + if ($display_errors) { |
|
639 | + throw new EE_Error( |
|
640 | + sprintf( |
|
641 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
642 | + $section, |
|
643 | + $name |
|
644 | + ) |
|
645 | + ); |
|
646 | + } |
|
647 | + return false; |
|
648 | + } else { |
|
649 | + // and make sure it's not serialized |
|
650 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
651 | + } |
|
652 | + break; |
|
653 | + // TEST #8 : check that config is the requested type |
|
654 | + case 8: |
|
655 | + if (! $this->{$section}->{$name} instanceof $config_class) { |
|
656 | + if ($display_errors) { |
|
657 | + throw new EE_Error( |
|
658 | + sprintf( |
|
659 | + __( |
|
660 | + 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
661 | + 'event_espresso' |
|
662 | + ), |
|
663 | + $section, |
|
664 | + $name, |
|
665 | + $config_class |
|
666 | + ) |
|
667 | + ); |
|
668 | + } |
|
669 | + return false; |
|
670 | + } |
|
671 | + break; |
|
672 | + // TEST #9 : verify config object |
|
673 | + case 9: |
|
674 | + if (! $config_obj instanceof EE_Config_Base) { |
|
675 | + if ($display_errors) { |
|
676 | + throw new EE_Error( |
|
677 | + sprintf( |
|
678 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
679 | + print_r($config_obj, true) |
|
680 | + ) |
|
681 | + ); |
|
682 | + } |
|
683 | + return false; |
|
684 | + } |
|
685 | + break; |
|
686 | + } |
|
687 | + } |
|
688 | + } catch (EE_Error $e) { |
|
689 | + $e->get_error(); |
|
690 | + } |
|
691 | + // you have successfully run the gauntlet |
|
692 | + return true; |
|
693 | + } |
|
694 | + |
|
695 | + |
|
696 | + /** |
|
697 | + * _generate_config_option_name |
|
698 | + * |
|
699 | + * @access protected |
|
700 | + * @param string $section |
|
701 | + * @param string $name |
|
702 | + * @return string |
|
703 | + */ |
|
704 | + private function _generate_config_option_name($section = '', $name = '') |
|
705 | + { |
|
706 | + return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
707 | + } |
|
708 | + |
|
709 | + |
|
710 | + /** |
|
711 | + * _set_config_class |
|
712 | + * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
713 | + * |
|
714 | + * @access private |
|
715 | + * @param string $config_class |
|
716 | + * @param string $name |
|
717 | + * @return string |
|
718 | + */ |
|
719 | + private function _set_config_class($config_class = '', $name = '') |
|
720 | + { |
|
721 | + return ! empty($config_class) |
|
722 | + ? $config_class |
|
723 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
724 | + } |
|
725 | + |
|
726 | + |
|
727 | + /** |
|
728 | + * set_config |
|
729 | + * |
|
730 | + * @access protected |
|
731 | + * @param string $section |
|
732 | + * @param string $name |
|
733 | + * @param string $config_class |
|
734 | + * @param EE_Config_Base $config_obj |
|
735 | + * @return EE_Config_Base |
|
736 | + */ |
|
737 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
738 | + { |
|
739 | + // ensure config class is set to something |
|
740 | + $config_class = $this->_set_config_class($config_class, $name); |
|
741 | + // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
742 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
743 | + return null; |
|
744 | + } |
|
745 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
746 | + // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
747 | + if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
748 | + $this->_addon_option_names[ $config_option_name ] = $config_class; |
|
749 | + $this->update_addon_option_names(); |
|
750 | + } |
|
751 | + // verify the incoming config object but suppress errors |
|
752 | + if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
753 | + $config_obj = new $config_class(); |
|
754 | + } |
|
755 | + if (get_option($config_option_name)) { |
|
756 | + EE_Config::log($config_option_name); |
|
757 | + update_option($config_option_name, $config_obj); |
|
758 | + $this->{$section}->{$name} = $config_obj; |
|
759 | + return $this->{$section}->{$name}; |
|
760 | + } else { |
|
761 | + // create a wp-option for this config |
|
762 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
763 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
764 | + return $this->{$section}->{$name}; |
|
765 | + } else { |
|
766 | + EE_Error::add_error( |
|
767 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
768 | + __FILE__, |
|
769 | + __FUNCTION__, |
|
770 | + __LINE__ |
|
771 | + ); |
|
772 | + return null; |
|
773 | + } |
|
774 | + } |
|
775 | + } |
|
776 | + |
|
777 | + |
|
778 | + /** |
|
779 | + * update_config |
|
780 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
781 | + * |
|
782 | + * @access public |
|
783 | + * @param string $section |
|
784 | + * @param string $name |
|
785 | + * @param EE_Config_Base|string $config_obj |
|
786 | + * @param bool $throw_errors |
|
787 | + * @return bool |
|
788 | + */ |
|
789 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
790 | + { |
|
791 | + // don't allow config updates during WP heartbeats |
|
792 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
793 | + return false; |
|
794 | + } |
|
795 | + $config_obj = maybe_unserialize($config_obj); |
|
796 | + // get class name of the incoming object |
|
797 | + $config_class = get_class($config_obj); |
|
798 | + // run tests 1-5 and 9 to verify config |
|
799 | + if (! $this->_verify_config_params( |
|
800 | + $section, |
|
801 | + $name, |
|
802 | + $config_class, |
|
803 | + $config_obj, |
|
804 | + array(1, 2, 3, 4, 7, 9) |
|
805 | + ) |
|
806 | + ) { |
|
807 | + return false; |
|
808 | + } |
|
809 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
810 | + // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
811 | + if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
812 | + // save new config to db |
|
813 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
814 | + return true; |
|
815 | + } |
|
816 | + } else { |
|
817 | + // first check if the record already exists |
|
818 | + $existing_config = get_option($config_option_name); |
|
819 | + $config_obj = serialize($config_obj); |
|
820 | + // just return if db record is already up to date (NOT type safe comparison) |
|
821 | + if ($existing_config == $config_obj) { |
|
822 | + $this->{$section}->{$name} = $config_obj; |
|
823 | + return true; |
|
824 | + } elseif (update_option($config_option_name, $config_obj)) { |
|
825 | + EE_Config::log($config_option_name); |
|
826 | + // update wp-option for this config class |
|
827 | + $this->{$section}->{$name} = $config_obj; |
|
828 | + return true; |
|
829 | + } elseif ($throw_errors) { |
|
830 | + EE_Error::add_error( |
|
831 | + sprintf( |
|
832 | + __( |
|
833 | + 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
834 | + 'event_espresso' |
|
835 | + ), |
|
836 | + $config_class, |
|
837 | + 'EE_Config->' . $section . '->' . $name |
|
838 | + ), |
|
839 | + __FILE__, |
|
840 | + __FUNCTION__, |
|
841 | + __LINE__ |
|
842 | + ); |
|
843 | + } |
|
844 | + } |
|
845 | + return false; |
|
846 | + } |
|
847 | + |
|
848 | + |
|
849 | + /** |
|
850 | + * get_config |
|
851 | + * |
|
852 | + * @access public |
|
853 | + * @param string $section |
|
854 | + * @param string $name |
|
855 | + * @param string $config_class |
|
856 | + * @return mixed EE_Config_Base | NULL |
|
857 | + */ |
|
858 | + public function get_config($section = '', $name = '', $config_class = '') |
|
859 | + { |
|
860 | + // ensure config class is set to something |
|
861 | + $config_class = $this->_set_config_class($config_class, $name); |
|
862 | + // run tests 1-4, 6 and 7 to verify that all params have been set |
|
863 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
864 | + return null; |
|
865 | + } |
|
866 | + // now test if the requested config object exists, but suppress errors |
|
867 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
868 | + // config already exists, so pass it back |
|
869 | + return $this->{$section}->{$name}; |
|
870 | + } |
|
871 | + // load config option from db if it exists |
|
872 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
873 | + // verify the newly retrieved config object, but suppress errors |
|
874 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
875 | + // config is good, so set it and pass it back |
|
876 | + $this->{$section}->{$name} = $config_obj; |
|
877 | + return $this->{$section}->{$name}; |
|
878 | + } |
|
879 | + // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
880 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
881 | + // verify the newly created config object |
|
882 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
883 | + return $this->{$section}->{$name}; |
|
884 | + } else { |
|
885 | + EE_Error::add_error( |
|
886 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
887 | + __FILE__, |
|
888 | + __FUNCTION__, |
|
889 | + __LINE__ |
|
890 | + ); |
|
891 | + } |
|
892 | + return null; |
|
893 | + } |
|
894 | + |
|
895 | + |
|
896 | + /** |
|
897 | + * get_config_option |
|
898 | + * |
|
899 | + * @access public |
|
900 | + * @param string $config_option_name |
|
901 | + * @return mixed EE_Config_Base | FALSE |
|
902 | + */ |
|
903 | + public function get_config_option($config_option_name = '') |
|
904 | + { |
|
905 | + // retrieve the wp-option for this config class. |
|
906 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
907 | + if (empty($config_option)) { |
|
908 | + EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
909 | + } |
|
910 | + return $config_option; |
|
911 | + } |
|
912 | + |
|
913 | + |
|
914 | + /** |
|
915 | + * log |
|
916 | + * |
|
917 | + * @param string $config_option_name |
|
918 | + */ |
|
919 | + public static function log($config_option_name = '') |
|
920 | + { |
|
921 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
922 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
923 | + // copy incoming $_REQUEST and sanitize it so we can save it |
|
924 | + $_request = $_REQUEST; |
|
925 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
926 | + $config_log[ (string) microtime(true) ] = array( |
|
927 | + 'config_name' => $config_option_name, |
|
928 | + 'request' => $_request, |
|
929 | + ); |
|
930 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
931 | + } |
|
932 | + } |
|
933 | + |
|
934 | + |
|
935 | + /** |
|
936 | + * trim_log |
|
937 | + * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
938 | + */ |
|
939 | + public static function trim_log() |
|
940 | + { |
|
941 | + if (! EE_Config::logging_enabled()) { |
|
942 | + return; |
|
943 | + } |
|
944 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
945 | + $log_length = count($config_log); |
|
946 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
947 | + ksort($config_log); |
|
948 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
949 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
950 | + } |
|
951 | + } |
|
952 | + |
|
953 | + |
|
954 | + /** |
|
955 | + * get_page_for_posts |
|
956 | + * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
957 | + * wp-option "page_for_posts", or "posts" if no page is selected |
|
958 | + * |
|
959 | + * @access public |
|
960 | + * @return string |
|
961 | + */ |
|
962 | + public static function get_page_for_posts() |
|
963 | + { |
|
964 | + $page_for_posts = get_option('page_for_posts'); |
|
965 | + if (! $page_for_posts) { |
|
966 | + return 'posts'; |
|
967 | + } |
|
968 | + /** @type WPDB $wpdb */ |
|
969 | + global $wpdb; |
|
970 | + $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
971 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
972 | + } |
|
973 | + |
|
974 | + |
|
975 | + /** |
|
976 | + * register_shortcodes_and_modules. |
|
977 | + * At this point, it's too early to tell if we're maintenance mode or not. |
|
978 | + * In fact, this is where we give modules a chance to let core know they exist |
|
979 | + * so they can help trigger maintenance mode if it's needed |
|
980 | + * |
|
981 | + * @access public |
|
982 | + * @return void |
|
983 | + */ |
|
984 | + public function register_shortcodes_and_modules() |
|
985 | + { |
|
986 | + // allow modules to set hooks for the rest of the system |
|
987 | + EE_Registry::instance()->modules = $this->_register_modules(); |
|
988 | + } |
|
989 | + |
|
990 | + |
|
991 | + /** |
|
992 | + * initialize_shortcodes_and_modules |
|
993 | + * meaning they can start adding their hooks to get stuff done |
|
994 | + * |
|
995 | + * @access public |
|
996 | + * @return void |
|
997 | + */ |
|
998 | + public function initialize_shortcodes_and_modules() |
|
999 | + { |
|
1000 | + // allow modules to set hooks for the rest of the system |
|
1001 | + $this->_initialize_modules(); |
|
1002 | + } |
|
1003 | + |
|
1004 | + |
|
1005 | + /** |
|
1006 | + * widgets_init |
|
1007 | + * |
|
1008 | + * @access private |
|
1009 | + * @return void |
|
1010 | + */ |
|
1011 | + public function widgets_init() |
|
1012 | + { |
|
1013 | + // only init widgets on admin pages when not in complete maintenance, and |
|
1014 | + // on frontend when not in any maintenance mode |
|
1015 | + if (! EE_Maintenance_Mode::instance()->level() |
|
1016 | + || ( |
|
1017 | + is_admin() |
|
1018 | + && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1019 | + ) |
|
1020 | + ) { |
|
1021 | + // grab list of installed widgets |
|
1022 | + $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1023 | + // filter list of modules to register |
|
1024 | + $widgets_to_register = apply_filters( |
|
1025 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1026 | + $widgets_to_register |
|
1027 | + ); |
|
1028 | + if (! empty($widgets_to_register)) { |
|
1029 | + // cycle thru widget folders |
|
1030 | + foreach ($widgets_to_register as $widget_path) { |
|
1031 | + // add to list of installed widget modules |
|
1032 | + EE_Config::register_ee_widget($widget_path); |
|
1033 | + } |
|
1034 | + } |
|
1035 | + // filter list of installed modules |
|
1036 | + EE_Registry::instance()->widgets = apply_filters( |
|
1037 | + 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1038 | + EE_Registry::instance()->widgets |
|
1039 | + ); |
|
1040 | + } |
|
1041 | + } |
|
1042 | + |
|
1043 | + |
|
1044 | + /** |
|
1045 | + * register_ee_widget - makes core aware of this widget |
|
1046 | + * |
|
1047 | + * @access public |
|
1048 | + * @param string $widget_path - full path up to and including widget folder |
|
1049 | + * @return void |
|
1050 | + */ |
|
1051 | + public static function register_ee_widget($widget_path = null) |
|
1052 | + { |
|
1053 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1054 | + $widget_ext = '.widget.php'; |
|
1055 | + // make all separators match |
|
1056 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1057 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1058 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
1059 | + // grab and shortcode file name from directory name and break apart at dots |
|
1060 | + $file_name = explode('.', basename($widget_path)); |
|
1061 | + // take first segment from file name pieces and remove class prefix if it exists |
|
1062 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1063 | + // sanitize shortcode directory name |
|
1064 | + $widget = sanitize_key($widget); |
|
1065 | + // now we need to rebuild the shortcode path |
|
1066 | + $widget_path = explode(DS, $widget_path); |
|
1067 | + // remove last segment |
|
1068 | + array_pop($widget_path); |
|
1069 | + // glue it back together |
|
1070 | + $widget_path = implode(DS, $widget_path); |
|
1071 | + } else { |
|
1072 | + // grab and sanitize widget directory name |
|
1073 | + $widget = sanitize_key(basename($widget_path)); |
|
1074 | + } |
|
1075 | + // create classname from widget directory name |
|
1076 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1077 | + // add class prefix |
|
1078 | + $widget_class = 'EEW_' . $widget; |
|
1079 | + // does the widget exist ? |
|
1080 | + if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1081 | + $msg = sprintf( |
|
1082 | + __( |
|
1083 | + 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1084 | + 'event_espresso' |
|
1085 | + ), |
|
1086 | + $widget_class, |
|
1087 | + $widget_path . DS . $widget_class . $widget_ext |
|
1088 | + ); |
|
1089 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1090 | + return; |
|
1091 | + } |
|
1092 | + // load the widget class file |
|
1093 | + require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1094 | + // verify that class exists |
|
1095 | + if (! class_exists($widget_class)) { |
|
1096 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1097 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1098 | + return; |
|
1099 | + } |
|
1100 | + register_widget($widget_class); |
|
1101 | + // add to array of registered widgets |
|
1102 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1103 | + } |
|
1104 | + |
|
1105 | + |
|
1106 | + /** |
|
1107 | + * _register_modules |
|
1108 | + * |
|
1109 | + * @access private |
|
1110 | + * @return array |
|
1111 | + */ |
|
1112 | + private function _register_modules() |
|
1113 | + { |
|
1114 | + // grab list of installed modules |
|
1115 | + $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1116 | + // filter list of modules to register |
|
1117 | + $modules_to_register = apply_filters( |
|
1118 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1119 | + $modules_to_register |
|
1120 | + ); |
|
1121 | + if (! empty($modules_to_register)) { |
|
1122 | + // loop through folders |
|
1123 | + foreach ($modules_to_register as $module_path) { |
|
1124 | + /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1125 | + if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1126 | + && $module_path !== EE_MODULES . 'gateways' |
|
1127 | + ) { |
|
1128 | + // add to list of installed modules |
|
1129 | + EE_Config::register_module($module_path); |
|
1130 | + } |
|
1131 | + } |
|
1132 | + } |
|
1133 | + // filter list of installed modules |
|
1134 | + return apply_filters( |
|
1135 | + 'FHEE__EE_Config___register_modules__installed_modules', |
|
1136 | + EE_Registry::instance()->modules |
|
1137 | + ); |
|
1138 | + } |
|
1139 | + |
|
1140 | + |
|
1141 | + /** |
|
1142 | + * register_module - makes core aware of this module |
|
1143 | + * |
|
1144 | + * @access public |
|
1145 | + * @param string $module_path - full path up to and including module folder |
|
1146 | + * @return bool |
|
1147 | + */ |
|
1148 | + public static function register_module($module_path = null) |
|
1149 | + { |
|
1150 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1151 | + $module_ext = '.module.php'; |
|
1152 | + // make all separators match |
|
1153 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1154 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1155 | + if (strpos($module_path, $module_ext) !== false) { |
|
1156 | + // grab and shortcode file name from directory name and break apart at dots |
|
1157 | + $module_file = explode('.', basename($module_path)); |
|
1158 | + // now we need to rebuild the shortcode path |
|
1159 | + $module_path = explode(DS, $module_path); |
|
1160 | + // remove last segment |
|
1161 | + array_pop($module_path); |
|
1162 | + // glue it back together |
|
1163 | + $module_path = implode(DS, $module_path) . DS; |
|
1164 | + // take first segment from file name pieces and sanitize it |
|
1165 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1166 | + // ensure class prefix is added |
|
1167 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1168 | + } else { |
|
1169 | + // we need to generate the filename based off of the folder name |
|
1170 | + // grab and sanitize module name |
|
1171 | + $module = strtolower(basename($module_path)); |
|
1172 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1173 | + // like trailingslashit() |
|
1174 | + $module_path = rtrim($module_path, DS) . DS; |
|
1175 | + // create classname from module directory name |
|
1176 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1177 | + // add class prefix |
|
1178 | + $module_class = 'EED_' . $module; |
|
1179 | + } |
|
1180 | + // does the module exist ? |
|
1181 | + if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1182 | + $msg = sprintf( |
|
1183 | + __( |
|
1184 | + 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1185 | + 'event_espresso' |
|
1186 | + ), |
|
1187 | + $module |
|
1188 | + ); |
|
1189 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1190 | + return false; |
|
1191 | + } |
|
1192 | + // load the module class file |
|
1193 | + require_once($module_path . $module_class . $module_ext); |
|
1194 | + // verify that class exists |
|
1195 | + if (! class_exists($module_class)) { |
|
1196 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1197 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1198 | + return false; |
|
1199 | + } |
|
1200 | + // add to array of registered modules |
|
1201 | + EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1202 | + do_action( |
|
1203 | + 'AHEE__EE_Config__register_module__complete', |
|
1204 | + $module_class, |
|
1205 | + EE_Registry::instance()->modules->{$module_class} |
|
1206 | + ); |
|
1207 | + return true; |
|
1208 | + } |
|
1209 | + |
|
1210 | + |
|
1211 | + /** |
|
1212 | + * _initialize_modules |
|
1213 | + * allow modules to set hooks for the rest of the system |
|
1214 | + * |
|
1215 | + * @access private |
|
1216 | + * @return void |
|
1217 | + */ |
|
1218 | + private function _initialize_modules() |
|
1219 | + { |
|
1220 | + // cycle thru shortcode folders |
|
1221 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1222 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1223 | + // which set hooks ? |
|
1224 | + if (is_admin()) { |
|
1225 | + // fire immediately |
|
1226 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1227 | + } else { |
|
1228 | + // delay until other systems are online |
|
1229 | + add_action( |
|
1230 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1231 | + array($module_class, 'set_hooks') |
|
1232 | + ); |
|
1233 | + } |
|
1234 | + } |
|
1235 | + } |
|
1236 | + |
|
1237 | + |
|
1238 | + /** |
|
1239 | + * register_route - adds module method routes to route_map |
|
1240 | + * |
|
1241 | + * @access public |
|
1242 | + * @param string $route - "pretty" public alias for module method |
|
1243 | + * @param string $module - module name (classname without EED_ prefix) |
|
1244 | + * @param string $method_name - the actual module method to be routed to |
|
1245 | + * @param string $key - url param key indicating a route is being called |
|
1246 | + * @return bool |
|
1247 | + */ |
|
1248 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1249 | + { |
|
1250 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1251 | + $module = str_replace('EED_', '', $module); |
|
1252 | + $module_class = 'EED_' . $module; |
|
1253 | + if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1254 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1255 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1256 | + return false; |
|
1257 | + } |
|
1258 | + if (empty($route)) { |
|
1259 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1260 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1261 | + return false; |
|
1262 | + } |
|
1263 | + if (! method_exists('EED_' . $module, $method_name)) { |
|
1264 | + $msg = sprintf( |
|
1265 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1266 | + $route |
|
1267 | + ); |
|
1268 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1269 | + return false; |
|
1270 | + } |
|
1271 | + EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name); |
|
1272 | + return true; |
|
1273 | + } |
|
1274 | + |
|
1275 | + |
|
1276 | + /** |
|
1277 | + * get_route - get module method route |
|
1278 | + * |
|
1279 | + * @access public |
|
1280 | + * @param string $route - "pretty" public alias for module method |
|
1281 | + * @param string $key - url param key indicating a route is being called |
|
1282 | + * @return string |
|
1283 | + */ |
|
1284 | + public static function get_route($route = null, $key = 'ee') |
|
1285 | + { |
|
1286 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1287 | + $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
1288 | + if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) { |
|
1289 | + return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1290 | + } |
|
1291 | + return null; |
|
1292 | + } |
|
1293 | + |
|
1294 | + |
|
1295 | + /** |
|
1296 | + * get_routes - get ALL module method routes |
|
1297 | + * |
|
1298 | + * @access public |
|
1299 | + * @return array |
|
1300 | + */ |
|
1301 | + public static function get_routes() |
|
1302 | + { |
|
1303 | + return EE_Config::$_module_route_map; |
|
1304 | + } |
|
1305 | + |
|
1306 | + |
|
1307 | + /** |
|
1308 | + * register_forward - allows modules to forward request to another module for further processing |
|
1309 | + * |
|
1310 | + * @access public |
|
1311 | + * @param string $route - "pretty" public alias for module method |
|
1312 | + * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1313 | + * class, allows different forwards to be served based on status |
|
1314 | + * @param array|string $forward - function name or array( class, method ) |
|
1315 | + * @param string $key - url param key indicating a route is being called |
|
1316 | + * @return bool |
|
1317 | + */ |
|
1318 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1319 | + { |
|
1320 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1321 | + if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1322 | + $msg = sprintf( |
|
1323 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1324 | + $route |
|
1325 | + ); |
|
1326 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1327 | + return false; |
|
1328 | + } |
|
1329 | + if (empty($forward)) { |
|
1330 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1331 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1332 | + return false; |
|
1333 | + } |
|
1334 | + if (is_array($forward)) { |
|
1335 | + if (! isset($forward[1])) { |
|
1336 | + $msg = sprintf( |
|
1337 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1338 | + $route |
|
1339 | + ); |
|
1340 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1341 | + return false; |
|
1342 | + } |
|
1343 | + if (! method_exists($forward[0], $forward[1])) { |
|
1344 | + $msg = sprintf( |
|
1345 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1346 | + $forward[1], |
|
1347 | + $route |
|
1348 | + ); |
|
1349 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1350 | + return false; |
|
1351 | + } |
|
1352 | + } elseif (! function_exists($forward)) { |
|
1353 | + $msg = sprintf( |
|
1354 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1355 | + $forward, |
|
1356 | + $route |
|
1357 | + ); |
|
1358 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1359 | + return false; |
|
1360 | + } |
|
1361 | + EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward; |
|
1362 | + return true; |
|
1363 | + } |
|
1364 | + |
|
1365 | + |
|
1366 | + /** |
|
1367 | + * get_forward - get forwarding route |
|
1368 | + * |
|
1369 | + * @access public |
|
1370 | + * @param string $route - "pretty" public alias for module method |
|
1371 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1372 | + * allows different forwards to be served based on status |
|
1373 | + * @param string $key - url param key indicating a route is being called |
|
1374 | + * @return string |
|
1375 | + */ |
|
1376 | + public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1377 | + { |
|
1378 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1379 | + if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) { |
|
1380 | + return apply_filters( |
|
1381 | + 'FHEE__EE_Config__get_forward', |
|
1382 | + EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], |
|
1383 | + $route, |
|
1384 | + $status |
|
1385 | + ); |
|
1386 | + } |
|
1387 | + return null; |
|
1388 | + } |
|
1389 | + |
|
1390 | + |
|
1391 | + /** |
|
1392 | + * register_forward - allows modules to specify different view templates for different method routes and status |
|
1393 | + * results |
|
1394 | + * |
|
1395 | + * @access public |
|
1396 | + * @param string $route - "pretty" public alias for module method |
|
1397 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1398 | + * allows different views to be served based on status |
|
1399 | + * @param string $view |
|
1400 | + * @param string $key - url param key indicating a route is being called |
|
1401 | + * @return bool |
|
1402 | + */ |
|
1403 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1404 | + { |
|
1405 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1406 | + if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1407 | + $msg = sprintf( |
|
1408 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1409 | + $route |
|
1410 | + ); |
|
1411 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1412 | + return false; |
|
1413 | + } |
|
1414 | + if (! is_readable($view)) { |
|
1415 | + $msg = sprintf( |
|
1416 | + __( |
|
1417 | + 'The %s view file could not be found or is not readable due to file permissions.', |
|
1418 | + 'event_espresso' |
|
1419 | + ), |
|
1420 | + $view |
|
1421 | + ); |
|
1422 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1423 | + return false; |
|
1424 | + } |
|
1425 | + EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view; |
|
1426 | + return true; |
|
1427 | + } |
|
1428 | + |
|
1429 | + |
|
1430 | + /** |
|
1431 | + * get_view - get view for route and status |
|
1432 | + * |
|
1433 | + * @access public |
|
1434 | + * @param string $route - "pretty" public alias for module method |
|
1435 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1436 | + * allows different views to be served based on status |
|
1437 | + * @param string $key - url param key indicating a route is being called |
|
1438 | + * @return string |
|
1439 | + */ |
|
1440 | + public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1441 | + { |
|
1442 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1443 | + if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) { |
|
1444 | + return apply_filters( |
|
1445 | + 'FHEE__EE_Config__get_view', |
|
1446 | + EE_Config::$_module_view_map[ $key ][ $route ][ $status ], |
|
1447 | + $route, |
|
1448 | + $status |
|
1449 | + ); |
|
1450 | + } |
|
1451 | + return null; |
|
1452 | + } |
|
1453 | + |
|
1454 | + |
|
1455 | + public function update_addon_option_names() |
|
1456 | + { |
|
1457 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1458 | + } |
|
1459 | + |
|
1460 | + |
|
1461 | + public function shutdown() |
|
1462 | + { |
|
1463 | + $this->update_addon_option_names(); |
|
1464 | + } |
|
1465 | + |
|
1466 | + |
|
1467 | + /** |
|
1468 | + * @return LegacyShortcodesManager |
|
1469 | + */ |
|
1470 | + public static function getLegacyShortcodesManager() |
|
1471 | + { |
|
1472 | + |
|
1473 | + if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1474 | + EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
1475 | + EE_Registry::instance() |
|
1476 | + ); |
|
1477 | + } |
|
1478 | + return EE_Config::instance()->legacy_shortcodes_manager; |
|
1479 | + } |
|
1480 | + |
|
1481 | + |
|
1482 | + /** |
|
1483 | + * register_shortcode - makes core aware of this shortcode |
|
1484 | + * |
|
1485 | + * @deprecated 4.9.26 |
|
1486 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
1487 | + * @return bool |
|
1488 | + */ |
|
1489 | + public static function register_shortcode($shortcode_path = null) |
|
1490 | + { |
|
1491 | + EE_Error::doing_it_wrong( |
|
1492 | + __METHOD__, |
|
1493 | + __( |
|
1494 | + 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
1495 | + 'event_espresso' |
|
1496 | + ), |
|
1497 | + '4.9.26' |
|
1498 | + ); |
|
1499 | + return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
1500 | + } |
|
1501 | +} |
|
2130 | 1502 | |
1503 | +/** |
|
1504 | + * Base class used for config classes. These classes should generally not have |
|
1505 | + * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1506 | + * basically, they should just be well-defined stdClasses |
|
1507 | + */ |
|
1508 | +class EE_Config_Base |
|
1509 | +{ |
|
2131 | 1510 | |
2132 | - /** |
|
2133 | - * class constructor |
|
2134 | - * |
|
2135 | - * @access public |
|
2136 | - * @param string $CNT_ISO |
|
2137 | - * @throws \EE_Error |
|
2138 | - */ |
|
2139 | - public function __construct($CNT_ISO = '') |
|
2140 | - { |
|
2141 | - /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2142 | - $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2143 | - // get country code from organization settings or use default |
|
2144 | - $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2145 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2146 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2147 | - : ''; |
|
2148 | - // but override if requested |
|
2149 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2150 | - // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2151 | - if (! empty($CNT_ISO) |
|
2152 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
2153 | - && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2154 | - ) { |
|
2155 | - // retrieve the country settings from the db, just in case they have been customized |
|
2156 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2157 | - if ($country instanceof EE_Country) { |
|
2158 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2159 | - $this->name = $country->currency_name_single(); // Dollar |
|
2160 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2161 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2162 | - $this->sign_b4 = $country->currency_sign_before( |
|
2163 | - ); // currency sign before or after: $TRUE or FALSE$ |
|
2164 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2165 | - $this->dec_mrk = $country->currency_decimal_mark( |
|
2166 | - ); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2167 | - $this->thsnds = $country->currency_thousands_separator( |
|
2168 | - ); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2169 | - } |
|
2170 | - } |
|
2171 | - // fallback to hardcoded defaults, in case the above failed |
|
2172 | - if (empty($this->code)) { |
|
2173 | - // set default currency settings |
|
2174 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2175 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2176 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2177 | - $this->sign = '$'; // currency sign: $ |
|
2178 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2179 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2180 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2181 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2182 | - } |
|
2183 | - } |
|
1511 | + /** |
|
1512 | + * Utility function for escaping the value of a property and returning. |
|
1513 | + * |
|
1514 | + * @param string $property property name (checks to see if exists). |
|
1515 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1516 | + * @throws \EE_Error |
|
1517 | + */ |
|
1518 | + public function get_pretty($property) |
|
1519 | + { |
|
1520 | + if (! property_exists($this, $property)) { |
|
1521 | + throw new EE_Error( |
|
1522 | + sprintf( |
|
1523 | + __( |
|
1524 | + '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1525 | + 'event_espresso' |
|
1526 | + ), |
|
1527 | + get_class($this), |
|
1528 | + $property |
|
1529 | + ) |
|
1530 | + ); |
|
1531 | + } |
|
1532 | + // just handling escaping of strings for now. |
|
1533 | + if (is_string($this->{$property})) { |
|
1534 | + return stripslashes($this->{$property}); |
|
1535 | + } |
|
1536 | + return $this->{$property}; |
|
1537 | + } |
|
1538 | + |
|
1539 | + |
|
1540 | + public function populate() |
|
1541 | + { |
|
1542 | + // grab defaults via a new instance of this class. |
|
1543 | + $class_name = get_class($this); |
|
1544 | + $defaults = new $class_name; |
|
1545 | + // loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1546 | + // default from our $defaults object. |
|
1547 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1548 | + if ($this->{$property} === null) { |
|
1549 | + $this->{$property} = $value; |
|
1550 | + } |
|
1551 | + } |
|
1552 | + // cleanup |
|
1553 | + unset($defaults); |
|
1554 | + } |
|
1555 | + |
|
1556 | + |
|
1557 | + /** |
|
1558 | + * __isset |
|
1559 | + * |
|
1560 | + * @param $a |
|
1561 | + * @return bool |
|
1562 | + */ |
|
1563 | + public function __isset($a) |
|
1564 | + { |
|
1565 | + return false; |
|
1566 | + } |
|
1567 | + |
|
1568 | + |
|
1569 | + /** |
|
1570 | + * __unset |
|
1571 | + * |
|
1572 | + * @param $a |
|
1573 | + * @return bool |
|
1574 | + */ |
|
1575 | + public function __unset($a) |
|
1576 | + { |
|
1577 | + return false; |
|
1578 | + } |
|
1579 | + |
|
1580 | + |
|
1581 | + /** |
|
1582 | + * __clone |
|
1583 | + */ |
|
1584 | + public function __clone() |
|
1585 | + { |
|
1586 | + } |
|
1587 | + |
|
1588 | + |
|
1589 | + /** |
|
1590 | + * __wakeup |
|
1591 | + */ |
|
1592 | + public function __wakeup() |
|
1593 | + { |
|
1594 | + } |
|
1595 | + |
|
1596 | + |
|
1597 | + /** |
|
1598 | + * __destruct |
|
1599 | + */ |
|
1600 | + public function __destruct() |
|
1601 | + { |
|
1602 | + } |
|
2184 | 1603 | } |
2185 | 1604 | |
2186 | 1605 | |
2187 | 1606 | /** |
2188 | 1607 | * Class for defining what's in the EE_Config relating to registration settings |
2189 | 1608 | */ |
2190 | -class EE_Registration_Config extends EE_Config_Base |
|
1609 | +class EE_Core_Config extends EE_Config_Base |
|
2191 | 1610 | { |
2192 | 1611 | |
2193 | - /** |
|
2194 | - * Default registration status |
|
2195 | - * |
|
2196 | - * @var string $default_STS_ID |
|
2197 | - * eg 'RPP' |
|
2198 | - */ |
|
2199 | - public $default_STS_ID; |
|
2200 | - |
|
2201 | - |
|
2202 | - /** |
|
2203 | - * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
2204 | - * registrations) |
|
2205 | - * |
|
2206 | - * @var int |
|
2207 | - */ |
|
2208 | - public $default_maximum_number_of_tickets; |
|
2209 | - |
|
2210 | - |
|
2211 | - /** |
|
2212 | - * level of validation to apply to email addresses |
|
2213 | - * |
|
2214 | - * @var string $email_validation_level |
|
2215 | - * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2216 | - */ |
|
2217 | - public $email_validation_level; |
|
2218 | - |
|
2219 | - /** |
|
2220 | - * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2221 | - * |
|
2222 | - * @var boolean $show_pending_payment_options |
|
2223 | - */ |
|
2224 | - public $show_pending_payment_options; |
|
2225 | - |
|
2226 | - /** |
|
2227 | - * Whether to skip the registration confirmation page |
|
2228 | - * |
|
2229 | - * @var boolean $skip_reg_confirmation |
|
2230 | - */ |
|
2231 | - public $skip_reg_confirmation; |
|
2232 | - |
|
2233 | - /** |
|
2234 | - * an array of SPCO reg steps where: |
|
2235 | - * the keys denotes the reg step order |
|
2236 | - * each element consists of an array with the following elements: |
|
2237 | - * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2238 | - * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2239 | - * "slug" => the URL param used to trigger the reg step |
|
2240 | - * |
|
2241 | - * @var array $reg_steps |
|
2242 | - */ |
|
2243 | - public $reg_steps; |
|
2244 | - |
|
2245 | - /** |
|
2246 | - * Whether registration confirmation should be the last page of SPCO |
|
2247 | - * |
|
2248 | - * @var boolean $reg_confirmation_last |
|
2249 | - */ |
|
2250 | - public $reg_confirmation_last; |
|
2251 | - |
|
2252 | - /** |
|
2253 | - * Whether or not to enable the EE Bot Trap |
|
2254 | - * |
|
2255 | - * @var boolean $use_bot_trap |
|
2256 | - */ |
|
2257 | - public $use_bot_trap; |
|
2258 | - |
|
2259 | - /** |
|
2260 | - * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2261 | - * |
|
2262 | - * @var boolean $use_encryption |
|
2263 | - */ |
|
2264 | - public $use_encryption; |
|
2265 | - |
|
2266 | - /** |
|
2267 | - * Whether or not to use ReCaptcha |
|
2268 | - * |
|
2269 | - * @var boolean $use_captcha |
|
2270 | - */ |
|
2271 | - public $use_captcha; |
|
2272 | - |
|
2273 | - /** |
|
2274 | - * ReCaptcha Theme |
|
2275 | - * |
|
2276 | - * @var string $recaptcha_theme |
|
2277 | - * options: 'dark', 'light', 'invisible' |
|
2278 | - */ |
|
2279 | - public $recaptcha_theme; |
|
2280 | - |
|
2281 | - /** |
|
2282 | - * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
2283 | - * |
|
2284 | - * @var string $recaptcha_badge |
|
2285 | - * options: 'bottomright', 'bottomleft', 'inline' |
|
2286 | - */ |
|
2287 | - public $recaptcha_badge; |
|
2288 | - |
|
2289 | - /** |
|
2290 | - * ReCaptcha Type |
|
2291 | - * |
|
2292 | - * @var string $recaptcha_type |
|
2293 | - * options: 'audio', 'image' |
|
2294 | - */ |
|
2295 | - public $recaptcha_type; |
|
2296 | - |
|
2297 | - /** |
|
2298 | - * ReCaptcha language |
|
2299 | - * |
|
2300 | - * @var string $recaptcha_language |
|
2301 | - * eg 'en' |
|
2302 | - */ |
|
2303 | - public $recaptcha_language; |
|
2304 | - |
|
2305 | - /** |
|
2306 | - * ReCaptcha public key |
|
2307 | - * |
|
2308 | - * @var string $recaptcha_publickey |
|
2309 | - */ |
|
2310 | - public $recaptcha_publickey; |
|
2311 | - |
|
2312 | - /** |
|
2313 | - * ReCaptcha private key |
|
2314 | - * |
|
2315 | - * @var string $recaptcha_privatekey |
|
2316 | - */ |
|
2317 | - public $recaptcha_privatekey; |
|
2318 | - |
|
2319 | - /** |
|
2320 | - * array of form names protected by ReCaptcha |
|
2321 | - * |
|
2322 | - * @var array $recaptcha_protected_forms |
|
2323 | - */ |
|
2324 | - public $recaptcha_protected_forms; |
|
2325 | - |
|
2326 | - /** |
|
2327 | - * ReCaptcha width |
|
2328 | - * |
|
2329 | - * @var int $recaptcha_width |
|
2330 | - * @deprecated |
|
2331 | - */ |
|
2332 | - public $recaptcha_width; |
|
2333 | - |
|
2334 | - /** |
|
2335 | - * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2336 | - * |
|
2337 | - * @var boolean $track_invalid_checkout_access |
|
2338 | - */ |
|
2339 | - protected $track_invalid_checkout_access = true; |
|
2340 | - |
|
2341 | - /** |
|
2342 | - * String describing how long to keep payment logs. Passed into DateTime constructor |
|
2343 | - * @var string |
|
2344 | - */ |
|
2345 | - public $gateway_log_lifespan = '1 week'; |
|
2346 | - |
|
1612 | + public $current_blog_id; |
|
1613 | + |
|
1614 | + public $ee_ueip_optin; |
|
1615 | + |
|
1616 | + public $ee_ueip_has_notified; |
|
1617 | + |
|
1618 | + /** |
|
1619 | + * Not to be confused with the 4 critical page variables (See |
|
1620 | + * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1621 | + * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1622 | + * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1623 | + * |
|
1624 | + * @var array |
|
1625 | + */ |
|
1626 | + public $post_shortcodes; |
|
1627 | + |
|
1628 | + public $module_route_map; |
|
1629 | + |
|
1630 | + public $module_forward_map; |
|
1631 | + |
|
1632 | + public $module_view_map; |
|
1633 | + |
|
1634 | + /** |
|
1635 | + * The next 4 vars are the IDs of critical EE pages. |
|
1636 | + * |
|
1637 | + * @var int |
|
1638 | + */ |
|
1639 | + public $reg_page_id; |
|
1640 | + |
|
1641 | + public $txn_page_id; |
|
1642 | + |
|
1643 | + public $thank_you_page_id; |
|
1644 | + |
|
1645 | + public $cancel_page_id; |
|
1646 | + |
|
1647 | + /** |
|
1648 | + * The next 4 vars are the URLs of critical EE pages. |
|
1649 | + * |
|
1650 | + * @var int |
|
1651 | + */ |
|
1652 | + public $reg_page_url; |
|
1653 | + |
|
1654 | + public $txn_page_url; |
|
1655 | + |
|
1656 | + public $thank_you_page_url; |
|
1657 | + |
|
1658 | + public $cancel_page_url; |
|
1659 | + |
|
1660 | + /** |
|
1661 | + * The next vars relate to the custom slugs for EE CPT routes |
|
1662 | + */ |
|
1663 | + public $event_cpt_slug; |
|
1664 | + |
|
1665 | + |
|
1666 | + /** |
|
1667 | + * This caches the _ee_ueip_option in case this config is reset in the same |
|
1668 | + * request across blog switches in a multisite context. |
|
1669 | + * Avoids extra queries to the db for this option. |
|
1670 | + * |
|
1671 | + * @var bool |
|
1672 | + */ |
|
1673 | + public static $ee_ueip_option; |
|
1674 | + |
|
1675 | + |
|
1676 | + /** |
|
1677 | + * class constructor |
|
1678 | + * |
|
1679 | + * @access public |
|
1680 | + */ |
|
1681 | + public function __construct() |
|
1682 | + { |
|
1683 | + // set default organization settings |
|
1684 | + $this->current_blog_id = get_current_blog_id(); |
|
1685 | + $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1686 | + $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1687 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1688 | + $this->post_shortcodes = array(); |
|
1689 | + $this->module_route_map = array(); |
|
1690 | + $this->module_forward_map = array(); |
|
1691 | + $this->module_view_map = array(); |
|
1692 | + // critical EE page IDs |
|
1693 | + $this->reg_page_id = 0; |
|
1694 | + $this->txn_page_id = 0; |
|
1695 | + $this->thank_you_page_id = 0; |
|
1696 | + $this->cancel_page_id = 0; |
|
1697 | + // critical EE page URLs |
|
1698 | + $this->reg_page_url = ''; |
|
1699 | + $this->txn_page_url = ''; |
|
1700 | + $this->thank_you_page_url = ''; |
|
1701 | + $this->cancel_page_url = ''; |
|
1702 | + // cpt slugs |
|
1703 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1704 | + // ueip constant check |
|
1705 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1706 | + $this->ee_ueip_optin = false; |
|
1707 | + $this->ee_ueip_has_notified = true; |
|
1708 | + } |
|
1709 | + } |
|
1710 | + |
|
1711 | + |
|
1712 | + /** |
|
1713 | + * @return array |
|
1714 | + */ |
|
1715 | + public function get_critical_pages_array() |
|
1716 | + { |
|
1717 | + return array( |
|
1718 | + $this->reg_page_id, |
|
1719 | + $this->txn_page_id, |
|
1720 | + $this->thank_you_page_id, |
|
1721 | + $this->cancel_page_id, |
|
1722 | + ); |
|
1723 | + } |
|
1724 | + |
|
1725 | + |
|
1726 | + /** |
|
1727 | + * @return array |
|
1728 | + */ |
|
1729 | + public function get_critical_pages_shortcodes_array() |
|
1730 | + { |
|
1731 | + return array( |
|
1732 | + $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1733 | + $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1734 | + $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1735 | + $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1736 | + ); |
|
1737 | + } |
|
1738 | + |
|
1739 | + |
|
1740 | + /** |
|
1741 | + * gets/returns URL for EE reg_page |
|
1742 | + * |
|
1743 | + * @access public |
|
1744 | + * @return string |
|
1745 | + */ |
|
1746 | + public function reg_page_url() |
|
1747 | + { |
|
1748 | + if (! $this->reg_page_url) { |
|
1749 | + $this->reg_page_url = add_query_arg( |
|
1750 | + array('uts' => time()), |
|
1751 | + get_permalink($this->reg_page_id) |
|
1752 | + ) . '#checkout'; |
|
1753 | + } |
|
1754 | + return $this->reg_page_url; |
|
1755 | + } |
|
1756 | + |
|
1757 | + |
|
1758 | + /** |
|
1759 | + * gets/returns URL for EE txn_page |
|
1760 | + * |
|
1761 | + * @param array $query_args like what gets passed to |
|
1762 | + * add_query_arg() as the first argument |
|
1763 | + * @access public |
|
1764 | + * @return string |
|
1765 | + */ |
|
1766 | + public function txn_page_url($query_args = array()) |
|
1767 | + { |
|
1768 | + if (! $this->txn_page_url) { |
|
1769 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1770 | + } |
|
1771 | + if ($query_args) { |
|
1772 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1773 | + } else { |
|
1774 | + return $this->txn_page_url; |
|
1775 | + } |
|
1776 | + } |
|
1777 | + |
|
1778 | + |
|
1779 | + /** |
|
1780 | + * gets/returns URL for EE thank_you_page |
|
1781 | + * |
|
1782 | + * @param array $query_args like what gets passed to |
|
1783 | + * add_query_arg() as the first argument |
|
1784 | + * @access public |
|
1785 | + * @return string |
|
1786 | + */ |
|
1787 | + public function thank_you_page_url($query_args = array()) |
|
1788 | + { |
|
1789 | + if (! $this->thank_you_page_url) { |
|
1790 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1791 | + } |
|
1792 | + if ($query_args) { |
|
1793 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1794 | + } else { |
|
1795 | + return $this->thank_you_page_url; |
|
1796 | + } |
|
1797 | + } |
|
1798 | + |
|
1799 | + |
|
1800 | + /** |
|
1801 | + * gets/returns URL for EE cancel_page |
|
1802 | + * |
|
1803 | + * @access public |
|
1804 | + * @return string |
|
1805 | + */ |
|
1806 | + public function cancel_page_url() |
|
1807 | + { |
|
1808 | + if (! $this->cancel_page_url) { |
|
1809 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1810 | + } |
|
1811 | + return $this->cancel_page_url; |
|
1812 | + } |
|
1813 | + |
|
1814 | + |
|
1815 | + /** |
|
1816 | + * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1817 | + * |
|
1818 | + * @since 4.7.5 |
|
1819 | + */ |
|
1820 | + protected function _reset_urls() |
|
1821 | + { |
|
1822 | + $this->reg_page_url = ''; |
|
1823 | + $this->txn_page_url = ''; |
|
1824 | + $this->cancel_page_url = ''; |
|
1825 | + $this->thank_you_page_url = ''; |
|
1826 | + } |
|
1827 | + |
|
1828 | + |
|
1829 | + /** |
|
1830 | + * Used to return what the optin value is set for the EE User Experience Program. |
|
1831 | + * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1832 | + * on the main site only. |
|
1833 | + * |
|
1834 | + * @return mixed|void |
|
1835 | + */ |
|
1836 | + protected function _get_main_ee_ueip_optin() |
|
1837 | + { |
|
1838 | + // if this is the main site then we can just bypass our direct query. |
|
1839 | + if (is_main_site()) { |
|
1840 | + return get_option('ee_ueip_optin', false); |
|
1841 | + } |
|
1842 | + // is this already cached for this request? If so use it. |
|
1843 | + if (! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1844 | + return EE_Core_Config::$ee_ueip_option; |
|
1845 | + } |
|
1846 | + global $wpdb; |
|
1847 | + $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1848 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1849 | + $option = 'ee_ueip_optin'; |
|
1850 | + // set correct table for query |
|
1851 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1852 | + // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1853 | + // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1854 | + // re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1855 | + // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1856 | + // for the purpose of caching. |
|
1857 | + $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1858 | + if (false !== $pre) { |
|
1859 | + EE_Core_Config::$ee_ueip_option = $pre; |
|
1860 | + return EE_Core_Config::$ee_ueip_option; |
|
1861 | + } |
|
1862 | + $row = $wpdb->get_row( |
|
1863 | + $wpdb->prepare( |
|
1864 | + "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
1865 | + $option |
|
1866 | + ) |
|
1867 | + ); |
|
1868 | + if (is_object($row)) { |
|
1869 | + $value = $row->option_value; |
|
1870 | + } else { // option does not exist so use default. |
|
1871 | + return apply_filters('default_option_' . $option, false, $option); |
|
1872 | + } |
|
1873 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1874 | + return EE_Core_Config::$ee_ueip_option; |
|
1875 | + } |
|
1876 | + |
|
1877 | + /** |
|
1878 | + * Utility function for escaping the value of a property and returning. |
|
1879 | + * |
|
1880 | + * @param string $property property name (checks to see if exists). |
|
1881 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1882 | + * @throws \EE_Error |
|
1883 | + */ |
|
1884 | + public function get_pretty($property) |
|
1885 | + { |
|
1886 | + if ($property === 'ee_ueip_optin') { |
|
1887 | + return $this->ee_ueip_optin ? 'yes' : 'no'; |
|
1888 | + } |
|
1889 | + return parent::get_pretty($property); |
|
1890 | + } |
|
1891 | + |
|
1892 | + |
|
1893 | + /** |
|
1894 | + * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
1895 | + * on the object. |
|
1896 | + * |
|
1897 | + * @return array |
|
1898 | + */ |
|
1899 | + public function __sleep() |
|
1900 | + { |
|
1901 | + // reset all url properties |
|
1902 | + $this->_reset_urls(); |
|
1903 | + // return what to save to db |
|
1904 | + return array_keys(get_object_vars($this)); |
|
1905 | + } |
|
1906 | +} |
|
2347 | 1907 | |
2348 | - /** |
|
2349 | - * class constructor |
|
2350 | - * |
|
2351 | - * @access public |
|
2352 | - */ |
|
2353 | - public function __construct() |
|
2354 | - { |
|
2355 | - // set default registration settings |
|
2356 | - $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2357 | - $this->email_validation_level = 'wp_default'; |
|
2358 | - $this->show_pending_payment_options = true; |
|
2359 | - $this->skip_reg_confirmation = true; |
|
2360 | - $this->reg_steps = array(); |
|
2361 | - $this->reg_confirmation_last = false; |
|
2362 | - $this->use_bot_trap = true; |
|
2363 | - $this->use_encryption = true; |
|
2364 | - $this->use_captcha = false; |
|
2365 | - $this->recaptcha_theme = 'light'; |
|
2366 | - $this->recaptcha_badge = 'bottomleft'; |
|
2367 | - $this->recaptcha_type = 'image'; |
|
2368 | - $this->recaptcha_language = 'en'; |
|
2369 | - $this->recaptcha_publickey = null; |
|
2370 | - $this->recaptcha_privatekey = null; |
|
2371 | - $this->recaptcha_protected_forms = array(); |
|
2372 | - $this->recaptcha_width = 500; |
|
2373 | - $this->default_maximum_number_of_tickets = 10; |
|
2374 | - $this->gateway_log_lifespan = '7 days'; |
|
2375 | - } |
|
2376 | - |
|
2377 | - |
|
2378 | - /** |
|
2379 | - * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2380 | - * |
|
2381 | - * @since 4.8.8.rc.019 |
|
2382 | - */ |
|
2383 | - public function do_hooks() |
|
2384 | - { |
|
2385 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2386 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
2387 | - } |
|
2388 | 1908 | |
1909 | +/** |
|
1910 | + * Config class for storing info on the Organization |
|
1911 | + */ |
|
1912 | +class EE_Organization_Config extends EE_Config_Base |
|
1913 | +{ |
|
2389 | 1914 | |
2390 | - /** |
|
2391 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the |
|
2392 | - * EVT_default_registration_status field matches the config setting for default_STS_ID. |
|
2393 | - */ |
|
2394 | - public function set_default_reg_status_on_EEM_Event() |
|
2395 | - { |
|
2396 | - EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2397 | - } |
|
1915 | + /** |
|
1916 | + * @var string $name |
|
1917 | + * eg EE4.1 |
|
1918 | + */ |
|
1919 | + public $name; |
|
1920 | + |
|
1921 | + /** |
|
1922 | + * @var string $address_1 |
|
1923 | + * eg 123 Onna Road |
|
1924 | + */ |
|
1925 | + public $address_1; |
|
1926 | + |
|
1927 | + /** |
|
1928 | + * @var string $address_2 |
|
1929 | + * eg PO Box 123 |
|
1930 | + */ |
|
1931 | + public $address_2; |
|
1932 | + |
|
1933 | + /** |
|
1934 | + * @var string $city |
|
1935 | + * eg Inna City |
|
1936 | + */ |
|
1937 | + public $city; |
|
1938 | + |
|
1939 | + /** |
|
1940 | + * @var int $STA_ID |
|
1941 | + * eg 4 |
|
1942 | + */ |
|
1943 | + public $STA_ID; |
|
1944 | + |
|
1945 | + /** |
|
1946 | + * @var string $CNT_ISO |
|
1947 | + * eg US |
|
1948 | + */ |
|
1949 | + public $CNT_ISO; |
|
1950 | + |
|
1951 | + /** |
|
1952 | + * @var string $zip |
|
1953 | + * eg 12345 or V1A 2B3 |
|
1954 | + */ |
|
1955 | + public $zip; |
|
1956 | + |
|
1957 | + /** |
|
1958 | + * @var string $email |
|
1959 | + * eg [email protected] |
|
1960 | + */ |
|
1961 | + public $email; |
|
1962 | + |
|
1963 | + |
|
1964 | + /** |
|
1965 | + * @var string $phone |
|
1966 | + * eg. 111-111-1111 |
|
1967 | + */ |
|
1968 | + public $phone; |
|
1969 | + |
|
1970 | + |
|
1971 | + /** |
|
1972 | + * @var string $vat |
|
1973 | + * VAT/Tax Number |
|
1974 | + */ |
|
1975 | + public $vat; |
|
1976 | + |
|
1977 | + /** |
|
1978 | + * @var string $logo_url |
|
1979 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
1980 | + */ |
|
1981 | + public $logo_url; |
|
1982 | + |
|
1983 | + |
|
1984 | + /** |
|
1985 | + * The below are all various properties for holding links to organization social network profiles |
|
1986 | + * |
|
1987 | + * @var string |
|
1988 | + */ |
|
1989 | + /** |
|
1990 | + * facebook (facebook.com/profile.name) |
|
1991 | + * |
|
1992 | + * @var string |
|
1993 | + */ |
|
1994 | + public $facebook; |
|
1995 | + |
|
1996 | + |
|
1997 | + /** |
|
1998 | + * twitter (twitter.com/twitter_handle) |
|
1999 | + * |
|
2000 | + * @var string |
|
2001 | + */ |
|
2002 | + public $twitter; |
|
2003 | + |
|
2004 | + |
|
2005 | + /** |
|
2006 | + * linkedin (linkedin.com/in/profile_name) |
|
2007 | + * |
|
2008 | + * @var string |
|
2009 | + */ |
|
2010 | + public $linkedin; |
|
2011 | + |
|
2012 | + |
|
2013 | + /** |
|
2014 | + * pinterest (www.pinterest.com/profile_name) |
|
2015 | + * |
|
2016 | + * @var string |
|
2017 | + */ |
|
2018 | + public $pinterest; |
|
2019 | + |
|
2020 | + |
|
2021 | + /** |
|
2022 | + * google+ (google.com/+profileName) |
|
2023 | + * |
|
2024 | + * @var string |
|
2025 | + */ |
|
2026 | + public $google; |
|
2027 | + |
|
2028 | + |
|
2029 | + /** |
|
2030 | + * instagram (instagram.com/handle) |
|
2031 | + * |
|
2032 | + * @var string |
|
2033 | + */ |
|
2034 | + public $instagram; |
|
2035 | + |
|
2036 | + |
|
2037 | + /** |
|
2038 | + * class constructor |
|
2039 | + * |
|
2040 | + * @access public |
|
2041 | + */ |
|
2042 | + public function __construct() |
|
2043 | + { |
|
2044 | + // set default organization settings |
|
2045 | + // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
2046 | + $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
2047 | + $this->address_1 = '123 Onna Road'; |
|
2048 | + $this->address_2 = 'PO Box 123'; |
|
2049 | + $this->city = 'Inna City'; |
|
2050 | + $this->STA_ID = 4; |
|
2051 | + $this->CNT_ISO = 'US'; |
|
2052 | + $this->zip = '12345'; |
|
2053 | + $this->email = get_bloginfo('admin_email'); |
|
2054 | + $this->phone = ''; |
|
2055 | + $this->vat = '123456789'; |
|
2056 | + $this->logo_url = ''; |
|
2057 | + $this->facebook = ''; |
|
2058 | + $this->twitter = ''; |
|
2059 | + $this->linkedin = ''; |
|
2060 | + $this->pinterest = ''; |
|
2061 | + $this->google = ''; |
|
2062 | + $this->instagram = ''; |
|
2063 | + } |
|
2064 | +} |
|
2398 | 2065 | |
2399 | 2066 | |
2400 | - /** |
|
2401 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
2402 | - * for Events matches the config setting for default_maximum_number_of_tickets |
|
2403 | - */ |
|
2404 | - public function set_default_max_ticket_on_EEM_Event() |
|
2405 | - { |
|
2406 | - EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
2407 | - } |
|
2067 | +/** |
|
2068 | + * Class for defining what's in the EE_Config relating to currency |
|
2069 | + */ |
|
2070 | +class EE_Currency_Config extends EE_Config_Base |
|
2071 | +{ |
|
2408 | 2072 | |
2073 | + /** |
|
2074 | + * @var string $code |
|
2075 | + * eg 'US' |
|
2076 | + */ |
|
2077 | + public $code; |
|
2078 | + |
|
2079 | + /** |
|
2080 | + * @var string $name |
|
2081 | + * eg 'Dollar' |
|
2082 | + */ |
|
2083 | + public $name; |
|
2084 | + |
|
2085 | + /** |
|
2086 | + * plural name |
|
2087 | + * |
|
2088 | + * @var string $plural |
|
2089 | + * eg 'Dollars' |
|
2090 | + */ |
|
2091 | + public $plural; |
|
2092 | + |
|
2093 | + /** |
|
2094 | + * currency sign |
|
2095 | + * |
|
2096 | + * @var string $sign |
|
2097 | + * eg '$' |
|
2098 | + */ |
|
2099 | + public $sign; |
|
2100 | + |
|
2101 | + /** |
|
2102 | + * Whether the currency sign should come before the number or not |
|
2103 | + * |
|
2104 | + * @var boolean $sign_b4 |
|
2105 | + */ |
|
2106 | + public $sign_b4; |
|
2107 | + |
|
2108 | + /** |
|
2109 | + * How many digits should come after the decimal place |
|
2110 | + * |
|
2111 | + * @var int $dec_plc |
|
2112 | + */ |
|
2113 | + public $dec_plc; |
|
2114 | + |
|
2115 | + /** |
|
2116 | + * Symbol to use for decimal mark |
|
2117 | + * |
|
2118 | + * @var string $dec_mrk |
|
2119 | + * eg '.' |
|
2120 | + */ |
|
2121 | + public $dec_mrk; |
|
2122 | + |
|
2123 | + /** |
|
2124 | + * Symbol to use for thousands |
|
2125 | + * |
|
2126 | + * @var string $thsnds |
|
2127 | + * eg ',' |
|
2128 | + */ |
|
2129 | + public $thsnds; |
|
2130 | + |
|
2131 | + |
|
2132 | + /** |
|
2133 | + * class constructor |
|
2134 | + * |
|
2135 | + * @access public |
|
2136 | + * @param string $CNT_ISO |
|
2137 | + * @throws \EE_Error |
|
2138 | + */ |
|
2139 | + public function __construct($CNT_ISO = '') |
|
2140 | + { |
|
2141 | + /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2142 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2143 | + // get country code from organization settings or use default |
|
2144 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2145 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2146 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2147 | + : ''; |
|
2148 | + // but override if requested |
|
2149 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2150 | + // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2151 | + if (! empty($CNT_ISO) |
|
2152 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
2153 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2154 | + ) { |
|
2155 | + // retrieve the country settings from the db, just in case they have been customized |
|
2156 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2157 | + if ($country instanceof EE_Country) { |
|
2158 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2159 | + $this->name = $country->currency_name_single(); // Dollar |
|
2160 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2161 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2162 | + $this->sign_b4 = $country->currency_sign_before( |
|
2163 | + ); // currency sign before or after: $TRUE or FALSE$ |
|
2164 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2165 | + $this->dec_mrk = $country->currency_decimal_mark( |
|
2166 | + ); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2167 | + $this->thsnds = $country->currency_thousands_separator( |
|
2168 | + ); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2169 | + } |
|
2170 | + } |
|
2171 | + // fallback to hardcoded defaults, in case the above failed |
|
2172 | + if (empty($this->code)) { |
|
2173 | + // set default currency settings |
|
2174 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2175 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2176 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2177 | + $this->sign = '$'; // currency sign: $ |
|
2178 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2179 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2180 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2181 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2182 | + } |
|
2183 | + } |
|
2184 | +} |
|
2409 | 2185 | |
2410 | - /** |
|
2411 | - * @return boolean |
|
2412 | - */ |
|
2413 | - public function track_invalid_checkout_access() |
|
2414 | - { |
|
2415 | - return $this->track_invalid_checkout_access; |
|
2416 | - } |
|
2417 | 2186 | |
2187 | +/** |
|
2188 | + * Class for defining what's in the EE_Config relating to registration settings |
|
2189 | + */ |
|
2190 | +class EE_Registration_Config extends EE_Config_Base |
|
2191 | +{ |
|
2418 | 2192 | |
2419 | - /** |
|
2420 | - * @param boolean $track_invalid_checkout_access |
|
2421 | - */ |
|
2422 | - public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2423 | - { |
|
2424 | - $this->track_invalid_checkout_access = filter_var( |
|
2425 | - $track_invalid_checkout_access, |
|
2426 | - FILTER_VALIDATE_BOOLEAN |
|
2427 | - ); |
|
2428 | - } |
|
2429 | - |
|
2430 | - |
|
2431 | - /** |
|
2432 | - * Gets the options to make availalbe for the gateway log lifespan |
|
2433 | - * @return array |
|
2434 | - */ |
|
2435 | - public function gatewayLogLifespanOptions() |
|
2436 | - { |
|
2437 | - return (array) apply_filters( |
|
2438 | - 'FHEE_EE_Admin_Config__gatewayLogLifespanOptions', |
|
2439 | - array( |
|
2440 | - '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'), |
|
2441 | - '1 day' => esc_html__('1 Day', 'event_espresso'), |
|
2442 | - '7 days' => esc_html__('7 Days', 'event_espresso'), |
|
2443 | - '14 days' => esc_html__('14 Days', 'event_espresso'), |
|
2444 | - '30 days' => esc_html__('30 Days', 'event_espresso') |
|
2445 | - ) |
|
2446 | - ); |
|
2447 | - } |
|
2193 | + /** |
|
2194 | + * Default registration status |
|
2195 | + * |
|
2196 | + * @var string $default_STS_ID |
|
2197 | + * eg 'RPP' |
|
2198 | + */ |
|
2199 | + public $default_STS_ID; |
|
2200 | + |
|
2201 | + |
|
2202 | + /** |
|
2203 | + * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
2204 | + * registrations) |
|
2205 | + * |
|
2206 | + * @var int |
|
2207 | + */ |
|
2208 | + public $default_maximum_number_of_tickets; |
|
2209 | + |
|
2210 | + |
|
2211 | + /** |
|
2212 | + * level of validation to apply to email addresses |
|
2213 | + * |
|
2214 | + * @var string $email_validation_level |
|
2215 | + * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2216 | + */ |
|
2217 | + public $email_validation_level; |
|
2218 | + |
|
2219 | + /** |
|
2220 | + * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2221 | + * |
|
2222 | + * @var boolean $show_pending_payment_options |
|
2223 | + */ |
|
2224 | + public $show_pending_payment_options; |
|
2225 | + |
|
2226 | + /** |
|
2227 | + * Whether to skip the registration confirmation page |
|
2228 | + * |
|
2229 | + * @var boolean $skip_reg_confirmation |
|
2230 | + */ |
|
2231 | + public $skip_reg_confirmation; |
|
2232 | + |
|
2233 | + /** |
|
2234 | + * an array of SPCO reg steps where: |
|
2235 | + * the keys denotes the reg step order |
|
2236 | + * each element consists of an array with the following elements: |
|
2237 | + * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2238 | + * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2239 | + * "slug" => the URL param used to trigger the reg step |
|
2240 | + * |
|
2241 | + * @var array $reg_steps |
|
2242 | + */ |
|
2243 | + public $reg_steps; |
|
2244 | + |
|
2245 | + /** |
|
2246 | + * Whether registration confirmation should be the last page of SPCO |
|
2247 | + * |
|
2248 | + * @var boolean $reg_confirmation_last |
|
2249 | + */ |
|
2250 | + public $reg_confirmation_last; |
|
2251 | + |
|
2252 | + /** |
|
2253 | + * Whether or not to enable the EE Bot Trap |
|
2254 | + * |
|
2255 | + * @var boolean $use_bot_trap |
|
2256 | + */ |
|
2257 | + public $use_bot_trap; |
|
2258 | + |
|
2259 | + /** |
|
2260 | + * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2261 | + * |
|
2262 | + * @var boolean $use_encryption |
|
2263 | + */ |
|
2264 | + public $use_encryption; |
|
2265 | + |
|
2266 | + /** |
|
2267 | + * Whether or not to use ReCaptcha |
|
2268 | + * |
|
2269 | + * @var boolean $use_captcha |
|
2270 | + */ |
|
2271 | + public $use_captcha; |
|
2272 | + |
|
2273 | + /** |
|
2274 | + * ReCaptcha Theme |
|
2275 | + * |
|
2276 | + * @var string $recaptcha_theme |
|
2277 | + * options: 'dark', 'light', 'invisible' |
|
2278 | + */ |
|
2279 | + public $recaptcha_theme; |
|
2280 | + |
|
2281 | + /** |
|
2282 | + * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
2283 | + * |
|
2284 | + * @var string $recaptcha_badge |
|
2285 | + * options: 'bottomright', 'bottomleft', 'inline' |
|
2286 | + */ |
|
2287 | + public $recaptcha_badge; |
|
2288 | + |
|
2289 | + /** |
|
2290 | + * ReCaptcha Type |
|
2291 | + * |
|
2292 | + * @var string $recaptcha_type |
|
2293 | + * options: 'audio', 'image' |
|
2294 | + */ |
|
2295 | + public $recaptcha_type; |
|
2296 | + |
|
2297 | + /** |
|
2298 | + * ReCaptcha language |
|
2299 | + * |
|
2300 | + * @var string $recaptcha_language |
|
2301 | + * eg 'en' |
|
2302 | + */ |
|
2303 | + public $recaptcha_language; |
|
2304 | + |
|
2305 | + /** |
|
2306 | + * ReCaptcha public key |
|
2307 | + * |
|
2308 | + * @var string $recaptcha_publickey |
|
2309 | + */ |
|
2310 | + public $recaptcha_publickey; |
|
2311 | + |
|
2312 | + /** |
|
2313 | + * ReCaptcha private key |
|
2314 | + * |
|
2315 | + * @var string $recaptcha_privatekey |
|
2316 | + */ |
|
2317 | + public $recaptcha_privatekey; |
|
2318 | + |
|
2319 | + /** |
|
2320 | + * array of form names protected by ReCaptcha |
|
2321 | + * |
|
2322 | + * @var array $recaptcha_protected_forms |
|
2323 | + */ |
|
2324 | + public $recaptcha_protected_forms; |
|
2325 | + |
|
2326 | + /** |
|
2327 | + * ReCaptcha width |
|
2328 | + * |
|
2329 | + * @var int $recaptcha_width |
|
2330 | + * @deprecated |
|
2331 | + */ |
|
2332 | + public $recaptcha_width; |
|
2333 | + |
|
2334 | + /** |
|
2335 | + * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2336 | + * |
|
2337 | + * @var boolean $track_invalid_checkout_access |
|
2338 | + */ |
|
2339 | + protected $track_invalid_checkout_access = true; |
|
2340 | + |
|
2341 | + /** |
|
2342 | + * String describing how long to keep payment logs. Passed into DateTime constructor |
|
2343 | + * @var string |
|
2344 | + */ |
|
2345 | + public $gateway_log_lifespan = '1 week'; |
|
2346 | + |
|
2347 | + |
|
2348 | + /** |
|
2349 | + * class constructor |
|
2350 | + * |
|
2351 | + * @access public |
|
2352 | + */ |
|
2353 | + public function __construct() |
|
2354 | + { |
|
2355 | + // set default registration settings |
|
2356 | + $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2357 | + $this->email_validation_level = 'wp_default'; |
|
2358 | + $this->show_pending_payment_options = true; |
|
2359 | + $this->skip_reg_confirmation = true; |
|
2360 | + $this->reg_steps = array(); |
|
2361 | + $this->reg_confirmation_last = false; |
|
2362 | + $this->use_bot_trap = true; |
|
2363 | + $this->use_encryption = true; |
|
2364 | + $this->use_captcha = false; |
|
2365 | + $this->recaptcha_theme = 'light'; |
|
2366 | + $this->recaptcha_badge = 'bottomleft'; |
|
2367 | + $this->recaptcha_type = 'image'; |
|
2368 | + $this->recaptcha_language = 'en'; |
|
2369 | + $this->recaptcha_publickey = null; |
|
2370 | + $this->recaptcha_privatekey = null; |
|
2371 | + $this->recaptcha_protected_forms = array(); |
|
2372 | + $this->recaptcha_width = 500; |
|
2373 | + $this->default_maximum_number_of_tickets = 10; |
|
2374 | + $this->gateway_log_lifespan = '7 days'; |
|
2375 | + } |
|
2376 | + |
|
2377 | + |
|
2378 | + /** |
|
2379 | + * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2380 | + * |
|
2381 | + * @since 4.8.8.rc.019 |
|
2382 | + */ |
|
2383 | + public function do_hooks() |
|
2384 | + { |
|
2385 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2386 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
2387 | + } |
|
2388 | + |
|
2389 | + |
|
2390 | + /** |
|
2391 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the |
|
2392 | + * EVT_default_registration_status field matches the config setting for default_STS_ID. |
|
2393 | + */ |
|
2394 | + public function set_default_reg_status_on_EEM_Event() |
|
2395 | + { |
|
2396 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2397 | + } |
|
2398 | + |
|
2399 | + |
|
2400 | + /** |
|
2401 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
2402 | + * for Events matches the config setting for default_maximum_number_of_tickets |
|
2403 | + */ |
|
2404 | + public function set_default_max_ticket_on_EEM_Event() |
|
2405 | + { |
|
2406 | + EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
2407 | + } |
|
2408 | + |
|
2409 | + |
|
2410 | + /** |
|
2411 | + * @return boolean |
|
2412 | + */ |
|
2413 | + public function track_invalid_checkout_access() |
|
2414 | + { |
|
2415 | + return $this->track_invalid_checkout_access; |
|
2416 | + } |
|
2417 | + |
|
2418 | + |
|
2419 | + /** |
|
2420 | + * @param boolean $track_invalid_checkout_access |
|
2421 | + */ |
|
2422 | + public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2423 | + { |
|
2424 | + $this->track_invalid_checkout_access = filter_var( |
|
2425 | + $track_invalid_checkout_access, |
|
2426 | + FILTER_VALIDATE_BOOLEAN |
|
2427 | + ); |
|
2428 | + } |
|
2429 | + |
|
2430 | + |
|
2431 | + /** |
|
2432 | + * Gets the options to make availalbe for the gateway log lifespan |
|
2433 | + * @return array |
|
2434 | + */ |
|
2435 | + public function gatewayLogLifespanOptions() |
|
2436 | + { |
|
2437 | + return (array) apply_filters( |
|
2438 | + 'FHEE_EE_Admin_Config__gatewayLogLifespanOptions', |
|
2439 | + array( |
|
2440 | + '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'), |
|
2441 | + '1 day' => esc_html__('1 Day', 'event_espresso'), |
|
2442 | + '7 days' => esc_html__('7 Days', 'event_espresso'), |
|
2443 | + '14 days' => esc_html__('14 Days', 'event_espresso'), |
|
2444 | + '30 days' => esc_html__('30 Days', 'event_espresso') |
|
2445 | + ) |
|
2446 | + ); |
|
2447 | + } |
|
2448 | 2448 | } |
2449 | 2449 | |
2450 | 2450 | |
@@ -2454,154 +2454,154 @@ discard block |
||
2454 | 2454 | class EE_Admin_Config extends EE_Config_Base |
2455 | 2455 | { |
2456 | 2456 | |
2457 | - /** |
|
2458 | - * @var boolean $use_personnel_manager |
|
2459 | - */ |
|
2460 | - public $use_personnel_manager; |
|
2461 | - |
|
2462 | - /** |
|
2463 | - * @var boolean $use_dashboard_widget |
|
2464 | - */ |
|
2465 | - public $use_dashboard_widget; |
|
2466 | - |
|
2467 | - /** |
|
2468 | - * @var int $events_in_dashboard |
|
2469 | - */ |
|
2470 | - public $events_in_dashboard; |
|
2471 | - |
|
2472 | - /** |
|
2473 | - * @var boolean $use_event_timezones |
|
2474 | - */ |
|
2475 | - public $use_event_timezones; |
|
2476 | - |
|
2477 | - /** |
|
2478 | - * @var boolean $use_full_logging |
|
2479 | - */ |
|
2480 | - public $use_full_logging; |
|
2481 | - |
|
2482 | - /** |
|
2483 | - * @var string $log_file_name |
|
2484 | - */ |
|
2485 | - public $log_file_name; |
|
2486 | - |
|
2487 | - /** |
|
2488 | - * @var string $debug_file_name |
|
2489 | - */ |
|
2490 | - public $debug_file_name; |
|
2491 | - |
|
2492 | - /** |
|
2493 | - * @var boolean $use_remote_logging |
|
2494 | - */ |
|
2495 | - public $use_remote_logging; |
|
2496 | - |
|
2497 | - /** |
|
2498 | - * @var string $remote_logging_url |
|
2499 | - */ |
|
2500 | - public $remote_logging_url; |
|
2501 | - |
|
2502 | - /** |
|
2503 | - * @var boolean $show_reg_footer |
|
2504 | - */ |
|
2505 | - public $show_reg_footer; |
|
2506 | - |
|
2507 | - /** |
|
2508 | - * @var string $affiliate_id |
|
2509 | - */ |
|
2510 | - public $affiliate_id; |
|
2511 | - |
|
2512 | - /** |
|
2513 | - * help tours on or off (global setting) |
|
2514 | - * |
|
2515 | - * @var boolean |
|
2516 | - */ |
|
2517 | - public $help_tour_activation; |
|
2518 | - |
|
2519 | - /** |
|
2520 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
2521 | - * but is incompatible with some server configuration errors |
|
2522 | - * if you get "500 internal server errors" during registration, try turning this on |
|
2523 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2524 | - * |
|
2525 | - * @var boolean $encode_session_data |
|
2526 | - */ |
|
2527 | - private $encode_session_data = false; |
|
2528 | - |
|
2529 | - |
|
2530 | - /** |
|
2531 | - * class constructor |
|
2532 | - * |
|
2533 | - * @access public |
|
2534 | - */ |
|
2535 | - public function __construct() |
|
2536 | - { |
|
2537 | - // set default general admin settings |
|
2538 | - $this->use_personnel_manager = true; |
|
2539 | - $this->use_dashboard_widget = true; |
|
2540 | - $this->events_in_dashboard = 30; |
|
2541 | - $this->use_event_timezones = false; |
|
2542 | - $this->use_full_logging = false; |
|
2543 | - $this->use_remote_logging = false; |
|
2544 | - $this->remote_logging_url = null; |
|
2545 | - $this->show_reg_footer = true; |
|
2546 | - $this->affiliate_id = 'default'; |
|
2547 | - $this->help_tour_activation = true; |
|
2548 | - $this->encode_session_data = false; |
|
2549 | - } |
|
2550 | - |
|
2551 | - |
|
2552 | - /** |
|
2553 | - * @param bool $reset |
|
2554 | - * @return string |
|
2555 | - */ |
|
2556 | - public function log_file_name($reset = false) |
|
2557 | - { |
|
2558 | - if (empty($this->log_file_name) || $reset) { |
|
2559 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2560 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2561 | - } |
|
2562 | - return $this->log_file_name; |
|
2563 | - } |
|
2564 | - |
|
2565 | - |
|
2566 | - /** |
|
2567 | - * @param bool $reset |
|
2568 | - * @return string |
|
2569 | - */ |
|
2570 | - public function debug_file_name($reset = false) |
|
2571 | - { |
|
2572 | - if (empty($this->debug_file_name) || $reset) { |
|
2573 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2574 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2575 | - } |
|
2576 | - return $this->debug_file_name; |
|
2577 | - } |
|
2578 | - |
|
2579 | - |
|
2580 | - /** |
|
2581 | - * @return string |
|
2582 | - */ |
|
2583 | - public function affiliate_id() |
|
2584 | - { |
|
2585 | - return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2586 | - } |
|
2587 | - |
|
2588 | - |
|
2589 | - /** |
|
2590 | - * @return boolean |
|
2591 | - */ |
|
2592 | - public function encode_session_data() |
|
2593 | - { |
|
2594 | - return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2595 | - } |
|
2596 | - |
|
2597 | - |
|
2598 | - /** |
|
2599 | - * @param boolean $encode_session_data |
|
2600 | - */ |
|
2601 | - public function set_encode_session_data($encode_session_data) |
|
2602 | - { |
|
2603 | - $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2604 | - } |
|
2457 | + /** |
|
2458 | + * @var boolean $use_personnel_manager |
|
2459 | + */ |
|
2460 | + public $use_personnel_manager; |
|
2461 | + |
|
2462 | + /** |
|
2463 | + * @var boolean $use_dashboard_widget |
|
2464 | + */ |
|
2465 | + public $use_dashboard_widget; |
|
2466 | + |
|
2467 | + /** |
|
2468 | + * @var int $events_in_dashboard |
|
2469 | + */ |
|
2470 | + public $events_in_dashboard; |
|
2471 | + |
|
2472 | + /** |
|
2473 | + * @var boolean $use_event_timezones |
|
2474 | + */ |
|
2475 | + public $use_event_timezones; |
|
2476 | + |
|
2477 | + /** |
|
2478 | + * @var boolean $use_full_logging |
|
2479 | + */ |
|
2480 | + public $use_full_logging; |
|
2481 | + |
|
2482 | + /** |
|
2483 | + * @var string $log_file_name |
|
2484 | + */ |
|
2485 | + public $log_file_name; |
|
2486 | + |
|
2487 | + /** |
|
2488 | + * @var string $debug_file_name |
|
2489 | + */ |
|
2490 | + public $debug_file_name; |
|
2491 | + |
|
2492 | + /** |
|
2493 | + * @var boolean $use_remote_logging |
|
2494 | + */ |
|
2495 | + public $use_remote_logging; |
|
2496 | + |
|
2497 | + /** |
|
2498 | + * @var string $remote_logging_url |
|
2499 | + */ |
|
2500 | + public $remote_logging_url; |
|
2501 | + |
|
2502 | + /** |
|
2503 | + * @var boolean $show_reg_footer |
|
2504 | + */ |
|
2505 | + public $show_reg_footer; |
|
2506 | + |
|
2507 | + /** |
|
2508 | + * @var string $affiliate_id |
|
2509 | + */ |
|
2510 | + public $affiliate_id; |
|
2511 | + |
|
2512 | + /** |
|
2513 | + * help tours on or off (global setting) |
|
2514 | + * |
|
2515 | + * @var boolean |
|
2516 | + */ |
|
2517 | + public $help_tour_activation; |
|
2518 | + |
|
2519 | + /** |
|
2520 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
2521 | + * but is incompatible with some server configuration errors |
|
2522 | + * if you get "500 internal server errors" during registration, try turning this on |
|
2523 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2524 | + * |
|
2525 | + * @var boolean $encode_session_data |
|
2526 | + */ |
|
2527 | + private $encode_session_data = false; |
|
2528 | + |
|
2529 | + |
|
2530 | + /** |
|
2531 | + * class constructor |
|
2532 | + * |
|
2533 | + * @access public |
|
2534 | + */ |
|
2535 | + public function __construct() |
|
2536 | + { |
|
2537 | + // set default general admin settings |
|
2538 | + $this->use_personnel_manager = true; |
|
2539 | + $this->use_dashboard_widget = true; |
|
2540 | + $this->events_in_dashboard = 30; |
|
2541 | + $this->use_event_timezones = false; |
|
2542 | + $this->use_full_logging = false; |
|
2543 | + $this->use_remote_logging = false; |
|
2544 | + $this->remote_logging_url = null; |
|
2545 | + $this->show_reg_footer = true; |
|
2546 | + $this->affiliate_id = 'default'; |
|
2547 | + $this->help_tour_activation = true; |
|
2548 | + $this->encode_session_data = false; |
|
2549 | + } |
|
2550 | + |
|
2551 | + |
|
2552 | + /** |
|
2553 | + * @param bool $reset |
|
2554 | + * @return string |
|
2555 | + */ |
|
2556 | + public function log_file_name($reset = false) |
|
2557 | + { |
|
2558 | + if (empty($this->log_file_name) || $reset) { |
|
2559 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2560 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2561 | + } |
|
2562 | + return $this->log_file_name; |
|
2563 | + } |
|
2564 | + |
|
2565 | + |
|
2566 | + /** |
|
2567 | + * @param bool $reset |
|
2568 | + * @return string |
|
2569 | + */ |
|
2570 | + public function debug_file_name($reset = false) |
|
2571 | + { |
|
2572 | + if (empty($this->debug_file_name) || $reset) { |
|
2573 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2574 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2575 | + } |
|
2576 | + return $this->debug_file_name; |
|
2577 | + } |
|
2578 | + |
|
2579 | + |
|
2580 | + /** |
|
2581 | + * @return string |
|
2582 | + */ |
|
2583 | + public function affiliate_id() |
|
2584 | + { |
|
2585 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2586 | + } |
|
2587 | + |
|
2588 | + |
|
2589 | + /** |
|
2590 | + * @return boolean |
|
2591 | + */ |
|
2592 | + public function encode_session_data() |
|
2593 | + { |
|
2594 | + return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2595 | + } |
|
2596 | + |
|
2597 | + |
|
2598 | + /** |
|
2599 | + * @param boolean $encode_session_data |
|
2600 | + */ |
|
2601 | + public function set_encode_session_data($encode_session_data) |
|
2602 | + { |
|
2603 | + $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2604 | + } |
|
2605 | 2605 | } |
2606 | 2606 | |
2607 | 2607 | |
@@ -2611,70 +2611,70 @@ discard block |
||
2611 | 2611 | class EE_Template_Config extends EE_Config_Base |
2612 | 2612 | { |
2613 | 2613 | |
2614 | - /** |
|
2615 | - * @var boolean $enable_default_style |
|
2616 | - */ |
|
2617 | - public $enable_default_style; |
|
2618 | - |
|
2619 | - /** |
|
2620 | - * @var string $custom_style_sheet |
|
2621 | - */ |
|
2622 | - public $custom_style_sheet; |
|
2623 | - |
|
2624 | - /** |
|
2625 | - * @var boolean $display_address_in_regform |
|
2626 | - */ |
|
2627 | - public $display_address_in_regform; |
|
2628 | - |
|
2629 | - /** |
|
2630 | - * @var int $display_description_on_multi_reg_page |
|
2631 | - */ |
|
2632 | - public $display_description_on_multi_reg_page; |
|
2633 | - |
|
2634 | - /** |
|
2635 | - * @var boolean $use_custom_templates |
|
2636 | - */ |
|
2637 | - public $use_custom_templates; |
|
2638 | - |
|
2639 | - /** |
|
2640 | - * @var string $current_espresso_theme |
|
2641 | - */ |
|
2642 | - public $current_espresso_theme; |
|
2643 | - |
|
2644 | - /** |
|
2645 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2646 | - */ |
|
2647 | - public $EED_Ticket_Selector; |
|
2648 | - |
|
2649 | - /** |
|
2650 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
2651 | - */ |
|
2652 | - public $EED_Event_Single; |
|
2653 | - |
|
2654 | - /** |
|
2655 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2656 | - */ |
|
2657 | - public $EED_Events_Archive; |
|
2658 | - |
|
2659 | - |
|
2660 | - /** |
|
2661 | - * class constructor |
|
2662 | - * |
|
2663 | - * @access public |
|
2664 | - */ |
|
2665 | - public function __construct() |
|
2666 | - { |
|
2667 | - // set default template settings |
|
2668 | - $this->enable_default_style = true; |
|
2669 | - $this->custom_style_sheet = null; |
|
2670 | - $this->display_address_in_regform = true; |
|
2671 | - $this->display_description_on_multi_reg_page = false; |
|
2672 | - $this->use_custom_templates = false; |
|
2673 | - $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2674 | - $this->EED_Event_Single = null; |
|
2675 | - $this->EED_Events_Archive = null; |
|
2676 | - $this->EED_Ticket_Selector = null; |
|
2677 | - } |
|
2614 | + /** |
|
2615 | + * @var boolean $enable_default_style |
|
2616 | + */ |
|
2617 | + public $enable_default_style; |
|
2618 | + |
|
2619 | + /** |
|
2620 | + * @var string $custom_style_sheet |
|
2621 | + */ |
|
2622 | + public $custom_style_sheet; |
|
2623 | + |
|
2624 | + /** |
|
2625 | + * @var boolean $display_address_in_regform |
|
2626 | + */ |
|
2627 | + public $display_address_in_regform; |
|
2628 | + |
|
2629 | + /** |
|
2630 | + * @var int $display_description_on_multi_reg_page |
|
2631 | + */ |
|
2632 | + public $display_description_on_multi_reg_page; |
|
2633 | + |
|
2634 | + /** |
|
2635 | + * @var boolean $use_custom_templates |
|
2636 | + */ |
|
2637 | + public $use_custom_templates; |
|
2638 | + |
|
2639 | + /** |
|
2640 | + * @var string $current_espresso_theme |
|
2641 | + */ |
|
2642 | + public $current_espresso_theme; |
|
2643 | + |
|
2644 | + /** |
|
2645 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2646 | + */ |
|
2647 | + public $EED_Ticket_Selector; |
|
2648 | + |
|
2649 | + /** |
|
2650 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
2651 | + */ |
|
2652 | + public $EED_Event_Single; |
|
2653 | + |
|
2654 | + /** |
|
2655 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2656 | + */ |
|
2657 | + public $EED_Events_Archive; |
|
2658 | + |
|
2659 | + |
|
2660 | + /** |
|
2661 | + * class constructor |
|
2662 | + * |
|
2663 | + * @access public |
|
2664 | + */ |
|
2665 | + public function __construct() |
|
2666 | + { |
|
2667 | + // set default template settings |
|
2668 | + $this->enable_default_style = true; |
|
2669 | + $this->custom_style_sheet = null; |
|
2670 | + $this->display_address_in_regform = true; |
|
2671 | + $this->display_description_on_multi_reg_page = false; |
|
2672 | + $this->use_custom_templates = false; |
|
2673 | + $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2674 | + $this->EED_Event_Single = null; |
|
2675 | + $this->EED_Events_Archive = null; |
|
2676 | + $this->EED_Ticket_Selector = null; |
|
2677 | + } |
|
2678 | 2678 | } |
2679 | 2679 | |
2680 | 2680 | |
@@ -2684,114 +2684,114 @@ discard block |
||
2684 | 2684 | class EE_Map_Config extends EE_Config_Base |
2685 | 2685 | { |
2686 | 2686 | |
2687 | - /** |
|
2688 | - * @var boolean $use_google_maps |
|
2689 | - */ |
|
2690 | - public $use_google_maps; |
|
2691 | - |
|
2692 | - /** |
|
2693 | - * @var string $api_key |
|
2694 | - */ |
|
2695 | - public $google_map_api_key; |
|
2696 | - |
|
2697 | - /** |
|
2698 | - * @var int $event_details_map_width |
|
2699 | - */ |
|
2700 | - public $event_details_map_width; |
|
2701 | - |
|
2702 | - /** |
|
2703 | - * @var int $event_details_map_height |
|
2704 | - */ |
|
2705 | - public $event_details_map_height; |
|
2706 | - |
|
2707 | - /** |
|
2708 | - * @var int $event_details_map_zoom |
|
2709 | - */ |
|
2710 | - public $event_details_map_zoom; |
|
2711 | - |
|
2712 | - /** |
|
2713 | - * @var boolean $event_details_display_nav |
|
2714 | - */ |
|
2715 | - public $event_details_display_nav; |
|
2716 | - |
|
2717 | - /** |
|
2718 | - * @var boolean $event_details_nav_size |
|
2719 | - */ |
|
2720 | - public $event_details_nav_size; |
|
2721 | - |
|
2722 | - /** |
|
2723 | - * @var string $event_details_control_type |
|
2724 | - */ |
|
2725 | - public $event_details_control_type; |
|
2726 | - |
|
2727 | - /** |
|
2728 | - * @var string $event_details_map_align |
|
2729 | - */ |
|
2730 | - public $event_details_map_align; |
|
2731 | - |
|
2732 | - /** |
|
2733 | - * @var int $event_list_map_width |
|
2734 | - */ |
|
2735 | - public $event_list_map_width; |
|
2736 | - |
|
2737 | - /** |
|
2738 | - * @var int $event_list_map_height |
|
2739 | - */ |
|
2740 | - public $event_list_map_height; |
|
2741 | - |
|
2742 | - /** |
|
2743 | - * @var int $event_list_map_zoom |
|
2744 | - */ |
|
2745 | - public $event_list_map_zoom; |
|
2746 | - |
|
2747 | - /** |
|
2748 | - * @var boolean $event_list_display_nav |
|
2749 | - */ |
|
2750 | - public $event_list_display_nav; |
|
2751 | - |
|
2752 | - /** |
|
2753 | - * @var boolean $event_list_nav_size |
|
2754 | - */ |
|
2755 | - public $event_list_nav_size; |
|
2756 | - |
|
2757 | - /** |
|
2758 | - * @var string $event_list_control_type |
|
2759 | - */ |
|
2760 | - public $event_list_control_type; |
|
2761 | - |
|
2762 | - /** |
|
2763 | - * @var string $event_list_map_align |
|
2764 | - */ |
|
2765 | - public $event_list_map_align; |
|
2766 | - |
|
2767 | - |
|
2768 | - /** |
|
2769 | - * class constructor |
|
2770 | - * |
|
2771 | - * @access public |
|
2772 | - */ |
|
2773 | - public function __construct() |
|
2774 | - { |
|
2775 | - // set default map settings |
|
2776 | - $this->use_google_maps = true; |
|
2777 | - $this->google_map_api_key = ''; |
|
2778 | - // for event details pages (reg page) |
|
2779 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2780 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2781 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2782 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2783 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2784 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2785 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2786 | - // for event list pages |
|
2787 | - $this->event_list_map_width = 300; // ee_map_width |
|
2788 | - $this->event_list_map_height = 185; // ee_map_height |
|
2789 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2790 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2791 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2792 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2793 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2794 | - } |
|
2687 | + /** |
|
2688 | + * @var boolean $use_google_maps |
|
2689 | + */ |
|
2690 | + public $use_google_maps; |
|
2691 | + |
|
2692 | + /** |
|
2693 | + * @var string $api_key |
|
2694 | + */ |
|
2695 | + public $google_map_api_key; |
|
2696 | + |
|
2697 | + /** |
|
2698 | + * @var int $event_details_map_width |
|
2699 | + */ |
|
2700 | + public $event_details_map_width; |
|
2701 | + |
|
2702 | + /** |
|
2703 | + * @var int $event_details_map_height |
|
2704 | + */ |
|
2705 | + public $event_details_map_height; |
|
2706 | + |
|
2707 | + /** |
|
2708 | + * @var int $event_details_map_zoom |
|
2709 | + */ |
|
2710 | + public $event_details_map_zoom; |
|
2711 | + |
|
2712 | + /** |
|
2713 | + * @var boolean $event_details_display_nav |
|
2714 | + */ |
|
2715 | + public $event_details_display_nav; |
|
2716 | + |
|
2717 | + /** |
|
2718 | + * @var boolean $event_details_nav_size |
|
2719 | + */ |
|
2720 | + public $event_details_nav_size; |
|
2721 | + |
|
2722 | + /** |
|
2723 | + * @var string $event_details_control_type |
|
2724 | + */ |
|
2725 | + public $event_details_control_type; |
|
2726 | + |
|
2727 | + /** |
|
2728 | + * @var string $event_details_map_align |
|
2729 | + */ |
|
2730 | + public $event_details_map_align; |
|
2731 | + |
|
2732 | + /** |
|
2733 | + * @var int $event_list_map_width |
|
2734 | + */ |
|
2735 | + public $event_list_map_width; |
|
2736 | + |
|
2737 | + /** |
|
2738 | + * @var int $event_list_map_height |
|
2739 | + */ |
|
2740 | + public $event_list_map_height; |
|
2741 | + |
|
2742 | + /** |
|
2743 | + * @var int $event_list_map_zoom |
|
2744 | + */ |
|
2745 | + public $event_list_map_zoom; |
|
2746 | + |
|
2747 | + /** |
|
2748 | + * @var boolean $event_list_display_nav |
|
2749 | + */ |
|
2750 | + public $event_list_display_nav; |
|
2751 | + |
|
2752 | + /** |
|
2753 | + * @var boolean $event_list_nav_size |
|
2754 | + */ |
|
2755 | + public $event_list_nav_size; |
|
2756 | + |
|
2757 | + /** |
|
2758 | + * @var string $event_list_control_type |
|
2759 | + */ |
|
2760 | + public $event_list_control_type; |
|
2761 | + |
|
2762 | + /** |
|
2763 | + * @var string $event_list_map_align |
|
2764 | + */ |
|
2765 | + public $event_list_map_align; |
|
2766 | + |
|
2767 | + |
|
2768 | + /** |
|
2769 | + * class constructor |
|
2770 | + * |
|
2771 | + * @access public |
|
2772 | + */ |
|
2773 | + public function __construct() |
|
2774 | + { |
|
2775 | + // set default map settings |
|
2776 | + $this->use_google_maps = true; |
|
2777 | + $this->google_map_api_key = ''; |
|
2778 | + // for event details pages (reg page) |
|
2779 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2780 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2781 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2782 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2783 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2784 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2785 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2786 | + // for event list pages |
|
2787 | + $this->event_list_map_width = 300; // ee_map_width |
|
2788 | + $this->event_list_map_height = 185; // ee_map_height |
|
2789 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2790 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2791 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2792 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2793 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2794 | + } |
|
2795 | 2795 | } |
2796 | 2796 | |
2797 | 2797 | |
@@ -2801,46 +2801,46 @@ discard block |
||
2801 | 2801 | class EE_Events_Archive_Config extends EE_Config_Base |
2802 | 2802 | { |
2803 | 2803 | |
2804 | - public $display_status_banner; |
|
2804 | + public $display_status_banner; |
|
2805 | 2805 | |
2806 | - public $display_description; |
|
2806 | + public $display_description; |
|
2807 | 2807 | |
2808 | - public $display_ticket_selector; |
|
2808 | + public $display_ticket_selector; |
|
2809 | 2809 | |
2810 | - public $display_datetimes; |
|
2810 | + public $display_datetimes; |
|
2811 | 2811 | |
2812 | - public $display_venue; |
|
2812 | + public $display_venue; |
|
2813 | 2813 | |
2814 | - public $display_expired_events; |
|
2814 | + public $display_expired_events; |
|
2815 | 2815 | |
2816 | - public $use_sortable_display_order; |
|
2816 | + public $use_sortable_display_order; |
|
2817 | 2817 | |
2818 | - public $display_order_tickets; |
|
2818 | + public $display_order_tickets; |
|
2819 | 2819 | |
2820 | - public $display_order_datetimes; |
|
2820 | + public $display_order_datetimes; |
|
2821 | 2821 | |
2822 | - public $display_order_event; |
|
2822 | + public $display_order_event; |
|
2823 | 2823 | |
2824 | - public $display_order_venue; |
|
2824 | + public $display_order_venue; |
|
2825 | 2825 | |
2826 | 2826 | |
2827 | - /** |
|
2828 | - * class constructor |
|
2829 | - */ |
|
2830 | - public function __construct() |
|
2831 | - { |
|
2832 | - $this->display_status_banner = 0; |
|
2833 | - $this->display_description = 1; |
|
2834 | - $this->display_ticket_selector = 0; |
|
2835 | - $this->display_datetimes = 1; |
|
2836 | - $this->display_venue = 0; |
|
2837 | - $this->display_expired_events = 0; |
|
2838 | - $this->use_sortable_display_order = false; |
|
2839 | - $this->display_order_tickets = 100; |
|
2840 | - $this->display_order_datetimes = 110; |
|
2841 | - $this->display_order_event = 120; |
|
2842 | - $this->display_order_venue = 130; |
|
2843 | - } |
|
2827 | + /** |
|
2828 | + * class constructor |
|
2829 | + */ |
|
2830 | + public function __construct() |
|
2831 | + { |
|
2832 | + $this->display_status_banner = 0; |
|
2833 | + $this->display_description = 1; |
|
2834 | + $this->display_ticket_selector = 0; |
|
2835 | + $this->display_datetimes = 1; |
|
2836 | + $this->display_venue = 0; |
|
2837 | + $this->display_expired_events = 0; |
|
2838 | + $this->use_sortable_display_order = false; |
|
2839 | + $this->display_order_tickets = 100; |
|
2840 | + $this->display_order_datetimes = 110; |
|
2841 | + $this->display_order_event = 120; |
|
2842 | + $this->display_order_venue = 130; |
|
2843 | + } |
|
2844 | 2844 | } |
2845 | 2845 | |
2846 | 2846 | |
@@ -2850,34 +2850,34 @@ discard block |
||
2850 | 2850 | class EE_Event_Single_Config extends EE_Config_Base |
2851 | 2851 | { |
2852 | 2852 | |
2853 | - public $display_status_banner_single; |
|
2853 | + public $display_status_banner_single; |
|
2854 | 2854 | |
2855 | - public $display_venue; |
|
2855 | + public $display_venue; |
|
2856 | 2856 | |
2857 | - public $use_sortable_display_order; |
|
2857 | + public $use_sortable_display_order; |
|
2858 | 2858 | |
2859 | - public $display_order_tickets; |
|
2859 | + public $display_order_tickets; |
|
2860 | 2860 | |
2861 | - public $display_order_datetimes; |
|
2861 | + public $display_order_datetimes; |
|
2862 | 2862 | |
2863 | - public $display_order_event; |
|
2863 | + public $display_order_event; |
|
2864 | 2864 | |
2865 | - public $display_order_venue; |
|
2865 | + public $display_order_venue; |
|
2866 | 2866 | |
2867 | 2867 | |
2868 | - /** |
|
2869 | - * class constructor |
|
2870 | - */ |
|
2871 | - public function __construct() |
|
2872 | - { |
|
2873 | - $this->display_status_banner_single = 0; |
|
2874 | - $this->display_venue = 1; |
|
2875 | - $this->use_sortable_display_order = false; |
|
2876 | - $this->display_order_tickets = 100; |
|
2877 | - $this->display_order_datetimes = 110; |
|
2878 | - $this->display_order_event = 120; |
|
2879 | - $this->display_order_venue = 130; |
|
2880 | - } |
|
2868 | + /** |
|
2869 | + * class constructor |
|
2870 | + */ |
|
2871 | + public function __construct() |
|
2872 | + { |
|
2873 | + $this->display_status_banner_single = 0; |
|
2874 | + $this->display_venue = 1; |
|
2875 | + $this->use_sortable_display_order = false; |
|
2876 | + $this->display_order_tickets = 100; |
|
2877 | + $this->display_order_datetimes = 110; |
|
2878 | + $this->display_order_event = 120; |
|
2879 | + $this->display_order_venue = 130; |
|
2880 | + } |
|
2881 | 2881 | } |
2882 | 2882 | |
2883 | 2883 | |
@@ -2887,146 +2887,146 @@ discard block |
||
2887 | 2887 | class EE_Ticket_Selector_Config extends EE_Config_Base |
2888 | 2888 | { |
2889 | 2889 | |
2890 | - /** |
|
2891 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2892 | - */ |
|
2893 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2894 | - |
|
2895 | - /** |
|
2896 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2897 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2898 | - */ |
|
2899 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2900 | - |
|
2901 | - /** |
|
2902 | - * @var boolean $show_ticket_sale_columns |
|
2903 | - */ |
|
2904 | - public $show_ticket_sale_columns; |
|
2905 | - |
|
2906 | - /** |
|
2907 | - * @var boolean $show_ticket_details |
|
2908 | - */ |
|
2909 | - public $show_ticket_details; |
|
2910 | - |
|
2911 | - /** |
|
2912 | - * @var boolean $show_expired_tickets |
|
2913 | - */ |
|
2914 | - public $show_expired_tickets; |
|
2915 | - |
|
2916 | - /** |
|
2917 | - * whether or not to display a dropdown box populated with event datetimes |
|
2918 | - * that toggles which tickets are displayed for a ticket selector. |
|
2919 | - * uses one of the *_DATETIME_SELECTOR constants defined above |
|
2920 | - * |
|
2921 | - * @var string $show_datetime_selector |
|
2922 | - */ |
|
2923 | - private $show_datetime_selector = 'no_datetime_selector'; |
|
2924 | - |
|
2925 | - /** |
|
2926 | - * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
2927 | - * |
|
2928 | - * @var int $datetime_selector_threshold |
|
2929 | - */ |
|
2930 | - private $datetime_selector_threshold = 3; |
|
2931 | - |
|
2932 | - |
|
2933 | - /** |
|
2934 | - * class constructor |
|
2935 | - */ |
|
2936 | - public function __construct() |
|
2937 | - { |
|
2938 | - $this->show_ticket_sale_columns = true; |
|
2939 | - $this->show_ticket_details = true; |
|
2940 | - $this->show_expired_tickets = true; |
|
2941 | - $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
2942 | - $this->datetime_selector_threshold = 3; |
|
2943 | - } |
|
2944 | - |
|
2945 | - |
|
2946 | - /** |
|
2947 | - * returns true if a datetime selector should be displayed |
|
2948 | - * |
|
2949 | - * @param array $datetimes |
|
2950 | - * @return bool |
|
2951 | - */ |
|
2952 | - public function showDatetimeSelector(array $datetimes) |
|
2953 | - { |
|
2954 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2955 | - return ! ( |
|
2956 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
2957 | - || ( |
|
2958 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
2959 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
2960 | - ) |
|
2961 | - ); |
|
2962 | - } |
|
2963 | - |
|
2964 | - |
|
2965 | - /** |
|
2966 | - * @return string |
|
2967 | - */ |
|
2968 | - public function getShowDatetimeSelector() |
|
2969 | - { |
|
2970 | - return $this->show_datetime_selector; |
|
2971 | - } |
|
2972 | - |
|
2973 | - |
|
2974 | - /** |
|
2975 | - * @param bool $keys_only |
|
2976 | - * @return array |
|
2977 | - */ |
|
2978 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
2979 | - { |
|
2980 | - return $keys_only |
|
2981 | - ? array( |
|
2982 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
2983 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
2984 | - ) |
|
2985 | - : array( |
|
2986 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2987 | - 'Do not show date & time filter', |
|
2988 | - 'event_espresso' |
|
2989 | - ), |
|
2990 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2991 | - 'Maybe show date & time filter', |
|
2992 | - 'event_espresso' |
|
2993 | - ), |
|
2994 | - ); |
|
2995 | - } |
|
2996 | - |
|
2997 | - |
|
2998 | - /** |
|
2999 | - * @param string $show_datetime_selector |
|
3000 | - */ |
|
3001 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
3002 | - { |
|
3003 | - $this->show_datetime_selector = in_array( |
|
3004 | - $show_datetime_selector, |
|
3005 | - $this->getShowDatetimeSelectorOptions(), |
|
3006 | - true |
|
3007 | - ) |
|
3008 | - ? $show_datetime_selector |
|
3009 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3010 | - } |
|
3011 | - |
|
3012 | - |
|
3013 | - /** |
|
3014 | - * @return int |
|
3015 | - */ |
|
3016 | - public function getDatetimeSelectorThreshold() |
|
3017 | - { |
|
3018 | - return $this->datetime_selector_threshold; |
|
3019 | - } |
|
3020 | - |
|
3021 | - |
|
3022 | - /** |
|
3023 | - * @param int $datetime_selector_threshold |
|
3024 | - */ |
|
3025 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3026 | - { |
|
3027 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3028 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3029 | - } |
|
2890 | + /** |
|
2891 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2892 | + */ |
|
2893 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2894 | + |
|
2895 | + /** |
|
2896 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2897 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2898 | + */ |
|
2899 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2900 | + |
|
2901 | + /** |
|
2902 | + * @var boolean $show_ticket_sale_columns |
|
2903 | + */ |
|
2904 | + public $show_ticket_sale_columns; |
|
2905 | + |
|
2906 | + /** |
|
2907 | + * @var boolean $show_ticket_details |
|
2908 | + */ |
|
2909 | + public $show_ticket_details; |
|
2910 | + |
|
2911 | + /** |
|
2912 | + * @var boolean $show_expired_tickets |
|
2913 | + */ |
|
2914 | + public $show_expired_tickets; |
|
2915 | + |
|
2916 | + /** |
|
2917 | + * whether or not to display a dropdown box populated with event datetimes |
|
2918 | + * that toggles which tickets are displayed for a ticket selector. |
|
2919 | + * uses one of the *_DATETIME_SELECTOR constants defined above |
|
2920 | + * |
|
2921 | + * @var string $show_datetime_selector |
|
2922 | + */ |
|
2923 | + private $show_datetime_selector = 'no_datetime_selector'; |
|
2924 | + |
|
2925 | + /** |
|
2926 | + * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
2927 | + * |
|
2928 | + * @var int $datetime_selector_threshold |
|
2929 | + */ |
|
2930 | + private $datetime_selector_threshold = 3; |
|
2931 | + |
|
2932 | + |
|
2933 | + /** |
|
2934 | + * class constructor |
|
2935 | + */ |
|
2936 | + public function __construct() |
|
2937 | + { |
|
2938 | + $this->show_ticket_sale_columns = true; |
|
2939 | + $this->show_ticket_details = true; |
|
2940 | + $this->show_expired_tickets = true; |
|
2941 | + $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
2942 | + $this->datetime_selector_threshold = 3; |
|
2943 | + } |
|
2944 | + |
|
2945 | + |
|
2946 | + /** |
|
2947 | + * returns true if a datetime selector should be displayed |
|
2948 | + * |
|
2949 | + * @param array $datetimes |
|
2950 | + * @return bool |
|
2951 | + */ |
|
2952 | + public function showDatetimeSelector(array $datetimes) |
|
2953 | + { |
|
2954 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2955 | + return ! ( |
|
2956 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
2957 | + || ( |
|
2958 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
2959 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
2960 | + ) |
|
2961 | + ); |
|
2962 | + } |
|
2963 | + |
|
2964 | + |
|
2965 | + /** |
|
2966 | + * @return string |
|
2967 | + */ |
|
2968 | + public function getShowDatetimeSelector() |
|
2969 | + { |
|
2970 | + return $this->show_datetime_selector; |
|
2971 | + } |
|
2972 | + |
|
2973 | + |
|
2974 | + /** |
|
2975 | + * @param bool $keys_only |
|
2976 | + * @return array |
|
2977 | + */ |
|
2978 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
2979 | + { |
|
2980 | + return $keys_only |
|
2981 | + ? array( |
|
2982 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
2983 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
2984 | + ) |
|
2985 | + : array( |
|
2986 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2987 | + 'Do not show date & time filter', |
|
2988 | + 'event_espresso' |
|
2989 | + ), |
|
2990 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2991 | + 'Maybe show date & time filter', |
|
2992 | + 'event_espresso' |
|
2993 | + ), |
|
2994 | + ); |
|
2995 | + } |
|
2996 | + |
|
2997 | + |
|
2998 | + /** |
|
2999 | + * @param string $show_datetime_selector |
|
3000 | + */ |
|
3001 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
3002 | + { |
|
3003 | + $this->show_datetime_selector = in_array( |
|
3004 | + $show_datetime_selector, |
|
3005 | + $this->getShowDatetimeSelectorOptions(), |
|
3006 | + true |
|
3007 | + ) |
|
3008 | + ? $show_datetime_selector |
|
3009 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3010 | + } |
|
3011 | + |
|
3012 | + |
|
3013 | + /** |
|
3014 | + * @return int |
|
3015 | + */ |
|
3016 | + public function getDatetimeSelectorThreshold() |
|
3017 | + { |
|
3018 | + return $this->datetime_selector_threshold; |
|
3019 | + } |
|
3020 | + |
|
3021 | + |
|
3022 | + /** |
|
3023 | + * @param int $datetime_selector_threshold |
|
3024 | + */ |
|
3025 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3026 | + { |
|
3027 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3028 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3029 | + } |
|
3030 | 3030 | } |
3031 | 3031 | |
3032 | 3032 | |
@@ -3040,81 +3040,81 @@ discard block |
||
3040 | 3040 | class EE_Environment_Config extends EE_Config_Base |
3041 | 3041 | { |
3042 | 3042 | |
3043 | - /** |
|
3044 | - * Hold any php environment variables that we want to track. |
|
3045 | - * |
|
3046 | - * @var stdClass; |
|
3047 | - */ |
|
3048 | - public $php; |
|
3049 | - |
|
3050 | - |
|
3051 | - /** |
|
3052 | - * constructor |
|
3053 | - */ |
|
3054 | - public function __construct() |
|
3055 | - { |
|
3056 | - $this->php = new stdClass(); |
|
3057 | - $this->_set_php_values(); |
|
3058 | - } |
|
3059 | - |
|
3060 | - |
|
3061 | - /** |
|
3062 | - * This sets the php environment variables. |
|
3063 | - * |
|
3064 | - * @since 4.4.0 |
|
3065 | - * @return void |
|
3066 | - */ |
|
3067 | - protected function _set_php_values() |
|
3068 | - { |
|
3069 | - $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3070 | - $this->php->version = phpversion(); |
|
3071 | - } |
|
3072 | - |
|
3073 | - |
|
3074 | - /** |
|
3075 | - * helper method for determining whether input_count is |
|
3076 | - * reaching the potential maximum the server can handle |
|
3077 | - * according to max_input_vars |
|
3078 | - * |
|
3079 | - * @param int $input_count the count of input vars. |
|
3080 | - * @return array { |
|
3081 | - * An array that represents whether available space and if no available space the error |
|
3082 | - * message. |
|
3083 | - * @type bool $has_space whether more inputs can be added. |
|
3084 | - * @type string $msg Any message to be displayed. |
|
3085 | - * } |
|
3086 | - */ |
|
3087 | - public function max_input_vars_limit_check($input_count = 0) |
|
3088 | - { |
|
3089 | - if (! empty($this->php->max_input_vars) |
|
3090 | - && ($input_count >= $this->php->max_input_vars) |
|
3091 | - && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3092 | - ) { |
|
3093 | - return sprintf( |
|
3094 | - __( |
|
3095 | - 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3096 | - 'event_espresso' |
|
3097 | - ), |
|
3098 | - '<br>', |
|
3099 | - $input_count, |
|
3100 | - $this->php->max_input_vars |
|
3101 | - ); |
|
3102 | - } else { |
|
3103 | - return ''; |
|
3104 | - } |
|
3105 | - } |
|
3106 | - |
|
3107 | - |
|
3108 | - /** |
|
3109 | - * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3110 | - * |
|
3111 | - * @since 4.4.1 |
|
3112 | - * @return void |
|
3113 | - */ |
|
3114 | - public function recheck_values() |
|
3115 | - { |
|
3116 | - $this->_set_php_values(); |
|
3117 | - } |
|
3043 | + /** |
|
3044 | + * Hold any php environment variables that we want to track. |
|
3045 | + * |
|
3046 | + * @var stdClass; |
|
3047 | + */ |
|
3048 | + public $php; |
|
3049 | + |
|
3050 | + |
|
3051 | + /** |
|
3052 | + * constructor |
|
3053 | + */ |
|
3054 | + public function __construct() |
|
3055 | + { |
|
3056 | + $this->php = new stdClass(); |
|
3057 | + $this->_set_php_values(); |
|
3058 | + } |
|
3059 | + |
|
3060 | + |
|
3061 | + /** |
|
3062 | + * This sets the php environment variables. |
|
3063 | + * |
|
3064 | + * @since 4.4.0 |
|
3065 | + * @return void |
|
3066 | + */ |
|
3067 | + protected function _set_php_values() |
|
3068 | + { |
|
3069 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3070 | + $this->php->version = phpversion(); |
|
3071 | + } |
|
3072 | + |
|
3073 | + |
|
3074 | + /** |
|
3075 | + * helper method for determining whether input_count is |
|
3076 | + * reaching the potential maximum the server can handle |
|
3077 | + * according to max_input_vars |
|
3078 | + * |
|
3079 | + * @param int $input_count the count of input vars. |
|
3080 | + * @return array { |
|
3081 | + * An array that represents whether available space and if no available space the error |
|
3082 | + * message. |
|
3083 | + * @type bool $has_space whether more inputs can be added. |
|
3084 | + * @type string $msg Any message to be displayed. |
|
3085 | + * } |
|
3086 | + */ |
|
3087 | + public function max_input_vars_limit_check($input_count = 0) |
|
3088 | + { |
|
3089 | + if (! empty($this->php->max_input_vars) |
|
3090 | + && ($input_count >= $this->php->max_input_vars) |
|
3091 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3092 | + ) { |
|
3093 | + return sprintf( |
|
3094 | + __( |
|
3095 | + 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3096 | + 'event_espresso' |
|
3097 | + ), |
|
3098 | + '<br>', |
|
3099 | + $input_count, |
|
3100 | + $this->php->max_input_vars |
|
3101 | + ); |
|
3102 | + } else { |
|
3103 | + return ''; |
|
3104 | + } |
|
3105 | + } |
|
3106 | + |
|
3107 | + |
|
3108 | + /** |
|
3109 | + * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3110 | + * |
|
3111 | + * @since 4.4.1 |
|
3112 | + * @return void |
|
3113 | + */ |
|
3114 | + public function recheck_values() |
|
3115 | + { |
|
3116 | + $this->_set_php_values(); |
|
3117 | + } |
|
3118 | 3118 | } |
3119 | 3119 | |
3120 | 3120 | |
@@ -3128,21 +3128,21 @@ discard block |
||
3128 | 3128 | class EE_Tax_Config extends EE_Config_Base |
3129 | 3129 | { |
3130 | 3130 | |
3131 | - /* |
|
3131 | + /* |
|
3132 | 3132 | * flag to indicate whether or not to display ticket prices with the taxes included |
3133 | 3133 | * |
3134 | 3134 | * @var boolean $prices_displayed_including_taxes |
3135 | 3135 | */ |
3136 | - public $prices_displayed_including_taxes; |
|
3136 | + public $prices_displayed_including_taxes; |
|
3137 | 3137 | |
3138 | 3138 | |
3139 | - /** |
|
3140 | - * class constructor |
|
3141 | - */ |
|
3142 | - public function __construct() |
|
3143 | - { |
|
3144 | - $this->prices_displayed_including_taxes = true; |
|
3145 | - } |
|
3139 | + /** |
|
3140 | + * class constructor |
|
3141 | + */ |
|
3142 | + public function __construct() |
|
3143 | + { |
|
3144 | + $this->prices_displayed_including_taxes = true; |
|
3145 | + } |
|
3146 | 3146 | } |
3147 | 3147 | |
3148 | 3148 | |
@@ -3157,18 +3157,18 @@ discard block |
||
3157 | 3157 | class EE_Messages_Config extends EE_Config_Base |
3158 | 3158 | { |
3159 | 3159 | |
3160 | - /** |
|
3161 | - * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
3162 | - * A value of 0 represents never deleting. Default is 0. |
|
3163 | - * |
|
3164 | - * @var integer |
|
3165 | - */ |
|
3166 | - public $delete_threshold; |
|
3167 | - |
|
3168 | - public function __construct() |
|
3169 | - { |
|
3170 | - $this->delete_threshold = 0; |
|
3171 | - } |
|
3160 | + /** |
|
3161 | + * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
3162 | + * A value of 0 represents never deleting. Default is 0. |
|
3163 | + * |
|
3164 | + * @var integer |
|
3165 | + */ |
|
3166 | + public $delete_threshold; |
|
3167 | + |
|
3168 | + public function __construct() |
|
3169 | + { |
|
3170 | + $this->delete_threshold = 0; |
|
3171 | + } |
|
3172 | 3172 | } |
3173 | 3173 | |
3174 | 3174 | |
@@ -3180,31 +3180,31 @@ discard block |
||
3180 | 3180 | class EE_Gateway_Config extends EE_Config_Base |
3181 | 3181 | { |
3182 | 3182 | |
3183 | - /** |
|
3184 | - * Array with keys that are payment gateways slugs, and values are arrays |
|
3185 | - * with any config info the gateway wants to store |
|
3186 | - * |
|
3187 | - * @var array |
|
3188 | - */ |
|
3189 | - public $payment_settings; |
|
3190 | - |
|
3191 | - /** |
|
3192 | - * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3193 | - * the gateway is stored in the uploads directory |
|
3194 | - * |
|
3195 | - * @var array |
|
3196 | - */ |
|
3197 | - public $active_gateways; |
|
3198 | - |
|
3199 | - |
|
3200 | - /** |
|
3201 | - * class constructor |
|
3202 | - * |
|
3203 | - * @deprecated |
|
3204 | - */ |
|
3205 | - public function __construct() |
|
3206 | - { |
|
3207 | - $this->payment_settings = array(); |
|
3208 | - $this->active_gateways = array('Invoice' => false); |
|
3209 | - } |
|
3183 | + /** |
|
3184 | + * Array with keys that are payment gateways slugs, and values are arrays |
|
3185 | + * with any config info the gateway wants to store |
|
3186 | + * |
|
3187 | + * @var array |
|
3188 | + */ |
|
3189 | + public $payment_settings; |
|
3190 | + |
|
3191 | + /** |
|
3192 | + * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3193 | + * the gateway is stored in the uploads directory |
|
3194 | + * |
|
3195 | + * @var array |
|
3196 | + */ |
|
3197 | + public $active_gateways; |
|
3198 | + |
|
3199 | + |
|
3200 | + /** |
|
3201 | + * class constructor |
|
3202 | + * |
|
3203 | + * @deprecated |
|
3204 | + */ |
|
3205 | + public function __construct() |
|
3206 | + { |
|
3207 | + $this->payment_settings = array(); |
|
3208 | + $this->active_gateways = array('Invoice' => false); |
|
3209 | + } |
|
3210 | 3210 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.63.rc.008'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.63.rc.008'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |