Completed
Branch FET/attendee-importer (b47c55)
by
unknown
34:18 queued 25:45
created
core/domain/services/assets/CoreAssetManager.php 1 patch
Indentation   +534 added lines, -534 removed lines patch added patch discarded remove patch
@@ -31,557 +31,557 @@
 block discarded – undo
31 31
 class CoreAssetManager extends AssetManager
32 32
 {
33 33
 
34
-    // WordPress core / Third party JS asset handles
35
-    const JS_HANDLE_JQUERY = 'jquery';
34
+	// WordPress core / Third party JS asset handles
35
+	const JS_HANDLE_JQUERY = 'jquery';
36 36
 
37
-    const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
37
+	const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
38 38
 
39
-    const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
39
+	const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
40 40
 
41
-    const JS_HANDLE_UNDERSCORE = 'underscore';
41
+	const JS_HANDLE_UNDERSCORE = 'underscore';
42 42
 
43
-    const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
43
+	const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
44 44
 
45
-    /**
46
-     * @since 4.9.71.p
47
-     */
48
-    const JS_HANDLE_REACT = 'react';
45
+	/**
46
+	 * @since 4.9.71.p
47
+	 */
48
+	const JS_HANDLE_REACT = 'react';
49 49
 
50
-    /**
51
-     * @since 4.9.71.p
52
-     */
53
-    const JS_HANDLE_REACT_DOM = 'react-dom';
50
+	/**
51
+	 * @since 4.9.71.p
52
+	 */
53
+	const JS_HANDLE_REACT_DOM = 'react-dom';
54 54
 
55
-    /**
56
-     * @since 4.9.71.p
57
-     */
58
-    const JS_HANDLE_LODASH = 'lodash';
55
+	/**
56
+	 * @since 4.9.71.p
57
+	 */
58
+	const JS_HANDLE_LODASH = 'lodash';
59 59
 
60
-    // EE JS assets handles
61
-    const JS_HANDLE_MANIFEST = 'ee-manifest';
60
+	// EE JS assets handles
61
+	const JS_HANDLE_MANIFEST = 'ee-manifest';
62 62
 
63
-    const JS_HANDLE_JS_CORE = 'eejs-core';
63
+	const JS_HANDLE_JS_CORE = 'eejs-core';
64 64
 
65
-    const JS_HANDLE_VENDOR = 'eventespresso-vendor';
65
+	const JS_HANDLE_VENDOR = 'eventespresso-vendor';
66 66
 
67
-    const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores';
67
+	const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores';
68 68
 
69
-    const JS_HANDLE_HELPERS = 'eventespresso-helpers';
69
+	const JS_HANDLE_HELPERS = 'eventespresso-helpers';
70 70
 
71
-    const JS_HANDLE_MODEL = 'eventespresso-model';
71
+	const JS_HANDLE_MODEL = 'eventespresso-model';
72 72
 
73
-    const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects';
73
+	const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects';
74 74
 
75
-    const JS_HANDLE_HOCS = 'eventespresso-hocs';
75
+	const JS_HANDLE_HOCS = 'eventespresso-hocs';
76 76
 
77
-    const JS_HANDLE_COMPONENTS = 'eventespresso-components';
78
-
79
-    const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs';
77
+	const JS_HANDLE_COMPONENTS = 'eventespresso-components';
78
+
79
+	const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs';
80 80
 
81
-    const JS_HANDLE_VALIDATORS = 'eventespresso-validators';
81
+	const JS_HANDLE_VALIDATORS = 'eventespresso-validators';
82 82
 
83
-    const JS_HANDLE_CORE = 'espresso_core';
83
+	const JS_HANDLE_CORE = 'espresso_core';
84 84
 
85
-    const JS_HANDLE_I18N = 'eei18n';
86
-
87
-    const JS_HANDLE_ACCOUNTING = 'ee-accounting';
88
-
89
-    const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
90
-
91
-    // EE CSS assets handles
92
-    const CSS_HANDLE_DEFAULT = 'espresso_default';
93
-
94
-    const CSS_HANDLE_CUSTOM = 'espresso_custom_css';
95
-
96
-    const CSS_HANDLE_COMPONENTS = 'eventespresso-components';
97
-
98
-    /**
99
-     * @var EE_Currency_Config $currency_config
100
-     */
101
-    protected $currency_config;
102
-
103
-    /**
104
-     * @var EE_Template_Config $template_config
105
-     */
106
-    protected $template_config;
107
-
108
-
109
-    /**
110
-     * CoreAssetRegister constructor.
111
-     *
112
-     * @param AssetCollection    $assets
113
-     * @param EE_Currency_Config $currency_config
114
-     * @param EE_Template_Config $template_config
115
-     * @param DomainInterface    $domain
116
-     * @param Registry           $registry
117
-     */
118
-    public function __construct(
119
-        AssetCollection $assets,
120
-        EE_Currency_Config $currency_config,
121
-        EE_Template_Config $template_config,
122
-        DomainInterface $domain,
123
-        Registry $registry
124
-    ) {
125
-        $this->currency_config = $currency_config;
126
-        $this->template_config = $template_config;
127
-        parent::__construct($domain, $assets, $registry);
128
-    }
129
-
130
-
131
-    /**
132
-     * @since 4.9.62.p
133
-     * @throws DomainException
134
-     * @throws DuplicateCollectionIdentifierException
135
-     * @throws InvalidArgumentException
136
-     * @throws InvalidDataTypeException
137
-     * @throws InvalidEntityException
138
-     * @throws InvalidInterfaceException
139
-     */
140
-    public function addAssets()
141
-    {
142
-        $this->addJavascriptFiles();
143
-        $this->addStylesheetFiles();
144
-    }
145
-
146
-
147
-    /**
148
-     * @since 4.9.62.p
149
-     * @throws DomainException
150
-     * @throws DuplicateCollectionIdentifierException
151
-     * @throws InvalidArgumentException
152
-     * @throws InvalidDataTypeException
153
-     * @throws InvalidEntityException
154
-     * @throws InvalidInterfaceException
155
-     */
156
-    public function addJavascriptFiles()
157
-    {
158
-        $this->loadCoreJs();
159
-        $this->loadJqueryValidate();
160
-        $this->loadAccountingJs();
161
-        add_action(
162
-            'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
163
-            array($this, 'loadQtipJs')
164
-        );
165
-        $this->registerAdminAssets();
166
-    }
167
-
168
-
169
-    /**
170
-     * @since 4.9.62.p
171
-     * @throws DuplicateCollectionIdentifierException
172
-     * @throws InvalidDataTypeException
173
-     * @throws InvalidEntityException
174
-     */
175
-    public function addStylesheetFiles()
176
-    {
177
-        $this->loadCoreCss();
178
-    }
179
-
180
-
181
-    /**
182
-     * core default javascript
183
-     *
184
-     * @since 4.9.62.p
185
-     * @throws DomainException
186
-     * @throws DuplicateCollectionIdentifierException
187
-     * @throws InvalidArgumentException
188
-     * @throws InvalidDataTypeException
189
-     * @throws InvalidEntityException
190
-     * @throws InvalidInterfaceException
191
-     */
192
-    private function loadCoreJs()
193
-    {
194
-        // conditionally load third-party libraries that WP core MIGHT have.
195
-        $this->registerWpAssets();
196
-
197
-        $this->addJavascript(
198
-            CoreAssetManager::JS_HANDLE_MANIFEST,
199
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
200
-        );
201
-
202
-        $this->addJavascript(
203
-            CoreAssetManager::JS_HANDLE_JS_CORE,
204
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
205
-            array(CoreAssetManager::JS_HANDLE_MANIFEST)
206
-        )
207
-        ->setHasInlineData();
208
-
209
-        $this->addJavascript(
210
-            CoreAssetManager::JS_HANDLE_VENDOR,
211
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
212
-            array(
213
-                CoreAssetManager::JS_HANDLE_JS_CORE,
214
-                CoreAssetManager::JS_HANDLE_REACT,
215
-                CoreAssetManager::JS_HANDLE_REACT_DOM,
216
-                CoreAssetManager::JS_HANDLE_LODASH,
217
-            )
218
-        );
219
-
220
-        $this->addJavascript(
221
-            CoreAssetManager::JS_HANDLE_VALIDATORS,
222
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators')
223
-        )->setRequiresTranslation();
224
-
225
-        $this->addJavascript(
226
-            CoreAssetManager::JS_HANDLE_HELPERS,
227
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'),
228
-            array(
229
-                CoreAssetManager::JS_HANDLE_VALIDATORS
230
-            )
231
-        )->setRequiresTranslation();
232
-
233
-        $this->addJavascript(
234
-            CoreAssetManager::JS_HANDLE_MODEL,
235
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
236
-            array(
237
-                CoreAssetManager::JS_HANDLE_HELPERS,
238
-                CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
239
-            )
240
-        )->setRequiresTranslation();
241
-
242
-        $this->addJavascript(
243
-            CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
244
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
245
-            array(
246
-                CoreAssetManager::JS_HANDLE_VALIDATORS,
247
-                CoreAssetManager::JS_HANDLE_HELPERS,
248
-            )
249
-        )->setRequiresTranslation();
250
-
251
-        $this->addJavascript(
252
-            CoreAssetManager::JS_HANDLE_DATA_STORES,
253
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
254
-            array(
255
-                CoreAssetManager::JS_HANDLE_VENDOR,
256
-                'wp-data',
257
-                'wp-api-fetch',
258
-                CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
259
-                CoreAssetManager::JS_HANDLE_MODEL,
260
-            )
261
-        )
262
-             ->setRequiresTranslation()
263
-             ->setInlineDataCallback(
264
-                 function() {
265
-                     wp_add_inline_script(
266
-                         CoreAssetManager::JS_HANDLE_DATA_STORES,
267
-                         is_admin()
268
-                             ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )'
269
-                             : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )'
270
-                     );
271
-                 }
272
-             );
273
-
274
-        $this->addJavascript(
275
-            CoreAssetManager::JS_HANDLE_HOCS,
276
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'),
277
-            array(
278
-                CoreAssetManager::JS_HANDLE_DATA_STORES,
279
-                CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
280
-                'wp-components',
281
-            )
282
-        )->setRequiresTranslation();
283
-
284
-        $this->addJavascript(
285
-            CoreAssetManager::JS_HANDLE_COMPONENTS,
286
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
287
-            array(
288
-                CoreAssetManager::JS_HANDLE_DATA_STORES,
289
-                CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
290
-                'wp-components',
291
-            )
292
-        )
293
-        ->setRequiresTranslation();
294
-
295
-        $this->addJavascript(
296
-            CoreAssetManager::JS_HANDLE_EDITOR_HOCS,
297
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'),
298
-            array(
299
-                CoreAssetManager::JS_HANDLE_COMPONENTS
300
-            )
301
-        )->setRequiresTranslation();
302
-
303
-        $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
304
-        $this->registry->addData(
305
-            'paths',
306
-            array(
307
-                'base_rest_route' => rest_url(),
308
-                'rest_route' => rest_url('ee/v4.8.36/'),
309
-                'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
310
-                'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
311
-                'site_url' => site_url('/'),
312
-                'admin_url' => admin_url('/'),
313
-            )
314
-        );
315
-        /** site formatting values **/
316
-        $this->registry->addData(
317
-            'site_formats',
318
-            array(
319
-                'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
320
-            )
321
-        );
322
-        /** currency data **/
323
-        $this->registry->addData(
324
-            'currency_config',
325
-            $this->getCurrencySettings()
326
-        );
327
-        /** site timezone */
328
-        $this->registry->addData(
329
-            'default_timezone',
330
-            array(
331
-                'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
332
-                'string' => get_option('timezone_string'),
333
-                'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
334
-            )
335
-        );
336
-        /** site locale (user locale if user logged in) */
337
-        $this->registry->addData(
338
-            'locale',
339
-            array(
340
-                'user' => get_user_locale(),
341
-                'site' => get_locale()
342
-            )
343
-        );
344
-
345
-        $this->addJavascript(
346
-            CoreAssetManager::JS_HANDLE_CORE,
347
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
348
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
349
-        )
350
-        ->setInlineDataCallback(
351
-            function () {
352
-                wp_localize_script(
353
-                    CoreAssetManager::JS_HANDLE_CORE,
354
-                    CoreAssetManager::JS_HANDLE_I18N,
355
-                    EE_Registry::$i18n_js_strings
356
-                );
357
-            }
358
-        );
359
-    }
360
-
361
-
362
-    /**
363
-     * Registers vendor files that are bundled with a later version WP but might not be for the current version of
364
-     * WordPress in the running environment.
365
-     *
366
-     * @throws DuplicateCollectionIdentifierException
367
-     * @throws InvalidDataTypeException
368
-     * @throws InvalidEntityException
369
-     * @throws DomainException
370
-     * @since 4.9.71.p
371
-     */
372
-    private function registerWpAssets()
373
-    {
374
-        global $wp_version;
375
-        if (version_compare($wp_version, '5.0.beta', '>=')) {
376
-            return;
377
-        }
378
-        $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT)
379
-            ->setVersion('16.6.0');
380
-        $this->addVendorJavascript(
381
-            CoreAssetManager::JS_HANDLE_REACT_DOM,
382
-            array(CoreAssetManager::JS_HANDLE_REACT)
383
-        )->setVersion('16.6.0');
384
-        $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH)
385
-            ->setInlineDataCallback(
386
-                function() {
387
-                    wp_add_inline_script(
388
-                        CoreAssetManager::JS_HANDLE_LODASH,
389
-                        'window.lodash = _.noConflict();'
390
-                    );
391
-                }
392
-            )
393
-            ->setVersion('4.17.11');
394
-    }
395
-
396
-
397
-    /**
398
-     * Returns configuration data for the accounting-js library.
399
-     * @since 4.9.71.p
400
-     * @return array
401
-     */
402
-    private function getAccountingSettings() {
403
-        return array(
404
-            'currency' => array(
405
-                'symbol'    => $this->currency_config->sign,
406
-                'format'    => array(
407
-                    'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
408
-                    'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
409
-                    'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
410
-                ),
411
-                'decimal'   => $this->currency_config->dec_mrk,
412
-                'thousand'  => $this->currency_config->thsnds,
413
-                'precision' => $this->currency_config->dec_plc,
414
-            ),
415
-            'number'   => array(
416
-                'precision' => $this->currency_config->dec_plc,
417
-                'thousand'  => $this->currency_config->thsnds,
418
-                'decimal'   => $this->currency_config->dec_mrk,
419
-            ),
420
-        );
421
-    }
422
-
423
-
424
-    /**
425
-     * Returns configuration data for the js Currency VO.
426
-     * @since 4.9.71.p
427
-     * @return array
428
-     */
429
-    private function getCurrencySettings()
430
-    {
431
-        return array(
432
-            'code' => $this->currency_config->code,
433
-            'singularLabel' => $this->currency_config->name,
434
-            'pluralLabel' => $this->currency_config->plural,
435
-            'sign' => $this->currency_config->sign,
436
-            'signB4' => $this->currency_config->sign_b4,
437
-            'decimalPlaces' => $this->currency_config->dec_plc,
438
-            'decimalMark' => $this->currency_config->dec_mrk,
439
-            'thousandsSeparator' => $this->currency_config->thsnds,
440
-        );
441
-    }
442
-
443
-
444
-    /**
445
-     * @since 4.9.62.p
446
-     * @throws DuplicateCollectionIdentifierException
447
-     * @throws InvalidDataTypeException
448
-     * @throws InvalidEntityException
449
-     */
450
-    private function loadCoreCss()
451
-    {
452
-        if ($this->template_config->enable_default_style && ! is_admin()) {
453
-            $this->addStylesheet(
454
-                CoreAssetManager::CSS_HANDLE_DEFAULT,
455
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
456
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
457
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
458
-                array('dashicons')
459
-            );
460
-            //Load custom style sheet if available
461
-            if ($this->template_config->custom_style_sheet !== null) {
462
-                $this->addStylesheet(
463
-                    CoreAssetManager::CSS_HANDLE_CUSTOM,
464
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
465
-                    array(CoreAssetManager::CSS_HANDLE_DEFAULT)
466
-                );
467
-            }
468
-        }
469
-        $this->addStylesheet(
470
-            CoreAssetManager::CSS_HANDLE_COMPONENTS,
471
-            $this->registry->getCssUrl(
472
-                $this->domain->assetNamespace(),
473
-                'components'
474
-            )
475
-        );
476
-    }
477
-
478
-
479
-    /**
480
-     * jQuery Validate for form validation
481
-     *
482
-     * @since 4.9.62.p
483
-     * @throws DomainException
484
-     * @throws DuplicateCollectionIdentifierException
485
-     * @throws InvalidDataTypeException
486
-     * @throws InvalidEntityException
487
-     */
488
-    private function loadJqueryValidate()
489
-    {
490
-        $this->addJavascript(
491
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
492
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
493
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
494
-        )
495
-        ->setVersion('1.15.0');
496
-
497
-        $this->addJavascript(
498
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
499
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
500
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
501
-        )
502
-        ->setVersion('1.15.0');
503
-    }
504
-
505
-
506
-    /**
507
-     * accounting.js for performing client-side calculations
508
-     *
509
-     * @since 4.9.62.p
510
-     * @throws DomainException
511
-     * @throws DuplicateCollectionIdentifierException
512
-     * @throws InvalidDataTypeException
513
-     * @throws InvalidEntityException
514
-     */
515
-    private function loadAccountingJs()
516
-    {
517
-        //accounting.js library
518
-        // @link http://josscrowcroft.github.io/accounting.js/
519
-        $this->addJavascript(
520
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
521
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
522
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
523
-        )
524
-        ->setVersion('0.3.2');
525
-
526
-        $this->addJavascript(
527
-            CoreAssetManager::JS_HANDLE_ACCOUNTING,
528
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
529
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
530
-        )
531
-        ->setInlineDataCallback(
532
-            function () {
533
-                 wp_localize_script(
534
-                     CoreAssetManager::JS_HANDLE_ACCOUNTING,
535
-                     'EE_ACCOUNTING_CFG',
536
-                     $this->getAccountingSettings()
537
-                 );
538
-            }
539
-        )
540
-        ->setVersion();
541
-    }
542
-
543
-
544
-    /**
545
-     * registers assets for cleaning your ears
546
-     *
547
-     * @param JavascriptAsset $script
548
-     */
549
-    public function loadQtipJs(JavascriptAsset $script)
550
-    {
551
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
552
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
553
-        if (
554
-            $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE
555
-            && apply_filters('FHEE_load_qtip', false)
556
-        ) {
557
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
558
-        }
559
-    }
560
-
561
-
562
-    /**
563
-     * assets that are used in the WordPress admin
564
-     *
565
-     * @since 4.9.62.p
566
-     * @throws DuplicateCollectionIdentifierException
567
-     * @throws InvalidDataTypeException
568
-     * @throws InvalidEntityException
569
-     */
570
-    private function registerAdminAssets()
571
-    {
572
-        $this->addJavascript(
573
-            CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE,
574
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
575
-            array(
576
-                CoreAssetManager::JS_HANDLE_JQUERY,
577
-                CoreAssetManager::JS_HANDLE_VENDOR,
578
-            )
579
-        )
580
-        ->setRequiresTranslation();
581
-
582
-        $this->addStylesheet(
583
-            CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE,
584
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
585
-        );
586
-    }
85
+	const JS_HANDLE_I18N = 'eei18n';
86
+
87
+	const JS_HANDLE_ACCOUNTING = 'ee-accounting';
88
+
89
+	const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
90
+
91
+	// EE CSS assets handles
92
+	const CSS_HANDLE_DEFAULT = 'espresso_default';
93
+
94
+	const CSS_HANDLE_CUSTOM = 'espresso_custom_css';
95
+
96
+	const CSS_HANDLE_COMPONENTS = 'eventespresso-components';
97
+
98
+	/**
99
+	 * @var EE_Currency_Config $currency_config
100
+	 */
101
+	protected $currency_config;
102
+
103
+	/**
104
+	 * @var EE_Template_Config $template_config
105
+	 */
106
+	protected $template_config;
107
+
108
+
109
+	/**
110
+	 * CoreAssetRegister constructor.
111
+	 *
112
+	 * @param AssetCollection    $assets
113
+	 * @param EE_Currency_Config $currency_config
114
+	 * @param EE_Template_Config $template_config
115
+	 * @param DomainInterface    $domain
116
+	 * @param Registry           $registry
117
+	 */
118
+	public function __construct(
119
+		AssetCollection $assets,
120
+		EE_Currency_Config $currency_config,
121
+		EE_Template_Config $template_config,
122
+		DomainInterface $domain,
123
+		Registry $registry
124
+	) {
125
+		$this->currency_config = $currency_config;
126
+		$this->template_config = $template_config;
127
+		parent::__construct($domain, $assets, $registry);
128
+	}
129
+
130
+
131
+	/**
132
+	 * @since 4.9.62.p
133
+	 * @throws DomainException
134
+	 * @throws DuplicateCollectionIdentifierException
135
+	 * @throws InvalidArgumentException
136
+	 * @throws InvalidDataTypeException
137
+	 * @throws InvalidEntityException
138
+	 * @throws InvalidInterfaceException
139
+	 */
140
+	public function addAssets()
141
+	{
142
+		$this->addJavascriptFiles();
143
+		$this->addStylesheetFiles();
144
+	}
145
+
146
+
147
+	/**
148
+	 * @since 4.9.62.p
149
+	 * @throws DomainException
150
+	 * @throws DuplicateCollectionIdentifierException
151
+	 * @throws InvalidArgumentException
152
+	 * @throws InvalidDataTypeException
153
+	 * @throws InvalidEntityException
154
+	 * @throws InvalidInterfaceException
155
+	 */
156
+	public function addJavascriptFiles()
157
+	{
158
+		$this->loadCoreJs();
159
+		$this->loadJqueryValidate();
160
+		$this->loadAccountingJs();
161
+		add_action(
162
+			'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
163
+			array($this, 'loadQtipJs')
164
+		);
165
+		$this->registerAdminAssets();
166
+	}
167
+
168
+
169
+	/**
170
+	 * @since 4.9.62.p
171
+	 * @throws DuplicateCollectionIdentifierException
172
+	 * @throws InvalidDataTypeException
173
+	 * @throws InvalidEntityException
174
+	 */
175
+	public function addStylesheetFiles()
176
+	{
177
+		$this->loadCoreCss();
178
+	}
179
+
180
+
181
+	/**
182
+	 * core default javascript
183
+	 *
184
+	 * @since 4.9.62.p
185
+	 * @throws DomainException
186
+	 * @throws DuplicateCollectionIdentifierException
187
+	 * @throws InvalidArgumentException
188
+	 * @throws InvalidDataTypeException
189
+	 * @throws InvalidEntityException
190
+	 * @throws InvalidInterfaceException
191
+	 */
192
+	private function loadCoreJs()
193
+	{
194
+		// conditionally load third-party libraries that WP core MIGHT have.
195
+		$this->registerWpAssets();
196
+
197
+		$this->addJavascript(
198
+			CoreAssetManager::JS_HANDLE_MANIFEST,
199
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
200
+		);
201
+
202
+		$this->addJavascript(
203
+			CoreAssetManager::JS_HANDLE_JS_CORE,
204
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
205
+			array(CoreAssetManager::JS_HANDLE_MANIFEST)
206
+		)
207
+		->setHasInlineData();
208
+
209
+		$this->addJavascript(
210
+			CoreAssetManager::JS_HANDLE_VENDOR,
211
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
212
+			array(
213
+				CoreAssetManager::JS_HANDLE_JS_CORE,
214
+				CoreAssetManager::JS_HANDLE_REACT,
215
+				CoreAssetManager::JS_HANDLE_REACT_DOM,
216
+				CoreAssetManager::JS_HANDLE_LODASH,
217
+			)
218
+		);
219
+
220
+		$this->addJavascript(
221
+			CoreAssetManager::JS_HANDLE_VALIDATORS,
222
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'validators')
223
+		)->setRequiresTranslation();
224
+
225
+		$this->addJavascript(
226
+			CoreAssetManager::JS_HANDLE_HELPERS,
227
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'),
228
+			array(
229
+				CoreAssetManager::JS_HANDLE_VALIDATORS
230
+			)
231
+		)->setRequiresTranslation();
232
+
233
+		$this->addJavascript(
234
+			CoreAssetManager::JS_HANDLE_MODEL,
235
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
236
+			array(
237
+				CoreAssetManager::JS_HANDLE_HELPERS,
238
+				CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
239
+			)
240
+		)->setRequiresTranslation();
241
+
242
+		$this->addJavascript(
243
+			CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
244
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
245
+			array(
246
+				CoreAssetManager::JS_HANDLE_VALIDATORS,
247
+				CoreAssetManager::JS_HANDLE_HELPERS,
248
+			)
249
+		)->setRequiresTranslation();
250
+
251
+		$this->addJavascript(
252
+			CoreAssetManager::JS_HANDLE_DATA_STORES,
253
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
254
+			array(
255
+				CoreAssetManager::JS_HANDLE_VENDOR,
256
+				'wp-data',
257
+				'wp-api-fetch',
258
+				CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
259
+				CoreAssetManager::JS_HANDLE_MODEL,
260
+			)
261
+		)
262
+			 ->setRequiresTranslation()
263
+			 ->setInlineDataCallback(
264
+				 function() {
265
+					 wp_add_inline_script(
266
+						 CoreAssetManager::JS_HANDLE_DATA_STORES,
267
+						 is_admin()
268
+							 ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )'
269
+							 : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )'
270
+					 );
271
+				 }
272
+			 );
273
+
274
+		$this->addJavascript(
275
+			CoreAssetManager::JS_HANDLE_HOCS,
276
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'),
277
+			array(
278
+				CoreAssetManager::JS_HANDLE_DATA_STORES,
279
+				CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
280
+				'wp-components',
281
+			)
282
+		)->setRequiresTranslation();
283
+
284
+		$this->addJavascript(
285
+			CoreAssetManager::JS_HANDLE_COMPONENTS,
286
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
287
+			array(
288
+				CoreAssetManager::JS_HANDLE_DATA_STORES,
289
+				CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
290
+				'wp-components',
291
+			)
292
+		)
293
+		->setRequiresTranslation();
294
+
295
+		$this->addJavascript(
296
+			CoreAssetManager::JS_HANDLE_EDITOR_HOCS,
297
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'),
298
+			array(
299
+				CoreAssetManager::JS_HANDLE_COMPONENTS
300
+			)
301
+		)->setRequiresTranslation();
302
+
303
+		$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
304
+		$this->registry->addData(
305
+			'paths',
306
+			array(
307
+				'base_rest_route' => rest_url(),
308
+				'rest_route' => rest_url('ee/v4.8.36/'),
309
+				'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
310
+				'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
311
+				'site_url' => site_url('/'),
312
+				'admin_url' => admin_url('/'),
313
+			)
314
+		);
315
+		/** site formatting values **/
316
+		$this->registry->addData(
317
+			'site_formats',
318
+			array(
319
+				'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
320
+			)
321
+		);
322
+		/** currency data **/
323
+		$this->registry->addData(
324
+			'currency_config',
325
+			$this->getCurrencySettings()
326
+		);
327
+		/** site timezone */
328
+		$this->registry->addData(
329
+			'default_timezone',
330
+			array(
331
+				'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
332
+				'string' => get_option('timezone_string'),
333
+				'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
334
+			)
335
+		);
336
+		/** site locale (user locale if user logged in) */
337
+		$this->registry->addData(
338
+			'locale',
339
+			array(
340
+				'user' => get_user_locale(),
341
+				'site' => get_locale()
342
+			)
343
+		);
344
+
345
+		$this->addJavascript(
346
+			CoreAssetManager::JS_HANDLE_CORE,
347
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
348
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
349
+		)
350
+		->setInlineDataCallback(
351
+			function () {
352
+				wp_localize_script(
353
+					CoreAssetManager::JS_HANDLE_CORE,
354
+					CoreAssetManager::JS_HANDLE_I18N,
355
+					EE_Registry::$i18n_js_strings
356
+				);
357
+			}
358
+		);
359
+	}
360
+
361
+
362
+	/**
363
+	 * Registers vendor files that are bundled with a later version WP but might not be for the current version of
364
+	 * WordPress in the running environment.
365
+	 *
366
+	 * @throws DuplicateCollectionIdentifierException
367
+	 * @throws InvalidDataTypeException
368
+	 * @throws InvalidEntityException
369
+	 * @throws DomainException
370
+	 * @since 4.9.71.p
371
+	 */
372
+	private function registerWpAssets()
373
+	{
374
+		global $wp_version;
375
+		if (version_compare($wp_version, '5.0.beta', '>=')) {
376
+			return;
377
+		}
378
+		$this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT)
379
+			->setVersion('16.6.0');
380
+		$this->addVendorJavascript(
381
+			CoreAssetManager::JS_HANDLE_REACT_DOM,
382
+			array(CoreAssetManager::JS_HANDLE_REACT)
383
+		)->setVersion('16.6.0');
384
+		$this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH)
385
+			->setInlineDataCallback(
386
+				function() {
387
+					wp_add_inline_script(
388
+						CoreAssetManager::JS_HANDLE_LODASH,
389
+						'window.lodash = _.noConflict();'
390
+					);
391
+				}
392
+			)
393
+			->setVersion('4.17.11');
394
+	}
395
+
396
+
397
+	/**
398
+	 * Returns configuration data for the accounting-js library.
399
+	 * @since 4.9.71.p
400
+	 * @return array
401
+	 */
402
+	private function getAccountingSettings() {
403
+		return array(
404
+			'currency' => array(
405
+				'symbol'    => $this->currency_config->sign,
406
+				'format'    => array(
407
+					'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
408
+					'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
409
+					'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
410
+				),
411
+				'decimal'   => $this->currency_config->dec_mrk,
412
+				'thousand'  => $this->currency_config->thsnds,
413
+				'precision' => $this->currency_config->dec_plc,
414
+			),
415
+			'number'   => array(
416
+				'precision' => $this->currency_config->dec_plc,
417
+				'thousand'  => $this->currency_config->thsnds,
418
+				'decimal'   => $this->currency_config->dec_mrk,
419
+			),
420
+		);
421
+	}
422
+
423
+
424
+	/**
425
+	 * Returns configuration data for the js Currency VO.
426
+	 * @since 4.9.71.p
427
+	 * @return array
428
+	 */
429
+	private function getCurrencySettings()
430
+	{
431
+		return array(
432
+			'code' => $this->currency_config->code,
433
+			'singularLabel' => $this->currency_config->name,
434
+			'pluralLabel' => $this->currency_config->plural,
435
+			'sign' => $this->currency_config->sign,
436
+			'signB4' => $this->currency_config->sign_b4,
437
+			'decimalPlaces' => $this->currency_config->dec_plc,
438
+			'decimalMark' => $this->currency_config->dec_mrk,
439
+			'thousandsSeparator' => $this->currency_config->thsnds,
440
+		);
441
+	}
442
+
443
+
444
+	/**
445
+	 * @since 4.9.62.p
446
+	 * @throws DuplicateCollectionIdentifierException
447
+	 * @throws InvalidDataTypeException
448
+	 * @throws InvalidEntityException
449
+	 */
450
+	private function loadCoreCss()
451
+	{
452
+		if ($this->template_config->enable_default_style && ! is_admin()) {
453
+			$this->addStylesheet(
454
+				CoreAssetManager::CSS_HANDLE_DEFAULT,
455
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
456
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
457
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
458
+				array('dashicons')
459
+			);
460
+			//Load custom style sheet if available
461
+			if ($this->template_config->custom_style_sheet !== null) {
462
+				$this->addStylesheet(
463
+					CoreAssetManager::CSS_HANDLE_CUSTOM,
464
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
465
+					array(CoreAssetManager::CSS_HANDLE_DEFAULT)
466
+				);
467
+			}
468
+		}
469
+		$this->addStylesheet(
470
+			CoreAssetManager::CSS_HANDLE_COMPONENTS,
471
+			$this->registry->getCssUrl(
472
+				$this->domain->assetNamespace(),
473
+				'components'
474
+			)
475
+		);
476
+	}
477
+
478
+
479
+	/**
480
+	 * jQuery Validate for form validation
481
+	 *
482
+	 * @since 4.9.62.p
483
+	 * @throws DomainException
484
+	 * @throws DuplicateCollectionIdentifierException
485
+	 * @throws InvalidDataTypeException
486
+	 * @throws InvalidEntityException
487
+	 */
488
+	private function loadJqueryValidate()
489
+	{
490
+		$this->addJavascript(
491
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
492
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
493
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
494
+		)
495
+		->setVersion('1.15.0');
496
+
497
+		$this->addJavascript(
498
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
499
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
500
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
501
+		)
502
+		->setVersion('1.15.0');
503
+	}
504
+
505
+
506
+	/**
507
+	 * accounting.js for performing client-side calculations
508
+	 *
509
+	 * @since 4.9.62.p
510
+	 * @throws DomainException
511
+	 * @throws DuplicateCollectionIdentifierException
512
+	 * @throws InvalidDataTypeException
513
+	 * @throws InvalidEntityException
514
+	 */
515
+	private function loadAccountingJs()
516
+	{
517
+		//accounting.js library
518
+		// @link http://josscrowcroft.github.io/accounting.js/
519
+		$this->addJavascript(
520
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
521
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
522
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
523
+		)
524
+		->setVersion('0.3.2');
525
+
526
+		$this->addJavascript(
527
+			CoreAssetManager::JS_HANDLE_ACCOUNTING,
528
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
529
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
530
+		)
531
+		->setInlineDataCallback(
532
+			function () {
533
+				 wp_localize_script(
534
+					 CoreAssetManager::JS_HANDLE_ACCOUNTING,
535
+					 'EE_ACCOUNTING_CFG',
536
+					 $this->getAccountingSettings()
537
+				 );
538
+			}
539
+		)
540
+		->setVersion();
541
+	}
542
+
543
+
544
+	/**
545
+	 * registers assets for cleaning your ears
546
+	 *
547
+	 * @param JavascriptAsset $script
548
+	 */
549
+	public function loadQtipJs(JavascriptAsset $script)
550
+	{
551
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
552
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
553
+		if (
554
+			$script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE
555
+			&& apply_filters('FHEE_load_qtip', false)
556
+		) {
557
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
558
+		}
559
+	}
560
+
561
+
562
+	/**
563
+	 * assets that are used in the WordPress admin
564
+	 *
565
+	 * @since 4.9.62.p
566
+	 * @throws DuplicateCollectionIdentifierException
567
+	 * @throws InvalidDataTypeException
568
+	 * @throws InvalidEntityException
569
+	 */
570
+	private function registerAdminAssets()
571
+	{
572
+		$this->addJavascript(
573
+			CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE,
574
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
575
+			array(
576
+				CoreAssetManager::JS_HANDLE_JQUERY,
577
+				CoreAssetManager::JS_HANDLE_VENDOR,
578
+			)
579
+		)
580
+		->setRequiresTranslation();
581
+
582
+		$this->addStylesheet(
583
+			CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE,
584
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
585
+		);
586
+	}
587 587
 }
