| @@ -1,435 +1,203 @@ | ||
| 1 | 1 | <?php |
| 2 | -/* | |
| 3 | - Plugin Name: MakeCommerce for WooCommerce | |
| 4 | - Description: Adds MakeCommerce payment gateway and Itella/Omniva parcel machine shipping methods to Woocommerce checkout | |
| 5 | - Version: 2.2.0 | |
| 6 | - Author: Maksekeskus AS | |
| 7 | - Author URI: https://MakeCommerce.net/ | |
| 8 | - Text Domain: wc_makecommerce_domain | |
| 9 | -*/ | |
| 10 | 2 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | - exit; // Exit if accessed directly. | |
| 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.12 | |
| 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; | |
| 13 | 28 | } |
| 14 | 29 | |
| 15 | -if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { | |
| 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.12' ); | |
| 35 | +define( 'MAKECOMMERCE_PLUGIN_ID', 'makecommerce' ); | |
| 16 | 36 | |
| 37 | +//table name for banklinks | |
| 38 | +define( 'MAKECOMMERCE_TABLENAME', 'mc_banklinks' ); | |
| 39 | +define( 'MAKECOMMERCE_SCO_TABLENAME', 'woocommerce_makecommerce_sc' ); | |
| 17 | 40 | |
| 18 | - define('WC_MC_VERSION', 2.0); | |
| 41 | +//WC makecommerce version | |
| 42 | +define( 'WC_MC_VERSION', 2.0 ); | |
| 19 | 43 | |
| 20 | - $enable_experimental = get_option('mk_checkout_sco', 'no'); | |
| 21 | - if ($enable_experimental === 'yes') { | |
| 22 | - require_once(__DIR__.'/makecommerce-simplecheckout.php'); | |
| 23 | - } | |
| 24 | - require_once(__DIR__.'/makecommerce-transport.php'); | |
| 25 | - require_once(__DIR__.'/makecommerce-payment.php'); | |
| 44 | +register_activation_hook( __FILE__, 'activate_makecommerce' ); | |
| 45 | +register_deactivation_hook( __FILE__, 'deactivate_makecommerce' ); | |
| 26 | 46 | |
| 27 | - if (is_admin() && !extension_loaded('curl')) { | |
| 28 | - add_action('admin_notices', function(){ | |
| 29 | - $class = 'notice notice-error'; | |
| 30 | - $message = __( 'You have enabled MakeCommerce module but it seems that you don\'t have CURL enabled. This way MakeCommerce unfortunately does not work!', 'wc_makecommerce_domain'); | |
| 31 | - printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) ); | |
| 32 | - }); | |
| 33 | - } | |
| 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' ) ) { | |
| 34 | 51 | |
| 52 | + add_action( 'admin_notices', 'namespace_or_class_already_in_use' ); | |
| 35 | 53 | |
| 36 | - global $mkDbTable; | |
| 37 | - $mkDbTable = 'mc_banklinks'; | |
| 54 | + deactivate_plugins( plugin_dir_path( __FILE__ ) . '/makecommerce.php' ); | |
| 38 | 55 | |
| 39 | - function mc_install() { | |
| 40 | - global $wpdb; | |
| 41 | - global $mkDbTable; | |
| 42 | - | |
| 43 | - $tableName = $wpdb->prefix . $mkDbTable; | |
| 44 | - | |
| 45 | - $charset = $wpdb->get_charset_collate(); | |
| 46 | - | |
| 47 | - $sql = "CREATE TABLE $tableName ( | |
| 48 | - id mediumint(9) NOT NULL AUTO_INCREMENT, | |
| 49 | - type varchar(10) NOT NULL, | |
| 50 | - country char(2) NOT NULL, | |
| 51 | - name varchar(25) NOT NULL, | |
| 52 | - url varchar(250) NOT NULL, | |
| 53 | - UNIQUE KEY id (id) | |
| 54 | - ) $charset;"; | |
| 55 | - | |
| 56 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); | |
| 57 | - dbDelta( $sql ); | |
| 58 | - } | |
| 56 | + return false; | |
| 57 | +} | |
| 59 | 58 | |
| 60 | - register_activation_hook( __FILE__, 'mc_install' ); | |
| 59 | +/** | |
| 60 | + * Check if a namespace already exists | |
| 61 | + * | |
| 62 | + * @since 3.0.0 | |
| 63 | + */ | |
| 64 | +function namespaceExists( $namespace ) { | |
| 61 | 65 | |
| 62 | - // On uninstall remove scheduled hook | |
| 63 | - function mc_uninstall() { | |
| 64 | - if (wp_next_scheduled ( 'mc_banklinks_update_cron' )) { | |
| 65 | - wp_clear_scheduled_hook('mc_banklinks_update_cron'); | |
| 66 | - } | |
| 66 | + $namespace .= "\\"; | |
| 67 | + | |
| 68 | + foreach ( get_declared_classes() as $name ) { | |
| 69 | + | |
| 70 | + if ( strpos( $name, $namespace ) === 0 ) { | |
| 71 | + return true; | |
| 72 | + } | |
| 67 | 73 | } |
| 68 | 74 | |
| 69 | - register_deactivation_hook(__FILE__, 'mc_uninstall'); | |
| 75 | + return false; | |
| 76 | +} | |
| 70 | 77 | |
| 71 | - // WP schedule callable action | |
| 72 | - add_action('mc_banklinks_update_cron', 'update_mc_banklinks'); | |
| 73 | - // Assign schedule if not set, update compatible no need to reactivate, format('U') php 5.2 compatible | |
| 74 | - // Assigns task at 23.59.59 by local time, task runs if time has passed and somebody navigates the site | |
| 75 | - if (! wp_next_scheduled ( 'mc_banklinks_update_cron' )) { | |
| 76 | - $date = new DateTime(); | |
| 77 | - $date->setTime(04,10,00); | |
| 78 | - $timestamp = intval($date->format('U')); | |
| 79 | - //$local = 3600 * intval(get_option('gmt_offset')); | |
| 80 | - //wp_schedule_event($timestamp - $local, 'twicedaily', 'mc_banklinks_update_cron'); | |
| 81 | - wp_schedule_event($timestamp, 'twicedaily', 'mc_banklinks_update_cron'); | |
| 82 | - } | |
| 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 | +} | |
| 83 | 91 | |
| 84 | - if (!class_exists('wc_makecommerce_domain')) { | |
| 85 | - require_once('includes/vendor/autoload.php'); | |
| 86 | - require_once('includes/Maksekeskus.php'); | |
| 87 | - } | |
| 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' ) ) ) ) { | |
| 88 | 96 | |
| 89 | - function mk_check_payment() { | |
| 97 | + if ( is_multisite() ) { | |
| 90 | 98 | |
| 91 | - global $woocommerce; | |
| 92 | - $api = mk_get_api(); | |
| 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(); | |
| 93 | 102 | |
| 94 | - $returnUrl = home_url(); | |
| 95 | - | |
| 96 | - $request = stripslashes_deep($_POST); | |
| 97 | - if ($api->verifyMac($request)) { | |
| 98 | - $data = $api->extractRequestData($request); | |
| 99 | - $reference = false; | |
| 103 | + deactivate_plugins( plugin_dir_path( __FILE__ ) . '/makecommerce.php' ); | |
| 100 | 104 | |
| 101 | - if (!empty($data['error']) ) { | |
| 102 | - wc_add_notice(__('Payment failed', 'wc_makecommerce_domain'), 'error'); | |
| 103 | - return $returnUrl; | |
| 104 | - } | |
| 105 | - | |
| 106 | - if (!empty($data['message_type']) ) { | |
| 107 | - if ($data['message_type'] == 'payment_return') { | |
| 108 | - $transactionId = $data['transaction']; | |
| 109 | - $reference = $data['reference']; | |
| 110 | - $paymentStatus = $data['status']; | |
| 111 | - } | |
| 112 | - if ($data['message_type'] == 'token_return') { | |
| 113 | - if (!empty($data['transaction']['reference'])) { | |
| 114 | - $reference = $data['transaction']['reference']; | |
| 115 | - } | |
| 116 | - $paymentStatus = $data['transaction']['status']; | |
| 117 | - $transactionId = $data['transaction']['id']; | |
| 118 | - | |
| 119 | - // for API backward compatibility - if we didn't find reference in the mesage, or the transaction state vas still PENDING | |
| 120 | - // we'll fetch the transaction data from API, and make a payment request if needed | |
| 121 | - // this all can be removed after 2017-jan | |
| 122 | - if (!$reference or $paymentStatus == 'PENDING') { | |
| 123 | - $transaction = $api->getTransaction($transactionId); | |
| 124 | - if (!empty($transaction->reference)) { | |
| 125 | - $reference = $transaction->reference; | |
| 126 | - } | |
| 127 | - | |
| 128 | - $paymentStatus = $transaction->status; | |
| 129 | - | |
| 130 | - if ($paymentStatus == 'PENDING') { | |
| 131 | - $paymentRequest = array( | |
| 132 | - 'amount' => $transaction->amount, | |
| 133 | - 'currency' => $transaction->currency, | |
| 134 | - 'token' => $data['token']['id'] | |
| 135 | - ); | |
| 136 | - $payment = $api->createPayment($transactionId, $paymentRequest); | |
| 137 | - // TODO: validate | |
| 138 | - $paymentStatus = $payment->transaction->status; | |
| 139 | - } | |
| 140 | - | |
| 141 | - } | |
| 142 | - | |
| 143 | - | |
| 144 | - } | |
| 145 | - | |
| 146 | - } | |
| 105 | + return false; | |
| 147 | 106 | } |
| 107 | + } else { | |
| 108 | + woocommerce_not_found_or_active(); | |
| 148 | 109 | |
| 149 | - // if we didn't find reference to an Order, we send user to shop landing-page. TODO: could be improved | |
| 150 | - if (!$reference) { return $returnUrl; } | |
| 110 | + deactivate_plugins( plugin_dir_path( __FILE__ ) . '/makecommerce.php' ); | |
| 151 | 111 | |
| 152 | - $order = new WC_Order($reference); | |
| 153 | - // if we din't find the Order, we send user to shop landing-page. TODO: could be improved | |
| 154 | - if (!$order->id) { return $returnUrl; } | |
| 112 | + return false; | |
| 113 | + } | |
| 114 | +} | |
| 155 | 115 | |
| 156 | - $returnUrl = $order->get_checkout_order_received_url(); | |
| 116 | +/** | |
| 117 | + * If no WooCommerce is found | |
| 118 | + * | |
| 119 | + * @since 3.0.3 | |
| 120 | + */ | |
| 121 | +function woocommerce_not_found_or_active() { | |
| 157 | 122 | |
| 158 | - switch($paymentStatus) { | |
| 123 | + add_action( 'admin_notices', 'no_woocommerce_found' ); | |
| 159 | 124 | |
| 160 | - case 'CANCELLED': | |
| 161 | - $order->update_status( 'cancelled' ); | |
| 162 | - wc_add_notice(__('Payment transaction cancelled', 'wc_makecommerce_domain'), 'error'); | |
| 163 | - $returnUrl = $woocommerce->cart->get_cart_url(); | |
| 164 | - break; | |
| 125 | + deactivate_makecommerce(); | |
| 126 | +} | |
| 165 | 127 | |
| 166 | - case 'COMPLETED': | |
| 167 | - $orderNote = array(); | |
| 168 | - $orderNote[] = __('Transaction ID', 'wc_makecommerce_domain') . ': <a target=_blank href="'.$api->getEnvUrls()->merchantUrl.'/merchant/shop/deals/detail.html?id='. $transactionId .'">'.$transactionId.'</a>'; | |
| 169 | - $orderNote[] = __('Payment option', 'wc_makecommerce_domain') . ': ' . get_post_meta($order->id, '_makecommerce_preselected_method', true); | |
| 170 | - $order->add_order_note(implode("\r\n", $orderNote)); | |
| 171 | - | |
| 172 | - $order->payment_complete( $transactionId ); | |
| 173 | - $order->update_status( 'processing' ); | |
| 174 | - $woocommerce->cart->empty_cart(); | |
| 175 | - break; | |
| 128 | +/** | |
| 129 | + * Shows error in admin that we cannot continue | |
| 130 | + * | |
| 131 | + * @since 3.0.0 | |
| 132 | + */ | |
| 133 | +function no_woocommerce_found() { | |
| 134 | + | |
| 135 | + ?> | |
| 136 | + <div class="error notice"> | |
| 137 | + <p><?php _e( 'Cannot initiate MakeCommerce, there seems to be no WooCommerce present or active...', 'wc_makecommerce_domain' ); ?></p> | |
| 138 | + </div> | |
| 139 | + <?php | |
| 140 | +} | |
| 176 | 141 | |
| 177 | - } | |
| 142 | +/** | |
| 143 | + * Disable automatic updates for MakeCommerce plugin | |
| 144 | + * | |
| 145 | + * @since 3.0.1 | |
| 146 | + */ | |
| 147 | +function disable_makecommerce_automatic_updates( $should_update, $plugin ) { | |
| 178 | 148 | |
| 179 | - return $returnUrl; | |
| 149 | + if ( ! isset( $plugin->plugin, $plugin->new_version ) ) { | |
| 150 | + return $should_update; | |
| 180 | 151 | } |
| 181 | 152 | |
| 182 | - | |
| 183 | - | |
| 184 | - | |
| 185 | - $MKAPI = false; | |
| 186 | - function mk_get_api() { | |
| 187 | - global $MKAPI; | |
| 188 | - if ($MKAPI) { | |
| 189 | - //return $MKAPI; | |
| 190 | - } | |
| 191 | - $mk_api_type = get_option('mk_api_type', false); | |
| 192 | - if (!$mk_api_type) { | |
| 193 | - return false; | |
| 194 | - } | |
| 195 | - if ($mk_api_type !== 'live') { | |
| 196 | - $key_prefix = $mk_api_type.'_'; | |
| 197 | - } else { | |
| 198 | - $key_prefix = ''; | |
| 199 | - } | |
| 200 | - $mk_shop_id = get_option('mk_'.$key_prefix.'shop_id', ''); | |
| 201 | - $mk_public_key = get_option('mk_'.$key_prefix.'public_key', ''); | |
| 202 | - $mk_private_key = get_option('mk_'.$key_prefix.'private_key', ''); | |
| 203 | - if (!$mk_shop_id || !$mk_public_key || !$mk_shop_id) { | |
| 204 | - return false; | |
| 205 | - } | |
| 206 | - $MKAPI = new \Maksekeskus\Maksekeskus($mk_shop_id, $mk_public_key, $mk_private_key, $mk_api_type === 'live' ? false : true); | |
| 207 | - return $MKAPI; | |
| 153 | + if ( 'makecommerce/makecommerce.php' !== $plugin->plugin ) { | |
| 154 | + return $should_update; | |
| 208 | 155 | } |
| 209 | 156 | |
| 210 | - function mk_is_api_set() { | |
| 211 | - $mk_api_type = get_option('mk_api_type', false); | |
| 212 | - if (!$mk_api_type) { | |
| 213 | - return false; | |
| 214 | - } | |
| 215 | - if ($mk_api_type !== 'live') { | |
| 216 | - $key_prefix = $mk_api_type.'_'; | |
| 217 | - } else { | |
| 218 | - $key_prefix = ''; | |
| 219 | - } | |
| 220 | - $mk_shop_id = get_option('mk_'.$key_prefix.'shop_id', ''); | |
| 221 | - $mk_public_key = get_option('mk_'.$key_prefix.'public_key', ''); | |
| 222 | - $mk_private_key = get_option('mk_'.$key_prefix.'private_key', ''); | |
| 223 | - if (!$mk_shop_id || !$mk_public_key || !$mk_shop_id) { | |
| 224 | - return false; | |
| 225 | - } | |
| 226 | - return true; | |
| 227 | - } | |
| 157 | + return false; | |
| 158 | +} | |
| 228 | 159 | |
| 160 | +add_filter( 'auto_update_plugin', 'disable_makecommerce_automatic_updates', 99, 2 ); | |
| 229 | 161 | |
| 230 | - function mk_admin_error() { | |
| 231 | - printf( '<div class="%1$s"><p>%2$s</p></div>', 'notice notice-error', __('Please check that you have configured correctly MakeCommerce API accesses', 'wc_makecommerce_domain')); | |
| 232 | - } | |
| 162 | +/** | |
| 163 | + * The code that runs during plugin activation. | |
| 164 | + * This action is documented in includes/class-makecommerce-activator.php | |
| 165 | + * | |
| 166 | + * @since 3.0.1 | |
| 167 | + */ | |
| 168 | +function activate_makecommerce() { | |
| 233 | 169 | |
| 170 | + require_once plugin_dir_path( __FILE__ ) . 'includes/activator.php'; | |
| 171 | + MakeCommerce\Activator::activate(); | |
| 172 | +} | |
| 234 | 173 | |
| 174 | +/** | |
| 175 | + * The code that runs during plugin deactivation. | |
| 176 | + * This action is documented in includes/class-makecommerce-deactivator.php | |
| 177 | + * | |
| 178 | + * @since 3.0.1 | |
| 179 | + */ | |
| 180 | +function deactivate_makecommerce() { | |
| 235 | 181 | |
| 236 | - add_filter('query_vars', 'mk_cron_query_vars'); | |
| 237 | - add_action('parse_request', 'mk_parse_cron_update_vars'); | |
| 182 | + require_once plugin_dir_path( __FILE__ ) . 'includes/deactivator.php'; | |
| 183 | + MakeCommerce\Deactivator::deactivate(); | |
| 184 | +} | |
| 238 | 185 | |
| 239 | - function mk_cron_query_vars($vars) { | |
| 240 | - $vars[] = 'mk-action'; | |
| 241 | - $vars[] = 'mk-shop-id'; | |
| 242 | - $vars[] = 'mk-test-shop-id'; | |
| 243 | - return $vars; | |
| 244 | - } | |
| 186 | +/** | |
| 187 | + * The core plugin class that is used to define internationalization, | |
| 188 | + * payment-specific hooks, and shipping-specific site hooks. | |
| 189 | + */ | |
| 190 | +require plugin_dir_path( __FILE__ ) . 'includes/makecommerce.php'; | |
| 245 | 191 | |
| 246 | - function mk_parse_cron_update_vars($wp) { | |
| 247 | - if (array_key_exists('mk-action', $wp->query_vars) && $wp->query_vars['mk-action'] == 'mk-update' | |
| 248 | - && (array_key_exists('mk-shop-id', $wp->query_vars) || array_key_exists('mk-test-shop-id', $wp->query_vars) ) ) { | |
| 249 | - if( (strlen($wp->query_vars['mk-shop-id']) && $wp->query_vars['mk-shop-id'] == get_option('mk_shop_id', false) ) | |
| 250 | - || (strlen($wp->query_vars['mk-test-shop-id']) && $wp->query_vars['mk-test-shop-id'] == get_option('mk_test_shop_id', false) ) ) { | |
| 251 | - update_mc_banklinks(); | |
| 252 | - exit(); | |
| 253 | - } | |
| 254 | - } | |
| 255 | - } | |
| 192 | +/** | |
| 193 | + * Begins execution of the plugin. | |
| 194 | + * | |
| 195 | + * @since 3.0.0 | |
| 196 | + */ | |
| 197 | +function run_makecommerce() { | |
| 256 | 198 | |
| 257 | - function mk_admin_login_update($user_login, $user) { | |
| 258 | - if(user_can( $user, 'administrator' )) { | |
| 259 | - update_mc_banklinks(); | |
| 260 | - } | |
| 261 | - } | |
| 262 | - add_action('wp_login', 'mk_admin_login_update', 10, 2); | |
| 199 | + $makeCommerce = new MakeCommerce(); | |
| 200 | + $makeCommerce->run(); | |
| 201 | +} | |
| 263 | 202 | |
| 264 | - | |
| 265 | - | |
| 266 | - function mk_admin_add_api_settings($sections) { | |
| 267 | - $sections['mk_api'] = __('MakeCommerce API access', 'wc_makecommerce_domain'); | |
| 268 | - return $sections; | |
| 269 | - } | |
| 270 | - | |
| 271 | - function mk_admin_api_settings($settings) { | |
| 272 | - global $current_section; | |
| 273 | - if ($current_section !== 'mk_api') { | |
| 274 | - return $settings; | |
| 275 | - } | |
| 276 | - return array( | |
| 277 | - array('type' => 'title', 'desc' => __get_logo_html()), | |
| 278 | - array( | |
| 279 | - 'type' => 'title', | |
| 280 | - 'title' => __('MakeCommerce API access credentials', 'wc_makecommerce_domain'), | |
| 281 | - 'desc' => __('To use MakeCommerce/Maksekeskus services you need to enter API credentials below here <br/> <br/>', 'wc_makecommerce_domain'). | |
| 282 | - sprintf( __('To further configure the Payment methods please go to <a href=."%s">MakeCommerce Checkout Options</a>, links to settings of our Shipment methods are listed below', 'wc_makecommerce_domain'), 'admin.php?page=wc-settings&tab=checkout§ion=makecommerce'), | |
| 283 | - 'id' => 'mk_api_settings' | |
| 284 | - ), | |
| 285 | - array( | |
| 286 | - 'type' => 'select', | |
| 287 | - 'title' => __('Current environment', 'wc_makecommerce_domain'), | |
| 288 | - 'desc' => __('See more about <a href="https://maksekeskus.ee/en/for-developers/test-environment/">MakeCommerce Test environment</a>', 'wc_makecommerce_domain'), | |
| 289 | - 'default' => 'live', | |
| 290 | - 'options' => array( | |
| 291 | - 'live' => __('Live', 'wc_makecommerce_domain'), | |
| 292 | - 'test' => __('Test', 'wc_makecommerce_domain'), | |
| 293 | - ), | |
| 294 | - 'id' => 'mk_api_type' | |
| 295 | - ), | |
| 296 | - array( | |
| 297 | - 'id' => 'mk_shop_id', | |
| 298 | - 'type' => 'text', | |
| 299 | - 'title' => __('Shop ID (live)', 'wc_makecommerce_domain'), | |
| 300 | - 'desc' => __('Get it from <a href="https://merchant.maksekeskus.ee/api.html" target="_blank">Merchant Portal</a>','wc_makecommerce_domain'), | |
| 301 | - 'class' => 'input-text regular-input', | |
| 302 | - ), | |
| 303 | - array( | |
| 304 | - 'id' => 'mk_private_key', | |
| 305 | - 'type' => 'text', | |
| 306 | - 'title' => __('Secret key (live)', 'wc_makecommerce_domain'), | |
| 307 | - 'class' => 'input-text regular-input', | |
| 308 | - ), | |
| 309 | - array( | |
| 310 | - 'id' => 'mk_public_key', | |
| 311 | - 'type' => 'text', | |
| 312 | - 'title' => __('Publishable key (live)', 'wc_makecommerce_domain'), | |
| 313 | - 'class' => 'input-text regular-input', | |
| 314 | - ), | |
| 315 | - array( | |
| 316 | - 'id' => 'mk_test_shop_id', | |
| 317 | - 'type' => 'text', | |
| 318 | - 'title' => __('Shop ID (test)', 'wc_makecommerce_domain'), | |
| 319 | - 'class' => 'input-text regular-input', | |
| 320 | - 'default' => 'f64b4f20-5ef9-4b7b-a6fa-d623d87f0b9c', | |
| 321 | - 'desc' => __('Get it from <a href="https://merchant-test.maksekeskus.ee/api.html" target="_blank">Merchant Portal Test</a>','wc_makecommerce_domain'), | |
| 322 | - ), | |
| 323 | - array( | |
| 324 | - 'id' => 'mk_test_private_key', | |
| 325 | - 'type' => 'text', | |
| 326 | - 'title' => __('Secret key (test)', 'wc_makecommerce_domain'), | |
| 327 | - 'default' => 'MPjcVMoRZPAucsTuGK5ZukOlV7BlzgSvXOowJUkk9IFSQPVooRwcVOxzz3mhEpgM', | |
| 328 | - 'class' => 'input-text regular-input', | |
| 329 | - ), | |
| 330 | - array( | |
| 331 | - 'id' => 'mk_test_public_key', | |
| 332 | - 'type' => 'text', | |
| 333 | - 'title' => __('Publishable key (test)', 'wc_makecommerce_domain'), | |
| 334 | - 'default' => '7Hog41ci2mKkmtviMycWxpNx14pNP70m', | |
| 335 | - 'class' => 'input-text regular-input', | |
| 336 | - ), | |
| 337 | - array('type' => 'sectionend', 'id' => 'mk_api_settings'), | |
| 338 | - array( | |
| 339 | - 'type' => 'title', | |
| 340 | - 'desc' => '<br><hr><br>', | |
| 341 | - ), | |
| 342 | - array( | |
| 343 | - 'id' => 'mk_module_title', | |
| 344 | - 'type' => 'title', | |
| 345 | - 'title' => __('Makecommerce modules', 'wc_makecommerce_domain'), | |
| 346 | - 'desc' => __('Our plugin adds several modules to your shop. Here you can switch off modules that are not important for you, they will disappear from Woocommerce settings menus.<br> Each active module have their own settings dialog, where they must also be Enabled before use.', 'wc_makecommerce_domain'), | |
| 347 | - 'class' => '', | |
| 348 | - ), | |
| 349 | - array( | |
| 350 | - 'id' => 'mk_transport_apt_omniva', | |
| 351 | - 'type' => 'checkbox', | |
| 352 | - 'default' => 'yes', | |
| 353 | - 'title' => __('Omniva Parcel Machine', 'wc_makecommerce_domain'), | |
| 354 | - 'desc' => __('enable Omniva parcel machines shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping§ion=parcelmachine_omniva')).')', | |
| 355 | - 'class' => '', | |
| 356 | - ), | |
| 357 | - array( | |
| 358 | - 'id' => 'mk_transport_apt_smartpost', | |
| 359 | - 'type' => 'checkbox', | |
| 360 | - 'default' => 'yes', | |
| 361 | - 'title' => __('SmartPOST Parcel Machine', 'wc_makecommerce_domain'), | |
| 362 | - 'desc' => __('enable SmartPOST parcel machines shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping§ion=parcelmachine_smartpost')).')', | |
| 363 | - 'class' => '', | |
| 364 | - ), | |
| 365 | -// array( | |
| 366 | -// 'id' => 'mk_transport_apt_dpd', | |
| 367 | -// 'type' => 'checkbox', | |
| 368 | -// 'default' => 'no', | |
| 369 | -// 'title' => __('DPD Pickup Network', 'wc_makecommerce_domain'), | |
| 370 | -// 'desc' => __('enable DPD Pickup network shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping§ion=parcelmachine_dpd')).')', | |
| 371 | -// 'class' => '', | |
| 372 | -// ), | |
| 373 | - array( | |
| 374 | - 'id' => 'mk_transport_courier_omniva', | |
| 375 | - 'type' => 'checkbox', | |
| 376 | - 'default' => 'yes', | |
| 377 | - 'title' => __('Omniva Courier', 'wc_makecommerce_domain'), | |
| 378 | - 'desc' => __('enable Omniva courier shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping§ion=courier_omniva')).')', | |
| 379 | - 'class' => '', | |
| 380 | - ), | |
| 381 | - array( | |
| 382 | - 'id' => 'mk_transport_courier_smartpost', | |
| 383 | - 'type' => 'checkbox', | |
| 384 | - 'default' => 'yes', | |
| 385 | - 'title' => __('SmartPOST Courier', 'wc_makecommerce_domain'), | |
| 386 | - 'desc' => __('enable SmartPOST courier shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping§ion=courier_smartpost')).')', | |
| 387 | - 'class' => '', | |
| 388 | - ), | |
| 389 | - array( | |
| 390 | - 'id' => 'mk_checkout_sco', | |
| 391 | - 'type' => 'checkbox', | |
| 392 | - 'title' => __('SimpleCheckout', 'wc_makecommerce_domain'), | |
| 393 | - 'desc' => __('enable SimpleCheckout™ Checkout method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=checkout§ion=makecommerce_sc')).')', | |
| 394 | - 'class' => '', | |
| 395 | - ), | |
| 396 | - array( | |
| 397 | - 'id' => 'mk_javascript_ui', | |
| 398 | - 'type' => 'api_javascript_ui', | |
| 399 | - ), | |
| 400 | - array('type' => 'sectionend', 'id' => 'mk_api_settings') | |
| 401 | - ); | |
| 402 | - } | |
| 403 | - | |
| 404 | - function mk_admin_save_api_settings() { | |
| 405 | - // reload banklinks | |
| 406 | - global $current_section; | |
| 407 | - if ($current_section !== 'mk_api') { | |
| 408 | - return; | |
| 409 | - } | |
| 410 | - update_mc_banklinks(); | |
| 411 | - } | |
| 412 | - | |
| 413 | - function mk_admin_plugin_settings_link($links) { | |
| 414 | - $settings_link = '<a href="admin.php?page=wc-settings&tab=api§ion=mk_api">API '.__('Settings').'</a>'; | |
| 415 | - array_unshift($links, $settings_link); | |
| 416 | - return $links; | |
| 417 | - } | |
| 418 | - add_filter('woocommerce_get_settings_api', 'mk_admin_api_settings', 10, 2); | |
| 419 | - add_action('woocommerce_get_sections_api', 'mk_admin_add_api_settings'); | |
| 420 | - add_action('woocommerce_settings_saved', 'mk_admin_save_api_settings', 30, 0); | |
| 421 | - add_filter("plugin_action_links_".plugin_basename(__FILE__), 'mk_admin_plugin_settings_link' ); | |
| 422 | - | |
| 423 | - function __get_logo_html() { | |
| 424 | - return '<div class="makecommerce-info">'. | |
| 425 | - '<div class="makecommerce-logo">'. | |
| 426 | - '<a target="_blank" href="http://maksekeskus.ee"><img src="'. plugins_url('/images/makecommerce_logo_en.svg', __FILE__) .'" class="makecommerce-logo"></a>'. | |
| 427 | - '</div>'. | |
| 428 | - '<div class="makecommerce-links">'. | |
| 429 | - '<div class="makecommerce-link"><a target="_blank" href="https://merchant.maksekeskus.ee">Merchant Portal</a></div>'. | |
| 430 | - '<div class="makecommerce-link"><a target="_blank" href="https://makecommerce.net/">makecommerce.net</a></div>'. | |
| 431 | - '<div class="makecommerce-link"><a target="_blank" href="http://maksekeskus.ee">maksekeskus.ee</a></div>'. | |
| 432 | - '</div>'. | |
| 433 | - '</div>'; | |
| 434 | - } | |
| 435 | -} | |
| 203 | +run_makecommerce(); | |