-
id . $discount_code_link) ) ) ); ?>">
+
id . $discount_code_link)))); ?>">
function($tx) {
+ 'orderId' => function ($tx) {
return '
' . $tx->orderId . '';
}
],
@@ -27,8 +36,8 @@ public function __construct()
['updatedAt']
);
}
-
- Hook::addFilter('init_pmpro', function(object $data) {
+
+ Hook::addFilter('init_pmpro', function (object $data) {
global $pmpro_levels;
if (!isset($pmpro_levels[$data->params->pmpro->levelId])) {
@@ -38,7 +47,13 @@ public function __construct()
return $data;
});
- function pmpro_check_discount_code(object $order, object &$level) {
+ /**
+ * @param object $order
+ * @param object $level
+ * @return void
+ */
+ function pmpro_check_discount_code(object $order, object &$level): void
+ {
global $wpdb;
if (isset($order->discountCode)) {
$codeCheck = pmpro_checkDiscountCode($order->discountCode, $level->id, true);
@@ -56,18 +71,18 @@ function pmpro_check_discount_code(object $order, object &$level) {
}
}
- Hook::addAction('payment_started_pmpro', function(object $data) {
+ Hook::addAction('payment_started_pmpro', function (object $data): void {
global $pmpro_levels;
$currentUser = wp_get_current_user();
-
+
$order = new \MemberOrder();
$level = $pmpro_levels[$data->params->pmpro->levelId];
pmpro_check_discount_code($data->order, $level);
- if(empty($order->code)) {
+ if (empty($order->code)) {
$order->code = $order->getRandomCode();
}
-
+
// Set order values.
$order->membership_id = $level->id;
$order->membership_name = $level->name;
@@ -122,7 +137,7 @@ function pmpro_check_discount_code(object $order, object &$level) {
$data->model->update(['orderId' => $order->id], ['hash' => $data->hash]);
});
- Hook::addAction('payment_finished_pmpro', function(object $data) {
+ Hook::addAction('payment_finished_pmpro', function (object $data): void {
global $pmpro_levels, $wpdb;
$orderId = ($data->model->findOneBy(['hash' => $data->hash]))->orderId;
@@ -140,12 +155,12 @@ function pmpro_check_discount_code(object $order, object &$level) {
$level = $pmpro_levels[$data->params->pmpro->levelId];
pmpro_check_discount_code($data->order, $level);
- $startdate = current_time( "mysql" );
+ $startdate = current_time("mysql");
if (!empty($level->expiration_number)) {
- if( $level->expiration_period == 'Hour' ){
- $enddate = date( "Y-m-d H:i:s", strtotime( "+ " . $level->expiration_number . " " . $level->expiration_period, current_time( "timestamp" ) ) );
+ if ($level->expiration_period == 'Hour') {
+ $enddate = date("Y-m-d H:i:s", strtotime("+ " . $level->expiration_number . " " . $level->expiration_period, current_time("timestamp")));
} else {
- $enddate = date( "Y-m-d 23:59:59", strtotime( "+ " . $level->expiration_number . " " . $level->expiration_period, current_time( "timestamp" ) ) );
+ $enddate = date("Y-m-d 23:59:59", strtotime("+ " . $level->expiration_number . " " . $level->expiration_period, current_time("timestamp")));
}
} else {
$enddate = "NULL";
@@ -154,21 +169,21 @@ function pmpro_check_discount_code(object $order, object &$level) {
$discountCodeId = "";
if (isset($data->order->discountCode)) {
$codeCheck = pmpro_checkDiscountCode($data->order->discountCode, $level->id, true);
-
+
if ($codeCheck[0] == false) {
$useDiscountCode = false;
} else {
$useDiscountCode = true;
}
-
- //update membership_user table.
+
+ // update membership_user table.
if (!empty($data->order->discountCode) && !empty($useDiscountCode)) {
$discountCodeId = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_discount_codes WHERE code = '" . esc_sql($data->order->discountCode) . "' LIMIT 1");
-
- $wpdb->query("INSERT INTO $wpdb->pmpro_discount_codes_uses (code_id, user_id, order_id, timestamp) VALUES('" . $discountCodeId . "', '" . $data->userId . "', '" . intval($orderId) . "', '" . current_time( "mysql" ) . "')");
+
+ $wpdb->query("INSERT INTO $wpdb->pmpro_discount_codes_uses (code_id, user_id, order_id, timestamp) VALUES('" . $discountCodeId . "', '" . $data->userId . "', '" . intval($orderId) . "', '" . current_time("mysql") . "')");
}
}
-
+
$userLevel = array(
'user_id' => $data->userId,
'membership_id' => $level->id,
@@ -189,8 +204,8 @@ function pmpro_check_discount_code(object $order, object &$level) {
$order->status = "success";
$order->saveOrder();
});
-
- Hook::addFilter('payment_redirect_urls_pmpro', function(object $data) {
+
+ Hook::addFilter('payment_redirect_urls_pmpro', function (object $data) {
return [
'success' => pmpro_url("confirmation", "?level=" . $data->params->pmpro->levelId),
'failed' => pmpro_url("account"),
@@ -201,4 +216,4 @@ function pmpro_check_discount_code(object $order, object &$level) {
}
}
-new PMPro_Register_Hooks();
\ No newline at end of file
+new PMPro_Register_Hooks();
diff --git a/classes/pro/class.pmpro_transaction_model.php b/classes/pro/class.pmpro_transaction_model.php
index f1a23f6..a5bd913 100644
--- a/classes/pro/class.pmpro_transaction_model.php
+++ b/classes/pro/class.pmpro_transaction_model.php
@@ -1,11 +1,19 @@
$gateways
+ * @return array
*/
- public static function pmpro_gateways(array $gateways) : array
+ public static function pmpro_gateways(array $gateways): array
{
- if (empty($gateways['cryptopay'])) {
- $gateways['cryptopay'] = __('CryptoPay', 'pmpro-cryptopay');
- }
+ if (empty($gateways['cryptopay'])) {
+ $gateways['cryptopay'] = __('CryptoPay', 'pmpro-cryptopay');
+ }
- return $gateways;
- }
+ return $gateways;
+ }
/**
- * @return array
+ * @return array
*/
- public static function getGatewayOptions() : array
+ public static function getGatewayOptions(): array
{
return [
'currency',
@@ -66,41 +74,41 @@ public static function getGatewayOptions() : array
}
/**
- * @param array $options
- * @return array
+ * @param array $options
+ * @return array
*/
- public static function pmpro_payment_options(array $options) : array
+ public static function pmpro_payment_options(array $options): array
{
return array_merge(self::getGatewayOptions(), $options);
}
/**
- * @param array $fields
- * @return array
+ * @param array $fields
+ * @return array
*/
- static function pmpro_required_billing_fields(array $fields) : array
+ public static function pmpro_required_billing_fields(array $fields): array
{
- unset($fields['bfirstname']);
- unset($fields['blastname']);
- unset($fields['baddress1']);
- unset($fields['bcity']);
- unset($fields['bstate']);
- unset($fields['bzipcode']);
- unset($fields['bphone']);
- unset($fields['bemail']);
- unset($fields['bcountry']);
- unset($fields['CardType']);
- unset($fields['AccountNumber']);
- unset($fields['ExpirationMonth']);
- unset($fields['ExpirationYear']);
- unset($fields['CVV']);
- return $fields;
- }
+ unset($fields['bfirstname']);
+ unset($fields['blastname']);
+ unset($fields['baddress1']);
+ unset($fields['bcity']);
+ unset($fields['bstate']);
+ unset($fields['bzipcode']);
+ unset($fields['bphone']);
+ unset($fields['bemail']);
+ unset($fields['bcountry']);
+ unset($fields['CardType']);
+ unset($fields['AccountNumber']);
+ unset($fields['ExpirationMonth']);
+ unset($fields['ExpirationYear']);
+ unset($fields['CVV']);
+ return $fields;
+ }
/**
* @return void
*/
- public static function pmpro_checkout()
+ public static function pmpro_checkout(): void
{
global $gateway, $pmpro_level, $discount_code;
@@ -108,7 +116,7 @@ public static function pmpro_checkout()
?>
-
id . $discount_code_link) ) ) ); ?>">
+
id . $discount_code_link)))); ?>">
createTable();
- }
- if (class_exists(LiteLoader::class)) {
- require_once __DIR__ . '/classes/lite/class.pmpro_transaction_model.php';
- (new PMPro_Transaction_Model_Lite())->createTable();
- }
+register_activation_hook(PMPRO_CRYPTOPAY_FILE, function (): void {
+ if (class_exists(Loader::class)) {
+ require_once __DIR__ . '/classes/pro/class.pmpro_transaction_model.php';
+ (new PMPro_Transaction_Model())->createTable();
+ }
+ if (class_exists(LiteLoader::class)) {
+ require_once __DIR__ . '/classes/lite/class.pmpro_transaction_model.php';
+ (new PMPro_Transaction_Model_Lite())->createTable();
+ }
});
-function pmpro_cryptopay_addModels() {
- if (class_exists(Loader::class)) {
- require_once __DIR__ . '/classes/pro/class.pmpro_transaction_model.php';
- Hook::addFilter('models', function($models) {
- return array_merge($models, [
- 'pmpro' => new PMPro_Transaction_Model()
- ]);
- });
- }
-
- if (class_exists(LiteLoader::class)) {
- require_once __DIR__ . '/classes/lite/class.pmpro_transaction_model.php';
- LiteHook::addFilter('models', function($models) {
- return array_merge($models, [
- 'pmpro_lite' => new PMPro_Transaction_Model_Lite()
- ]);
- });
- }
+/**
+ * Add models to the plugin.
+ * @return void
+ */
+function pmpro_cryptopay_addModels(): void
+{
+ if (class_exists(Loader::class)) {
+ require_once __DIR__ . '/classes/pro/class.pmpro_transaction_model.php';
+ Hook::addFilter('models', function ($models) {
+ return array_merge($models, [
+ 'pmpro' => new PMPro_Transaction_Model()
+ ]);
+ });
+ }
+
+ if (class_exists(LiteLoader::class)) {
+ require_once __DIR__ . '/classes/lite/class.pmpro_transaction_model.php';
+ LiteHook::addFilter('models', function ($models) {
+ return array_merge($models, [
+ 'pmpro_lite' => new PMPro_Transaction_Model_Lite()
+ ]);
+ });
+ }
}
pmpro_cryptopay_addModels();
-add_action('plugins_loaded', function() {
-
- pmpro_cryptopay_addModels();
-
- load_plugin_textdomain('pmpro-cryptopay', false, basename(__DIR__) . '/languages');
-
- if (defined('PMPRO_DIR') == false) {
- return add_action('admin_notices', function () {
- ?>
-
-
'.esc_html__('clicking here', 'pmpro-cryptopay').''); ?>
-
-
-
-
-
-
'.esc_html__('clicking here', 'pmpro-cryptopay').''); ?>
-
- ' . esc_html__('clicking here', 'pmpro-cryptopay') . '');
+ printf('
', esc_attr($class), $message);
+ });
+ return;
+ }
+
+ if ((class_exists(Loader::class) || class_exists(LiteLoader::class))) {
+ require_once __DIR__ . '/classes/class.pmpro_ajax_api.php';
+
+ if (class_exists(Loader::class)) {
+ require_once __DIR__ . '/classes/pro/class.pmpro_register_hooks.php';
+ require_once __DIR__ . '/classes/pro/class.pmprogateway_cryptopay.php';
+ }
+
+ if (class_exists(LiteLoader::class)) {
+ require_once __DIR__ . '/classes/lite/class.pmpro_register_hooks.php';
+ require_once __DIR__ . '/classes/lite/class.pmprogateway_cryptopay.php';
+ }
+
+ add_action('admin_footer', function (): void {
+ ?>
+
+
+
+
' . esc_html__('clicking here', 'pmpro-cryptopay') . ''); ?>
+
+
+
+
+
+ BeycanPressStandard
+
+ ./**/*.php
+
+ */views/*
+ */vendor/*
+ */PluginHero/templates/*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+