Please login to merge, or discard this patch.
templates/txn_admin_details_main_meta_box_txn_details.template.php 2 patches
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
     <a id="display-additional-transaction-session-info" class="display-the-hidden smaller-text"
16 16
        rel="additional-transaction-session-info">
17 17
         <span class="dashicons dashicons-plus-alt"></span><?php esc_html_e(
18
-            'view additional transaction session details',
19
-            'event_espresso'
20
-        ); ?>
18
+			'view additional transaction session details',
19
+			'event_espresso'
20
+		); ?>
21 21
     </a>
22 22
 
23 23
     <div id="additional-transaction-session-info-dv" class="hidden">
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
         <a id="hide-additional-transaction-session-info" class="hide-the-displayed hidden smaller-text"
26 26
            rel="additional-transaction-session-info">
27 27
             <span class="dashicons dashicons-dismiss"></span><?php esc_html_e(
28
-                'hide additional transaction session details',
29
-                'event_espresso'
30
-            ); ?>
28
+				'hide additional transaction session details',
29
+				'event_espresso'
30
+			); ?>
31 31
         </a>
32 32
         <br class="clear"/>
33 33
 
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
 
53 53
 
54 54
     <?php if ($attendee instanceof EE_Attendee && ($grand_raw_total > 0 || $TXN_status !== EEM_Transaction::complete_status_code || ! empty($payments))) :
55
-        $no_payment_text = $can_edit_payments
56
-            ? esc_html__(
57
-                'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.',
58
-                'event_espresso'
59
-            )
60
-            : esc_html__(
61
-                'No payments have been applied to this transaction yet.',
62
-                'event_espresso'
63
-            );
64
-        ?>
55
+		$no_payment_text = $can_edit_payments
56
+			? esc_html__(
57
+				'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.',
58
+				'event_espresso'
59
+			)
60
+			: esc_html__(
61
+				'No payments have been applied to this transaction yet.',
62
+				'event_espresso'
63
+			);
64
+		?>
65 65
 
66 66
         <h3 class="admin-primary-mbox-h4 hdr-has-icon">
67 67
             <span class="ee-icon ee-icon-cash"></span><?php esc_html_e('Payment Details', 'event_espresso'); ?>
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
                 <?php if ($payments) : ?>
89 89
                     <?php $payment_total = 0; ?>
90 90
                     <?php foreach ($payments as $PAY_ID => $payment) :
91
-                        $existing_reg_payment_json = isset($existing_reg_payments[ $PAY_ID ])
92
-                            ? wp_json_encode($existing_reg_payments[ $PAY_ID ])
93
-                            : '{}';
94
-                        ?>
91
+						$existing_reg_payment_json = isset($existing_reg_payments[ $PAY_ID ])
92
+							? wp_json_encode($existing_reg_payments[ $PAY_ID ])
93
+							: '{}';
94
+						?>
95 95
                         <tr id="txn-admin-payment-tr-<?php echo $PAY_ID; ?>">
96 96
                             <td>
97 97
                                 <span id="payment-status-<?php echo $PAY_ID; ?>"
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
                                 </div>
137 137
                                 <div id="payment-gateway-<?php echo $PAY_ID; ?>">
138 138
                                     <?php echo $payment->payment_method()
139
-                                        ? $payment->payment_method()->admin_name()
140
-                                        : esc_html__(
141
-                                            "Unknown",
142
-                                            'event_espresso'
143
-                                        ); ?>
139
+										? $payment->payment_method()->admin_name()
140
+										: esc_html__(
141
+											"Unknown",
142
+											'event_espresso'
143
+										); ?>
144 144
                                 </div>
145 145
                                 <div id="payment-gateway-id-<?php echo $PAY_ID; ?>"
146 146
                                      class="hidden"><?php echo $payment->payment_method()
147
-                                        ? $payment->payment_method()->ID()
148
-                                        : 0; ?></div>
147
+										? $payment->payment_method()->ID()
148
+										: 0; ?></div>
149 149
                             </td>
150 150
                             <td class=" jst-left">
151 151
                                 <div id="payment-response-<?php echo $PAY_ID; ?>"><?php echo $payment->gateway_response(); ?></div>
@@ -162,29 +162,29 @@  discard block
 block discarded – undo
162 162
                             </td>
163 163
                             <td class=" jst-rght">
164 164
                                 <?php $payment_class = $payment->amount() > 0
165
-                                    ? 'txn-admin-payment-status-' . $payment->STS_ID()
166
-                                    : 'txn-admin-payment-status-PDC'; ?>
165
+									? 'txn-admin-payment-status-' . $payment->STS_ID()
166
+									: 'txn-admin-payment-status-PDC'; ?>
167 167
                                 <span class="<?php echo $payment_class; ?>">
168 168
                                 <div id="payment-amount-<?php echo $PAY_ID; ?>" style="display:inline;">
169 169
                                 <?php echo EEH_Template::format_currency(
170
-                                    $payment->amount(),
171
-                                    false,
172
-                                    false
173
-                                ); ?></div>
170
+									$payment->amount(),
171
+									false,
172
+									false
173
+								); ?></div>
174 174
                             </span>
175 175
                             </td>
176 176
                         </tr>
177 177
                         <?php
178
-                        $payment_total += $payment->STS_ID() == 'PAP' ? $payment->amount() : 0;
179
-                        ?>
178
+						$payment_total += $payment->STS_ID() == 'PAP' ? $payment->amount() : 0;
179
+						?>
180 180
                     <?php endforeach; // $payment?>
181 181
                     <?php
182
-                    $pay_totals_class = $payment_total > $grand_raw_total ? ' important-notice' : '';
183
-                    $overpaid = $payment_total > $grand_raw_total
184
-                        ? '<span id="overpaid">' . esc_html__('This transaction has been overpaid ! ', 'event_espresso')
185
-                          . '</span>'
186
-                        : '';
187
-                    ?>
182
+					$pay_totals_class = $payment_total > $grand_raw_total ? ' important-notice' : '';
183
+					$overpaid = $payment_total > $grand_raw_total
184
+						? '<span id="overpaid">' . esc_html__('This transaction has been overpaid ! ', 'event_espresso')
185
+						  . '</span>'
186
+						: '';
187
+					?>
188 188
                     <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr hidden">
189 189
                         <td class=" jst-rght" colspan="10">
190 190
                             <span class="important-notice"><?php echo $no_payment_text; ?></span>
@@ -195,20 +195,20 @@  discard block
 block discarded – undo
195 195
                         <th class=" jst-rght" colspan="9"><span
196 196
                                 id="payments-total-spn">
197 197
                                 <?php echo $overpaid
198
-                                           . sprintf(
199
-                                               esc_html__(
200
-                                                   'Payments Total %s',
201
-                                                   'event_espresso'
202
-                                               ),
203
-                                               '(' . EE_Registry::instance()->CFG->currency->code . ')'
204
-                                           ); ?></span></th>
198
+										   . sprintf(
199
+											   esc_html__(
200
+												   'Payments Total %s',
201
+												   'event_espresso'
202
+											   ),
203
+											   '(' . EE_Registry::instance()->CFG->currency->code . ')'
204
+										   ); ?></span></th>
205 205
                         <th class=" jst-rght"><span
206 206
                                 id="txn-admin-payment-total">
207 207
                                 <?php echo EEH_Template::format_currency(
208
-                                    $payment_total,
209
-                                    false,
210
-                                    false
211
-                                ); ?></span></th>
208
+									$payment_total,
209
+									false,
210
+									false
211
+								); ?></span></th>
212 212
                     </tr>
213 213
                 <?php else : ?>
214 214
                     <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr">
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
                         <th class=" jst-rght" colspan="9"><span
221 221
                                 id="payments-total-spn">
222 222
                                 <?php echo esc_html__(
223
-                                    'Payments Total',
224
-                                    'event_espresso'
225
-                                ); ?></span></th>
223
+									'Payments Total',
224
+									'event_espresso'
225
+								); ?></span></th>
226 226
                         <th class=" jst-rght"><span id="txn-admin-payment-total"></span></th>
227 227
                     </tr>
228 228
                 <?php endif; // $payments
229
-                ?>
229
+				?>
230 230
 
231 231
                 <tr id="txn-admin-payment-empty-row-tr" class="hidden">
232 232
                     <td>
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
         <ul id="txn-admin-payment-options-ul">
293 293
             <?php if ($can_edit_payments) :
294
-                ?>
294
+				?>
295 295
                 <li>
296 296
                     <a id="display-txn-admin-apply-payment" class="button-primary no-icon no-hide"
297 297
                        rel="txn-admin-apply-payment"> <!--display-the-hidden -->
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
                 <li>
309 309
                     <p>
310 310
                         <?php esc_html__(
311
-                            'You do not have access to apply payments or refunds.',
312
-                            'event_espresso'
313
-                        ); ?></p>
311
+							'You do not have access to apply payments or refunds.',
312
+							'event_espresso'
313
+						); ?></p>
314 314
                 </li>
315 315
             <?php endif; ?>
316 316
         </ul>
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
                 style="display:none;">
329 329
                 <div class="ee-icon ee-icon-cash-edit float-left"></div>
330 330
                 <?php
331
-                echo sprintf(
332
-                    __('Edit Payment #%s for Transaction #%s', 'event_espresso'),
333
-                    '<span></span>',
334
-                    $txn_nmbr['value']
335
-                );
336
-                ?>
331
+				echo sprintf(
332
+					__('Edit Payment #%s for Transaction #%s', 'event_espresso'),
333
+					'<span></span>',
334
+					$txn_nmbr['value']
335
+				);
336
+				?>
337 337
             </h2>
338 338
 
339 339
             <h2 id="admin-modal-dialog-edit-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;">
340 340
                 <div class="ee-icon ee-icon-cash-edit float-left"></div>
341 341
                 <?php
342
-                echo sprintf(
343
-                    __('Edit Refund #%s for Transaction #%s', 'event_espresso'),
344
-                    '<span></span>',
345
-                    $txn_nmbr['value']
346
-                );
347
-                ?>
342
+				echo sprintf(
343
+					__('Edit Refund #%s for Transaction #%s', 'event_espresso'),
344
+					'<span></span>',
345
+					$txn_nmbr['value']
346
+				);
347
+				?>
348 348
             </h2>
349 349
 
350 350
             <h2 id="admin-modal-dialog-apply-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon"
@@ -378,55 +378,55 @@  discard block
 block discarded – undo
378 378
                         <div class="txn-admin-apply-payment-date-dv admin-modal-dialog-row">
379 379
                             <div class="validation-notice-dv">
380 380
                                 <?php esc_html_e(
381
-                                    'The following is  a required field',
382
-                                    'event_espresso'
383
-                                ); ?></div>
381
+									'The following is  a required field',
382
+									'event_espresso'
383
+								); ?></div>
384 384
                             <label for="txn-admin-payment-date-inp" class="">
385 385
                                 <?php esc_html_e(
386
-                                    'Payment Date',
387
-                                    'event_espresso'
388
-                                ); ?></label>
386
+									'Payment Date',
387
+									'event_espresso'
388
+								); ?></label>
389 389
                             <input name="txn_admin_payment[date]" id="txn-admin-payment-date-inp"
390 390
                                    class="txn-admin-apply-payment-inp required" type="text"
391 391
                                    value="<?php echo date('Y-m-d g:i a', current_time('timestamp')); ?>"/>
392 392
                             <p class="description">
393 393
                                 <?php esc_html_e(
394
-                                    'The date the payment was actually made on',
395
-                                    'event_espresso'
396
-                                ); ?></p>
394
+									'The date the payment was actually made on',
395
+									'event_espresso'
396
+								); ?></p>
397 397
                         </div>
398 398
 
399 399
                         <div class="txn-admin-apply-payment-amount-dv admin-modal-dialog-row">
400 400
                             <div class="validation-notice-dv">
401 401
                                 <?php esc_html_e(
402
-                                    'The following is  a required field',
403
-                                    'event_espresso'
404
-                                ); ?></div>
402
+									'The following is  a required field',
403
+									'event_espresso'
404
+								); ?></div>
405 405
                             <label for="txn-admin-payment-amount-inp" class="">
