PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.2.0
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.2.0
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.2.0, at easy-invoice.php

212 lines 6.8 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.2.0
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.2.0' );
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 // Initialize promotion service
104 \EasyInvoice\Services\PromotionService::init();
105
106 do_action('easy_invoice_loaded');
107
108 }
109 add_action( 'init', 'easy_invoice_init' );
110
111 /**
112 * Handle payment gateway logging
113 */
114 function easy_invoice_payment_gateway_log_handler($message, $level, $gateway_name) {
115 $log_message = sprintf('[%s] Easy Invoice %s Gateway: %s',
116 date('Y-m-d H:i:s'),
117 ucfirst($gateway_name),
118 $message
119 );
120
121 if (defined('WP_DEBUG') && WP_DEBUG) {
122 error_log($log_message);
123 }
124 }
125 add_action('easy_invoice_payment_gateway_log', 'easy_invoice_payment_gateway_log_handler', 10, 3);
126
127 // Initialize migration system
128 if ( class_exists( 'EasyInvoice\Migration\MigrationInit' ) ) {
129
130 EasyInvoice\Migration\MigrationInit::init();
131 }
132 /**
133 * Register post types early to ensure they're available
134 */
135 function easy_invoice_register_post_types() {
136 // Initialize the main plugin class and register post types
137 $plugin = \EasyInvoice\EasyInvoice::getInstance();
138 $plugin->registerPostTypes();
139 $plugin->registerCustomStatuses();
140 }
141 add_action( 'init', 'easy_invoice_register_post_types', 0 ); // Priority 0 to run early
142
143 /**
144 * Load textdomain early to avoid translation loading warnings.
145 *
146 * @since 1.0.0
147 * @return void
148 */
149 function easy_invoice_load_textdomain() {
150 load_plugin_textdomain('easy-invoice', false, dirname(plugin_basename(__FILE__)) . '/languages');
151 }
152 add_action( 'init', 'easy_invoice_load_textdomain', 1 );
153
154
155
156
157
158 /**
159 * Plugin activation hook.
160 *
161 * @since 1.0.0
162 * @return void
163 */
164 register_activation_hook( __FILE__, 'easy_invoice_activate' );
165 function easy_invoice_activate() {
166 // Initialization of post types so rewrite rules can be flushed properly.
167 \EasyInvoice\EasyInvoice::getInstance()->registerPostTypes();
168
169 // Initialize default settings
170 $settings_controller = new \EasyInvoice\Controllers\SettingsController();
171 $settings_controller->initializeSettings();
172
173 // Record first install timestamp (do not overwrite if it already exists)
174 if (!get_option('easy_invoice_installed')) {
175 update_option('easy_invoice_installed', current_time('mysql'));
176 }
177
178 // Check if this is a fresh installation or an upgrade
179 $stored_version = get_option('easy_invoice_version', '');
180
181 // If no version is stored, this is a fresh installation
182 if (empty($stored_version)) {
183 update_option('easy_invoice_version', EASY_INVOICE_VERSION);
184 update_option('easy_invoice_migration_completed', true);
185 } else {
186 // This is an upgrade. Do NOT bump version here; migration will set it when completed.
187 }
188
189 // Flush rewrite rules.
190 flush_rewrite_rules();
191 }
192
193 /**
194 * Plugin deactivation hook.
195 *
196 * @since 1.0.0
197 * @return void
198 */
199 register_deactivation_hook( __FILE__, 'easy_invoice_deactivate' );
200 function easy_invoice_deactivate() {
201 // Flush rewrite rules.
202 flush_rewrite_rules();
203
204 // Clear scheduled events
205 \EasyInvoice\Services\QuoteExpirationService::clear_schedule();
206 }
207
208 /**
209 * Toast notification helper functions
210 */
211
212