PluginProbe
MakeCommerce for WooCommerce / 3.0.14
MakeCommerce for WooCommerce v3.0.14
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.0.14, at makecommerce.php

199 lines 4.7 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/Simplecheckout payment gateway and Itella/Omniva/DPD parcel machine shipping methods to WooCommerce checkout
12 * Version: 3.0.14
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: 6.1.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.0.14' );
35 define( 'MAKECOMMERCE_PLUGIN_ID', 'makecommerce' );
36
37 //table name for banklinks
38 define( 'MAKECOMMERCE_TABLENAME', 'mc_banklinks' );
39 define( 'MAKECOMMERCE_SCO_TABLENAME', 'woocommerce_makecommerce_sc' );
40
41 //WC makecommerce version
42 define( 'WC_MC_VERSION', 2.0 );
43
44 register_activation_hook( __FILE__, 'activate_makecommerce' );
45 register_deactivation_hook( __FILE__, 'deactivate_makecommerce' );
46
47 /**
48 * Check if we are ok to continue (if namesoace and class doesn't already exist)
49 */
50 if ( class_exists( 'MakeCommerce' ) || namespaceExists( 'MakeCommerce' ) ) {
51
52 add_action( 'admin_notices', 'namespace_or_class_already_in_use' );
53
54 deactivate_plugins( plugin_dir_path( __FILE__ ) . '/makecommerce.php' );
55
56 return false;
57 }
58
59 /**
60 * Check if a namespace already exists
61 *
62 * @since 3.0.0
63 */
64 function namespaceExists( $namespace ) {
65
66 $namespace .= "\\";
67
68 foreach ( get_declared_classes() as $name ) {
69
70 if ( strpos( $name, $namespace ) === 0 ) {
71 return true;
72 }
73 }
74
75 return false;
76 }
77
78 /**
79 * Shows error in admin that we cannot continue
80 *
81 * @since 3.0.0
82 */
83 function namespace_or_class_already_in_use() {
84
85 ?>
86 <div class="error notice">
87 <p><?php _e( 'Cannot initiate MakeCommerce, a class and/or namespace called "MakeCommerce" is already in use somewhere else...', 'wc_makecommerce_domain' ); ?></p>
88 </div>
89 <?php
90 }
91
92 /**
93 * Check if WooCommerce exists and is active. Can't do much without it
94 */
95 if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
96
97 if ( is_multisite() ) {
98
99 include_once( ABSPATH . "wp-admin/includes/plugin.php" );
100 if ( !is_plugin_active_for_network( "woocommerce/woocommerce.php" ) ) {
101 woocommerce_not_found_or_active();
102
103 return false;
104 }
105 } else {
106 woocommerce_not_found_or_active();
107
108 return false;
109 }
110 }
111
112 /**
113 * If no WooCommerce is found
114 *
115 * @since 3.0.3
116 */
117 function woocommerce_not_found_or_active() {
118
119 add_action( 'admin_notices', 'no_woocommerce_found' );
120
121 deactivate_makecommerce();
122 }
123
124 /**
125 * Shows error in admin that we cannot continue
126 *
127 * @since 3.0.0
128 */
129 function no_woocommerce_found() {
130
131 ?>
132 <div class="error notice">
133 <p><?php _e( 'Cannot initiate MakeCommerce, there seems to be no WooCommerce present or active...', 'wc_makecommerce_domain' ); ?></p>
134 </div>
135 <?php
136 }
137
138 /**
139 * Disable automatic updates for MakeCommerce plugin
140 *
141 * @since 3.0.1
142 */
143 function disable_makecommerce_automatic_updates( $should_update, $plugin ) {
144
145 if ( ! isset( $plugin->plugin, $plugin->new_version ) ) {
146 return $should_update;
147 }
148
149 if ( 'makecommerce/makecommerce.php' !== $plugin->plugin ) {
150 return $should_update;
151 }
152
153 return false;
154 }
155
156 add_filter( 'auto_update_plugin', 'disable_makecommerce_automatic_updates', 99, 2 );
157
158 /**
159 * The code that runs during plugin activation.
160 * This action is documented in includes/class-makecommerce-activator.php
161 *
162 * @since 3.0.1
163 */
164 function activate_makecommerce() {
165
166 require_once plugin_dir_path( __FILE__ ) . 'includes/activator.php';
167 MakeCommerce\Activator::activate();
168 }
169
170 /**
171 * The code that runs during plugin deactivation.
172 * This action is documented in includes/class-makecommerce-deactivator.php
173 *
174 * @since 3.0.1
175 */
176 function deactivate_makecommerce() {
177
178 require_once plugin_dir_path( __FILE__ ) . 'includes/deactivator.php';
179 MakeCommerce\Deactivator::deactivate();
180 }
181
182 /**
183 * The core plugin class that is used to define internationalization,
184 * payment-specific hooks, and shipping-specific site hooks.
185 */
186 require plugin_dir_path( __FILE__ ) . 'includes/makecommerce.php';
187
188 /**
189 * Begins execution of the plugin.
190 *
191 * @since 3.0.0
192 */
193 function run_makecommerce() {
194
195 $makeCommerce = new MakeCommerce();
196 $makeCommerce->run();
197 }
198
199 run_makecommerce();