406 406
                                 <?php esc_html_e(
407
-                                    'Amount',
408
-                                    'event_espresso'
409
-                                ); ?></label>
407
+									'Amount',
408
+									'event_espresso'
409
+								); ?></label>
410 410
                             <input name="txn_admin_payment[amount]" id="txn-admin-payment-amount-inp"
411 411
                                    class="txn-admin-apply-payment-inp required" type="text" value=""/>
412 412
                             <p class="description">
413 413
                                 <?php esc_html_e(
414
-                                    'The amount of the payment',
415
-                                    'event_espresso'
416
-                                ); ?></p>
414
+									'The amount of the payment',
415
+									'event_espresso'
416
+								); ?></p>
417 417
                         </div>
418 418
 
419 419
                         <div class="txn-admin-apply-payment-method-dv admin-modal-dialog-row">
420 420
                             <div class="validation-notice-dv">
421 421
                                 <?php esc_html_e(
422
-                                    'The following is  a required field',
423
-                                    'event_espresso'
424
-                                ); ?></div>
422
+									'The following is  a required field',
423
+									'event_espresso'
424
+								); ?></div>
425 425
                             <label for="txn-admin-payment-method-inp" class="">
426 426
                                 <?php esc_html_e(
427
-                                    'Method of Payment',
428
-                                    'event_espresso'
429
-                                ); ?></label>
427
+									'Method of Payment',
428
+									'event_espresso'
429
+								); ?></label>
430 430
                             <select name="txn_admin_payment[PMD_ID]" id="txn-admin-payment-method-slct"
431 431
                                     class="txn-admin-apply-payment-slct required" type="text">
432 432
                                 <?php foreach ($payment_methods as $method) : ?>
@@ -434,39 +434,39 @@  discard block
 block discarded – undo
434 434
                                     <option id="payment-method-opt-<?php echo $method->slug(); ?>"
435 435
                                             value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>>
436 436
                                         <?php echo sanitize_key(
437
-                                            $method->admin_desc()
438
-                                        )
439
-                                            ? substr(
440
-                                                $method->admin_desc(),
441
-                                                0,
442
-                                                128
443
-                                            )
444
-                                            : $method->admin_name(); ?>&nbsp;&nbsp;
437
+											$method->admin_desc()
438
+										)
439
+											? substr(
440
+												$method->admin_desc(),
441
+												0,
442
+												128
443
+											)
444
+											: $method->admin_name(); ?>&nbsp;&nbsp;
445 445
                                     </option>
446 446
                                 <?php endforeach; ?>
447 447
                             </select>
448 448
                             <p class="description">
449 449
                                 <?php esc_html_e(
450
-                                    'Whether the payment was made via PayPal, Credit Card, Cheque, or Cash',
451
-                                    'event_espresso'
452
-                                ); ?></p>
450
+									'Whether the payment was made via PayPal, Credit Card, Cheque, or Cash',
451
+									'event_espresso'
452
+								); ?></p>
453 453
                         </div>
454 454
 
455 455
                         <div class="mop-PP mop-CC mop-CHQ mop">
456 456
                             <div class="txn-admin-apply-payment-gw-txn-id-dv admin-modal-dialog-row">
457 457
                                 <label for="txn-admin-payment-txn-id-inp" class="">
458 458
                                     <?php esc_html_e(
459
-                                        'TXN ID / CHQ #',
460
-                                        'event_espresso'
461
-                                    ); ?></label>
459
+										'TXN ID / CHQ #',
460
+										'event_espresso'
461
+									); ?></label>
462 462
                                 <input name="txn_admin_payment[txn_id_chq_nmbr]"
463 463
                                        id="txn-admin-payment-txn-id-chq-nmbr-inp" class="txn-admin-apply-payment-inp"
464 464
                                        type="text" maxlength="100"/>
465 465
                                 <p class="description">
466 466
                                     <?php esc_html_e(
467
-                                        'The Transaction ID sent back from the payment gateway, or the Cheque #',
468
-                                        'event_espresso'
469
-                                    ); ?></p>
467
+										'The Transaction ID sent back from the payment gateway, or the Cheque #',
468
+										'event_espresso'
469
+									); ?></p>
470 470
                             </div>
471 471
                         </div>
472 472
 
@@ -479,9 +479,9 @@  discard block
 block discarded – undo
479 479
                                        type="text"/>
480 480
                                 <p class="description">
481 481
                                     <?php esc_html_e(
482
-                                        'The gateway response string (optional)',
483
-                                        'event_espresso'
484
-                                    ); ?></p>
482
+										'The gateway response string (optional)',
483
+										'event_espresso'
484
+									); ?></p>
485 485
                             </div>
486 486
                         </div>
487 487
 
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
                             <div class="txn-admin-apply-payment-status-dv admin-modal-dialog-row">
490 490
                                 <label for="txn-admin-payment-status-inp" class="">
491 491
                                     <?php esc_html_e(
492
-                                        'Payment Status',
493
-                                        'event_espresso'
494
-                                    ); ?></label>
492
+										'Payment Status',
493
+										'event_espresso'
494
+									); ?></label>
495 495
                                 <select name="txn_admin_payment[status]" id="txn-admin-payment-status-slct"
496 496
                                         class="txn-admin-apply-payment-slct" type="text">
497 497
                                     <?php foreach ($payment_status as $STS_ID => $STS_code) : ?>
@@ -504,52 +504,52 @@  discard block
 block discarded – undo
504 504
                                 </select>
505 505
                                 <p class="description">
506 506
                                     <?php esc_html_e(
507
-                                        'Whether the payment was approved, cancelled, declined or failed after submission to the gateway',
508
-                                        'event_espresso'
509
-                                    ); ?></p>
507
+										'Whether the payment was approved, cancelled, declined or failed after submission to the gateway',
508
+										'event_espresso'
509
+									); ?></p>
510 510
                             </div>
511 511
                         </div>
512 512
 
513 513
                         <div class="txn-admin-apply-payment-po-nmbr-dv admin-modal-dialog-row">
514 514
                             <label for="txn-admin-payment-po-nmbr-inp" class="">
515 515
                                 <?php esc_html_e(
516
-                                    'P.O. / S.O. #',
517
-                                    'event_espresso'
518
-                                ); ?></label>
516
+									'P.O. / S.O. #',
517
+									'event_espresso'
518
+								); ?></label>
519 519
                             <input name="txn_admin_payment[po_number]" id="txn-admin-payment-po-nmbr-inp"
520 520
                                    class="txn-admin-apply-payment-inp" type="text" maxlength="100"/>
521 521
                             <p class="description">
522 522
                                 <?php esc_html_e(
523
-                                    'The Purchase or Sales Order Number if any (optional)',
524
-                                    'event_espresso'
525
-                                ); ?></p>
523
+									'The Purchase or Sales Order Number if any (optional)',
524
+									'event_espresso'
525
+								); ?></p>
526 526
                         </div>
527 527
 
528 528
                         <div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row">
529 529
                             <label for="txn-admin-payment-accounting-inp"
530 530
                                    class="last">
531 531
                                 <?php esc_html_e(
532
-                                    'Notes / Extra Accounting',
533
-                                    'event_espresso'
534
-                                ); ?></label>
532
+									'Notes / Extra Accounting',
533
+									'event_espresso'
534
+								); ?></label>
535 535
                             <input name="txn_admin_payment[accounting]" id="txn-admin-payment-accounting-inp"
536 536
                                    class="txn-admin-apply-payment-inp" type="text" value="<?php echo $REG_code; ?>"
537 537
                                    maxlength="100"/> <input type="hidden" id="txn-admin-reg-code-inp"
538 538
                                                             value="<?php echo $REG_code; ?>"/>
539 539
                             <p class="description">
540 540
                                 <?php esc_html_e(
541
-                                    'An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.',
542
-                                    'event_espresso'
543
-                                ); ?></p>
541
+									'An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.',
542
+									'event_espresso'
543
+								); ?></p>
544 544
                         </div>
545 545
 
546 546
                         <div class="txn-admin-apply-payment-registrations-dv admin-modal-dialog-row">
547 547
                             <label for="txn-admin-payment-registrations-inp"
548 548
                                    class="last">
549 549
                                 <?php esc_html_e(
550
-                                    'Registrations to Apply Payment to:',
551
-                                    'event_espresso'
552
-                                ); ?></label>
550
+									'Registrations to Apply Payment to:',
551
+									'event_espresso'
552
+								); ?></label>
553 553
                             <label class="txn-admin-apply-payment-to-registrations-lbl">
554 554
                                 <input type="radio" value="1" id="txn-admin-apply-payment-to-all-registrations-inp"
555 555
                                        name="txn_admin_payment[apply_to_all_registrations]" checked="checked"/>
@@ -567,15 +567,15 @@  discard block
 block discarded – undo
567 567
                             <label for="txn-admin-payment-reg-status-inp"
568 568
                                    class="last">
569 569
                                 <?php esc_html_e(
570
-                                    'Change Registration Status?',
571
-                                    'event_espresso'
572
-                                ); ?></label>
570
+									'Change Registration Status?',
571
+									'event_espresso'
572
+								); ?></label>
573 573
                             <?php echo $status_change_select; ?>
574 574
                             <p class="description">
575 575
                                 <?php esc_html_e(
576
-                                    'If you wish to change the status for the registrations selected above, then select which status from this dropdown.',
577
-                                    'event_espresso'
578
-                                ); ?></p>
576
+									'If you wish to change the status for the registrations selected above, then select which status from this dropdown.',
577
+									'event_espresso'
578
+								); ?></p>
579 579
                             <br/>
580 580
                         </div>
581 581
 
@@ -596,14 +596,14 @@  discard block
 block discarded – undo
596 596
                             <br class="clear-float"/>
597 597
                             <p class="description">
598 598
                                 <?php printf(
599
-                                    esc_html__(
600
-                                        'By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.',
601
-                                        'event_espresso'
602
-                                    ),
603
-                                    '<strong>',
604
-                                    '</strong>',
605
-                                    '<br />'
606
-                                ); ?></p>
599
+									esc_html__(
600
+										'By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.',
601
+										'event_espresso'
602
+									),
603
+									'<strong>',
604
+									'</strong>',
605
+									'<br />'
606
+								); ?></p>
607 607
                             <label></label>
608 608
                         </div>
609 609
                         <div class="clear"></div>
@@ -644,9 +644,9 @@  discard block
 block discarded – undo
644 644
                     <li>
645 645
                         <span id="ee-ajax-processing-text" style="display:none;">
646 646
                             <?php esc_html_e(
647
-                                'Processing...',
648
-                                'event_espresso'
649
-                            ); ?></span>
647
+								'Processing...',
648
+								'event_espresso'
649
+							); ?></span>
650 650
                     </li>
651 651
                 </ul>
652 652
 
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
                 style="display:none;">
662 662
                 <span class="ee-icon ee-icon-cash-add"></span>
663 663
                 <?php echo esc_html__(
664
-                    'Delete Payment/Refund for Transaction #',
665
-                    'event_espresso'
666
-                ) . $txn_nmbr['value']; ?>
664
+					'Delete Payment/Refund for Transaction #',
665
+					'event_espresso'
666
+				) . $txn_nmbr['value']; ?>
667 667
             </h2>
668 668
 
669 669
             <form name="txn-admin-delete-payment-frm" id="txn-admin-delete-payment-frm"
@@ -685,19 +685,19 @@  discard block
 block discarded – undo
685 685
                             <label for="delete-txn-admin-payment-reg-status-inp"
686 686
                                    class="last">
687 687
                                 <?php esc_html_e(
688
-                                    'Change Registration Status?',
689
-                                    'event_espresso'
690
-                                ); ?></label>
688
+									'Change Registration Status?',
689
+									'event_espresso'
690
+								); ?></label>
691 691
                             <?php echo $delete_status_change_select; ?>
692 692
                             <p class="description">
693 693
                                 <?php printf(
694
-                                    esc_html__(
695
-                                        'If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s',
696
-                                        'event_espresso'
697
-                                    ),
698
-                                    '<strong>',
699
-                                    '</strong>'
700
-                                ); ?></p>
694
+									esc_html__(
695
+										'If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s',
696
+										'event_espresso'
697
+									),
698
+									'<strong>',
699
+									'</strong>'
700
+								); ?></p>
701 701
                         </div>
702 702
 
703 703
                         <div class="ee-attention txn-admin-apply-payment-accounting-dv admin-modal-dialog-row">
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
                             <input type="checkbox" value="1" name="delete_txn_reg_status_change[send_notifications]">
707 707
                             <p class="description">
708 708
                                 <?php esc_html_e(
709
-                                    'If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.',
710
-                                    'event_espresso'
711
-                                ); ?></p>
709
+									'If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.',
710
+									'event_espresso'
711
+								); ?></p>
712 712
                         </div>
713 713
                         <div class="clear"></div>
714 714
 
@@ -740,16 +740,16 @@  discard block
 block discarded – undo
740 740
     <?php endif; // $grand_raw_total > 0?>
741 741
 
742 742
     <?php
743
-    if (WP_DEBUG) {
744
-        $delivered_messages = get_option('EED_Messages__payment', array());
745
-        if (isset($delivered_messages[ $TXN_ID ])) {
746
-            ?>
743
+	if (WP_DEBUG) {
744
+		$delivered_messages = get_option('EED_Messages__payment', array());
745
+		if (isset($delivered_messages[ $TXN_ID ])) {
746
+			?>
747 747
             <h4 class="admin-primary-mbox-h4 hdr-has-icon"><span
748 748
                     class="dashicons dashicons-email-alt"></span>
749 749
                 <?php esc_html_e(
750
-                    'Messages Sent to Primary Registrant',
751
-                    'event_espresso'
752
-                ); ?></h4>
750
+					'Messages Sent to Primary Registrant',
751
+					'event_espresso'
752
+				); ?></h4>
753 753
 
754 754
             <div class="admin-primary-mbox-tbl-wrap">
755 755
                 <table class="admin-primary-mbox-tbl">
@@ -763,26 +763,26 @@  discard block
 block discarded – undo
763 763
                     </thead>
764 764
                     <tbody>
765 765
                     <?php foreach ($delivered_messages[ $TXN_ID ] as $timestamp => $delivered_message) :
766
-                        ?>
766
+						?>
767 767
                         <tr>
768 768
                             <td class="jst-left">
769 769
                                 <?php echo date(
770
-                                    get_option('date_format') . ' ' . get_option('time_format'),
771
-                                    ($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))
772
-                                ); ?></td>
770
+									get_option('date_format') . ' ' . get_option('time_format'),
771
+									($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))
772
+								); ?></td>
773 773
                             <td class="jst-left"><?php echo isset($delivered_message['message_type'])
774
-                                    ? $delivered_message['message_type'] : ''; ?></td>
774
+									? $delivered_message['message_type'] : ''; ?></td>
775 775
                             <td class="jst-left"><?php echo isset($delivered_message['pay_status'])
776
-                                    ? $delivered_message['pay_status'] : ''; ?></td>
776
+									? $delivered_message['pay_status'] : ''; ?></td>
777 777
                             <td class="jst-left"><?php echo isset($delivered_message['txn_status'])
778
-                                    ? $delivered_message['txn_status'] : ''; ?></td>
778
+									? $delivered_message['txn_status'] : ''; ?></td>
779 779
                         </tr>
780 780
                     <?php endforeach; // $delivered_messages?>
781 781
                     </tbody>
782 782
                 </table>
783 783
             </div>
784 784
             <?php
785
-        }
786
-    }
787
-    ?>
785
+		}
786
+	}
787
+	?>
788 788
 </div>
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -210,10 +210,13 @@  discard block
 block discarded – undo
210 210
                                     false
211 211
                                 ); ?></span></th>
212 212
                     </tr>
213
-                <?php else : ?>
213
+                <?php else {
214
+	: ?>
214 215
                     <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr">
215 216
                         <td class=" jst-rght" colspan="10">
216
-                            <span class="important-notice"><?php echo $no_payment_text; ?></span>
217
+                            <span class="important-notice"><?php echo $no_payment_text;
218
+}
219
+?></span>
217 220
                         </td>
218 221
                     </tr>
219 222
                     <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr hidden">
@@ -304,13 +307,16 @@  discard block
 block discarded – undo
304 307
                         <?php esc_html_e('Apply Refund', 'event_espresso'); ?>
305 308
                     </a>
306 309
                 </li>
307
-            <?php else : ?>
310
+            <?php else {
311
+	: ?>
308 312
                 <li>
309 313
                     <p>
310 314
                         <?php esc_html__(
311 315
                             'You do not have access to apply payments or refunds.',
312 316
                             'event_espresso'
313
-                        ); ?></p>
317
+                        );
318
+}
319
+?></p>
314 320
                 </li>
315 321
             <?php endif; ?>
316 322
         </ul>
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Registration_CheckIn_List_Table.class.php 1 patch
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -18,226 +18,226 @@
 block discarded – undo
18 18
 class EE_Registration_CheckIn_List_Table extends EE_Admin_List_Table
