PluginProbe
MakeCommerce for WooCommerce / 3.0.3
MakeCommerce for WooCommerce v3.0.3
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.3, at makecommerce.php

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