-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathedd-quaderno.php
132 lines (113 loc) · 4.6 KB
/
edd-quaderno.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
<?php
/**
* Plugin Name: EDD Quaderno
* Plugin URI: https://wordpress.org/plugins/edd-quaderno/
* Description: Automatically send customizable sales receipts and invoices with every order in your Easy Digital Downloads store.
* Version: 1.37.7
* Author: Quaderno
* Author URI: https://www.quaderno.io/integrations/easy-digital-downloads?utm_source=wordpress&utm_campaign=edd
* License: GPL v3
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'EDD_Quaderno' ) ) :
final class EDD_Quaderno {
private static $instance;
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof EDD_Quaderno ) ) {
self::$instance = new EDD_Quaderno;
self::$instance->setup_constants();
self::$instance->includes();
self::$instance->load_textdomain();
self::$instance->load_notices();
}
return self::$instance;
}
private function setup_constants() {
// Plugin Folder
if ( ! defined( 'EDD_QUADERNO_PLUGIN_DIR' ) ) {
define( 'EDD_QUADERNO_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
// Plugin Folder URL
if ( ! defined( 'EDD_QUADERNO_PLUGIN_URL' ) ) {
define('EDD_QUADERNO_PLUGIN_URL', plugin_dir_url( __FILE__ ));
}
// Plugin Root File
if ( ! defined( 'EDD_QUADERNO_PLUGIN_FILE' ) ) {
define( 'EDD_QUADERNO_PLUGIN_FILE', __FILE__ );
}
}
private function includes() {
require_once EDD_QUADERNO_PLUGIN_DIR . 'quaderno/quaderno_load.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/customer.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/tax_code_field.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/business_fields.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/required_fields.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/settings.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/scripts.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/taxes.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/invoices.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/credits.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/payments.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/order_details.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/purchase_history.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/emails.php';
require_once EDD_QUADERNO_PLUGIN_DIR . 'includes/settings.php';
}
private function load_textdomain() {
$lang_dir = plugin_dir_path( __FILE__ ) . '/languages/';
$locale = apply_filters( 'plugin_locale', get_locale(), 'edd-quaderno-quaderno' );
$mofile = sprintf( '%1$s-%2$s.mo', 'edd-quaderno', $locale );
/* Setup paths to current locale file */
$mofile_global = WP_LANG_DIR . '/edd-quaderno/' . $mofile;
$mofile_local = $lang_dir . $mofile;
if ( file_exists( $mofile_global ) ) {
/* Look in global /wp-content/languages/edd-quaderno/ folder */
load_textdomain( 'edd-quaderno', $mofile_global );
} elseif ( file_exists( $mofile_local ) ) {
/* Look in local /wp-content/plugins/edd-quaderno/languages/ folder */
load_textdomain( 'edd-quaderno', $mofile_local );
} else {
/* Load the default language files */
load_plugin_textdomain( 'edd-quaderno', false, $lang_dir );
}
}
private function load_notices() {
// Show review notice
if ( ! get_option( 'quaderno_dismiss_review' ) ) {
add_action( 'admin_notices', 'edd_quaderno_review' );
add_action( 'admin_footer', 'edd_quaderno_review_script' );
add_action( 'wp_ajax_quaderno_review', 'edd_quaderno_dismiss_review' );
}
}
}
endif;
// Deactivation code
function edd_quaderno_deactivate() {
global $wpdb;
// delete all transients
$sql = 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE "_transient_quaderno_tax_%"';
$wpdb->query($sql);
}
register_deactivation_hook( __FILE__, 'edd_quaderno_deactivate' );
function EDDQ() {
return EDD_Quaderno::instance();
}
/**
* Get EDD Quaderno Running
*/
EDDQ();
?>