PluginProbe
MakeCommerce for WooCommerce / 3.4.1
MakeCommerce for WooCommerce v3.4.1
4.1.0 4.0.8 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 All 96 releases
makecommerce / makecommerce.php

makecommerce.php in MakeCommerce for WooCommerce 3.4.1, at makecommerce.php

208 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @link https://makecommerce.net/
5 * @since 3.0.0
6 * @package Makecommerce
7 *
8 * @wordpress-plugin
9 * Plugin Name: MakeCommerce
10 * Plugin URI: https://makecommerce.net/
11 * Description: Adds MakeCommerce payment gateway and Itella/Omniva/DPD parcel machine shipping methods to WooCommerce checkout
12 * Version: 3.4.1
13 * Author: Maksekeskus AS
14 * Author URI: https://makecommerce.net/
15 * License: GPL-2.0+
16 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
17 * Text Domain: makecommerce
18 * Domain Path: /languages
19 * Requires at least: 5.6.1
20 * Requires PHP: 7.4
21 * WC requires at least: 5.0.0
22 * WC tested up to: 8.2.1
23 */
24
25 // If this file is called directly, abort.
26 if ( ! defined( 'WPINC' ) ) {
27 die;
28 }
29
30 /**
31 * Currently plugin version.
32 * Start at version 3.0.0 and use SemVer - https://semver.org
33 */
34 define( 'MAKECOMMERCE_VERSION', '3.4.1' );
35 define( 'MAKECOMMERCE_PLUGIN_ID', 'makecommerce' );
36
37 //table name for banklinks
38 define( 'MAKECOMMERCE_TABLENAME', 'mc_banklinks' );
39
40 //WC makecommerce version
41 define( 'WC_MC_VERSION', 2.0 );
42
43 //Tracking service link
44 define( 'MC_TRACKING_SERVICE_URL', 'https://tracking.makecommerce.net/' );
45
46 register_activation_hook( __FILE__, 'activate_makecommerce' );
47 register_deactivation_hook( __FILE__, 'deactivate_makecommerce' );
48
49 // Declare HPOS compatibility - true / false
50 add_action( 'before_woocommerce_init', function() {
51 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
52 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
53 }
54 } );
55
56 /**
57 * Check if we are ok to continue (if namesoace and class doesn't already exist)
58 */
59 if ( class_exists( 'MakeCommerce' ) || namespaceExists( 'MakeCommerce' ) ) {
60
61 add_action( 'admin_notices', 'namespace_or_class_already_in_use' );
62
63 deactivate_plugins( plugin_dir_path( __FILE__ ) . '/makecommerce.php' );
64
65 return false;
66 }
67
68 /**
69 * Check if a namespace already exists
70 *
71 * @since 3.0.0
72 */
73 function namespaceExists( $namespace ) {
74
75 $namespace .= "\\";
76
77 foreach ( get_declared_classes() as $name ) {
78
79 if ( strpos( $name, $namespace ) === 0 ) {
80 return true;
81 }
82 }
83
84 return false;
85 }
86
87 /**
88 * Shows error in admin that we cannot continue
89 *
90 * @since 3.0.0
91 */
92 function namespace_or_class_already_in_use() {
93
94 ?>
95 <div class="error notice">
96 <p><?php _e( 'Cannot initiate MakeCommerce, a class and/or namespace called "MakeCommerce" is already in use somewhere else...', 'wc_makecommerce_domain' ); ?></p>
97 </div>
98 <?php
99 }
100
101 /**
102 * Check if WooCommerce exists and is active. Can't do much without it
103 */
104 if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
105
106 if ( is_multisite() ) {
107
108 include_once( ABSPATH . "wp-admin/includes/plugin.php" );
109 if ( !is_plugin_active_for_network( "woocommerce/woocommerce.php" ) ) {
110 woocommerce_not_found_or_active();
111
112 return false;
113 }
114 } else {
115 woocommerce_not_found_or_active();
116
117 return false;
118 }
119 }
120
121 /**
122 * If no WooCommerce is found
123 *
124 * @since 3.0.3
125 */
126 function woocommerce_not_found_or_active() {
127
128 add_action( 'admin_notices', 'no_woocommerce_found' );
129
130 deactivate_makecommerce();
131 }
132
133 /**
134 * Shows error in admin that we cannot continue
135 *
136 * @since 3.0.0
137 */
138 function no_woocommerce_found() {
139
140 ?>
141 <div class="error notice">
142 <p><?php _e( 'Cannot initiate MakeCommerce, there seems to be no WooCommerce present or active...', 'wc_makecommerce_domain' ); ?></p>
143 </div>
144 <?php
145 }
146
147 /**
148 * Disable automatic updates for MakeCommerce plugin
149 *
150 * @since 3.0.1
151 */
152 function disable_makecommerce_automatic_updates( $should_update, $plugin ) {
153
154 if ( ! isset( $plugin->plugin, $plugin->new_version ) ) {
155 return $should_update;
156 }
157
158 if ( 'makecommerce/makecommerce.php' !== $plugin->plugin ) {
159 return $should_update;
160 }
161
162 return false;
163 }
164
165 add_filter( 'auto_update_plugin', 'disable_makecommerce_automatic_updates', 99, 2 );
166
167 /**
168 * The code that runs during plugin activation.
169 * This action is documented in includes/class-makecommerce-activator.php
170 *
171 * @since 3.0.1
172 */
173 function activate_makecommerce() {
174
175 require_once plugin_dir_path( __FILE__ ) . 'includes/activator.php';
176 MakeCommerce\Activator::activate();
177 }
178
179 /**
180 * The code that runs during plugin deactivation.
181 * This action is documented in includes/class-makecommerce-deactivator.php
182 *
183 * @since 3.0.1
184 */
185 function deactivate_makecommerce() {
186
187 require_once plugin_dir_path( __FILE__ ) . 'includes/deactivator.php';
188 MakeCommerce\Deactivator::deactivate();
189 }
190
191 /**
192 * The core plugin class that is used to define internationalization,
193 * payment-specific hooks, and shipping-specific site hooks.
194 */
195 require plugin_dir_path( __FILE__ ) . 'includes/makecommerce.php';
196
197 /**
198 * Begins execution of the plugin.
199 *
200 * @since 3.0.0
201 */
202 function run_makecommerce() {
203
204 $makeCommerce = new MakeCommerce();
205 $makeCommerce->run();
206 }
207
208 run_makecommerce();