19 19
 {
20 20
 
21
-    /**
22
-     * EE_Registration_CheckIn_List_Table constructor.
23
-     *
24
-     * @param EE_Admin_Page $admin_page
25
-     */
26
-    public function __construct($admin_page)
27
-    {
28
-        parent::__construct($admin_page);
29
-    }
30
-
31
-
32
-    /**
33
-     * @throws EE_Error
34
-     */
35
-    protected function _setup_data()
36
-    {
37
-        $this->_data = $this->_get_checkins($this->_per_page);
38
-        $this->_all_data_count = $this->_get_checkins($this->_per_page, true);
39
-    }
40
-
41
-
42
-    /**
43
-     * Sets up the properties for the list table.
44
-     */
45
-    protected function _set_properties()
46
-    {
47
-        $this->_wp_list_args = array(
48
-            'singular' => __('check-in', 'event_espresso'),
49
-            'plural'   => __('check-ins', 'event_espresso'),
50
-            'ajax'     => true,
51
-            'screen'   => $this->_admin_page->get_current_screen()->id,
52
-        );
53
-
54
-        $this->_columns = array(
55
-            'cb'            => '<input type="checkbox" />', // Render a checkbox instead of text
56
-            'CHK_in'        => __('Check-In', 'event_espresso'),
57
-            'CHK_timestamp' => __('Timestamp', 'event_espresso'),
58
-        );
59
-
60
-        $this->_sortable_columns = array(
61
-            'CHK_timestamp' => array('CHK_timestamp' => true),
62
-        );
63
-
64
-        $this->_primary_column = 'CHK_in';
65
-
66
-        $this->_hidden_columns = array();
67
-    }
68
-
69
-
70
-    /**
71
-     * @return array
72
-     */
73
-    protected function _get_table_filters()
74
-    {
75
-        return [];
76
-    }
77
-
78
-
79
-    /**
80
-     * Returning an empty string to remove the search box for this view.
81
-     *
82
-     * @param string $text
83
-     * @param string $input_id
84
-     * @return string
85
-     */
86
-    public function search_box($text, $input_id)
87
-    {
88
-        return '';
89
-    }
90
-
91
-
92
-    /**
93
-     * @throws EE_Error
94
-     */
95
-    protected function _add_view_counts()
96
-    {
97
-        $this->_views['all']['count'] = $this->_get_checkins(null, true);
98
-    }
99
-
100
-
101
-    /**
102
-     * @param EE_Checkin $item
103
-     * @return string
104
-     * @throws EE_Error
105
-     * @throws InvalidArgumentException
106
-     * @throws ReflectionException
107
-     * @throws InvalidDataTypeException
108
-     * @throws InvalidInterfaceException
109
-     */
110
-    public function column_cb($item)
111
-    {
112
-        return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID());
113
-    }
114
-
115
-
116
-    /**
117
-     * @param EE_Checkin $item
118
-     * @return string
119
-     * @throws EE_Error
120
-     * @throws InvalidArgumentException
121
-     * @throws InvalidDataTypeException
122
-     * @throws InvalidInterfaceException
123
-     * @throws ReflectionException
124
-     */
125
-    public function column_CHK_in(EE_Checkin $item)
126
-    {
127
-        $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item);
128
-        return '<span class="'
129
-               . $checkin_status_dashicon->cssClasses()
130
-               . '"></span><span class="show-on-mobile-view-only">'
131
-               . $item->get_datetime('CHK_timestamp')
132
-               . '</span>';
133
-    }
134
-
135
-
136
-    /**
137
-     * @param EE_Checkin $item
138
-     * @return string
139
-     * @throws EE_Error
140
-     * @throws InvalidArgumentException
141
-     * @throws InvalidDataTypeException
142
-     * @throws InvalidInterfaceException
143
-     * @throws ReflectionException
144
-     */
145
-    public function column_CHK_timestamp(EE_Checkin $item)
146
-    {
147
-        $actions = array();
148
-        $delete_url = EE_Admin_Page::add_query_args_and_nonce(
149
-            array(
150
-                'action'  => 'delete_checkin_row',
151
-                'DTT_ID'  => $this->_req_data['DTT_ID'],
152
-                '_REG_ID' => $this->_req_data['_REG_ID'],
153
-                'CHK_ID'  => $item->ID(),
154
-            )
155
-        );
156
-        $actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can(
157
-            'ee_delete_checkins',
158
-            'espresso_registrations_delete_checkin_row'
159
-        )
160
-            ? '<a href="' . $delete_url . '" title="'
161
-              . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">'
162
-              . __('Delete', 'event_espresso') . '</a>'
163
-            : '';
164
-
165
-        return sprintf(
166
-            '%1$s %2$s',
167
-            $item->get_datetime('CHK_timestamp', '', 'H:i:s a'),
168
-            $this->row_actions($actions)
169
-        );
170
-    }
171
-
172
-
173
-    /**
174
-     * This retrieves all the Check-ins for the given parameters.
175
-     * experimenting with having the query for the table values within the list table.
176
-     *
177
-     * @param int  $per_page How many to retrieve per page
178
-     * @param bool $count    Whether to return a count or not
179
-     * @return EE_Checkin[]|int
180
-     * @throws EE_Error
181
-     * @throws InvalidArgumentException
182
-     * @throws InvalidDataTypeException
183
-     * @throws InvalidInterfaceException
184
-     */
185
-    protected function _get_checkins($per_page = 10, $count = false)
186
-    {
187
-        $REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : false;
188
-        $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : false;
189
-
190
-        // if user does not have the capability for the checkins for this registration then get out!
191
-        if (! EE_Registry::instance()->CAP->current_user_can(
192
-            'ee_read_checkin',
193
-            'espresso_registrations_registration_checkins',
194
-            $REG_ID
195
-        )) {
196
-            return $count ? 0 : array();
197
-        }
198
-
199
-        // if no reg id then get out cause need a reg id
200
-        if (empty($REG_ID) || empty($DTT_ID)) {
201
-            throw new EE_Error(
202
-                __(
203
-                    'This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)',
204
-                    'event_espresso'
205
-                )
206
-            );
207
-        }
208
-
209
-        // set orderby
210
-        // note that with this table we're only providing the option to orderby the timestamp value.
211
-        $orderby = 'CHK_timestamp';
212
-
213
-        $order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
214
-
215
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
216
-            ? $this->_req_data['paged']
217
-            : 1;
218
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
219
-            ? $this->_req_data['perpage']
220
-            : $per_page;
221
-        $limit = null;
222
-        if (! $count) {
223
-            $offset = ($current_page - 1) * $per_page;
224
-            $limit = array($offset, $per_page);
225
-        }
226
-
227
-        $_where = array(
228
-            'REG_ID' => $REG_ID,
229
-            'DTT_ID' => $DTT_ID,
230
-        );
231
-
232
-        $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit);
233
-
234
-        // if no per_page value then we just want to return a count of all Check-ins
235
-        if ($count) {
236
-            return EEM_Checkin::instance()->count(array($_where));
237
-        }
238
-
239
-        return $count
240
-            ? EEM_Checkin::instance()->count(array($_where))
241
-            : EEM_Checkin::instance()->get_all($query_params);
242
-    }
21
+	/**
22
+	 * EE_Registration_CheckIn_List_Table constructor.
23
+	 *
24
+	 * @param EE_Admin_Page $admin_page
25
+	 */
26
+	public function __construct($admin_page)
27
+	{
28
+		parent::__construct($admin_page);
29
+	}
30
+
31
+
32
+	/**
33
+	 * @throws EE_Error
34
+	 */
35
+	protected function _setup_data()
36
+	{
37
+		$this->_data = $this->_get_checkins($this->_per_page);
38
+		$this->_all_data_count = $this->_get_checkins($this->_per_page, true);
39
+	}
40
+
41
+
42
+	/**
43
+	 * Sets up the properties for the list table.
44
+	 */
45
+	protected function _set_properties()
46
+	{
47
+		$this->_wp_list_args = array(
48
+			'singular' => __('check-in', 'event_espresso'),
49
+			'plural'   => __('check-ins', 'event_espresso'),
50
+			'ajax'     => true,
51
+			'screen'   => $this->_admin_page->get_current_screen()->id,
52
+		);
53
+
54
+		$this->_columns = array(
55
+			'cb'            => '<input type="checkbox" />', // Render a checkbox instead of text
56
+			'CHK_in'        => __('Check-In', 'event_espresso'),
57
+			'CHK_timestamp' => __('Timestamp', 'event_espresso'),
58
+		);
59
+
60
+		$this->_sortable_columns = array(
61
+			'CHK_timestamp' => array('CHK_timestamp' => true),
62
+		);
63
+
64
+		$this->_primary_column = 'CHK_in';
65
+
66
+		$this->_hidden_columns = array();
67
+	}
68
+
69
+
70
+	/**
71
+	 * @return array
72
+	 */
73
+	protected function _get_table_filters()
74
+	{
75
+		return [];
76
+	}
77
+
78
+
79
+	/**
80
+	 * Returning an empty string to remove the search box for this view.
81
+	 *
82
+	 * @param string $text
83
+	 * @param string $input_id
84
+	 * @return string
85
+	 */
86
+	public function search_box($text, $input_id)
87
+	{
88
+		return '';
89
+	}
90
+
91
+
92
+	/**
93
+	 * @throws EE_Error
94
+	 */
95
+	protected function _add_view_counts()
96
+	{
97
+		$this->_views['all']['count'] = $this->_get_checkins(null, true);
98
+	}
99
+
100
+
101
+	/**
102
+	 * @param EE_Checkin $item
103
+	 * @return string
104
+	 * @throws EE_Error
105
+	 * @throws InvalidArgumentException
106
+	 * @throws ReflectionException
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws InvalidInterfaceException
109
+	 */
110
+	public function column_cb($item)
111
+	{
112
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID());
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param EE_Checkin $item
118
+	 * @return string
119
+	 * @throws EE_Error
120
+	 * @throws InvalidArgumentException
121
+	 * @throws InvalidDataTypeException
122
+	 * @throws InvalidInterfaceException
123
+	 * @throws ReflectionException
124
+	 */
125
+	public function column_CHK_in(EE_Checkin $item)
126
+	{
127
+		$checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item);
128
+		return '<span class="'
129
+			   . $checkin_status_dashicon->cssClasses()
130
+			   . '"></span><span class="show-on-mobile-view-only">'
131
+			   . $item->get_datetime('CHK_timestamp')
132
+			   . '</span>';
133
+	}
134
+
135
+
136
+	/**
137
+	 * @param EE_Checkin $item
138
+	 * @return string
139
+	 * @throws EE_Error
140
+	 * @throws InvalidArgumentException
141
+	 * @throws InvalidDataTypeException
142
+	 * @throws InvalidInterfaceException
143
+	 * @throws ReflectionException
144
+	 */
145
+	public function column_CHK_timestamp(EE_Checkin $item)
146
+	{
147
+		$actions = array();
148
+		$delete_url = EE_Admin_Page::add_query_args_and_nonce(
149
+			array(
150
+				'action'  => 'delete_checkin_row',
151
+				'DTT_ID'  => $this->_req_data['DTT_ID'],
152
+				'_REG_ID' => $this->_req_data['_REG_ID'],
153
+				'CHK_ID'  => $item->ID(),
154
+			)
155
+		);
156
+		$actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can(
157
+			'ee_delete_checkins',
158
+			'espresso_registrations_delete_checkin_row'
159
+		)
160
+			? '<a href="' . $delete_url . '" title="'
161
+			  . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">'
162
+			  . __('Delete', 'event_espresso') . '</a>'
163
+			: '';
164
+
165
+		return sprintf(
166
+			'%1$s %2$s',
167
+			$item->get_datetime('CHK_timestamp', '', 'H:i:s a'),
168
+			$this->row_actions($actions)
169
+		);
170
+	}
171
+
172
+
173
+	/**
174
+	 * This retrieves all the Check-ins for the given parameters.
175
+	 * experimenting with having the query for the table values within the list table.
176
+	 *
177
+	 * @param int  $per_page How many to retrieve per page
178
+	 * @param bool $count    Whether to return a count or not
179
+	 * @return EE_Checkin[]|int
180
+	 * @throws EE_Error
181
+	 * @throws InvalidArgumentException
182
+	 * @throws InvalidDataTypeException
183
+	 * @throws InvalidInterfaceException
184
+	 */
185
+	protected function _get_checkins($per_page = 10, $count = false)
186
+	{
187
+		$REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : false;
188
+		$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : false;
189
+
190
+		// if user does not have the capability for the checkins for this registration then get out!
191
+		if (! EE_Registry::instance()->CAP->current_user_can(
192
+			'ee_read_checkin',
193
+			'espresso_registrations_registration_checkins',
194
+			$REG_ID
195
+		)) {
196
+			return $count ? 0 : array();
197
+		}
198
+
199
+		// if no reg id then get out cause need a reg id
200
+		if (empty($REG_ID) || empty($DTT_ID)) {
201
+			throw new EE_Error(
202
+				__(
203
+					'This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)',
204
+					'event_espresso'
205
+				)
206
+			);
207
+		}
208
+
209
+		// set orderby
210
+		// note that with this table we're only providing the option to orderby the timestamp value.
211
+		$orderby = 'CHK_timestamp';
212
+
213
+		$order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
214
+
215
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
216
+			? $this->_req_data['paged']
217
+			: 1;
218
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
219
+			? $this->_req_data['perpage']
220
+			: $per_page;
221
+		$limit = null;
222
+		if (! $count) {
223
+			$offset = ($current_page - 1) * $per_page;
224
+			$limit = array($offset, $per_page);
225
+		}
226
+
227
+		$_where = array(
228
+			'REG_ID' => $REG_ID,
229
+			'DTT_ID' => $DTT_ID,
230
+		);
231
+
232
+		$query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit);
233
+
234
+		// if no per_page value then we just want to return a count of all Check-ins
235
+		if ($count) {
236
+			return EEM_Checkin::instance()->count(array($_where));
237
+		}
238
+
239
+		return $count
240
+			? EEM_Checkin::instance()->count(array($_where))
241
+			: EEM_Checkin::instance()->get_all($query_params);
242
+	}
243 243
 }
Please login to merge, or discard this patch.
core/services/request/RequestInterface.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -16,145 +16,145 @@
 block discarded – undo
16 16
 interface RequestInterface extends RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @param RequestTypeContextCheckerInterface $type
21
-     */
22
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23
-
24
-    /**
25
-     * @return array
26
-     */
27
-    public function getParams();
28
-
29
-
30
-    /**
31
-     * @return array
32
-     */
33
-    public function postParams();
34
-
35
-
36
-    /**
37
-     * @return array
38
-     */
39
-    public function cookieParams();
40
-
41
-
42
-    /**
43
-     * @return array
44
-     */
45
-    public function serverParams();
46
-
47
-
48
-    /**
49
-     * @return array
50
-     */
51
-    public function filesParams();
19
+	/**
20
+	 * @param RequestTypeContextCheckerInterface $type
21
+	 */
22
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23
+
24
+	/**
25
+	 * @return array
26
+	 */
27
+	public function getParams();
28
+
29
+
30
+	/**
31
+	 * @return array
32
+	 */
33
+	public function postParams();
34
+
35
+
36
+	/**
37
+	 * @return array
38
+	 */
39
+	public function cookieParams();
40
+
41
+
42
+	/**
43
+	 * @return array
44
+	 */
45
+	public function serverParams();
46
+
47
+
48
+	/**
49
+	 * @return array
50
+	 */
51
+	public function filesParams();
52 52
 
53 53
 
54
-    /**
55
-     * returns contents of $_REQUEST
56
-     *
57
-     * @return array
58
-     */
59
-    public function requestParams();
54
+	/**
55
+	 * returns contents of $_REQUEST
56
+	 *
57
+	 * @return array
58
+	 */
59
+	public function requestParams();
60 60
 
61 61
 
62
-    /**
63
-     * @param string $key
64
-     * @param string $value
65
-     * @param bool   $override_ee
66
-     * @return    void
67
-     */
68
-    public function setRequestParam($key, $value, $override_ee = false);
62
+	/**
63
+	 * @param string $key
64
+	 * @param string $value
65
+	 * @param bool   $override_ee
66
+	 * @return    void
67
+	 */
68
+	public function setRequestParam($key, $value, $override_ee = false);
69 69
 
70 70
 
71
-    /**
72
-     * returns the value for a request param if the given key exists
73
-     *
74
-     * @param string $key
75
-     * @param null   $default
76
-     * @return mixed
77
-     */
78
-    public function getRequestParam($key, $default = null);
71
+	/**
72
+	 * returns the value for a request param if the given key exists
73
+	 *
74
+	 * @param string $key
75
+	 * @param null   $default
76
+	 * @return mixed
77
+	 */
78
+	public function getRequestParam($key, $default = null);
79 79
 
80 80
 
81
-    /**
82
-     * check if param exists
83
-     *
84
-     * @param string $key
85
-     * @return bool
86
-     */
87
-    public function requestParamIsSet($key);
81
+	/**
82
+	 * check if param exists
83
+	 *
84
+	 * @param string $key
85
+	 * @return bool
86
+	 */
87
+	public function requestParamIsSet($key);
88 88
 
89 89
 
90
-    /**
91
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
92
-     * and return the value for the first match found
93
-     * wildcards can be either of the following:
94
-     *      ? to represent a single character of any type
95
-     *      * to represent one or more characters of any type
96
-     *
97
-     * @param string     $pattern
98
-     * @param null|mixed $default
99
-     * @return false|int
100
-     */
101
-    public function getMatch($pattern, $default = null);
90
+	/**
91
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
92
+	 * and return the value for the first match found
93
+	 * wildcards can be either of the following:
94
+	 *      ? to represent a single character of any type
95
+	 *      * to represent one or more characters of any type
96
+	 *
97
+	 * @param string     $pattern
98
+	 * @param null|mixed $default
99
+	 * @return false|int
100
+	 */
101
+	public function getMatch($pattern, $default = null);
102 102
 
103 103
 
104
-    /**
105
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
106
-     * wildcards can be either of the following:
107
-     *      ? to represent a single character of any type
108
-     *      * to represent one or more characters of any type
109
-     * returns true if a match is found or false if not
110
-     *
111
-     * @param string $pattern
112
-     * @return false|int
113
-     */
114
-    public function matches($pattern);
104
+	/**
105
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
106
+	 * wildcards can be either of the following:
107
+	 *      ? to represent a single character of any type
108
+	 *      * to represent one or more characters of any type
109
+	 * returns true if a match is found or false if not
110
+	 *
111
+	 * @param string $pattern
112
+	 * @return false|int
113
+	 */
114
+	public function matches($pattern);
115 115
 
116 116
 
117
-    /**
118
-     * remove param
119
-     *
120
-     * @param string $key
121
-     * @param bool   $unset_from_global_too
122
-     */
123
-    public function unSetRequestParam($key, $unset_from_global_too = false);
117
+	/**
118
+	 * remove param
119
+	 *
120
+	 * @param string $key
121
+	 * @param bool   $unset_from_global_too
122
+	 */
123
+	public function unSetRequestParam($key, $unset_from_global_too = false);
124 124
 
125 125
 
126
-    /**
127
-     * @return string
128
-     */
129
-    public function ipAddress();
126
+	/**
127
+	 * @return string
128
+	 */
129
+	public function ipAddress();
130 130
 
131 131
 
132
-    /**
133
-     * @return string
134
-     */
135
-    public function requestUri();
136
-
132
+	/**
133
+	 * @return string
134
+	 */
135
+	public function requestUri();
136
+
137 137
 
138
-    /**
139
-     * @return string
140
-     */
141
-    public function userAgent();
142
-
143
-
144
-    /**
145
-     * @param string $user_agent
146
-     */
147
-    public function setUserAgent($user_agent = '');
148
-
149
-
150
-    /**
151
-     * @return bool
152
-     */
153
-    public function isBot();
154
-
155
-
156
-    /**
157
-     * @param bool $is_bot
158
-     */
159
-    public function setIsBot($is_bot);
138
+	/**
139
+	 * @return string
140
+	 */
141
+	public function userAgent();
142
+
143
+
144
+	/**
145
+	 * @param string $user_agent
146
+	 */
147
+	public function setUserAgent($user_agent = '');
148
+
149
+
150
+	/**
151
+	 * @return bool
152
+	 */
153
+	public function isBot();
154
+
155
+
156
+	/**
157
+	 * @param bool $is_bot
158
+	 */
159
+	public function setIsBot($is_bot);
160 160
 }
Please login to merge, or discard this patch.
core/services/request/Request.php 1 patch
Indentation   +620 added lines, -620 removed lines patch added patch discarded remove patch
@@ -17,624 +17,624 @@
 block discarded – undo
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19 19
 
