Skip to content

Commit

Permalink
Merge pull request #1379 from sapayth/enhance/restructure_plugin_codes
Browse files Browse the repository at this point in the history
enhance: restructure plugin codes
  • Loading branch information
sapayth authored Dec 26, 2023
2 parents c5e9c11 + 62ccfc9 commit 23b5ae1
Show file tree
Hide file tree
Showing 182 changed files with 9,605 additions and 10,274 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = function(grunt) {
files: {
'<%= dirs.css %>/wpuf-form-builder.css': ['admin/form-builder/assets/less/form-builder.less'],
'<%= dirs.css %>/admin.css': ['<%= dirs.less %>/admin.less'],
'<%= dirs.css %>/admin/whats-new.css': ['<%= dirs.less %>/whats-new.less'],
'<%= dirs.css %>/registration-forms.css': ['<%= dirs.less %>/registration-forms.less']
}
}
Expand Down Expand Up @@ -138,7 +139,6 @@ module.exports = function(grunt) {
'!**/readme.md',
'!**/docs.md',
'!**/*~',
'!vendor/**',
'!**/log.txt',
'!**/package-lock.json',
'!**/appsero.json',
Expand Down
39 changes: 6 additions & 33 deletions lib/gateway/bank.php → Lib/Gateway/Bank.php
Original file line number Diff line number Diff line change
@@ -1,46 +1,21 @@
<?php

namespace WeDevs\Wpuf\Lib\Gateway;

use WeDevs\Wpuf\Pro\Coupons;

/**
* WP User Frotnend Bank gateway
*
* @since 2.1.4
*/
class WPUF_Gateway_Bank {
class Bank {
public function __construct() {
add_action( 'wpuf_gateway_bank', [$this, 'prepare_to_send'] );
add_action( 'wpuf_options_payment', [$this, 'payment_options'] );
add_action( 'wpuf_gateway_bank_order_submit', [$this, 'order_notify_admin'] );
add_action( 'wpuf_gateway_bank_order_complete', [$this, 'order_notify_user'], 10, 2 );
}

/**
* Adds paypal specific options to the admin panel
*
* @param type $options
*
* @return string
*/
public function payment_options( $options ) {
$pages = wpuf_get_pages();

$options[] = [
'name' => 'gate_instruct_bank',
'label' => __( 'Bank Instruction', 'wp-user-frontend' ),
'type' => 'wysiwyg',
'default' => 'Make your payment directly into our bank account.',
];

$options[] = [
'name' => 'bank_success',
'label' => __( 'Bank Payment Success Page', 'wp-user-frontend' ),
'desc' => __( 'After payment users will be redirected here', 'wp-user-frontend' ),
'type' => 'select',
'options' => $pages,
];

return $options;
}

/**
* Prepare the payment form and send to paypal
*
Expand All @@ -58,7 +33,7 @@ public function prepare_to_send( $data ) {
$data['price'] = isset( $data['price'] ) ? empty( $data['price'] ) ? 0 : $data['price'] : 0;

if ( isset( $_POST['coupon_id'] ) && !empty( $_POST['coupon_id'] ) ) {
$data['price'] = WPUF_Coupons::init()->discount( $data['price'], $_POST['coupon_id'], $data['item_number'] );
$data['price'] = (new Coupons())->discount( $data['price'], $_POST['coupon_id'], $data['item_number'] );
}

$data['cost'] = apply_filters( 'wpuf_payment_amount', $data['price'] ); //price with tax from pro
Expand Down Expand Up @@ -118,5 +93,3 @@ public function order_notify_user( $transaction, $order_id ) {
wp_delete_post( $order_id, true );
}
}

$wpuf_gateway_bank = new WPUF_Gateway_Bank();
53 changes: 6 additions & 47 deletions lib/gateway/paypal.php → Lib/Gateway/Paypal.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

namespace WeDevs\Wpuf\Lib\Gateway;

/**
* WP User Frotnend Paypal gateway
* WP User Frontend PayPal gateway
*
* @since 0.8
*/
class WPUF_Paypal {
class Paypal {
private $gateway_url;

private $gateway_cancel_url;
Expand All @@ -18,7 +20,6 @@ public function __construct() {
$this->test_mode = false;

add_action( 'wpuf_gateway_paypal', [ $this, 'prepare_to_send' ] );
add_action( 'wpuf_options_payment', [ $this, 'payment_options' ] );
add_action( 'init', [ $this, 'check_response' ] );
add_action( 'wpuf_paypal_ipn_success', [ $this, 'paypal_success' ] );
add_action( 'wpuf_cancel_payment_paypal', [ $this, 'handle_cancel_subscription' ] );
Expand Down Expand Up @@ -114,48 +115,6 @@ public function recurring_change_status( $user_id, $status ) {
}
}

/**
* Adds paypal specific options to the admin panel
*
* @param type $options
*
* @return string
*/
public function payment_options( $options ) {
$options[] = [
'name' => 'paypal_email',
'label' => __( 'PayPal Email', 'wp-user-frontend' ),
];

$options[] = [
'name' => 'gate_instruct_paypal',
'label' => __( 'PayPal Instruction', 'wp-user-frontend' ),
'type' => 'wysiwyg',
'default' => "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account",
];

$options[] = [
'name' => 'paypal_api_username',
'label' => __( 'PayPal API username', 'wp-user-frontend' ),
];
$options[] = [
'name' => 'paypal_api_password',
'label' => __( 'PayPal API password', 'wp-user-frontend' ),
];
$options[] = [
'name' => 'paypal_api_signature',
'label' => __( 'PayPal API signature', 'wp-user-frontend' ),
];
/* $options[] = [
'name' => 'paypal_endpoint',
'label' => __('PayPal IPN endpoint', 'wp-user-frontend'),
'default' => home_url( '/action/wpuf_paypal_success', null ),
'desc' => __('Set this to your notification IPN listener', 'wp-user-frontend'),
'class' => 'disabled'
];*/
return $options;
}

/**
* Prepare the payment form and send to paypal
*
Expand Down Expand Up @@ -185,7 +144,7 @@ public function prepare_to_send( $data ) {
$data['tax'] = $billing_amount - $data['subtotal'];

if ( $billing_amount == 0 ) {
wpuf_get_user( $user_id )->subscription()->add_pack( $data['item_number'], $profile_id = null, false, 'free' );
wpuf_get_user( $user_id )->subscription()->add_pack( $data['item_number'], $profile_id = null, false, 'Free' );
wp_redirect( $return_url );
exit();
}
Expand Down Expand Up @@ -450,7 +409,7 @@ public function paypal_success() {

WP_User_Frontend::log( 'payment', 'inserting payment to database. ' . print_r( $data, true ) );

WPUF_Payment::insert_payment( $data, $transaction_id, $is_recurring );
_Payment::insert_payment( $data, $transaction_id, $is_recurring );

if ( $coupon_id ) {
$pre_usage = get_post_meta( $coupon_id, '_coupon_used', true );
Expand Down
13 changes: 6 additions & 7 deletions lib/class-wedevs-insights.php → Lib/WeDevs_Insights.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

namespace WeDevs\Wpuf\Lib;

use Appsero\Client;

if ( ! class_exists( 'WPUF_WeDevs_Insights' ) ) :

/**
Expand All @@ -13,18 +17,13 @@
*
* @author Tareq Hasan <[email protected]>
*/
class WPUF_WeDevs_Insights {
class WeDevs_Insights {

/**
* Initialize the class
*/
public function __construct( $file ) {

if ( ! class_exists( 'Appsero\Client' ) ) {
require_once __DIR__ . '/appsero/Client.php';
}

$client = new Appsero\Client( '958afc63-99f8-4b98-b321-fcbc5cf95694', 'WP User Frontend', $file );
$client = new Client( '958afc63-99f8-4b98-b321-fcbc5cf95694', 'WP User Frontend', $file );

$this->insights = $client->insights();

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 23b5ae1

Please sign in to comment.