PluginProbe
Holded integration / trunk
Holded integration vtrunk
trunk 1.1.4 1.1.5 1.1.6 3.3.2 3.3.3 3.3.4 3.3.5 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5
holded-integration / holded-integration.php

holded-integration.php in Holded integration trunk, at holded-integration.php

88 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Holded integration
4 * Plugin URI: https://www.holded.com/integrations/woocommerce
5 * Description: Holded service integration with WooCommerce
6 * Version: 3.5.5
7 * Requires at least: 4.9
8 * Requires PHP: 7.4
9 * WC requires at least: 3.0
10 * WC tested up to: 6.9.3
11 * Author: Holded
12 * Author URI: https://www.holded.com
13 * License: GPL v2 or later
14 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
15 * Text Domain: holded-integration
16 * Domain Path: /lang
17 */
18
19 /*
20 Holded integration is free software: you can redistribute it and/or modify
21 it under the terms of the GNU General Public License as published by
22 the Free Software Foundation, either version 2 of the License, or
23 any later version.
24
25 Holded integration is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 GNU General Public License for more details.
29
30 You should have received a copy of the GNU General Public License
31 along with Holded integration. If not, see <http://www.gnu.org/licenses/>.
32 */
33
34 use Holded\Woocommerce\Loggers\WoocommerceLogger;
35
36 defined('ABSPATH') || exit;
37
38 if (getenv('HOLDED_DEBUG') === "1") {
39 define('WP_DEBUG', true);
40 define('WP_DEBUG_DISPLAY', true);
41 @ini_set('display_errors', 1);
42 }
43
44 require __DIR__ . '/vendor/autoload.php';
45
46 define('HOLDED_PLUGIN_DIR', plugin_dir_url(__FILE__));
47 define('HOLDED_I10N_DOMAIN', 'holded-integration');
48
49 $holded = new \Holded\Woocommerce\Holded();
50 define('HOLDED_VERSION', $holded->version);
51
52 $holded->load();
53
54 //Plugin activation
55 function holdedWC_activate()
56 {
57 $settings = \Holded\Woocommerce\Services\Settings::getInstance();
58 $apiKey = $settings->getApiKey();
59 if (empty($apiKey)) {
60 $legacySettings = \Holded\Woocommerce\Services\Settings::getInstance();
61 $legacySettings->id = 'holded-integration';
62 $legacyApiKey = $legacySettings->get_option('api_key', '');
63 if (!empty($legacyApiKey)) {
64 $settings->setApiKey($legacyApiKey);
65 }
66 }
67
68 if ($settings->getApiKey()) {
69 $holdedSDK = new Holded\SDK\Holded($settings->getApiKey(), new WoocommerceLogger(), Holded\Woocommerce\Services\Settings::getInstance()->getApiUrl());
70
71 $shopService = new Holded\Woocommerce\Services\ShopService($holdedSDK);
72 $shopService->checkShop();
73 }
74 }
75 register_activation_hook(__FILE__, 'holdedWC_activate');
76
77 //Plugin deactivation
78 function holdedWC_deactivate()
79 {
80 }
81 register_deactivation_hook(__FILE__, 'holdedWC_deactivate');
82
83 add_action('before_woocommerce_init', function() {
84 if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
85 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
86 }
87 });
88