20
-    /**
21
-     * $_GET parameters
22
-     *
23
-     * @var array $get
24
-     */
25
-    private $get;
26
-
27
-    /**
28
-     * $_POST parameters
29
-     *
30
-     * @var array $post
31
-     */
32
-    private $post;
33
-
34
-    /**
35
-     * $_COOKIE parameters
36
-     *
37
-     * @var array $cookie
38
-     */
39
-    private $cookie;
40
-
41
-    /**
42
-     * $_SERVER parameters
43
-     *
44
-     * @var array $server
45
-     */
46
-    private $server;
47
-
48
-    /**
49
-     * $_FILES parameters
50
-     *
51
-     * @var array $files
52
-     */
53
-    private $files;
54
-
55
-    /**
56
-     * $_REQUEST parameters
57
-     *
58
-     * @var array $request
59
-     */
60
-    private $request;
61
-
62
-    /**
63
-     * @var RequestTypeContextCheckerInterface
64
-     */
65
-    private $request_type;
66
-
67
-    /**
68
-     * IP address for request
69
-     *
70
-     * @var string $ip_address
71
-     */
72
-    private $ip_address;
73
-
74
-    /**
75
-     * @var string $user_agent
76
-     */
77
-    private $user_agent;
78
-
79
-    /**
80
-     * true if current user appears to be some kind of bot
81
-     *
82
-     * @var bool $is_bot
83
-     */
84
-    private $is_bot;
85
-
86
-
87
-    /**
88
-     * @param array $get
89
-     * @param array $post
90
-     * @param array $cookie
91
-     * @param array $server
92
-     * @param array $files
93
-     */
94
-    public function __construct(array $get, array $post, array $cookie, array $server, array $files = array())
95
-    {
96
-        // grab request vars
97
-        $this->get = $get;
98
-        $this->post = $post;
99
-        $this->cookie = $cookie;
100
-        $this->server = $server;
101
-        $this->files = $files;
102
-        $this->request = array_merge($this->get, $this->post);
103
-        $this->ip_address = $this->visitorIp();
104
-    }
105
-
106
-
107
-    /**
108
-     * @param RequestTypeContextCheckerInterface $type
109
-     */
110
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
111
-    {
112
-        $this->request_type = $type;
113
-    }
114
-
115
-
116
-    /**
117
-     * @return array
118
-     */
119
-    public function getParams()
120
-    {
121
-        return $this->get;
122
-    }
123
-
124
-
125
-    /**
126
-     * @return array
127
-     */
128
-    public function postParams()
129
-    {
130
-        return $this->post;
131
-    }
132
-
133
-
134
-    /**
135
-     * @return array
136
-     */
137
-    public function cookieParams()
138
-    {
139
-        return $this->cookie;
140
-    }
141
-
142
-
143
-    /**
144
-     * @return array
145
-     */
146
-    public function serverParams()
147
-    {
148
-        return $this->server;
149
-    }
150
-
151
-
152
-    /**
153
-     * @return array
154
-     */
155
-    public function filesParams()
156
-    {
157
-        return $this->files;
158
-    }
159
-
160
-
161
-    /**
162
-     * returns contents of $_REQUEST
163
-     *
164
-     * @return array
165
-     */
166
-    public function requestParams()
167
-    {
168
-        return $this->request;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param      $key
174
-     * @param      $value
175
-     * @param bool $override_ee
176
-     * @return    void
177
-     */
178
-    public function setRequestParam($key, $value, $override_ee = false)
179
-    {
180
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
181
-        if ($key !== 'ee'
182
-            || ($key === 'ee' && empty($this->request['ee']))
183
-            || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184
-        ) {
185
-            $this->request[ $key ] = $value;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * returns   the value for a request param if the given key exists
192
-     *
193
-     * @param       $key
194
-     * @param null  $default
195
-     * @return mixed
196
-     */
197
-    public function getRequestParam($key, $default = null)
198
-    {
199
-        return $this->requestParameterDrillDown($key, $default, 'get');
200
-    }
201
-
202
-
203
-    /**
204
-     * check if param exists
205
-     *
206
-     * @param       $key
207
-     * @return bool
208
-     */
209
-    public function requestParamIsSet($key)
210
-    {
211
-        return $this->requestParameterDrillDown($key);
212
-    }
213
-
214
-
215
-    /**
216
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
217
-     * and return the value for the first match found
218
-     * wildcards can be either of the following:
219
-     *      ? to represent a single character of any type
220
-     *      * to represent one or more characters of any type
221
-     *
222
-     * @param string     $pattern
223
-     * @param null|mixed $default
224
-     * @return mixed
225
-     */
226
-    public function getMatch($pattern, $default = null)
227
-    {
228
-        return $this->requestParameterDrillDown($pattern, $default, 'match');
229
-    }
230
-
231
-
232
-    /**
233
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
234
-     * wildcards can be either of the following:
235
-     *      ? to represent a single character of any type
236
-     *      * to represent one or more characters of any type
237
-     * returns true if a match is found or false if not
238
-     *
239
-     * @param string $pattern
240
-     * @return bool
241
-     */
242
-    public function matches($pattern)
243
-    {
244
-        return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
245
-    }
246
-
247
-
248
-    /**
249
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
250
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
251
-     *                                      and used to search through the current request's parameter keys
252
-     * @param array  $request_params        The array of request parameters to search through
253
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
254
-     *                                      Default is null
255
-     * @param string $return                [optional] Controls what kind of value is returned.
256
-     *                                      Options are:
257
-     *                                      'bool' will return true or false if match is found or not
258
-     *                                      'key' will return the first key found that matches the supplied pattern
259
-     *                                      'value' will return the value for the first request parameter
260
-     *                                      whose key matches the supplied pattern
261
-     *                                      Default is 'value'
262
-     * @return boolean|string
263
-     */
264
-    private function match($pattern, array $request_params, $default = null, $return = 'value')
265
-    {
266
-        $return = in_array($return, array('bool', 'key', 'value'), true)
267
-            ? $return
268
-            : 'is_set';
269
-        // replace wildcard chars with regex chars
270
-        $pattern = str_replace(
271
-            array("\*", "\?"),
272
-            array('.*', '.'),
273
-            preg_quote($pattern, '/')
274
-        );
275
-        foreach ($request_params as $key => $request_param) {
276
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
277
-                // return value for request param
278
-                if ($return === 'value') {
279
-                    return $request_params[ $key ];
280
-                }
281
-                // or actual key or true just to indicate it was found
282
-                return $return === 'key' ? $key : true;
283
-            }
284
-        }
285
-        // match not found so return default value or false
286
-        return $return === 'value' ? $default : false;
287
-    }
288
-
289
-
290
-    /**
291
-     * the supplied key can be a simple string to represent a "top-level" request parameter
292
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
293
-     * by using square brackets to surround keys for deeper array elements.
294
-     * For example :
295
-     * if the supplied $key was: "first[second][third]"
296
-     * then this will attempt to drill down into the request parameter array to find a value.
297
-     * Given the following request parameters:
298
-     *  array(
299
-     *      'first' => array(
300
-     *          'second' => array(
301
-     *              'third' => 'has a value'
302
-     *          )
303
-     *      )
304
-     *  )
305
-     * would return true if default parameters were set
306
-     *
307
-     * @param string $callback
308
-     * @param        $key
309
-     * @param null   $default
310
-     * @param array  $request_params
311
-     * @return bool|mixed|null
312
-     */
313
-    private function requestParameterDrillDown(
314
-        $key,
315
-        $default = null,
316
-        $callback = 'is_set',
317
-        array $request_params = array()
318
-    ) {
319
-        $callback = in_array($callback, array('is_set', 'get', 'match'), true)
320
-            ? $callback
321
-            : 'is_set';
322
-        $request_params = ! empty($request_params)
323
-            ? $request_params
324
-            : $this->request;
325
-        // does incoming key represent an array like 'first[second][third]'  ?
326
-        if (strpos($key, '[') !== false) {
327
-            // turn it into an actual array
328
-            $key = str_replace(']', '', $key);
329
-            $keys = explode('[', $key);
330
-            $key = array_shift($keys);
331
-            if ($callback === 'match') {
332
-                $real_key = $this->match($key, $request_params, $default, 'key');
333
-                $key = $real_key ? $real_key : $key;
334
-            }
335
-            // check if top level key exists
336
-            if (isset($request_params[ $key ])) {
337
-                // build a new key to pass along like: 'second[third]'
338
-                // or just 'second' depending on depth of keys
339
-                $key_string = array_shift($keys);
340
-                if (! empty($keys)) {
341
-                    $key_string .= '[' . implode('][', $keys) . ']';
342
-                }
343
-                return $this->requestParameterDrillDown(
344
-                    $key_string,
345
-                    $default,
346
-                    $callback,
347
-                    $request_params[ $key ]
348
-                );
349
-            }
350
-        }
351
-        if ($callback === 'is_set') {
352
-            return isset($request_params[ $key ]);
353
-        }
354
-        if ($callback === 'match') {
355
-            return $this->match($key, $request_params, $default);
356
-        }
357
-        return isset($request_params[ $key ])
358
-            ? $request_params[ $key ]
359
-            : $default;
360
-    }
361
-
362
-
363
-    /**
364
-     * remove param
365
-     *
366
-     * @param      $key
367
-     * @param bool $unset_from_global_too
368
-     */
369
-    public function unSetRequestParam($key, $unset_from_global_too = false)
370
-    {
371
-        unset($this->request[ $key ]);
372
-        if ($unset_from_global_too) {
373
-            unset($_REQUEST[ $key ]);
374
-        }
375
-    }
376
-
377
-
378
-    /**
379
-     * @return string
380
-     */
381
-    public function ipAddress()
382
-    {
383
-        return $this->ip_address;
384
-    }
385
-
386
-
387
-    /**
388
-     * attempt to get IP address of current visitor from server
389
-     * plz see: http://stackoverflow.com/a/2031935/1475279
390
-     *
391
-     * @access public
392
-     * @return string
393
-     */
394
-    private function visitorIp()
395
-    {
396
-        $visitor_ip = '0.0.0.0';
397
-        $server_keys = array(
398
-            'HTTP_CLIENT_IP',
399
-            'HTTP_X_FORWARDED_FOR',
400
-            'HTTP_X_FORWARDED',
401
-            'HTTP_X_CLUSTER_CLIENT_IP',
402
-            'HTTP_FORWARDED_FOR',
403
-            'HTTP_FORWARDED',
404
-            'REMOTE_ADDR',
405
-        );
406
-        foreach ($server_keys as $key) {
407
-            if (isset($this->server[ $key ])) {
408
-                foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
409
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
410
-                        $visitor_ip = $ip;
411
-                    }
412
-                }
413
-            }
414
-        }
415
-        return $visitor_ip;
416
-    }
417
-
418
-
419
-    /**
420
-     * @return string
421
-     */
422
-    public function requestUri()
423
-    {
424
-        $request_uri = filter_input(
425
-            INPUT_SERVER,
426
-            'REQUEST_URI',
427
-            FILTER_SANITIZE_URL,
428
-            FILTER_NULL_ON_FAILURE
429
-        );
430
-        if (empty($request_uri)) {
431
-            // fallback sanitization if the above fails
432
-            $request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
433
-        }
434
-        return $request_uri;
435
-    }
436
-
437
-
438
-    /**
439
-     * @return string
440
-     */
441
-    public function userAgent()
442
-    {
443
-        return $this->user_agent;
444
-    }
445
-
446
-
447
-    /**
448
-     * @param string $user_agent
449
-     */
450
-    public function setUserAgent($user_agent = '')
451
-    {
452
-        if ($user_agent === '' || ! is_string($user_agent)) {
453
-            $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
454
-        }
455
-        $this->user_agent = $user_agent;
456
-    }
457
-
458
-
459
-    /**
460
-     * @return bool
461
-     */
462
-    public function isBot()
463
-    {
464
-        return $this->is_bot;
465
-    }
466
-
467
-
468
-    /**
469
-     * @param bool $is_bot
470
-     */
471
-    public function setIsBot($is_bot)
472
-    {
473
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
474
-    }
475
-
476
-
477
-    /**
478
-     * @return bool
479
-     */
480
-    public function isActivation()
481
-    {
482
-        return $this->request_type->isActivation();
483
-    }
484
-
485
-
486
-    /**
487
-     * @param $is_activation
488
-     * @return bool
489
-     */
490
-    public function setIsActivation($is_activation)
491
-    {
492
-        return $this->request_type->setIsActivation($is_activation);
493
-    }
494
-
495
-
496
-    /**
497
-     * @return bool
498
-     */
499
-    public function isAdmin()
500
-    {
501
-        return $this->request_type->isAdmin();
502
-    }
503
-
504
-
505
-    /**
506
-     * @return bool
507
-     */
508
-    public function isAdminAjax()
509
-    {
510
-        return $this->request_type->isAdminAjax();
511
-    }
512
-
513
-
514
-    /**
515
-     * @return bool
516
-     */
517
-    public function isAjax()
518
-    {
519
-        return $this->request_type->isAjax();
520
-    }
521
-
522
-
523
-    /**
524
-     * @return bool
525
-     */
526
-    public function isEeAjax()
527
-    {
528
-        return $this->request_type->isEeAjax();
529
-    }
530
-
531
-
532
-    /**
533
-     * @return bool
534
-     */
535
-    public function isOtherAjax()
536
-    {
537
-        return $this->request_type->isOtherAjax();
538
-    }
539
-
540
-
541
-    /**
542
-     * @return bool
543
-     */
544
-    public function isApi()
545
-    {
546
-        return $this->request_type->isApi();
547
-    }
548
-
549
-
550
-    /**
551
-     * @return bool
552
-     */
553
-    public function isCli()
554
-    {
555
-        return $this->request_type->isCli();
556
-    }
557
-
558
-
559
-    /**
560
-     * @return bool
561
-     */
562
-    public function isCron()
563
-    {
564
-        return $this->request_type->isCron();
565
-    }
566
-
567
-
568
-    /**
569
-     * @return bool
570
-     */
571
-    public function isFeed()
572
-    {
573
-        return $this->request_type->isFeed();
574
-    }
575
-
576
-
577
-    /**
578
-     * @return bool
579
-     */
580
-    public function isFrontend()
581
-    {
582
-        return $this->request_type->isFrontend();
583
-    }
584
-
585
-
586
-    /**
587
-     * @return bool
588
-     */
589
-    public function isFrontAjax()
590
-    {
591
-        return $this->request_type->isFrontAjax();
592
-    }
593
-
594
-
595
-    /**
596
-     * @return bool
597
-     */
598
-    public function isIframe()
599
-    {
600
-        return $this->request_type->isIframe();
601
-    }
602
-
603
-
604
-    /**
605
-     * @return bool
606
-     */
607
-    public function isWordPressApi()
608
-    {
609
-        return $this->request_type->isWordPressApi();
610
-    }
611
-
612
-
613
-
614
-    /**
615
-     * @return bool
616
-     */
617
-    public function isWordPressHeartbeat()
618
-    {
619
-        return $this->request_type->isWordPressHeartbeat();
620
-    }
621
-
622
-
623
-
624
-    /**
625
-     * @return bool
626
-     */
627
-    public function isWordPressScrape()
628
-    {
629
-        return $this->request_type->isWordPressScrape();
630
-    }
631
-
632
-
633
-    /**
634
-     * @return string
635
-     */
636
-    public function slug()
637
-    {
638
-        return $this->request_type->slug();
639
-    }
20
+	/**
21
+	 * $_GET parameters
22
+	 *
23
+	 * @var array $get
24
+	 */
25
+	private $get;
26
+
27
+	/**
28
+	 * $_POST parameters
29
+	 *
30
+	 * @var array $post
31
+	 */
32
+	private $post;
33
+
34
+	/**
35
+	 * $_COOKIE parameters
36
+	 *
37
+	 * @var array $cookie
38
+	 */
39
+	private $cookie;
40
+
41
+	/**
42
+	 * $_SERVER parameters
43
+	 *
44
+	 * @var array $server
45
+	 */
46
+	private $server;
47
+
48
+	/**
49
+	 * $_FILES parameters
50
+	 *
51
+	 * @var array $files
52
+	 */
53
+	private $files;
54
+
55
+	/**
56
+	 * $_REQUEST parameters
57
+	 *
58
+	 * @var array $request
59
+	 */
60
+	private $request;
61
+
62
+	/**
63
+	 * @var RequestTypeContextCheckerInterface
64
+	 */
65
+	private $request_type;
66
+
67
+	/**
68
+	 * IP address for request
69
+	 *
70
+	 * @var string $ip_address
71
+	 */
72
+	private $ip_address;
73
+
74
+	/**
75
+	 * @var string $user_agent
76
+	 */
77
+	private $user_agent;
78
+
79
+	/**
80
+	 * true if current user appears to be some kind of bot
81
+	 *
82
+	 * @var bool $is_bot
83
+	 */
84
+	private $is_bot;
85
+
86
+
87
+	/**
88
+	 * @param array $get
89
+	 * @param array $post
90
+	 * @param array $cookie
91
+	 * @param array $server
92
+	 * @param array $files
93
+	 */
94
+	public function __construct(array $get, array $post, array $cookie, array $server, array $files = array())
95
+	{
96
+		// grab request vars
97
+		$this->get = $get;
98
+		$this->post = $post;
99
+		$this->cookie = $cookie;
100
+		$this->server = $server;
101
+		$this->files = $files;
102
+		$this->request = array_merge($this->get, $this->post);
103
+		$this->ip_address = $this->visitorIp();
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param RequestTypeContextCheckerInterface $type
109
+	 */
110
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
111
+	{
112
+		$this->request_type = $type;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @return array
118
+	 */
119
+	public function getParams()
120
+	{
121
+		return $this->get;
122
+	}
123
+
124
+
125
+	/**
126
+	 * @return array
127
+	 */
128
+	public function postParams()
129
+	{
130
+		return $this->post;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return array
136
+	 */
137
+	public function cookieParams()
138
+	{
139
+		return $this->cookie;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @return array
145
+	 */
146
+	public function serverParams()
147
+	{
148
+		return $this->server;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @return array
154
+	 */
155
+	public function filesParams()
156
+	{
157
+		return $this->files;
158
+	}
159
+
160
+
161
+	/**
162
+	 * returns contents of $_REQUEST
163
+	 *
164
+	 * @return array
165
+	 */
166
+	public function requestParams()
167
+	{
168
+		return $this->request;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param      $key
174
+	 * @param      $value
175
+	 * @param bool $override_ee
176
+	 * @return    void
177
+	 */
178
+	public function setRequestParam($key, $value, $override_ee = false)
179
+	{
180
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
181
+		if ($key !== 'ee'
182
+			|| ($key === 'ee' && empty($this->request['ee']))
183
+			|| ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184
+		) {
185
+			$this->request[ $key ] = $value;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * returns   the value for a request param if the given key exists
192
+	 *
193
+	 * @param       $key
194
+	 * @param null  $default
195
+	 * @return mixed
196
+	 */
197
+	public function getRequestParam($key, $default = null)
198
+	{
199
+		return $this->requestParameterDrillDown($key, $default, 'get');
200
+	}
201
+
202
+
203
+	/**
204
+	 * check if param exists
205
+	 *
206
+	 * @param       $key
207
+	 * @return bool
208
+	 */
209
+	public function requestParamIsSet($key)
210
+	{
211
+		return $this->requestParameterDrillDown($key);
212
+	}
213
+
214
+
215
+	/**
216
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
217
+	 * and return the value for the first match found
218
+	 * wildcards can be either of the following:
219
+	 *      ? to represent a single character of any type
220
+	 *      * to represent one or more characters of any type
221
+	 *
222
+	 * @param string     $pattern
223
+	 * @param null|mixed $default
224
+	 * @return mixed
225
+	 */
226
+	public function getMatch($pattern, $default = null)
227
+	{
228
+		return $this->requestParameterDrillDown($pattern, $default, 'match');
229
+	}
230
+
231
+
232
+	/**
233
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
234
+	 * wildcards can be either of the following:
235
+	 *      ? to represent a single character of any type
236
+	 *      * to represent one or more characters of any type
237
+	 * returns true if a match is found or false if not
238
+	 *
239
+	 * @param string $pattern
240
+	 * @return bool
241
+	 */
242
+	public function matches($pattern)
243
+	{
244
+		return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
245
+	}
246
+
247
+
248
+	/**
249
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
250
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
251
+	 *                                      and used to search through the current request's parameter keys
252
+	 * @param array  $request_params        The array of request parameters to search through
253
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
254
+	 *                                      Default is null
255
+	 * @param string $return                [optional] Controls what kind of value is returned.
256
+	 *                                      Options are:
257
+	 *                                      'bool' will return true or false if match is found or not
258
+	 *                                      'key' will return the first key found that matches the supplied pattern
259
+	 *                                      'value' will return the value for the first request parameter
260
+	 *                                      whose key matches the supplied pattern
261
+	 *                                      Default is 'value'
262
+	 * @return boolean|string
263
+	 */
264
+	private function match($pattern, array $request_params, $default = null, $return = 'value')
265
+	{
266
+		$return = in_array($return, array('bool', 'key', 'value'), true)
267
+			? $return
268
+			: 'is_set';
269
+		// replace wildcard chars with regex chars
270
+		$pattern = str_replace(
271
+			array("\*", "\?"),
272
+			array('.*', '.'),
273
+			preg_quote($pattern, '/')
274
+		);
275
+		foreach ($request_params as $key => $request_param) {
276
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
277
+				// return value for request param
278
+				if ($return === 'value') {
279
+					return $request_params[ $key ];
280
+				}
281
+				// or actual key or true just to indicate it was found
282
+				return $return === 'key' ? $key : true;
283
+			}
284
+		}
285
+		// match not found so return default value or false
286
+		return $return === 'value' ? $default : false;
287
+	}
288
+
289
+
290
+	/**
291
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
292
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
293
+	 * by using square brackets to surround keys for deeper array elements.
294
+	 * For example :
295
+	 * if the supplied $key was: "first[second][third]"
296
+	 * then this will attempt to drill down into the request parameter array to find a value.
297
+	 * Given the following request parameters:
298
+	 *  array(
299
+	 *      'first' => array(
300
+	 *          'second' => array(
301
+	 *              'third' => 'has a value'
302
+	 *          )
303
+	 *      )
304
+	 *  )
305
+	 * would return true if default parameters were set
306
+	 *
307
+	 * @param string $callback
308
+	 * @param        $key
309
+	 * @param null   $default
310
+	 * @param array  $request_params
311
+	 * @return bool|mixed|null
312
+	 */
313
+	private function requestParameterDrillDown(
314
+		$key,
315
+		$default = null,
316
+		$callback = 'is_set',
317
+		array $request_params = array()
318
+	) {
319
+		$callback = in_array($callback, array('is_set', 'get', 'match'), true)
320
+			? $callback
321
+			: 'is_set';
322
+		$request_params = ! empty($request_params)
323
+			? $request_params
324
+			: $this->request;
325
+		// does incoming key represent an array like 'first[second][third]'  ?
326
+		if (strpos($key, '[') !== false) {
327
+			// turn it into an actual array
328
+			$key = str_replace(']', '', $key);
329
+			$keys = explode('[', $key);
330
+			$key = array_shift($keys);
331
+			if ($callback === 'match') {
332
+				$real_key = $this->match($key, $request_params, $default, 'key');
333
+				$key = $real_key ? $real_key : $key;
334
+			}
335
+			// check if top level key exists
336
+			if (isset($request_params[ $key ])) {
337
+				// build a new key to pass along like: 'second[third]'
338
+				// or just 'second' depending on depth of keys
339
+				$key_string = array_shift($keys);
340
+				if (! empty($keys)) {
341
+					$key_string .= '[' . implode('][', $keys) . ']';
342
+				}
343
+				return $this->requestParameterDrillDown(
344
+					$key_string,
345
+					$default,
346
+					$callback,
347
+					$request_params[ $key ]
348
+				);
349
+			}
350
+		}
351
+		if ($callback === 'is_set') {
352
+			return isset($request_params[ $key ]);
353
+		}
354
+		if ($callback === 'match') {
355
+			return $this->match($key, $request_params, $default);
356
+		}
357
+		return isset($request_params[ $key ])
358
+			? $request_params[ $key ]
359
+			: $default;
360
+	}
361
+
362
+
363
+	/**
364
+	 * remove param
365
+	 *
366
+	 * @param      $key
367
+	 * @param bool $unset_from_global_too
368
+	 */
369
+	public function unSetRequestParam($key, $unset_from_global_too = false)
370
+	{
371
+		unset($this->request[ $key ]);
372
+		if ($unset_from_global_too) {
373
+			unset($_REQUEST[ $key ]);
374
+		}
375
+	}
376
+
377
+
378
+	/**
379
+	 * @return string
380
+	 */
381
+	public function ipAddress()
382
+	{
383
+		return $this->ip_address;
384
+	}
385
+
386
+
387
+	/**
388
+	 * attempt to get IP address of current visitor from server
389
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
390
+	 *
391
+	 * @access public
392
+	 * @return string
393
+	 */
394
+	private function visitorIp()
395
+	{
396
+		$visitor_ip = '0.0.0.0';
397
+		$server_keys = array(
398
+			'HTTP_CLIENT_IP',
399
+			'HTTP_X_FORWARDED_FOR',
400
+			'HTTP_X_FORWARDED',
401
+			'HTTP_X_CLUSTER_CLIENT_IP',
402
+			'HTTP_FORWARDED_FOR',
403
+			'HTTP_FORWARDED',
404
+			'REMOTE_ADDR',
405
+		);
406
+		foreach ($server_keys as $key) {
407
+			if (isset($this->server[ $key ])) {
408
+				foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
409
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
410
+						$visitor_ip = $ip;
411
+					}
412
+				}
413
+			}
414
+		}
415
+		return $visitor_ip;
416
+	}
417
+
418
+
419
+	/**
420
+	 * @return string
421
+	 */
422
+	public function requestUri()
423
+	{
424
+		$request_uri = filter_input(
425
+			INPUT_SERVER,
426
+			'REQUEST_URI',
427
+			FILTER_SANITIZE_URL,
428
+			FILTER_NULL_ON_FAILURE
429
+		);
430
+		if (empty($request_uri)) {
431
+			// fallback sanitization if the above fails
432
+			$request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
433
+		}
434
+		return $request_uri;
435
+	}
436
+
437
+
438
+	/**
439
+	 * @return string
440
+	 */
441
+	public function userAgent()
442
+	{
443
+		return $this->user_agent;
444
+	}
445
+
446
+
447
+	/**
448
+	 * @param string $user_agent
449
+	 */
450
+	public function setUserAgent($user_agent = '')
451
+	{
452
+		if ($user_agent === '' || ! is_string($user_agent)) {
453
+			$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
454
+		}
455
+		$this->user_agent = $user_agent;
456
+	}
457
+
458
+
459
+	/**
460
+	 * @return bool
461
+	 */
462
+	public function isBot()
463
+	{
464
+		return $this->is_bot;
465
+	}
466
+
467
+
468
+	/**
469
+	 * @param bool $is_bot
470
+	 */
471
+	public function setIsBot($is_bot)
472
+	{
473
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
474
+	}
475
+
476
+
477
+	/**
478
+	 * @return bool
479
+	 */
480
+	public function isActivation()
481
+	{
482
+		return $this->request_type->isActivation();
483
+	}
484
+
485
+
486
+	/**
487
+	 * @param $is_activation
488
+	 * @return bool
489
+	 */
490
+	public function setIsActivation($is_activation)
491
+	{
492
+		return $this->request_type->setIsActivation($is_activation);
493
+	}
494
+
495
+
496
+	/**
497
+	 * @return bool
498
+	 */
499
+	public function isAdmin()
500
+	{
501
+		return $this->request_type->isAdmin();
502
+	}
503
+
504
+
505
+	/**
506
+	 * @return bool
507
+	 */
508
+	public function isAdminAjax()
509
+	{
510
+		return $this->request_type->isAdminAjax();
511
+	}
512
+
513
+
514
+	/**
515
+	 * @return bool
516
+	 */
517
+	public function isAjax()
518
+	{
519
+		return $this->request_type->isAjax();
520
+	}
521
+
522
+
523
+	/**
524
+	 * @return bool
525
+	 */
526
+	public function isEeAjax()
527
+	{
528
+		return $this->request_type->isEeAjax();
529
+	}
530
+
531
+
532
+	/**
533
+	 * @return bool
534
+	 */
535
+	public function isOtherAjax()
536
+	{
537
+		return $this->request_type->isOtherAjax();
538
+	}
539
+
540
+
541
+	/**
542
+	 * @return bool
543
+	 */
544
+	public function isApi()
545
+	{
546
+		return $this->request_type->isApi();
547
+	}
548
+
549
+
550
+	/**
551
+	 * @return bool
552
+	 */
553
+	public function isCli()
554
+	{
555
+		return $this->request_type->isCli();
556
+	}
557
+
558
+
559
+	/**
560
+	 * @return bool
561
+	 */
562
+	public function isCron()
563
+	{
564
+		return $this->request_type->isCron();
565
+	}
566
+
567
+
568
+	/**
569
+	 * @return bool
570
+	 */
571
+	public function isFeed()
572
+	{
573
+		return $this->request_type->isFeed();
574
+	}
575
+
576
+
577
+	/**
578
+	 * @return bool
579
+	 */
580
+	public function isFrontend()
581
+	{
582
+		return $this->request_type->isFrontend();
583
+	}
584
+
585
+
586
+	/**
587
+	 * @return bool
588
+	 */
589
+	public function isFrontAjax()
590
+	{
591
+		return $this->request_type->isFrontAjax();
592
+	}
593
+
594
+
595
+	/**
596
+	 * @return bool
597
+	 */
598
+	public function isIframe()
599
+	{
600
+		return $this->request_type->isIframe();
601
+	}
602
+
603
+
604
+	/**
605
+	 * @return bool
606
+	 */
607
+	public function isWordPressApi()
608
+	{
609
+		return $this->request_type->isWordPressApi();
610
+	}
611
+
612
+
613
+
614
+	/**
615
+	 * @return bool
616
+	 */
617
+	public function isWordPressHeartbeat()
618
+	{
619
+		return $this->request_type->isWordPressHeartbeat();
620
+	}
621
+
622
+
623
+
624
+	/**
625
+	 * @return bool
626
+	 */
627
+	public function isWordPressScrape()
628
+	{
629
+		return $this->request_type->isWordPressScrape();
630
+	}
631
+
632
+
633
+	/**
634
+	 * @return string
635
+	 */
636
+	public function slug()
637
+	{
638
+		return $this->request_type->slug();
639
+	}
640 640
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapRequestResponseObjects.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -25,80 +25,80 @@
 block discarded – undo
25 25
 class BootstrapRequestResponseObjects
26 26
 {
27 27
 
28
-    /**
29
-     * @type LegacyRequestInterface $legacy_request
30
-     */
31
-    protected $legacy_request;
28
+	/**
29
+	 * @type LegacyRequestInterface $legacy_request
30
+	 */
31
+	protected $legacy_request;
32 32
 
33
-    /**
34
-     * @type LoaderInterface $loader
35
-     */
36
-    protected $loader;
33
+	/**
34
+	 * @type LoaderInterface $loader
35
+	 */
36
+	protected $loader;
37 37
 
38
-    /**
39
-     * @var RequestInterface $request
40
-     */
41
-    protected $request;
38
+	/**
39
+	 * @var RequestInterface $request
40
+	 */
41
+	protected $request;
42 42
 
43
-    /**
44
-     * @var ResponseInterface $response
45
-     */
46
-    protected $response;
43
+	/**
44
+	 * @var ResponseInterface $response
45
+	 */
46
+	protected $response;
47 47
 
48 48
 
49
-    /**
50
-     * BootstrapRequestResponseObjects constructor.
51
-     *
52
-     * @param LoaderInterface $loader
53
-     */
54
-    public function __construct(LoaderInterface $loader)
55
-    {
56
-        $this->loader = $loader;
57
-    }
49
+	/**
50
+	 * BootstrapRequestResponseObjects constructor.
51
+	 *
52
+	 * @param LoaderInterface $loader
53
+	 */
54
+	public function __construct(LoaderInterface $loader)
55
+	{
56
+		$this->loader = $loader;
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * @return void
62
-     */
63
-    public function buildRequestResponse()
64
-    {
65
-        // load our Request and Response objects
66
-        $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES);
67
-        $this->response = new Response();
68
-    }
60
+	/**
61
+	 * @return void
62
+	 */
63
+	public function buildRequestResponse()
64
+	{
65
+		// load our Request and Response objects
66
+		$this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES);
67
+		$this->response = new Response();
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @return void
73
-     * @throws InvalidArgumentException
74
-     */
75
-    public function shareRequestResponse()
76
-    {
77
-        $this->loader->share('EventEspresso\core\services\request\Request', $this->request);
78
-        $this->loader->share('EventEspresso\core\services\request\Response', $this->response);
79
-        EE_Dependency_Map::instance()->setRequest($this->request);
80
-        EE_Dependency_Map::instance()->setResponse($this->response);
81
-    }
71
+	/**
72
+	 * @return void
73
+	 * @throws InvalidArgumentException
74
+	 */
75
+	public function shareRequestResponse()
76
+	{
77
+		$this->loader->share('EventEspresso\core\services\request\Request', $this->request);
78
+		$this->loader->share('EventEspresso\core\services\request\Response', $this->response);
79
+		EE_Dependency_Map::instance()->setRequest($this->request);
80
+		EE_Dependency_Map::instance()->setResponse($this->response);
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * @return void
86
-     * @throws InvalidArgumentException
87
-     * @throws EE_Error
88
-     */
89
-    public function setupLegacyRequest()
90
-    {
91
-        espresso_load_required(
92
-            'EE_Request',
93
-            EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
94
-        );
95
-        $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96
-        $this->legacy_request->setRequest($this->request);
97
-        $this->legacy_request->admin = $this->request->isAdmin();
98
-        $this->legacy_request->ajax = $this->request->isAjax();
99
-        $this->legacy_request->front_ajax = $this->request->isFrontAjax();
100
-        EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
101
-        $this->loader->share('EE_Request', $this->legacy_request);
102
-        $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
103
-    }
84
+	/**
85
+	 * @return void
86
+	 * @throws InvalidArgumentException
87
+	 * @throws EE_Error
88
+	 */
89
+	public function setupLegacyRequest()
90
+	{
91
+		espresso_load_required(
92
+			'EE_Request',
93
+			EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
94
+		);
95
+		$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96
+		$this->legacy_request->setRequest($this->request);
97
+		$this->legacy_request->admin = $this->request->isAdmin();
98
+		$this->legacy_request->ajax = $this->request->isAjax();
99
+		$this->legacy_request->front_ajax = $this->request->isFrontAjax();
100
+		EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
101
+		$this->loader->share('EE_Request', $this->legacy_request);
102
+		$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
103
+	}
104 104
 }
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 1 patch
Indentation   +602 added lines, -602 removed lines patch added patch discarded remove patch
@@ -11,606 +11,606 @@
 block discarded – undo
11 11
 class EEG_Paypal_Pro extends EE_Onsite_Gateway
12 12
 {
13 13
 
14
-    /**
15
-     * @var $_paypal_api_username string
16
-     */
17
-    protected $_api_username = null;
18
-
19
-    /**
20
-     * @var $_api_password string
21
-     */
22
-    protected $_api_password = null;
23
-
24
-    /**
25
-     * @var $_api_signature string
26
-     */
27
-    protected $_api_signature = null;
28
-
29
-    /**
30
-     * @var $_credit_card_types array with the keys for credit card types accepted on this account
31
-     */
32
-    protected $_credit_card_types    = null;
33
-
34
-    protected $_currencies_supported = array(
35
-        'USD',
36
-        'GBP',
37
-        'CAD',
38
-        'AUD',
39
-        'BRL',
40
-        'CHF',
41
-        'CZK',
42
-        'DKK',
43
-        'EUR',
44
-        'HKD',
45
-        'HUF',
46
-        'ILS',
47
-        'JPY',
48
-        'MXN',
49
-        'MYR',
50
-        'NOK',
51
-        'NZD',
52
-        'PHP',
53
-        'PLN',
54
-        'SEK',
55
-        'SGD',
56
-        'THB',
57
-        'TRY',
58
-        'TWD',
59
-        'RUB',
60
-        'INR',
61
-    );
62
-
63
-
64
-
65
-    /**
66
-     * @param EEI_Payment $payment
67
-     * @param array       $billing_info {
68
-     * @type string $credit_card
69
-     * @type string $credit_card_type
70
-     * @type string $exp_month always 2 characters
71
-     * @type string $exp_year always 4 characters
72
-     * @type string $cvv
73
-     * }
74
-     * @see      parent::do_direct_payment for more info
75
-     * @return EE_Payment|EEI_Payment
76
-     * @throws EE_Error
77
-     */
78
-    public function do_direct_payment($payment, $billing_info = null)
79
-    {
80
-        $transaction = $payment->transaction();
81
-        if (! $transaction instanceof EEI_Transaction) {
82
-            throw new EE_Error(
83
-                esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
84
-            );
85
-        }
86
-        $primary_registrant = $transaction->primary_registration();
87
-        if (! $primary_registrant instanceof EEI_Registration) {
88
-            throw new EE_Error(
89
-                esc_html__(
90
-                    'No primary registration on transaction while paying with PayPal Pro.',
91
-                    'event_espresso'
92
-                )
93
-            );
94
-        }
95
-        $attendee = $primary_registrant->attendee();
96
-        if (! $attendee instanceof EEI_Attendee) {
97
-            throw new EE_Error(
98
-                esc_html__(
99
-                    'No attendee on primary registration while paying with PayPal Pro.',
100
-                    'event_espresso'
101
-                )
102
-            );
103
-        }
104
-        $gateway_formatter = $this->_get_gateway_formatter();
105
-        $order_description = substr($gateway_formatter->formatOrderDescription($payment), 0, 127);
106
-        // charge for the full amount. Show itemized list
107
-        if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
108
-            $item_num = 1;
109
-            $total_line_item = $transaction->total_line_item();
110
-            $order_items = array();
111
-            foreach ($total_line_item->get_items() as $line_item) {
112
-                // ignore line items with a quantity of 0
113
-                if ($line_item->quantity() == 0) {
114
-                    continue;
115
-                }
116
-                // For percent items, whose unit_price is 0, use the total instead.
117
-                if ($line_item->is_percent()) {
118
-                    $unit_price = $line_item->total();
119
-                    $line_item_quantity = 1;
120
-                } else {
121
-                    $unit_price = $line_item->unit_price();
122
-                    $line_item_quantity = $line_item->quantity();
123
-                }
124
-                $item = array(
125
-                    // Item Name.  127 char max.
126
-                    'l_name'                 => substr(
127
-                        $gateway_formatter->formatLineItemName($line_item, $payment),
128
-                        0,
129
-                        127
130
-                    ),
131
-                    // Item description.  127 char max.
132
-                    'l_desc'                 => substr(
133
-                        $gateway_formatter->formatLineItemDesc($line_item, $payment),
134
-                        0,
135
-                        127
136
-                    ),
137
-                    // Cost of individual item.
138
-                    'l_amt'                  => $unit_price,
139
-                    // Item Number.  127 char max.
140
-                    'l_number'               => $item_num++,
141
-                    // Item quantity.  Must be any positive integer.
142
-                    'l_qty'                  => $line_item_quantity,
143
-                    // Item's sales tax amount.
144
-                    'l_taxamt'               => '',
145
-                    // eBay auction number of item.
146
-                    'l_ebayitemnumber'       => '',
147
-                    // eBay transaction ID of purchased item.
148
-                    'l_ebayitemauctiontxnid' => '',
149
-                    // eBay order ID for the item.
150
-                    'l_ebayitemorderid'      => '',
151
-                );
152
-                // add to array of all items
153
-                array_push($order_items, $item);
154
-            }
155
-            $item_amount = $total_line_item->get_items_total();
156
-            $tax_amount = $total_line_item->get_total_tax();
157
-        } else {
158
-            $order_items = array();
159
-            $item_amount = $payment->amount();
160
-            $tax_amount = 0;
161
-            array_push($order_items, array(
162
-                // Item Name.  127 char max.
163
-                'l_name'   => substr(
164
-                    $gateway_formatter->formatPartialPaymentLineItemName($payment),
165
-                    0,
166
-                    127
167
-                ),
168
-                // Item description.  127 char max.
169
-                'l_desc'   => substr(
170
-                    $gateway_formatter->formatPartialPaymentLineItemDesc($payment),
171
-                    0,
172
-                    127
173
-                ),
174
-                // Cost of individual item.
175
-                'l_amt'    => $payment->amount(),
176
-                // Item Number.  127 char max.
177
-                'l_number' => 1,
178
-                // Item quantity.  Must be any positive integer.
179
-                'l_qty'    => 1,
180
-            ));
181
-        }
182
-        // Populate data arrays with order data.
183
-        $DPFields = array(
184
-            // How you want to obtain payment ?
185
-            // Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
186
-            // Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
187
-            'paymentaction'    => 'Sale',
188
-            // Required.  IP address of the payer's browser.
189
-            'ipaddress'        => $_SERVER['REMOTE_ADDR'],
190
-            // Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
191
-            'returnfmfdetails' => '1',
192
-        );
193
-        $CCDetails = array(
194
-            // Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
195
-            // If Maestro or Solo, the currency code must be GBP.
196
-            //  In addition, either start date or issue number must be specified.
197
-            'creditcardtype' => $billing_info['credit_card_type'],
198
-            // Required.  Credit card number.  No spaces or punctuation.
199
-            'acct'           => $billing_info['credit_card'],
200
-            // Required.  Credit card expiration date.  Format is MMYYYY
201
-            'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
202
-            // Requirements determined by your PayPal account settings.  Security digits for credit card.
203
-            'cvv2'           => $billing_info['cvv'],
204
-        );
205
-        $PayerInfo = array(
206
-            // Email address of payer.
207
-            'email'       => $billing_info['email'],
208
-            // Unique PayPal customer ID for payer.
209
-            'payerid'     => '',
210
-            // Status of payer.  Values are verified or unverified
211
-            'payerstatus' => '',
212
-            // Payer's business name.
213
-            'business'    => '',
214
-        );
215
-        $PayerName = array(
216
-            // Payer's salutation.  20 char max.
217
-            'salutation' => '',
218
-            // Payer's first name.  25 char max.
219
-            'firstname'  => substr($billing_info['first_name'], 0, 25),
220
-            // Payer's middle name.  25 char max.
221
-            'middlename' => '',
222
-            // Payer's last name.  25 char max.
223
-            'lastname'   => substr($billing_info['last_name'], 0, 25),
224
-            // Payer's suffix.  12 char max.
225
-            'suffix'     => '',
226
-        );
227
-        $BillingAddress = array(
228
-            // Required.  First street address.
229
-            'street'      => $billing_info['address'],
230
-            // Second street address.
231
-            'street2'     => $billing_info['address2'],
232
-            // Required.  Name of City.
233
-            'city'        => $billing_info['city'],
234
-            // Required. Name of State or Province.
235
-            'state'       => substr($billing_info['state'], 0, 40),
236
-            // Required.  Country code.
237
-            'countrycode' => $billing_info['country'],
238
-            // Required.  Postal code of payer.
239
-            'zip'         => $billing_info['zip'],
240
-        );
241
-        // check if the registration info contains the needed fields for paypal pro
242
-        // (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
243
-        if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
244
-            $use_registration_address_info = true;
245
-        } else {
246
-            $use_registration_address_info = false;
247
-        }
248
-        // so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
249
-        // If not, use the billing info again
250
-        $ShippingAddress = array(
251
-            'shiptoname'     => substr($use_registration_address_info
252
-                ? $attendee->full_name()
253
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
254
-            'shiptostreet'   => substr($use_registration_address_info
255
-                ? $attendee->address()
256
-                : $billing_info['address'], 0, 100),
257
-            'shiptostreet2'  => substr($use_registration_address_info
258
-                ? $attendee->address2() : $billing_info['address2'], 0, 100),
259
-            'shiptocity'     => substr($use_registration_address_info
260
-                ? $attendee->city()
261
-                : $billing_info['city'], 0, 40),
262
-            'state'          => substr($use_registration_address_info
263
-                ? $attendee->state_name()
264
-                : $billing_info['state'], 0, 40),
265
-            'shiptocountry'  => $use_registration_address_info
266
-                ? $attendee->country_ID()
267
-                : $billing_info['country'],
268
-            'shiptozip'      => substr($use_registration_address_info
269
-                ? $attendee->zip()
270
-                : $billing_info['zip'], 0, 20),
271
-            'shiptophonenum' => substr($use_registration_address_info
272
-                ? $attendee->phone()
273
-                : $billing_info['phone'], 0, 20),
274
-        );
275
-        $PaymentDetails = array(
276
-            // Required.  Total amount of order, including shipping, handling, and tax.
277
-            'amt'          => $gateway_formatter->formatCurrency($payment->amount()),
278
-            // Required.  Three-letter currency code.  Default is USD.
279
-            'currencycode' => $payment->currency_code(),
280
-            // Required if you include itemized cart details. (L_AMTn, etc.)
281
-            // Subtotal of items not including S&H, or tax.
282
-            'itemamt'      => $gateway_formatter->formatCurrency($item_amount),//
283
-            // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
284
-            'shippingamt'  => '',
285
-            // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
286
-            'handlingamt'  => '',
287
-            // Required if you specify itemized cart tax details.
288
-            // Sum of tax for all items on the order.  Total sales tax.
289
-            'taxamt'       => $gateway_formatter->formatCurrency($tax_amount),
290
-            // Description of the order the customer is purchasing.  127 char max.
291
-            'desc'         => $order_description,
292
-            // Free-form field for your own use.  256 char max.
293
-            'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
294
-            // Your own invoice or tracking number
295
-            'invnum'       => wp_generate_password(12, false),// $transaction->ID(),
296
-            // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
297
-            'notifyurl'    => '',
298
-            'buttonsource' => 'EventEspresso_SP',// EE will blow up if you change this
299
-        );
300
-        // Wrap all data arrays into a single, "master" array which will be passed into the class function.
301
-        $PayPalRequestData = array(
302
-            'DPFields'        => $DPFields,
303
-            'CCDetails'       => $CCDetails,
304
-            'PayerInfo'       => $PayerInfo,
305
-            'PayerName'       => $PayerName,
306
-            'BillingAddress'  => $BillingAddress,
307
-            'ShippingAddress' => $ShippingAddress,
308
-            'PaymentDetails'  => $PaymentDetails,
309
-            'OrderItems'      => $order_items,
310
-        );
311
-        $this->_log_clean_request($PayPalRequestData, $payment);
312
-        try {
313
-            $PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
314
-            // remove PCI-sensitive data so it doesn't get stored
315
-            $PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
316
-            if (isset($PayPalResult['L_ERRORCODE0']) && $PayPalResult['L_ERRORCODE0'] === '10002') {
317
-                $message = esc_html__('PayPal did not accept your API username, password, or signature. Please double-check these credentials and if debug mode is on.', 'event_espresso');
318
-            } elseif (isset($PayPalResult['L_LONGMESSAGE0'])) {
319
-                $message = $PayPalResult['L_LONGMESSAGE0'];
320
-            } else {
321
-                $message = $PayPalResult['ACK'];
322
-            }
323
-            if (empty($PayPalResult['RAWRESPONSE'])) {
324
-                $payment->set_status($this->_pay_model->failed_status());
325
-                $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
326
-                $payment->set_details($PayPalResult);
327
-            } else {
328
-                if ($this->_APICallSuccessful($PayPalResult)) {
329
-                    $payment->set_status($this->_pay_model->approved_status());
330
-                } else {
331
-                    $payment->set_status($this->_pay_model->declined_status());
332
-                }
333
-                // make sure we interpret the AMT as a float, not an international string
334
-                // (where periods are thousand separators)
335
-                $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
336
-                $payment->set_gateway_response($message);
337
-                $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
338
-                    ? $PayPalResult['TRANSACTIONID']
339
-                    : null);
340
-                $primary_registration_code = $primary_registrant instanceof EE_Registration
341
-                    ? $primary_registrant->reg_code()
342
-                    : '';
343
-                $payment->set_extra_accntng($primary_registration_code);
344
-                $payment->set_details($PayPalResult);
345
-            }
346
-        } catch (Exception $e) {
347
-            $payment->set_status($this->_pay_model->failed_status());
348
-            $payment->set_gateway_response($e->getMessage());
349
-        }
350
-        // $payment->set_status( $this->_pay_model->declined_status() );
351
-        // $payment->set_gateway_response( '' );
352
-        return $payment;
353
-    }
354
-
355
-
356
-
357
-    /**
358
-     * CLeans out sensitive CC data and then logs it, and returns the cleaned request
359
-     *
360
-     * @param array       $request
361
-     * @param EEI_Payment $payment
362
-     * @return void
363
-     */
364
-    private function _log_clean_request($request, $payment)
365
-    {
366
-        $cleaned_request_data = $request;
367
-        unset($cleaned_request_data['CCDetails']['acct']);
368
-        unset($cleaned_request_data['CCDetails']['cvv2']);
369
-        unset($cleaned_request_data['CCDetails']['expdate']);
370
-        $this->log(array('Paypal Request' => $cleaned_request_data), $payment);
371
-    }
372
-
373
-
374
-
375
-    /**
376
-     * Cleans the response, logs it, and returns it
377
-     *
378
-     * @param array       $response
379
-     * @param EEI_Payment $payment
380
-     * @return array cleaned
381
-     */
382
-    private function _log_clean_response($response, $payment)
383
-    {
384
-        unset($response['REQUESTDATA']['CREDITCARDTYPE']);
385
-        unset($response['REQUESTDATA']['ACCT']);
386
-        unset($response['REQUESTDATA']['EXPDATE']);
387
-        unset($response['REQUESTDATA']['CVV2']);
388
-        unset($response['RAWREQUEST']);
389
-        $this->log(array('Paypal Response' => $response), $payment);
390
-        return $response;
391
-    }
392
-
393
-
394
-
395
-    /**
396
-     * @param $DataArray
397
-     * @return array
398
-     */
399
-    private function prep_and_curl_request($DataArray)
400
-    {
401
-        // Create empty holders for each portion of the NVP string
402
-        $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
403
-        $CCDetailsNVP = '';
404
-        $PayerInfoNVP = '';
405
-        $PayerNameNVP = '';
406
-        $BillingAddressNVP = '';
407
-        $ShippingAddressNVP = '';
408
-        $PaymentDetailsNVP = '';
409
-        $OrderItemsNVP = '';
410
-        $Secure3DNVP = '';
411
-        // DP Fields
412
-        $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
413
-        foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
414
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
415
-        }
416
-        // CC Details Fields
417
-        $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
418
-        foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
419
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
420
-        }
421
-        // PayerInfo Type Fields
422
-        $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
423
-        foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
424
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
425
-        }
426
-        // Payer Name Fields
427
-        $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
428
-        foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
429
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
430
-        }
431
-        // Address Fields (Billing)
432
-        $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
433
-        foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
434
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
435
-        }
436
-        // Payment Details Type Fields
437
-        $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
438
-        foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
439
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
440
-        }
441
-        // Payment Details Item Type Fields
442
-        $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
443
-        $n = 0;
444
-        foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
445
-            $CurrentItem = $OrderItems[ $OrderItemsVar ];
446
-            foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
447
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
448
-            }
449
-            $n++;
450
-        }
451
-        // Ship To Address Fields
452
-        $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
453
-        foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
454
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
455
-        }
456
-        // 3D Secure Fields
457
-        $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
458
-        foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
459
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
460
-        }
461
-        // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
462
-        $NVPRequest = 'USER='
463
-                      . $this->_api_username
464
-                      . '&PWD='
465
-                      . $this->_api_password
466
-                      . '&VERSION=64.0'
467
-                      . '&SIGNATURE='
468
-                      . $this->_api_signature
469
-                      . $DPFieldsNVP
470
-                      . $CCDetailsNVP
471
-                      . $PayerInfoNVP
472
-                      . $PayerNameNVP
473
-                      . $BillingAddressNVP
474
-                      . $PaymentDetailsNVP
475
-                      . $OrderItemsNVP
476
-                      . $ShippingAddressNVP
477
-                      . $Secure3DNVP;
478
-        $NVPResponse = $this->_CURLRequest($NVPRequest);
479
-        $NVPRequestArray = $this->_NVPToArray($NVPRequest);
480
-        $NVPResponseArray = $this->_NVPToArray($NVPResponse);
481
-        $Errors = $this->_GetErrors($NVPResponseArray);
482
-        $NVPResponseArray['ERRORS'] = $Errors;
483
-        $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
484
-        $NVPResponseArray['RAWREQUEST'] = $NVPRequest;
485
-        $NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
486
-        return $NVPResponseArray;
487
-    }
488
-
489
-
490
-
491
-    /**
492
-     * @param $Request
493
-     * @return mixed
494
-     */
495
-    private function _CURLRequest($Request)
496
-    {
497
-        $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
498
-        $curl = curl_init();
499
-        curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
500
-        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
501
-        curl_setopt($curl, CURLOPT_TIMEOUT, 60);
502
-        curl_setopt($curl, CURLOPT_URL, $EndPointURL);
503
-        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
504
-        curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
505
-        curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
506
-        // execute the curl POST
507
-        $Response = curl_exec($curl);
508
-        curl_close($curl);
509
-        return $Response;
510
-    }
511
-
512
-
513
-
514
-    /**
515
-     * @param $NVPString
516
-     * @return array
517
-     */
518
-    private function _NVPToArray($NVPString)
519
-    {
520
-        // prepare responses into array
521
-        $proArray = array();
522
-        while (strlen($NVPString)) {
523
-            // name
524
-            $keypos = strpos($NVPString, '=');
525
-            $keyval = substr($NVPString, 0, $keypos);
526
-            // value
527
-            $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
528
-            $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
529
-            // decoding the response
530
-            $proArray[ $keyval ] = urldecode($valval);
531
-            $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
532
-        }
533
-        return $proArray;
534
-    }
535
-
536
-
537
-
538
-    /**
539
-     * @param array $PayPalResult
540
-     * @return bool
541
-     */
542
-    private function _APICallSuccessful($PayPalResult)
543
-    {
544
-        $approved = false;
545
-        // check main response message from PayPal
546
-        if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
547
-            $ack = strtoupper($PayPalResult['ACK']);
548
-            $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
549
-        }
550
-        return $approved;
551
-    }
552
-
553
-
554
-
555
-    /**
556
-     * @param $DataArray
557
-     * @return array
558
-     */
559
-    private function _GetErrors($DataArray)
560
-    {
561
-        $Errors = array();
562
-        $n = 0;
563
-        while (isset($DataArray[ 'L_ERRORCODE' . $n . '' ])) {
564
-            $LErrorCode = isset($DataArray[ 'L_ERRORCODE' . $n . '' ]) ? $DataArray[ 'L_ERRORCODE' . $n . '' ] : '';
565
-            $LShortMessage = isset($DataArray[ 'L_SHORTMESSAGE' . $n . '' ])
566
-                ? $DataArray[ 'L_SHORTMESSAGE' . $n . '' ]
567
-                : '';
568
-            $LLongMessage = isset($DataArray[ 'L_LONGMESSAGE' . $n . '' ])
569
-                ? $DataArray[ 'L_LONGMESSAGE' . $n . '' ]
570
-                : '';
571
-            $LSeverityCode = isset($DataArray[ 'L_SEVERITYCODE' . $n . '' ])
572
-                ? $DataArray[ 'L_SEVERITYCODE' . $n . '' ]
573
-                : '';
574
-            $CurrentItem = array(
575
-                'L_ERRORCODE'    => $LErrorCode,
576
-                'L_SHORTMESSAGE' => $LShortMessage,
577
-                'L_LONGMESSAGE'  => $LLongMessage,
578
-                'L_SEVERITYCODE' => $LSeverityCode,
579
-            );
580
-            array_push($Errors, $CurrentItem);
581
-            $n++;
582
-        }
583
-        return $Errors;
584
-    }
585
-
586
-
587
-
588
-    /**
589
-     *        nothing to see here...  move along....
590
-     *
591
-     * @access protected
592
-     * @param $Errors
593
-     * @return string
594
-     */
595
-    private function _DisplayErrors($Errors)
596
-    {
597
-        $error = '';
598
-        foreach ($Errors as $ErrorVar => $ErrorVal) {
599
-            $CurrentError = $Errors[ $ErrorVar ];
600
-            foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
601
-                $CurrentVarName = '';
602
-                if ($CurrentErrorVar == 'L_ERRORCODE') {
603
-                    $CurrentVarName = 'Error Code';
604
-                } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
605
-                    $CurrentVarName = 'Short Message';
606
-                } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
607
-                    $CurrentVarName = 'Long Message';
608
-                } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
609
-                    $CurrentVarName = 'Severity Code';
610
-                }
611
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
612
-            }
613
-        }
614
-        return $error;
615
-    }
14
+	/**
15
+	 * @var $_paypal_api_username string
16
+	 */
17
+	protected $_api_username = null;
18
+
19
+	/**
20
+	 * @var $_api_password string
21
+	 */
22
+	protected $_api_password = null;
23
+
24
+	/**
25
+	 * @var $_api_signature string
26
+	 */
27
+	protected $_api_signature = null;
28
+
29
+	/**
30
+	 * @var $_credit_card_types array with the keys for credit card types accepted on this account
31
+	 */
32
+	protected $_credit_card_types    = null;
33
+
34
+	protected $_currencies_supported = array(
35
+		'USD',
36
+		'GBP',
37
+		'CAD',
38
+		'AUD',
39
+		'BRL',
40
+		'CHF',
41
+		'CZK',
42
+		'DKK',
43
+		'EUR',
44
+		'HKD',
45
+		'HUF',
46
+		'ILS',
47
+		'JPY',
48
+		'MXN',
49
+		'MYR',
50
+		'NOK',
51
+		'NZD',
52
+		'PHP',
53
+		'PLN',
54
+		'SEK',
55
+		'SGD',
56
+		'THB',
57
+		'TRY',
58
+		'TWD',
59
+		'RUB',
60
+		'INR',
61
+	);
62
+
63
+
64
+
65
+	/**
66
+	 * @param EEI_Payment $payment
67
+	 * @param array       $billing_info {
68
+	 * @type string $credit_card
69
+	 * @type string $credit_card_type
70
+	 * @type string $exp_month always 2 characters
71
+	 * @type string $exp_year always 4 characters
72
+	 * @type string $cvv
73
+	 * }
74
+	 * @see      parent::do_direct_payment for more info
75
+	 * @return EE_Payment|EEI_Payment
76
+	 * @throws EE_Error
77
+	 */
78
+	public function do_direct_payment($payment, $billing_info = null)
79
+	{
80
+		$transaction = $payment->transaction();
81
+		if (! $transaction instanceof EEI_Transaction) {
82
+			throw new EE_Error(
83
+				esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
84
+			);
85
+		}
86
+		$primary_registrant = $transaction->primary_registration();
87
+		if (! $primary_registrant instanceof EEI_Registration) {
88
+			throw new EE_Error(
89
+				esc_html__(
90
+					'No primary registration on transaction while paying with PayPal Pro.',
91
+					'event_espresso'
92
+				)
93
+			);
94
+		}
95
+		$attendee = $primary_registrant->attendee();
96
+		if (! $attendee instanceof EEI_Attendee) {
97
+			throw new EE_Error(
98
+				esc_html__(
99
+					'No attendee on primary registration while paying with PayPal Pro.',
100
+					'event_espresso'
101
+				)
102
+			);
103
+		}
104
+		$gateway_formatter = $this->_get_gateway_formatter();
105
+		$order_description = substr($gateway_formatter->formatOrderDescription($payment), 0, 127);
106
+		// charge for the full amount. Show itemized list
107
+		if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
108
+			$item_num = 1;
109
+			$total_line_item = $transaction->total_line_item();
110
+			$order_items = array();
111
+			foreach ($total_line_item->get_items() as $line_item) {
112
+				// ignore line items with a quantity of 0
113
+				if ($line_item->quantity() == 0) {
114
+					continue;
115
+				}
116
+				// For percent items, whose unit_price is 0, use the total instead.
117
+				if ($line_item->is_percent()) {
118
+					$unit_price = $line_item->total();
119
+					$line_item_quantity = 1;
120
+				} else {
121
+					$unit_price = $line_item->unit_price();
122
+					$line_item_quantity = $line_item->quantity();
123
+				}
124
+				$item = array(
125
+					// Item Name.  127 char max.
126
+					'l_name'                 => substr(
127
+						$gateway_formatter->formatLineItemName($line_item, $payment),
128
+						0,
129
+						127
130
+					),
131
+					// Item description.  127 char max.
132
+					'l_desc'                 => substr(
133
+						$gateway_formatter->formatLineItemDesc($line_item, $payment),
134
+						0,
135
+						127
136
+					),
137
+					// Cost of individual item.
138
+					'l_amt'                  => $unit_price,
139
+					// Item Number.  127 char max.
140
+					'l_number'               => $item_num++,
141
+					// Item quantity.  Must be any positive integer.
142
+					'l_qty'                  => $line_item_quantity,
143
+					// Item's sales tax amount.
144
+					'l_taxamt'               => '',
145
+					// eBay auction number of item.
146
+					'l_ebayitemnumber'       => '',
147
+					// eBay transaction ID of purchased item.
148
+					'l_ebayitemauctiontxnid' => '',
149
+					// eBay order ID for the item.
150
+					'l_ebayitemorderid'      => '',
151
+				);
152
+				// add to array of all items
153
+				array_push($order_items, $item);
154
+			}
155
+			$item_amount = $total_line_item->get_items_total();
156
+			$tax_amount = $total_line_item->get_total_tax();
157
+		} else {
158
+			$order_items = array();
159
+			$item_amount = $payment->amount();
160
+			$tax_amount = 0;
161
+			array_push($order_items, array(
162
+				// Item Name.  127 char max.
163
+				'l_name'   => substr(
164
+					$gateway_formatter->formatPartialPaymentLineItemName($payment),
165
+					0,
166
+					127
167
+				),
168
+				// Item description.  127 char max.
169
+				'l_desc'   => substr(
170
+					$gateway_formatter->formatPartialPaymentLineItemDesc($payment),
171
+					0,
172
+					127
173
+				),
174
+				// Cost of individual item.
175
+				'l_amt'    => $payment->amount(),
176
+				// Item Number.  127 char max.
177
+				'l_number' => 1,
178
+				// Item quantity.  Must be any positive integer.
179
+				'l_qty'    => 1,
180
+			));
181
+		}
182
+		// Populate data arrays with order data.
183
+		$DPFields = array(
184
+			// How you want to obtain payment ?
185
+			// Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
186
+			// Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
187
+			'paymentaction'    => 'Sale',
188
+			// Required.  IP address of the payer's browser.
189
+			'ipaddress'        => $_SERVER['REMOTE_ADDR'],
190
+			// Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
191
+			'returnfmfdetails' => '1',
192
+		);
193
+		$CCDetails = array(
194
+			// Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
195
+			// If Maestro or Solo, the currency code must be GBP.
196
+			//  In addition, either start date or issue number must be specified.
197
+			'creditcardtype' => $billing_info['credit_card_type'],
198
+			// Required.  Credit card number.  No spaces or punctuation.
199
+			'acct'           => $billing_info['credit_card'],
200
+			// Required.  Credit card expiration date.  Format is MMYYYY
201
+			'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
202
+			// Requirements determined by your PayPal account settings.  Security digits for credit card.
203
+			'cvv2'           => $billing_info['cvv'],
204
+		);
205
+		$PayerInfo = array(
206
+			// Email address of payer.
207
+			'email'       => $billing_info['email'],
208
+			// Unique PayPal customer ID for payer.
209
+			'payerid'     => '',
210
+			// Status of payer.  Values are verified or unverified
211
+			'payerstatus' => '',
212
+			// Payer's business name.
213
+			'business'    => '',
214
+		);
215
+		$PayerName = array(
216
+			// Payer's salutation.  20 char max.
217
+			'salutation' => '',
218
+			// Payer's first name.  25 char max.
219
+			'firstname'  => substr($billing_info['first_name'], 0, 25),
220
+			// Payer's middle name.  25 char max.
221
+			'middlename' => '',
222
+			// Payer's last name.  25 char max.
223
+			'lastname'   => substr($billing_info['last_name'], 0, 25),
224
+			// Payer's suffix.  12 char max.
225
+			'suffix'     => '',
226
+		);
227
+		$BillingAddress = array(
228
+			// Required.  First street address.
229
+			'street'      => $billing_info['address'],
230
+			// Second street address.
231
+			'street2'     => $billing_info['address2'],
232
+			// Required.  Name of City.
233
+			'city'        => $billing_info['city'],
234
+			// Required. Name of State or Province.
235
+			'state'       => substr($billing_info['state'], 0, 40),
236
+			// Required.  Country code.
237
+			'countrycode' => $billing_info['country'],
238
+			// Required.  Postal code of payer.
239
+			'zip'         => $billing_info['zip'],
240
+		);
241
+		// check if the registration info contains the needed fields for paypal pro
242
+		// (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
243
+		if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
244
+			$use_registration_address_info = true;
245
+		} else {
246
+			$use_registration_address_info = false;
247
+		}
248
+		// so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
249
+		// If not, use the billing info again
250
+		$ShippingAddress = array(
251
+			'shiptoname'     => substr($use_registration_address_info
252
+				? $attendee->full_name()
253
+				: $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
254
+			'shiptostreet'   => substr($use_registration_address_info
255
+				? $attendee->address()
256
+				: $billing_info['address'], 0, 100),
257
+			'shiptostreet2'  => substr($use_registration_address_info
258
+				? $attendee->address2() : $billing_info['address2'], 0, 100),
259
+			'shiptocity'     => substr($use_registration_address_info
260
+				? $attendee->city()
261
+				: $billing_info['city'], 0, 40),
262
+			'state'          => substr($use_registration_address_info
263
+				? $attendee->state_name()
264
+				: $billing_info['state'], 0, 40),
265
+			'shiptocountry'  => $use_registration_address_info
266
+				? $attendee->country_ID()
267
+				: $billing_info['country'],
268
+			'shiptozip'      => substr($use_registration_address_info
269
+				? $attendee->zip()
270
+				: $billing_info['zip'], 0, 20),
271
+			'shiptophonenum' => substr($use_registration_address_info
272
+				? $attendee->phone()
273
+				: $billing_info['phone'], 0, 20),
274
+		);
275
+		$PaymentDetails = array(
276
+			// Required.  Total amount of order, including shipping, handling, and tax.
277
+			'amt'          => $gateway_formatter->formatCurrency($payment->amount()),
278
+			// Required.  Three-letter currency code.  Default is USD.
279
+			'currencycode' => $payment->currency_code(),
280
+			// Required if you include itemized cart details. (L_AMTn, etc.)
281
+			// Subtotal of items not including S&H, or tax.
282
+			'itemamt'      => $gateway_formatter->formatCurrency($item_amount),//
283
+			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
284
+			'shippingamt'  => '',
285
+			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
286
+			'handlingamt'  => '',
287
+			// Required if you specify itemized cart tax details.
288
+			// Sum of tax for all items on the order.  Total sales tax.
289
+			'taxamt'       => $gateway_formatter->formatCurrency($tax_amount),
290
+			// Description of the order the customer is purchasing.  127 char max.
291
+			'desc'         => $order_description,
292
+			// Free-form field for your own use.  256 char max.
293
+			'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
294
+			// Your own invoice or tracking number
295
+			'invnum'       => wp_generate_password(12, false),// $transaction->ID(),
296
+			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
297
+			'notifyurl'    => '',
298
+			'buttonsource' => 'EventEspresso_SP',// EE will blow up if you change this
299
+		);
300
+		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
301
+		$PayPalRequestData = array(
302
+			'DPFields'        => $DPFields,
303
+			'CCDetails'       => $CCDetails,
304
+			'PayerInfo'       => $PayerInfo,
305
+			'PayerName'       => $PayerName,
306
+			'BillingAddress'  => $BillingAddress,
307
+			'ShippingAddress' => $ShippingAddress,
308
+			'PaymentDetails'  => $PaymentDetails,
309
+			'OrderItems'      => $order_items,
310
+		);
311
+		$this->_log_clean_request($PayPalRequestData, $payment);
312
+		try {
313
+			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
314
+			// remove PCI-sensitive data so it doesn't get stored
315
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
316
+			if (isset($PayPalResult['L_ERRORCODE0']) && $PayPalResult['L_ERRORCODE0'] === '10002') {
317
+				$message = esc_html__('PayPal did not accept your API username, password, or signature. Please double-check these credentials and if debug mode is on.', 'event_espresso');
318
+			} elseif (isset($PayPalResult['L_LONGMESSAGE0'])) {
319
+				$message = $PayPalResult['L_LONGMESSAGE0'];
320
+			} else {
321
+				$message = $PayPalResult['ACK'];
322
+			}
323
+			if (empty($PayPalResult['RAWRESPONSE'])) {
324
+				$payment->set_status($this->_pay_model->failed_status());
325
+				$payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
326
+				$payment->set_details($PayPalResult);
327
+			} else {
328
+				if ($this->_APICallSuccessful($PayPalResult)) {
329
+					$payment->set_status($this->_pay_model->approved_status());
330
+				} else {
331
+					$payment->set_status($this->_pay_model->declined_status());
332
+				}
333
+				// make sure we interpret the AMT as a float, not an international string
334
+				// (where periods are thousand separators)
335
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
336
+				$payment->set_gateway_response($message);
337
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
338
+					? $PayPalResult['TRANSACTIONID']
339
+					: null);
340
+				$primary_registration_code = $primary_registrant instanceof EE_Registration
341
+					? $primary_registrant->reg_code()
342
+					: '';
343
+				$payment->set_extra_accntng($primary_registration_code);
344
+				$payment->set_details($PayPalResult);
345
+			}
346
+		} catch (Exception $e) {
347
+			$payment->set_status($this->_pay_model->failed_status());
348
+			$payment->set_gateway_response($e->getMessage());
349
+		}
350
+		// $payment->set_status( $this->_pay_model->declined_status() );
351
+		// $payment->set_gateway_response( '' );
352
+		return $payment;
353
+	}
354
+
355
+
356
+
357
+	/**
358
+	 * CLeans out sensitive CC data and then logs it, and returns the cleaned request
359
+	 *
360
+	 * @param array       $request
361
+	 * @param EEI_Payment $payment
362
+	 * @return void
363
+	 */
364
+	private function _log_clean_request($request, $payment)
365
+	{
366
+		$cleaned_request_data = $request;
367
+		unset($cleaned_request_data['CCDetails']['acct']);
368
+		unset($cleaned_request_data['CCDetails']['cvv2']);
369
+		unset($cleaned_request_data['CCDetails']['expdate']);
370
+		$this->log(array('Paypal Request' => $cleaned_request_data), $payment);
371
+	}
372
+
373
+
374
+
375
+	/**
376
+	 * Cleans the response, logs it, and returns it
377
+	 *
378
+	 * @param array       $response
379
+	 * @param EEI_Payment $payment
380
+	 * @return array cleaned
381
+	 */
382
+	private function _log_clean_response($response, $payment)
383
+	{
384
+		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
385
+		unset($response['REQUESTDATA']['ACCT']);
386
+		unset($response['REQUESTDATA']['EXPDATE']);
387
+		unset($response['REQUESTDATA']['CVV2']);
388
+		unset($response['RAWREQUEST']);
389
+		$this->log(array('Paypal Response' => $response), $payment);
390
+		return $response;
391
+	}
392
+
393
+
394
+
395
+	/**
396
+	 * @param $DataArray
397
+	 * @return array
398
+	 */
399
+	private function prep_and_curl_request($DataArray)
400
+	{
401
+		// Create empty holders for each portion of the NVP string
402
+		$DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
403
+		$CCDetailsNVP = '';
404
+		$PayerInfoNVP = '';
405
+		$PayerNameNVP = '';
406
+		$BillingAddressNVP = '';
407
+		$ShippingAddressNVP = '';
408
+		$PaymentDetailsNVP = '';
409
+		$OrderItemsNVP = '';
410
+		$Secure3DNVP = '';
411
+		// DP Fields
412
+		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
413
+		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
414
+			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
415
+		}
416
+		// CC Details Fields
417
+		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
418
+		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
419
+			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
420
+		}
421
+		// PayerInfo Type Fields
422
+		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
423
+		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
424
+			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
425
+		}
426
+		// Payer Name Fields
427
+		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
428
+		foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
429
+			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
430
+		}
431
+		// Address Fields (Billing)
432
+		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
433
+		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
434
+			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
435
+		}
436
+		// Payment Details Type Fields
437
+		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
438
+		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
439
+			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
440
+		}
441
+		// Payment Details Item Type Fields
442
+		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
443
+		$n = 0;
444
+		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
445
+			$CurrentItem = $OrderItems[ $OrderItemsVar ];
446
+			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
447
+				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
448
+			}
449
+			$n++;
450
+		}
451
+		// Ship To Address Fields
452
+		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
453
+		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
454
+			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
455
+		}
456
+		// 3D Secure Fields
457
+		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
458
+		foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
459
+			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
460
+		}
461
+		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
462
+		$NVPRequest = 'USER='
463
+					  . $this->_api_username
464
+					  . '&PWD='
465
+					  . $this->_api_password
466
+					  . '&VERSION=64.0'
467
+					  . '&SIGNATURE='
468
+					  . $this->_api_signature
469
+					  . $DPFieldsNVP
470
+					  . $CCDetailsNVP
471
+					  . $PayerInfoNVP
472
+					  . $PayerNameNVP
473
+					  . $BillingAddressNVP
474
+					  . $PaymentDetailsNVP
475
+					  . $OrderItemsNVP
476
+					  . $ShippingAddressNVP
477
+					  . $Secure3DNVP;
478
+		$NVPResponse = $this->_CURLRequest($NVPRequest);
479
+		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
480
+		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
481
+		$Errors = $this->_GetErrors($NVPResponseArray);
482
+		$NVPResponseArray['ERRORS'] = $Errors;
483
+		$NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
484
+		$NVPResponseArray['RAWREQUEST'] = $NVPRequest;
485
+		$NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
486
+		return $NVPResponseArray;
487
+	}
488
+
489
+
490
+
491
+	/**
492
+	 * @param $Request
493
+	 * @return mixed
494
+	 */
495
+	private function _CURLRequest($Request)
496
+	{
497
+		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
498
+		$curl = curl_init();
499
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
500
+		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
501
+		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
502
+		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
503
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
504
+		curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
505
+		curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
506
+		// execute the curl POST
507
+		$Response = curl_exec($curl);
508
+		curl_close($curl);
509
+		return $Response;
510
+	}
511
+
512
+
513
+
514
+	/**
515
+	 * @param $NVPString
516
+	 * @return array
517
+	 */
518
+	private function _NVPToArray($NVPString)
519
+	{
520
+		// prepare responses into array
521
+		$proArray = array();
522
+		while (strlen($NVPString)) {
523
+			// name
524
+			$keypos = strpos($NVPString, '=');
525
+			$keyval = substr($NVPString, 0, $keypos);
526
+			// value
527
+			$valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
528
+			$valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
529
+			// decoding the response
530
+			$proArray[ $keyval ] = urldecode($valval);
531
+			$NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
532
+		}
533
+		return $proArray;
534
+	}
535
+
536
+
537
+
538
+	/**
539
+	 * @param array $PayPalResult
540
+	 * @return bool
541
+	 */
542
+	private function _APICallSuccessful($PayPalResult)
543
+	{
544
+		$approved = false;
545
+		// check main response message from PayPal
546
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
547
+			$ack = strtoupper($PayPalResult['ACK']);
548
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
549
+		}
550
+		return $approved;
551
+	}
552
+
553
+
554
+
555
+	/**
556
+	 * @param $DataArray
557
+	 * @return array
558
+	 */
559
+	private function _GetErrors($DataArray)
560
+	{
561
+		$Errors = array();
562
+		$n = 0;
563
+		while (isset($DataArray[ 'L_ERRORCODE' . $n . '' ])) {
564
+			$LErrorCode = isset($DataArray[ 'L_ERRORCODE' . $n . '' ]) ? $DataArray[ 'L_ERRORCODE' . $n . '' ] : '';
565
+			$LShortMessage = isset($DataArray[ 'L_SHORTMESSAGE' . $n . '' ])
566
+				? $DataArray[ 'L_SHORTMESSAGE' . $n . '' ]
567
+				: '';
568
+			$LLongMessage = isset($DataArray[ 'L_LONGMESSAGE' . $n . '' ])
569
+				? $DataArray[ 'L_LONGMESSAGE' . $n . '' ]
570
+				: '';
571
+			$LSeverityCode = isset($DataArray[ 'L_SEVERITYCODE' . $n . '' ])
572
+				? $DataArray[ 'L_SEVERITYCODE' . $n . '' ]
573
+				: '';
574
+			$CurrentItem = array(
575
+				'L_ERRORCODE'    => $LErrorCode,
576
+				'L_SHORTMESSAGE' => $LShortMessage,
577
+				'L_LONGMESSAGE'  => $LLongMessage,
578
+				'L_SEVERITYCODE' => $LSeverityCode,
579
+			);
580
+			array_push($Errors, $CurrentItem);
581
+			$n++;
582
+		}
583
+		return $Errors;
584
+	}
585
+
586
+
587
+
588
+	/**
589
+	 *        nothing to see here...  move along....
590
+	 *
591
+	 * @access protected
592
+	 * @param $Errors
593
+	 * @return string
594
+	 */
595
+	private function _DisplayErrors($Errors)
596
+	{
597
+		$error = '';
598
+		foreach ($Errors as $ErrorVar => $ErrorVal) {
599
+			$CurrentError = $Errors[ $ErrorVar ];
600
+			foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
601
+				$CurrentVarName = '';
602
+				if ($CurrentErrorVar == 'L_ERRORCODE') {
603
+					$CurrentVarName = 'Error Code';
604
+				} elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
605
+					$CurrentVarName = 'Short Message';
606
+				} elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
607
+					$CurrentVarName = 'Long Message';
608
+				} elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
609
+					$CurrentVarName = 'Severity Code';
610
+				}
611
+				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
612
+			}
613
+		}
614
+		return $error;
615
+	}
616 616
 }
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EE_PMT_Paypal_Pro.pm.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -63,22 +63,22 @@  discard block
 block discarded – undo
