-
Notifications
You must be signed in to change notification settings - Fork 6
/
woocommerce-payline.php
71 lines (57 loc) · 2.7 KB
/
woocommerce-payline.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
<?php
/**
* Plugin Name: Payline
* Plugin URI: http://www.payline.com
* Description: integrations of Payline payment solution in your WooCommerce store
* Version: 1.3.6
* Author: Monext
* Author URI: http://www.monext.fr
* License: LGPL-3.0+
* GitHub Plugin URI: https://github.com/PaylineByMonext/payline-woocommerce/
* Github Branch: master
*
* Copyright 2017 Monext (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if (!defined('ABSPATH')) exit;
define('WCPAYLINE_PLUGIN_URL', plugin_dir_url(__FILE__));
function woocommerce_payline_activation() {
if (!is_plugin_active('woocommerce/woocommerce.php')) {
deactivate_plugins(plugin_basename(__FILE__));
load_plugin_textdomain('payline', false, dirname(plugin_basename(__FILE__)) . '/languages/');
$message = sprintf(__('Sorry! In order to use WooCommerce %s Payment plugin, you need to install and activate the WooCommerce plugin.', 'payline'), 'Payline');
wp_die($message, 'WooCommerce Payline Gateway Plugin', array('back_link' => true));
}
}
register_activation_hook(__FILE__, 'woocommerce_payline_activation');
// inserts class gateway
function woocommerce_payline_init() {
// Load translation files
load_plugin_textdomain('payline', false, dirname(plugin_basename(__FILE__)) . '/languages/');
if (!class_exists('WC_Gateway_Payline')) {
require_once 'class-wc-gateway-payline.php';
}
require_once 'vendor/autoload.php';
}
add_action('woocommerce_init', 'woocommerce_payline_init');
// adds method to woocommerce methods
function woocommerce_payline_add_method($methods) {
$methods[] = 'WC_Gateway_Payline';
return $methods;
}
add_filter('woocommerce_payment_gateways', 'woocommerce_payline_add_method');
// add a link from plugin list to parameters
function woocommerce_payline_add_link($links, $file) {
$links[] = '<a href="'.admin_url('admin.php?page=wc-settings&tab=checkout§ion=payline').'">' . __('Settings') .'</a>';
return $links;
}
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'woocommerce_payline_add_link', 10, 2);