-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwc-cash-on-pickup.php
92 lines (81 loc) · 3.08 KB
/
wc-cash-on-pickup.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
<?php
/*
Plugin Name: WooCommerce Cash On Pickup
Plugin URI: https://wordpress.org/plugins/wc-cash-on-pickup/
Description: A WooCommerce Extension that adds the payment gateway "Cash On Pickup"
Version: 1.7.0
Author: Marian Kadanka
Author URI: https://kadanka.net/
Text Domain: wc-cash-on-pickup
Domain Path: /languages
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
GitHub Plugin URI: https://github.com/marian-kadanka/wc-cash-on-pickup
WC tested up to: 8.1
*/
/**
* WooCommerce Cash On Pickup
* Copyright (C) 2013-2014 Pinch Of Code. All rights reserved.
* Copyright (C) 2017-2020 Marian Kadanka. All rights reserved.
*
* This program 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 2
* of the License, or (at your option) any later version.
* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Start the plugin
*/
function wc_cop_init() {
global $woocommerce;
if ( !isset( $woocommerce ) ) {
return;
}
require_once( 'classes/class.wc-cop.php' );
}
add_action( 'plugins_loaded', 'wc_cop_init' );
/**
* Add COP in WooCommerce payment gateways
* @param $methods
* @return array
*/
function wc_cop_register_gateway( $methods ) {
$methods[] = 'WC_Gateway_Cash_on_pickup';
return $methods;
}
add_filter( 'woocommerce_payment_gateways', 'wc_cop_register_gateway' );
/**
* Show action links on the plugin screen.
*
* @param $links
* @param $file
* @return mixed
*/
function wc_cop_action_links( $links, $file ) {
if ( $file == plugin_basename( __FILE__ ) ) {
//Donate link
array_unshift( $links, '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&item_name=Donation+for+Marian+Kadanka" title="' . esc_attr__( 'Donate', 'wc-cash-on-pickup' ) . '" target="_blank">' . esc_html__( 'Donate', 'wc-cash-on-pickup' ) . '</a>' );
//Settings link
array_unshift( $links, '<a href="' . network_admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=cop' ) . '" title="' . esc_attr__( 'Settings', 'woocommerce' ) . '">' . esc_html__( 'Settings', 'woocommerce' ) . '</a>' );
}
return $links;
}
add_filter( 'plugin_action_links', 'wc_cop_action_links', 10, 4 );
/**
* Declare WooCommerce HPOS compatibility.
*/
add_action( 'before_woocommerce_init', function() {
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
} );