PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.1.10
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.1.10
2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.2 All 57 releases
easy-invoice / easy-invoice.php

easy-invoice.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.1.10, at easy-invoice.php

209 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Easy Invoice
4 * Plugin URI: https://matrixaddons.com/plugins/easy-invoice
5 * Description: A beautiful, full-featured invoicing solution for WordPress. Create professional invoices, quotes, and manage payments with ease.
6 * Version: 2.1.10
7 * Author: MatrixAddons
8 * Author URI: https://matrixaddons.com
9 * License: GPL v2 or later
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: easy-invoice
12 * Domain Path: /languages
13 * Requires at least: 5.6
14 * Tested up to: 6.9
15 * Requires PHP: 7.4
16 * Network: false
17 *
18 * @package EasyInvoice
19 */
20
21 // Exit if accessed directly.
22 if ( ! defined( 'ABSPATH' ) ) {
23 exit;
24 }
25
26
27 // Define plugin constants.
28 define( 'EASY_INVOICE_VERSION', '2.1.10' );
29 define( 'EASY_INVOICE_PLUGIN_FILE', __FILE__ );
30 define( 'EASY_INVOICE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
31 define( 'EASY_INVOICE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
32
33 // Load composer autoloader if it exists.
34 if ( file_exists( EASY_INVOICE_PLUGIN_DIR . 'vendor/autoload.php' ) ) {
35 require_once EASY_INVOICE_PLUGIN_DIR . 'vendor/autoload.php';
36 }
37
38 // Include standalone function files (not autoloaded by Composer)
39 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Helpers/NotificationHelper.php';
40 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Admin/Helpers/Utility.php';
41 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Helpers/GeneralHelper.php';
42 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Helpers/ToastHelper.php';
43 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Helpers/TaxHelper.php';
44 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Helpers/FormattingHelper.php';
45 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Helpers/EmailHelper.php';
46 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Helpers/EnqueueHelper.php';
47 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Helpers/PdfHelper.php';
48 require_once EASY_INVOICE_PLUGIN_DIR . 'includes/Helpers/QuoteInvoiceHelper.php';
49
50 /**
51 * Initialize the plugin.
52 *
53 * @since 1.0.0
54 * @return void
55 */
56 function easy_invoice_init() {
57 // Initialize the main plugin class.
58 $plugin = \EasyInvoice\EasyInvoice::getInstance();
59 $plugin->init();
60
61 // Initialize service providers.
62 $invoice_service_provider = new \EasyInvoice\Providers\InvoiceServiceProvider();
63 $invoice_service_provider->register();
64
65 $invoice_item_service_provider = new \EasyInvoice\Providers\InvoiceItemServiceProvider();
66 $invoice_item_service_provider->register();
67
68 $client_service_provider = new \EasyInvoice\Providers\ClientServiceProvider();
69 $client_service_provider->register();
70
71 $invoice_number_service_provider = new \EasyInvoice\Providers\InvoiceNumberServiceProvider();
72 $invoice_number_service_provider->register();
73
74 $quote_number_service_provider = new \EasyInvoice\Providers\QuoteNumberServiceProvider();
75 $quote_number_service_provider->register();
76
77 $quote_service_provider = new \EasyInvoice\Providers\QuoteServiceProvider();
78 $quote_service_provider->register();
79
80 // Initialize EmailManager
81 $email_manager = \EasyInvoice\Services\EmailManager::getInstance();
82
83 // Initialize form manager
84 //$form_manager = \EasyInvoice\Forms\FormManager::getInstance();
85 // $form_manager->setInvoiceNumberServiceProvider($invoice_number_service_provider);
86
87 // Initialize controllers.
88 $payment_controller = new \EasyInvoice\Controllers\PaymentController();
89 $payment_controller->init();
90
91 $settings_controller = new \EasyInvoice\Controllers\SettingsController();
92 $settings_controller->init();
93
94 $quote_controller = new \EasyInvoice\Controllers\QuoteController();
95 $quote_controller->init();
96
97 // Initialize shortcode manager
98 $shortcode_manager = new \EasyInvoice\Shortcodes\ShortcodeManager();
99
100 // Initialize review notice service
101 \EasyInvoice\Services\ReviewNoticeService::init();
102
103 do_action('easy_invoice_loaded');
104
105 }
106 add_action( 'init', 'easy_invoice_init' );
107
108 /**
109 * Handle payment gateway logging
110 */
111 function easy_invoice_payment_gateway_log_handler($message, $level, $gateway_name) {
112 $log_message = sprintf('[%s] Easy Invoice %s Gateway: %s',
113 date('Y-m-d H:i:s'),
114 ucfirst($gateway_name),
115 $message
116 );
117
118 if (defined('WP_DEBUG') && WP_DEBUG) {
119 error_log($log_message);
120 }
121 }
122 add_action('easy_invoice_payment_gateway_log', 'easy_invoice_payment_gateway_log_handler', 10, 3);
123
124 // Initialize migration system
125 if ( class_exists( 'EasyInvoice\Migration\MigrationInit' ) ) {
126
127 EasyInvoice\Migration\MigrationInit::init();
128 }
129 /**
130 * Register post types early to ensure they're available
131 */
132 function easy_invoice_register_post_types() {
133 // Initialize the main plugin class and register post types
134 $plugin = \EasyInvoice\EasyInvoice::getInstance();
135 $plugin->registerPostTypes();
136 $plugin->registerCustomStatuses();
137 }
138 add_action( 'init', 'easy_invoice_register_post_types', 0 ); // Priority 0 to run early
139
140 /**
141 * Load textdomain early to avoid translation loading warnings.
142 *
143 * @since 1.0.0
144 * @return void
145 */
146 function easy_invoice_load_textdomain() {
147 load_plugin_textdomain('easy-invoice', false, dirname(plugin_basename(__FILE__)) . '/languages');
148 }
149 add_action( 'init', 'easy_invoice_load_textdomain', 1 );
150
151
152
153
154
155 /**
156 * Plugin activation hook.
157 *
158 * @since 1.0.0
159 * @return void
160 */
161 register_activation_hook( __FILE__, 'easy_invoice_activate' );
162 function easy_invoice_activate() {
163 // Initialization of post types so rewrite rules can be flushed properly.
164 \EasyInvoice\EasyInvoice::getInstance()->registerPostTypes();
165
166 // Initialize default settings
167 $settings_controller = new \EasyInvoice\Controllers\SettingsController();
168 $settings_controller->initializeSettings();
169
170 // Record first install timestamp (do not overwrite if it already exists)
171 if (!get_option('easy_invoice_installed')) {
172 update_option('easy_invoice_installed', current_time('mysql'));
173 }
174
175 // Check if this is a fresh installation or an upgrade
176 $stored_version = get_option('easy_invoice_version', '');
177
178 // If no version is stored, this is a fresh installation
179 if (empty($stored_version)) {
180 update_option('easy_invoice_version', EASY_INVOICE_VERSION);
181 update_option('easy_invoice_migration_completed', true);
182 } else {
183 // This is an upgrade. Do NOT bump version here; migration will set it when completed.
184 }
185
186 // Flush rewrite rules.
187 flush_rewrite_rules();
188 }
189
190 /**
191 * Plugin deactivation hook.
192 *
193 * @since 1.0.0
194 * @return void
195 */
196 register_deactivation_hook( __FILE__, 'easy_invoice_deactivate' );
197 function easy_invoice_deactivate() {
198 // Flush rewrite rules.
199 flush_rewrite_rules();
200
201 // Clear scheduled events
202 \EasyInvoice\Services\QuoteExpirationService::clear_schedule();
203 }
204
205 /**
206 * Toast notification helper functions
207 */
208
209