PluginProbe
MakeCommerce for WooCommerce / 4.0.6
MakeCommerce for WooCommerce v4.0.6
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 / config.php

config.php in MakeCommerce for WooCommerce 4.0.6, at config.php

191 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 // If this file is called directly, abort.
5 if ( ! defined( 'WPINC' ) ) {
6 die;
7 }
8
9 /**
10 * Currently plugin version.
11 * Start at version 3.0.0 and use SemVer - https://semver.org
12 */
13 define( 'MAKECOMMERCE_VERSION', '4.0.6' );
14 define( 'MAKECOMMERCE_PLUGIN_ID', 'makecommerce' );
15
16 //table name for banklinks
17 define( 'MAKECOMMERCE_TABLENAME', 'mc_banklinks' );
18
19 //WC makecommerce version
20 define( 'WC_MC_VERSION', 2.0 );
21
22 //Tracking service link
23 define( 'MC_TRACKING_SERVICE_URL', 'https://tracking.makecommerce.net/' );
24
25 register_activation_hook( __FILE__, 'activate_makecommerce' );
26 register_deactivation_hook( __FILE__, 'deactivate_makecommerce' );
27
28 add_action( 'before_woocommerce_init', function() {
29 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
30 $plugin_main_file = plugin_dir_path( __DIR__ ) . 'makecommerce.php';
31 // Declare HPOS compatibility - true / false
32 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $plugin_main_file, true );
33
34 // Declare Blocks compatibility - true / false
35 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', $plugin_main_file, true );
36 }
37 } );
38
39 /**
40 * Check if we are ok to continue (if namesoace and class doesn't already exist)
41 */
42 if ( class_exists( 'MakeCommerce' ) || namespaceExists( 'MakeCommerce' ) ) {
43
44 add_action( 'admin_notices', 'namespace_or_class_already_in_use' );
45
46 deactivate_plugins( plugin_dir_path( __FILE__ ) . '/makecommerce.php' );
47
48 return false;
49 }
50
51 /**
52 * Check if a namespace already exists
53 *
54 * @since 3.0.0
55 */
56 function namespaceExists( $namespace ) {
57
58 $namespace .= "\\";
59
60 foreach ( get_declared_classes() as $name ) {
61
62 if ( strpos( $name, $namespace ) === 0 ) {
63 return true;
64 }
65 }
66
67 return false;
68 }
69
70 /**
71 * Shows error in admin that we cannot continue
72 *
73 * @since 3.0.0
74 */
75 function namespace_or_class_already_in_use() {
76
77 ?>
78 <div class="error notice">
79 <p><?php _e( 'Cannot initiate MakeCommerce, a class and/or namespace called "MakeCommerce" is already in use somewhere else...', 'wc_makecommerce_domain' ); ?></p>
80 </div>
81 <?php
82 }
83
84 /**
85 * Check if WooCommerce exists and is active. Can't do much without it
86 */
87 if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
88
89 if ( is_multisite() ) {
90
91 include_once( ABSPATH . "wp-admin/includes/plugin.php" );
92 if ( !is_plugin_active_for_network( "woocommerce/woocommerce.php" ) ) {
93 woocommerce_not_found_or_active();
94
95 return false;
96 }
97 } else {
98 woocommerce_not_found_or_active();
99
100 return false;
101 }
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 /**
175 * The core plugin class that is used to define internationalization,
176 * payment-specific hooks, and shipping-specific site hooks.
177 */
178 require plugin_dir_path( __FILE__ ) . 'includes/makecommerce.php';
179
180 /**
181 * Begins execution of the plugin.
182 *
183 * @since 3.0.0
184 */
185 function run_makecommerce() {
186
187 $makeCommerce = new MakeCommerce();
188 $makeCommerce->run();
189 }
190
191 run_makecommerce();