forked from knit-pay/upi-qr-code-payment-for-woocommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupi-qr-code-payment-for-woocommerce.php
131 lines (114 loc) · 5.35 KB
/
upi-qr-code-payment-for-woocommerce.php
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
128
129
130
131
<?php
/**
* Plugin Name: UPI QR Code Payment for WooCommerce
* Plugin URI: https://wordpress.org/plugins/upi-qr-code-payment-for-woocommerce/
* Description: It enables a Woocommerce site to accept payments through UPI apps like BHIM, Google Pay, Paytm, PhonePe or any Banking UPI app. Avoid payment gateway charges.
* Version: 1.1.2
* Author: Sayan Datta
* Author URI: https://www.sayandatta.in
* License: GPLv3
* Text Domain: upi-qr-code-payment-for-woocommerce
* Domain Path: /languages
* WC requires at least: 3.1
* WC tested up to: 4.2
*
* UPI QR Code Payment for WooCommerce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* UPI QR Code Payment for WooCommerce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with UPI QR Code Payment for WooCommerce plugin. If not, see <http://www.gnu.org/licenses/>.
*
* @category WooCommerce
* @package UPI QR Code Payment for WooCommerce
* @author Sayan Datta <[email protected]>
* @license http://www.gnu.org/licenses/ GNU General Public License
* @link https://wordpress.org/plugins/upi-qr-code-payment-for-woocommerce/
*
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$consts = array(
'UPI_WOO_PLUGIN_VERSION' => '1.1.2', // plugin version
'UPI_WOO_PLUGIN_BASENAME' => plugin_basename( __FILE__ ),
'UPI_WOO_PLUGIN_DIR' => plugin_dir_url( __FILE__ ),
//'UPI_WOO_PLUGIN_ENABLE_DEBUG' => true
);
foreach( $consts as $const => $value ) {
if ( ! defined( $const ) ) {
define( $const, $value );
}
}
// Internationalization
add_action( 'plugins_loaded', 'upiwc_plugin_load_textdomain' );
/**
* Load plugin textdomain.
*
* @since 1.0.0
*/
function upiwc_plugin_load_textdomain() {
load_plugin_textdomain( 'upi-qr-code-payment-for-woocommerce', false, dirname( UPI_WOO_PLUGIN_BASENAME ) . '/languages/' );
}
// register activation hook
register_activation_hook( __FILE__, 'upiwc_plugin_activation' );
function upiwc_plugin_activation() {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
set_transient( 'upiwc-admin-notice-on-activation', true, 5 );
}
// register deactivation hook
register_deactivation_hook( __FILE__, 'upiwc_plugin_deactivation' );
function upiwc_plugin_deactivation() {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
delete_option( 'upiwc_plugin_dismiss_rating_notice' );
delete_option( 'upiwc_plugin_no_thanks_rating_notice' );
delete_option( 'upiwc_plugin_installed_time' );
}
// plugin action links
add_filter( 'plugin_action_links_' . UPI_WOO_PLUGIN_BASENAME, 'upiwc_add_action_links', 10, 2 );
function upiwc_add_action_links( $links ) {
$upiwclinks = array(
'<a href="' . admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=wc-upi' ) . '">' . __( 'Settings', 'upi-qr-code-payment-for-woocommerce' ) . '</a>',
);
return array_merge( $upiwclinks, $links );
}
// plugin row elements
add_filter( 'plugin_row_meta', 'upiwc_plugin_meta_links', 10, 2 );
function upiwc_plugin_meta_links( $links, $file ) {
$plugin = UPI_WOO_PLUGIN_BASENAME;
if ( $file == $plugin ) // only for this plugin
return array_merge( $links,
array( '<a href="https://wordpress.org/support/plugin/upi-qr-code-payment-for-woocommerce/" target="_blank">' . __( 'Support', 'upi-qr-code-payment-for-woocommerce' ) . '</a>' ),
array( '<a href="https://wordpress.org/plugins/upi-qr-code-payment-for-woocommerce/#faq" target="_blank">' . __( 'FAQ', 'upi-qr-code-payment-for-woocommerce' ) . '</a>' ),
array( '<a href="https://www.paypal.me/iamsayan/" target="_blank">' . __( 'Donate', 'upi-qr-code-payment-for-woocommerce' ) . '</a>' )
);
return $links;
}
// add admin notices
add_action( 'admin_notices', 'upiwc_new_plugin_install_notice' );
function upiwc_new_plugin_install_notice() {
// Show a warning to sites running PHP < 5.6
if( version_compare( PHP_VERSION, '5.6', '<' ) ) {
echo '<div class="error"><p>' . __( 'Your version of PHP is below the minimum version of PHP required by UPI QR Code Payment for WooCommerce plugin. Please contact your host and request that your version be upgraded to 5.6 or later.', 'upi-qr-code-payment-for-woocommerce' ) . '</p></div>';
}
// Check transient, if available display notice
if( get_transient( 'upiwc-admin-notice-on-activation' ) ) { ?>
<div class="notice notice-success">
<p><strong><?php printf( __( 'Thanks for installing %1$s v%2$s plugin. Click <a href="%3$s">here</a> to configure plugin settings.', 'upi-qr-code-payment-for-woocommerce' ), 'UPI QR Code Payment for WooCommerce', UPI_WOO_PLUGIN_VERSION, admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=wc-upi' ) ); ?></strong></p>
</div> <?php
delete_transient( 'upiwc-admin-notice-on-activation' );
}
}
require_once plugin_dir_path( __FILE__ ) . 'includes/payment.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/notice.php';