-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy patheasyCheckout.php
More file actions
127 lines (108 loc) · 4.18 KB
/
Copy patheasyCheckout.php
File metadata and controls
127 lines (108 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* Plugin Name: SSLCommerz Payment Gateway
* Plugin URI: https://sslcommerz.com/
* Description: This plugin allows you to accept payments on your WooCommerce store from customers using Visa Cards, Master cards, American Express etc. Via SSLCommerz payment gateway with new V4 API & both Hosted & Popup.
* Version: 6.2.0
* Stable tag: 6.2.0
* Tested up to: 6.8.1
* Author: SSLCOMMERZ
* Author URI: https://github.com/sslcommerz/
* Author Email: integration@sslcommerz.com
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
**/
/**
* Fired during plugin activation.
*
* This class defines all code necessary to run during the plugin's activation.
*
* @since 4.0.0
* @package SSLCommerz_Woocommerce
* @author SSLCommerz Integration Team <integration@sslcommerz.com>
*/
if (!defined('ABSPATH')) exit; // Exit if accessed directly
define( 'SSLCOM_PATH', plugin_dir_path( __FILE__ ) );
define( 'SSLCOM_URL', plugin_dir_url( __FILE__ ) );
define ( 'SSLCOMMERZ_PLUGIN_VERSION', '6.2.0');
global $plugin_slug;
$plugin_slug = 'sslcommerz';
require_once( SSLCOM_PATH . 'lib/sslcommerz-easypopup.php' );
require_once( SSLCOM_PATH . 'lib/sslcommerz-webhook.php' );
add_action('plugins_loaded', 'woocommerce_sslcommerz_init', 0);
add_action('plugins_loaded', array(V4checkout_page::get_instance(), 'setup')); // V4checkout_page setup
add_action('plugins_loaded', array(SSLCommerz_Ipn::get_instance(), 'setup')); // IPN page setup
function sslcommerz_check_woocommerce_version() {
if (defined('WC_VERSION')) {
if (version_compare(WC_VERSION, '8.0', '>=')) {
add_action('before_woocommerce_init', function() {
if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
}
});
}
}
}
add_action('plugins_loaded', 'sslcommerz_check_woocommerce_version', 5);
/**
* Hook plugin activation
*/
register_activation_hook( __FILE__, 'WcSslcommerzActivator' );
function WcSslcommerzActivator() {
$installed_version = get_option( "sslcommerz_easy_version" );
if ( $installed_version == SSLCOMMERZ_PLUGIN_VERSION ) {
return true;
}
update_option( 'sslcommerz_easy_version', SSLCOMMERZ_PLUGIN_VERSION );
}
/**
* Hook plugin deactivation
*/
register_deactivation_hook( __FILE__, 'WcSslcommerzDeactivator' );
function WcSslcommerzDeactivator() { }
function woocommerce_sslcommerz_init()
{
require_once( SSLCOM_PATH . 'lib/sslcommerz-class.php' );
function woocommerce_add_sslcommerz_gateway($methods) {
if (class_exists('WC_SSLCOMMERZ')) {
$methods[] = 'WC_SSLCOMMERZ';
}
return $methods;
}
add_filter('woocommerce_payment_gateways', 'woocommerce_add_sslcommerz_gateway');
add_action('plugins_loaded', function() {
if (class_exists('WooCommerce')) {
// Force reload payment gateways for new admin interface
add_action('admin_init', function() {
if (is_admin() && current_user_can('manage_woocommerce')) {
WC()->payment_gateways();
}
});
}
});
function sslcom_settings_link($links)
{
$pluginLinks = array(
'settings' => '<a href="'. esc_url(admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=sslcommerz')) .'">Settings</a>',
'docs' => '<a href="https://developer.sslcommerz.com/doc/v4/" target="blank">Docs</a>',
'sandbox' => '<a href="https://developer.sslcommerz.com/registration/" target="blank">Create Sandbox</a>',
'support' => '<a href="mailto:integration@sslcommerz.com">Support</a>'
);
$links = array_merge($links, $pluginLinks);
return $links;
}
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'sslcom_settings_link');
/**
* Add Custom Icon
*/
function sslcom_gateway_icon($icon, $id)
{
if ($id === 'sslcommerz') {
return '<img style="max-width: 25%;" src="' . plugins_url( 'images/sslcz-verified.png', __FILE__) . '" > ';
} else {
return $icon;
}
}
add_filter('woocommerce_gateway_icon', 'sslcom_gateway_icon', 10, 2);
}
?>