63 63
             //              'html_id'=> 'ee-Paypal_Pro-billing-form',
64 64
                 'subsections'=>array(
65 65
                     'credit_card'=>new EE_Credit_Card_Input(
66
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Number', 'event_espresso'))
66
+                        array('required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Number', 'event_espresso'))
67 67
                     ),
68 68
                     'credit_card_type'=>new EE_Select_Input(
69 69
                         // the options are set dynamically
70 70
                         array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)),
71
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Type', 'event_espresso'))
71
+                        array('required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Type', 'event_espresso'))
72 72
                     ),
73 73
                     'exp_month'=>new EE_Credit_Card_Month_Input(
74 74
                         true,
75
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' =>  __('Expiry Month', 'event_espresso')  )
75
+                        array('required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' =>  __('Expiry Month', 'event_espresso'))
76 76
                     ),
77 77
                     'exp_year'=>new EE_Credit_Card_Year_Input(
78
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Year', 'event_espresso')  )
78
+                        array('required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Year', 'event_espresso'))
79 79
                     ),
80 80
                     'cvv'=>new EE_CVV_Input(
81
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('CVV', 'event_espresso') )
81
+                        array('required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('CVV', 'event_espresso'))
82 82
                     ),
83 83
                 )
84 84
             )
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
     {
100 100
         if ($this->_pm_instance->debug_mode()) {
101 101
             $billing_form->add_subsections(
102
-                array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
102
+                array('fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html()),
103 103
                 'credit_card'
104 104
             );
105 105
             $billing_form->add_subsections(
106
-                array( 'debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).DS.'templates'.DS.'paypal_pro_debug_info.template.php')),
106
+                array('debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).DS.'templates'.DS.'paypal_pro_debug_info.template.php')),
107 107
                 'first_name'
108 108
             );
109 109
             $billing_form->get_input('credit_card_type')->set_default('Visa');
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
             ]
185 185
         );
186 186
         // If they existed, set the new ones instead
187
-        if (!empty($old_extra_metas)) {
187
+        if ( ! empty($old_extra_metas)) {
188 188
             foreach ($old_extra_metas as $old_extra_meta) {
189
-                $old_extra_meta->set('EXM_key', 'api_' . $old_extra_meta->get('EXM_key'));
189
+                $old_extra_meta->set('EXM_key', 'api_'.$old_extra_meta->get('EXM_key'));
190 190
                 $old_extra_meta->save();
191 191
             }
192 192
         }
Please login to merge, or discard this patch.
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -14,182 +14,182 @@
 block discarded – undo
14 14
 class EE_PMT_Paypal_Pro extends EE_PMT_Base
15 15
 {
16 16
 
17
-    /**
18
-     * @param EE_Payment_Method $pm_instance
19
-     * @return EE_PMT_Paypal_Pro
20
-     */
21
-    public function __construct($pm_instance = null)
22
-    {
23
-        require_once($this->file_folder().'EEG_Paypal_Pro.gateway.php');
24
-        $this->_gateway = new EEG_Paypal_Pro();
25
-        $this->_pretty_name = __("Paypal Pro", 'event_espresso');
26
-        $this->_default_description = __('Please provide the following billing information.', 'event_espresso');
27
-        $this->_requires_https = true;
28
-        parent::__construct($pm_instance);
29
-    }
30
-
31
-
32
-    /**
33
-     * Gets the form for all the settings related to this payment method type
34
-     * @return EE_Payment_Method_Form
35
-     * @throws InvalidArgumentException
36
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
37
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
38
-     */
39
-    public function generate_new_settings_form()
40
-    {
41
-        return new PayPalProSettingsForm(array(), $this->get_help_tab_link());
42
-    }
43
-
44
-
45
-    /**
46
-     * Creates the billing form for this payment method type
47
-     * @param \EE_Transaction $transaction
48
-     * @throws \EE_Error
49
-     * @return EE_Billing_Info_Form
50
-     */
51
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
52
-    {
53
-        $allowed_types = $this->_pm_instance->get_extra_meta('credit_card_types', true);
54
-        // if allowed types is a string or empty array or null...
55
-        if (empty($allowed_types)) {
56
-            $allowed_types = array();
57
-        }
58
-
59
-        $billing_form = new EE_Billing_Attendee_Info_Form(
60
-            $this->_pm_instance,
61
-            array(
62
-                'name'=> 'Paypal_Pro_Billing_Form',
63
-            //              'html_id'=> 'ee-Paypal_Pro-billing-form',
64
-                'subsections'=>array(
65
-                    'credit_card'=>new EE_Credit_Card_Input(
66
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Number', 'event_espresso'))
67
-                    ),
68
-                    'credit_card_type'=>new EE_Select_Input(
69
-                        // the options are set dynamically
70
-                        array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)),
71
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Type', 'event_espresso'))
72
-                    ),
73
-                    'exp_month'=>new EE_Credit_Card_Month_Input(
74
-                        true,
75
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' =>  __('Expiry Month', 'event_espresso')  )
76
-                    ),
77
-                    'exp_year'=>new EE_Credit_Card_Year_Input(
78
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Year', 'event_espresso')  )
79
-                    ),
80
-                    'cvv'=>new EE_CVV_Input(
81
-                        array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('CVV', 'event_espresso') )
82
-                    ),
83
-                )
84
-            )
85
-        );
86
-        return $this->apply_billing_form_debug_settings($billing_form);
87
-    }
88
-
89
-
90
-
91
-    /**
92
-     * apply_billing_form_debug_settings
93
-     * applies debug data to the form
94
-     *
95
-     * @param \EE_Billing_Info_Form $billing_form
96
-     * @return \EE_Billing_Info_Form
97
-     */
98
-    public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
99
-    {
100
-        if ($this->_pm_instance->debug_mode()) {
101
-            $billing_form->add_subsections(
102
-                array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
103
-                'credit_card'
104
-            );
105
-            $billing_form->add_subsections(
106
-                array( 'debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).DS.'templates'.DS.'paypal_pro_debug_info.template.php')),
107
-                'first_name'
108
-            );
109
-            $billing_form->get_input('credit_card_type')->set_default('Visa');
110
-            $billing_form->get_input('exp_year')->set_default(2018);
111
-            $billing_form->get_input('cvv')->set_default('115');
112
-        }
113
-        return $billing_form;
114
-    }
115
-
116
-
117
-
118
-    /**
119
-     * Returns an array of all the payment cards possibly supported by paypal pro.
120
-     * Keys are their values, values are their pretty names.
121
-     * @return array
122
-     */
123
-    public static function card_types_supported()
124
-    {
125
-        return array(
126
-            'Visa'=>  __("Visa", 'event_espresso'),
127
-            'MasterCard'=>  __("MasterCard", 'event_espresso'),
128
-            'Amex'=>  __("American Express", 'event_espresso'),
129
-            'Discover'=>  __("Discover", 'event_espresso')
130
-            );
131
-    }
132
-
133
-
134
-
135
-    /**
136
-     * Adds the help tab
137
-     * @see EE_PMT_Base::help_tabs_config()
138
-     * @return array
139
-     */
140
-    public function help_tabs_config()
141
-    {
142
-        return array(
143
-            $this->get_help_tab_name() => array(
144
-                        'title' => __('PayPal Pro Settings', 'event_espresso'),
145
-                        'filename' => 'payment_methods_overview_paypalpro'
146
-                        ),
147
-        );
148
-    }
149
-
150
-    /**
151
-     * Overrides parent's _get_billing_values_from_form because we want to
152
-     * get the country's 2-character ISO code, not the name like most gateways
153
-     * @param EE_Billing_Info_Form $billing_form
154
-     * @return array
155
-     */
156
-    protected function _get_billing_values_from_form($billing_form)
157
-    {
158
-        $billing_values = parent::_get_billing_values_from_form($billing_form);
159
-        $billing_values['country'] = $billing_form->get_input_value('country');
160
-        $billing_values['credit_card_type'] = $billing_form->get_input_value('credit_card_type');
161
-        return $billing_values;
162
-    }
163
-
164
-    /**
165
-     * Override parent to account for a change in extra meta inputs in 4.9.75.p
166
-     * @since 4.9.79.p
167
-     * @param EE_Payment_Method $payment_method_instance
168
-     * @throws EE_Error
169
-     * @throws InvalidArgumentException
170
-     * @throws ReflectionException
171
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
172
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
173
-     */
174
-    public function set_instance($payment_method_instance)
175
-    {
176
-        // Check for the old extra meta inputs
177
-        $old_extra_metas = EEM_Extra_Meta::instance()->get_all(
178
-            [
179
-                [
180
-                    'EXM_type' => 'Payment_Method',
181
-                    'OBJ_ID' => $payment_method_instance->ID(),
182
-                    'EXM_key' => ['IN', ['username', 'password', 'signature']],
183
-                ]
184
-            ]
185
-        );
186
-        // If they existed, set the new ones instead
187
-        if (!empty($old_extra_metas)) {
188
-            foreach ($old_extra_metas as $old_extra_meta) {
189
-                $old_extra_meta->set('EXM_key', 'api_' . $old_extra_meta->get('EXM_key'));
190
-                $old_extra_meta->save();
191
-            }
192
-        }
193
-        return parent::set_instance($payment_method_instance);
194
-    }
17
+	/**
18
+	 * @param EE_Payment_Method $pm_instance
19
+	 * @return EE_PMT_Paypal_Pro
20
+	 */
21
+	public function __construct($pm_instance = null)
22
+	{
23
+		require_once($this->file_folder().'EEG_Paypal_Pro.gateway.php');
24
+		$this->_gateway = new EEG_Paypal_Pro();
25
+		$this->_pretty_name = __("Paypal Pro", 'event_espresso');
26
+		$this->_default_description = __('Please provide the following billing information.', 'event_espresso');
27
+		$this->_requires_https = true;
28
+		parent::__construct($pm_instance);
29
+	}
30
+
31
+
32
+	/**
33
+	 * Gets the form for all the settings related to this payment method type
34
+	 * @return EE_Payment_Method_Form
35
+	 * @throws InvalidArgumentException
36
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
37
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
38
+	 */
39
+	public function generate_new_settings_form()
40
+	{
41
+		return new PayPalProSettingsForm(array(), $this->get_help_tab_link());
42
+	}
43
+
44
+
45
+	/**
46
+	 * Creates the billing form for this payment method type
47
+	 * @param \EE_Transaction $transaction
48
+	 * @throws \EE_Error
49
+	 * @return EE_Billing_Info_Form
50
+	 */
51
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
52
+	{
53
+		$allowed_types = $this->_pm_instance->get_extra_meta('credit_card_types', true);
54
+		// if allowed types is a string or empty array or null...
55
+		if (empty($allowed_types)) {
56
+			$allowed_types = array();
57
+		}
58
+
59
+		$billing_form = new EE_Billing_Attendee_Info_Form(
60
+			$this->_pm_instance,
61
+			array(
62
+				'name'=> 'Paypal_Pro_Billing_Form',
63
+			//              'html_id'=> 'ee-Paypal_Pro-billing-form',
64
+				'subsections'=>array(
65
+					'credit_card'=>new EE_Credit_Card_Input(
66
+						array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Number', 'event_espresso'))
67
+					),
68
+					'credit_card_type'=>new EE_Select_Input(
69
+						// the options are set dynamically
70
+						array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)),
71
+						array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Card Type', 'event_espresso'))
72
+					),
73
+					'exp_month'=>new EE_Credit_Card_Month_Input(
74
+						true,
75
+						array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' =>  __('Expiry Month', 'event_espresso')  )
76
+					),
77
+					'exp_year'=>new EE_Credit_Card_Year_Input(
78
+						array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('Expiry Year', 'event_espresso')  )
79
+					),
80
+					'cvv'=>new EE_CVV_Input(
81
+						array( 'required'=>true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => __('CVV', 'event_espresso') )
82
+					),
83
+				)
84
+			)
85
+		);
86
+		return $this->apply_billing_form_debug_settings($billing_form);
87
+	}
88
+
89
+
90
+
91
+	/**
92
+	 * apply_billing_form_debug_settings
93
+	 * applies debug data to the form
94
+	 *
95
+	 * @param \EE_Billing_Info_Form $billing_form
96
+	 * @return \EE_Billing_Info_Form
97
+	 */
98
+	public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
99
+	{
100
+		if ($this->_pm_instance->debug_mode()) {
101
+			$billing_form->add_subsections(
102
+				array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
103
+				'credit_card'
104
+			);
105
+			$billing_form->add_subsections(
106
+				array( 'debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).DS.'templates'.DS.'paypal_pro_debug_info.template.php')),
107
+				'first_name'
108
+			);
109
+			$billing_form->get_input('credit_card_type')->set_default('Visa');
110
+			$billing_form->get_input('exp_year')->set_default(2018);
111
+			$billing_form->get_input('cvv')->set_default('115');
112
+		}
113
+		return $billing_form;
114
+	}
115
+
116
+
117
+
118
+	/**
119
+	 * Returns an array of all the payment cards possibly supported by paypal pro.
120
+	 * Keys are their values, values are their pretty names.
121
+	 * @return array
122
+	 */
123
+	public static function card_types_supported()
124
+	{
125
+		return array(
126
+			'Visa'=>  __("Visa", 'event_espresso'),
127
+			'MasterCard'=>  __("MasterCard", 'event_espresso'),
128
+			'Amex'=>  __("American Express", 'event_espresso'),
129
+			'Discover'=>  __("Discover", 'event_espresso')
130
+			);
131
+	}
132
+
133
+
134
+
135
+	/**
136
+	 * Adds the help tab
137
+	 * @see EE_PMT_Base::help_tabs_config()
138
+	 * @return array
139
+	 */
140
+	public function help_tabs_config()
141
+	{
142
+		return array(
143
+			$this->get_help_tab_name() => array(
144
+						'title' => __('PayPal Pro Settings', 'event_espresso'),
145
+						'filename' => 'payment_methods_overview_paypalpro'
146
+						),
147
+		);
148
+	}
149
+
150
+	/**
151
+	 * Overrides parent's _get_billing_values_from_form because we want to
152
+	 * get the country's 2-character ISO code, not the name like most gateways
153
+	 * @param EE_Billing_Info_Form $billing_form
154
+	 * @return array
155
+	 */
156
+	protected function _get_billing_values_from_form($billing_form)
157
+	{
158
+		$billing_values = parent::_get_billing_values_from_form($billing_form);
159
+		$billing_values['country'] = $billing_form->get_input_value('country');
160
+		$billing_values['credit_card_type'] = $billing_form->get_input_value('credit_card_type');
161
+		return $billing_values;
162
+	}
163
+
164
+	/**
165
+	 * Override parent to account for a change in extra meta inputs in 4.9.75.p
166
+	 * @since 4.9.79.p
167
+	 * @param EE_Payment_Method $payment_method_instance
168
+	 * @throws EE_Error
169
+	 * @throws InvalidArgumentException
170
+	 * @throws ReflectionException
171
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
172
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
173
+	 */
174
+	public function set_instance($payment_method_instance)
175
+	{
176
+		// Check for the old extra meta inputs
177
+		$old_extra_metas = EEM_Extra_Meta::instance()->get_all(
178
+			[
179
+				[
180
+					'EXM_type' => 'Payment_Method',
181
+					'OBJ_ID' => $payment_method_instance->ID(),
182
+					'EXM_key' => ['IN', ['username', 'password', 'signature']],
183
+				]
184
+			]
185
+		);
186
+		// If they existed, set the new ones instead
187
+		if (!empty($old_extra_metas)) {
188
+			foreach ($old_extra_metas as $old_extra_meta) {
189
+				$old_extra_meta->set('EXM_key', 'api_' . $old_extra_meta->get('EXM_key'));
190
+				$old_extra_meta->save();
191
+			}
192
+		}
193
+		return parent::set_instance($payment_method_instance);
194
+	}
195 195
 }
