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