| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
const GFEWAY_PLUGIN_OPTIONS = 'gfeway_plugin'; |
| 7 |
|
| 8 |
// error message names |
| 9 |
const GFEWAY_ERROR_ALREADY_SUBMITTED = 'gfeway_err_already'; |
| 10 |
const GFEWAY_ERROR_NO_AMOUNT = 'gfeway_err_no_amount'; |
| 11 |
const GFEWAY_ERROR_REQ_CARD_HOLDER = 'gfeway_err_req_card_holder'; |
| 12 |
const GFEWAY_ERROR_REQ_CARD_NAME = 'gfeway_err_req_card_name'; |
| 13 |
const GFEWAY_ERROR_EWAY_FAIL = 'gfeway_err_eway_fail'; |
| 14 |
|
| 15 |
// custom fields |
| 16 |
const GFEWAY_FIELD_RECURRING = 'gfewayrecurring'; |
| 17 |
|
| 18 |
// minimum versions required |
| 19 |
const GFEWAY_MIN_VERSION_GF = '1.9.15'; |
| 20 |
|
| 21 |
/** |
| 22 |
* custom exception types |
| 23 |
*/ |
| 24 |
class GFEwayException extends Exception {} |
| 25 |
class GFEwayCurlException extends Exception {} |
| 26 |
|
| 27 |
/** |
| 28 |
* kick start the plugin |
| 29 |
*/ |
| 30 |
add_action('plugins_loaded', function() : void { |
| 31 |
require GFEWAY_PLUGIN_ROOT . 'includes/functions.php'; |
| 32 |
require GFEWAY_PLUGIN_ROOT . 'includes/class.GFEwayPlugin.php'; |
| 33 |
GFEwayPlugin::getInstance()->addHooks(); |
| 34 |
}, 5); |
| 35 |
|
| 36 |
/** |
| 37 |
* autoload classes as/when needed |
| 38 |
*/ |
| 39 |
spl_autoload_register(function(string $class_name) : void { |
| 40 |
static $classMap = [ |
| 41 |
'GFEwayFormData' => 'includes/class.GFEwayFormData.php', |
| 42 |
'GFEwayPayment' => 'includes/class.GFEwayPayment.php', |
| 43 |
'GFEwayRapidAPI' => 'includes/class.GFEwayRapidAPI.php', |
| 44 |
'GFEwayRapidAPIResponse' => 'includes/class.GFEwayRapidAPIResponse.php', |
| 45 |
'GFEwayRecurringPayment' => 'includes/class.GFEwayRecurringPayment.php', |
| 46 |
'GFEwayStoredPayment' => 'includes/class.GFEwayStoredPayment.php', |
| 47 |
]; |
| 48 |
|
| 49 |
if (isset($classMap[$class_name])) { |
| 50 |
require GFEWAY_PLUGIN_ROOT . $classMap[$class_name]; |
| 51 |
} |
| 52 |
}); |
| 53 |
|