Please login to merge, or discard this patch.
core/services/request/files/FileSubmission.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function getType()
73 73
     {
74
-        if (!$this->type) {
74
+        if ( ! $this->type) {
75 75
             $this->type = $this->determineType();
76 76
         }
77 77
         return $this->type;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function determineType()
85 85
     {
86
-        if (!$this->getTmpFile()) {
86
+        if ( ! $this->getTmpFile()) {
87 87
             return '';
88 88
         }
89 89
         $finfo = new finfo(FILEINFO_MIME_TYPE);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function getExtension()
99 99
     {
100
-        if (!$this->extension) {
100
+        if ( ! $this->extension) {
101 101
             $this->extension = $this->determineExtension();
102 102
         }
103 103
         return $this->extension;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     protected function determineExtension()
112 112
     {
113
-        if (!$this->getTmpFile()) {
113
+        if ( ! $this->getTmpFile()) {
114 114
             return '';
115 115
         }
116 116
         return pathinfo($this->getTmpFile(), PATHINFO_EXTENSION);
Please login to merge, or discard this patch.
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -19,160 +19,160 @@
 block discarded – undo
19 19
  */
20 20
 class FileSubmission implements FileSubmissionInterface
21 21
 {
22
-    /**
23
-     * @var string original name on the client machine
24
-     */
25
-    protected $name;
26
-
27
-    /**
28
-     * @var string mime type
29
-     */
30
-    protected $type;
31
-
32
-    /**
33
-     * @var string file extension
34
-     */
35
-    protected $extension;
36
-
37
-    /**
38
-     * @var int in bytes
39
-     */
40
-    protected $size;
41
-
42
-    /**
43
-     * @var string local filepath to the temporary file
44
-     */
45
-    protected $tmp_file;
46
-
47
-    /**
48
-     * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values
49
-     * although those aren't expected.
50
-     */
51
-    protected $error_code;
52
-
53
-    /**
54
-     * FileSubmission constructor.
55
-     * @param $name
56
-     * @param $tmp_file
57
-     * @param $size
58
-     * @param null $error_code
59
-     * @throws InvalidArgumentException
60
-     */
61
-    public function __construct($name, $tmp_file, $size, $error_code = null)
62
-    {
63
-        $this->name = basename($name);
64
-        $scheme = parse_url($tmp_file, PHP_URL_SCHEME);
65
-        if (in_array($scheme, ['http', 'https'])) {
66
-            // Wait a minute- just local filepaths please, no URL schemes allowed!
67
-            throw new InvalidArgumentException(
68
-                sprintf(
69
-                    // @codingStandardsIgnoreStart
70
-                    esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'),
71
-                    // @codingStandardsIgnoreEnd
72
-                    $scheme,
73
-                    $tmp_file
74
-                )
75
-            );
76
-        }
77
-        $this->tmp_file = (string) $tmp_file;
78
-        $this->size = (int) $size;
79
-        $this->error_code = (int) $error_code;
80
-    }
81
-
82
-    /**
83
-     * @return string
84
-     */
85
-    public function getName()
86
-    {
87
-        return $this->name;
88
-    }
89
-
90
-    /**
91
-     * Gets the file's mime type
92
-     * @return string
93
-     */
94
-    public function getType()
95
-    {
96
-        if (!$this->type) {
97
-            $this->type = $this->determineType();
98
-        }
99
-        return $this->type;
100
-    }
101
-
102
-    /**
103
-     * @since $VID:$
104
-     * @return string
105
-     */
106
-    protected function determineType()
107
-    {
108
-        if (!$this->getTmpFile()) {
109
-            return '';
110
-        }
111
-        $finfo = new finfo(FILEINFO_MIME_TYPE);
112
-        return $finfo->file($this->getTmpFile());
113
-    }
114
-
115
-    /**
116
-     * Gets the file's extension.
117
-     * @since $VID:$
118
-     * @return string
119
-     */
120
-    public function getExtension()
121
-    {
122
-        if (!$this->extension) {
123
-            $this->extension = $this->determineExtension();
124
-        }
125
-        return $this->extension;
126
-    }
127
-
128
-    /**
129
-     * Determine's the file's extension given the temporary file.
130
-     * @since $VID:$
131
-     * @return string
132
-     */
133
-    protected function determineExtension()
134
-    {
135
-        if (!$this->getTmpFile()) {
136
-            return '';
137
-        }
138
-        return pathinfo($this->getTmpFile(), PATHINFO_EXTENSION);
139
-    }
140
-
141
-    /**
142
-     * Gets the size of the file
143
-     * @return int
144
-     */
145
-    public function getSize()
146
-    {
147
-        return $this->size;
148
-    }
149
-
150
-    /**
151
-     * Gets the path to the temporary file which was uploaded.
152
-     * @return string
153
-     */
154
-    public function getTmpFile()
155
-    {
156
-        return $this->tmp_file;
157
-    }
158
-
159
-    /**
160
-     * @since $VID:$
161
-     * @return string
162
-     */
163
-    public function __toString()
164
-    {
165
-        return $this->getTmpFile();
166
-    }
167
-
168
-    /**
169
-     * Gets the error code PHP reported for the file upload.
170
-     * @return string
171
-     */
172
-    public function getErrorCode()
173
-    {
174
-        return $this->error_code;
175
-    }
22
+	/**
23
+	 * @var string original name on the client machine
24
+	 */
25
+	protected $name;
26
+
27
+	/**
28
+	 * @var string mime type
29
+	 */
30
+	protected $type;
31
+
32
+	/**
33
+	 * @var string file extension
34
+	 */
35
+	protected $extension;
36
+
37
+	/**
38
+	 * @var int in bytes
39
+	 */
40
+	protected $size;
41
+
42
+	/**
43
+	 * @var string local filepath to the temporary file
44
+	 */
45
+	protected $tmp_file;
46
+
47
+	/**
48
+	 * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values
49
+	 * although those aren't expected.
50
+	 */
51
+	protected $error_code;
52
+
53
+	/**
54
+	 * FileSubmission constructor.
55
+	 * @param $name
56
+	 * @param $tmp_file
57
+	 * @param $size
58
+	 * @param null $error_code
59
+	 * @throws InvalidArgumentException
60
+	 */
61
+	public function __construct($name, $tmp_file, $size, $error_code = null)
62
+	{
63
+		$this->name = basename($name);
64
+		$scheme = parse_url($tmp_file, PHP_URL_SCHEME);
65
+		if (in_array($scheme, ['http', 'https'])) {
66
+			// Wait a minute- just local filepaths please, no URL schemes allowed!
67
+			throw new InvalidArgumentException(
68
+				sprintf(
69
+					// @codingStandardsIgnoreStart
70
+					esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'),
71
+					// @codingStandardsIgnoreEnd
72
+					$scheme,
73
+					$tmp_file
74
+				)
75
+			);
76
+		}
77
+		$this->tmp_file = (string) $tmp_file;
78
+		$this->size = (int) $size;
79
+		$this->error_code = (int) $error_code;
80
+	}
81
+
82
+	/**
83
+	 * @return string
84
+	 */
85
+	public function getName()
86
+	{
87
+		return $this->name;
88
+	}
89
+
90
+	/**
91
+	 * Gets the file's mime type
92
+	 * @return string
93
+	 */
94
+	public function getType()
95
+	{
96
+		if (!$this->type) {
97
+			$this->type = $this->determineType();
98
+		}
99
+		return $this->type;
100
+	}
101
+
102
+	/**
103
+	 * @since $VID:$
104
+	 * @return string
105
+	 */
106
+	protected function determineType()
107
+	{
108
+		if (!$this->getTmpFile()) {
109
+			return '';
110
+		}
111
+		$finfo = new finfo(FILEINFO_MIME_TYPE);
112
+		return $finfo->file($this->getTmpFile());
113
+	}
114
+
115
+	/**
116
+	 * Gets the file's extension.
117
+	 * @since $VID:$
118
+	 * @return string
119
+	 */
120
+	public function getExtension()
121
+	{
122
+		if (!$this->extension) {
123
+			$this->extension = $this->determineExtension();
124
+		}
125
+		return $this->extension;
126
+	}
127
+
128
+	/**
129
+	 * Determine's the file's extension given the temporary file.
130
+	 * @since $VID:$
131
+	 * @return string
132
+	 */
133
+	protected function determineExtension()
134
+	{
135
+		if (!$this->getTmpFile()) {
136
+			return '';
137
+		}
138
+		return pathinfo($this->getTmpFile(), PATHINFO_EXTENSION);
139
+	}
140
+
141
+	/**
142
+	 * Gets the size of the file
143
+	 * @return int
144
+	 */
145
+	public function getSize()
146
+	{
147
+		return $this->size;
148
+	}
149
+
150
+	/**
151
+	 * Gets the path to the temporary file which was uploaded.
152
+	 * @return string
153
+	 */
154
+	public function getTmpFile()
155
+	{
156
+		return $this->tmp_file;
157
+	}
158
+
159
+	/**
160
+	 * @since $VID:$
161
+	 * @return string
162
+	 */
163
+	public function __toString()
164
+	{
165
+		return $this->getTmpFile();
166
+	}
167
+
168
+	/**
169
+	 * Gets the error code PHP reported for the file upload.
170
+	 * @return string
171
+	 */
172
+	public function getErrorCode()
173
+	{
174
+		return $this->error_code;
175
+	}
176 176
 }
177 177
 // End of file FileSubmission.php
178 178
 // Location: EventEspresso\core\services\request\files/FileSubmission.php
Please login to merge, or discard this patch.