-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwoocommerce-extra-checkout-fields-for-brazil.php
157 lines (137 loc) · 5.02 KB
/
woocommerce-extra-checkout-fields-for-brazil.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/**
* Plugin Name: Brazilian Market on WooCommerce
* Plugin URI: https://github.com/claudiosanches/woocommerce-extra-checkout-fields-for-brazil
* Description: Adds new checkout fields, field masks and other things necessary to properly work with WooCommerce on Brazil.
* Author: Claudio Sanches
* Author URI: https://claudiosanches.com
* Version: 3.7.2
* License: GPLv2 or later
* Text Domain: woocommerce-extra-checkout-fields-for-brazil
* Domain Path: /languages
*
* Brazilian Market on 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 2 of the License, or any later version.
*
* Brazilian Market on 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 Brazilian Market on WooCommerce. If not, see
* <https://www.gnu.org/licenses/gpl-2.0.txt>.
*
* @package Extra_Checkout_Fields_For_Brazil
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'Extra_Checkout_Fields_For_Brazil' ) ) :
/**
* Plugin main class.
*/
class Extra_Checkout_Fields_For_Brazil {
/**
* Plugin version.
*
* @var string
*/
const VERSION = '3.7.2';
/**
* Instance of this class.
*
* @var object
*/
protected static $instance = null;
/**
* Initialize the plugin.
*
*/
private function __construct() {
// Load plugin text domain.
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
if ( class_exists( 'WooCommerce' ) ) {
if ( is_admin() ) {
$this->admin_includes();
}
$this->includes();
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
} else {
add_action( 'admin_notices', array( $this, 'woocommerce_fallback_notice' ) );
}
}
/**
* Return an instance of this class.
*
* @return object A single instance of this class.
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Get assets url.
*
* @return string
*/
public static function get_assets_url() {
return plugins_url( 'assets/', __FILE__ );
}
/**
* Load the plugin text domain for translation.
*/
public function load_plugin_textdomain() {
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-extra-checkout-fields-for-brazil' );
load_textdomain( 'woocommerce-extra-checkout-fields-for-brazil', trailingslashit( WP_LANG_DIR ) . 'woocommerce-extra-checkout-fields-for-brazil/woocommerce-extra-checkout-fields-for-brazil-' . $locale . '.mo' );
load_plugin_textdomain( 'woocommerce-extra-checkout-fields-for-brazil', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Includes.
*/
private function includes() {
include_once dirname( __FILE__ ) . '/includes/class-extra-checkout-fields-for-brazil-formatting.php';
include_once dirname( __FILE__ ) . '/includes/class-extra-checkout-fields-for-brazil-front-end.php';
include_once dirname( __FILE__ ) . '/includes/class-extra-checkout-fields-for-brazil-integrations.php';
include_once dirname( __FILE__ ) . '/includes/class-extra-checkout-fields-for-brazil-api.php';
}
/**
* Admin includes.
*/
private function admin_includes() {
include_once dirname( __FILE__ ) . '/includes/admin/class-extra-checkout-fields-for-brazil-admin.php';
include_once dirname( __FILE__ ) . '/includes/admin/class-extra-checkout-fields-for-brazil-settings.php';
include_once dirname( __FILE__ ) . '/includes/admin/class-extra-checkout-fields-for-brazil-order.php';
include_once dirname( __FILE__ ) . '/includes/admin/class-extra-checkout-fields-for-brazil-customer.php';
}
/**
* Action links.
*
* @param array $links Default plugin links.
*
* @return array
*/
public function plugin_action_links( $links ) {
$plugin_links = array();
$plugin_links[] = '<a href="' . esc_url( admin_url( 'admin.php?page=woocommerce-extra-checkout-fields-for-brazil' ) ) . '">' . __( 'Settings', 'woocommerce-extra-checkout-fields-for-brazil' ) . '</a>';
return array_merge( $plugin_links, $links );
}
/**
* WooCommerce fallback notice.
*
* @return string Fallack notice.
*/
public function woocommerce_fallback_notice() {
echo '<div class="error"><p>' . sprintf( __( 'Brazilian Market on WooCommerce depends on %s to work!', 'woocommerce-extra-checkout-fields-for-brazil' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">' . __( 'WooCommerce', 'woocommerce-extra-checkout-fields-for-brazil' ) . '</a>' ) . '</p></div>';
}
}
/**
* Initialize the plugin.
*/
add_action( 'plugins_loaded', array( 'Extra_Checkout_Fields_For_Brazil', 'get_instance' ) );
endif;