PluginProbe
WPify Woo – Withdrawal, CRN/VAT, QR payments, Heureka and more for WooCommerce / 5.4.21
WPify Woo – Withdrawal, CRN/VAT, QR payments, Heureka and more for WooCommerce v5.4.21
5.4.21 5.4.20 5.4.19 5.4.18 5.4.17 5.4.16 5.4.15 5.4.14 5.4.13 5.4.12 5.4.11 5.4.10 5.4.9 5.4.8 5.4.7 5.4.6 5.4.5 5.4.4 5.4.3 4.8.0 5.4.2 5.4.1 5.4.0 5.4.0-rc1 5.4.0-rc2 All 308 releases
wpify-woo / wpify-woo.php

wpify-woo.php in WPify Woo – Withdrawal, CRN/VAT, QR payments, Heureka and more for WooCommerce 5.4.21, at wpify-woo.php

199 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
2
3 defined( 'ABSPATH' ) || exit;
4
5 /*
6 * Plugin Name: WPify Woo
7 * Description: Custom functionality for WooCommerce
8 * Version: 5.4.21
9 * Requires PHP: 8.1
10 * Requires at least: 6.2
11 * Author: WPify s.r.o.
12 * Author URI: https://www.wpify.io/
13 * License: GPLv2 or later
14 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
15 * Text Domain: wpify-woo
16 * Domain Path: /languages
17 * WC requires at least: 7.0
18 * WC tested up to: 10.6
19 * Requires Plugins: woocommerce
20 * Tested up to: 7.0
21 */
22
23 use Automattic\WooCommerce\Utilities\FeaturesUtil;
24 use WpifyWoo\Plugin;
25 use WpifyWooDeps\DI;
26
27 if ( ! defined( 'WPIFY_WOO_MIN_PHP_VERSION' ) ) {
28 define( 'WPIFY_WOO_MIN_PHP_VERSION', '8.1.0' );
29 }
30
31 /**
32 * Singleton instance function. We will not use a global at all as that defeats the purpose of a singleton
33 * and is a bad design overall
34 * @SuppressWarnings(PHPMD.StaticAccess)
35 * @return WpifyWoo\Plugin
36 * @throws Exception
37 */
38 function wpify_woo(): Plugin {
39 return wpify_woo_container()->get( Plugin::class );
40 }
41
42 /**
43 * This container singleton enables you to setup unit testing by passing an environment file to map classes in Dice
44 *
45 * @param string $env
46 *
47 * @return DI\Container
48 * @throws Exception
49 */
50 function wpify_woo_container(): DI\Container {
51 static $container;
52
53 if ( empty( $container ) ) {
54 $definition = require_once __DIR__ . '/config.php';
55 $containerBuilder = new DI\ContainerBuilder();
56 $containerBuilder->addDefinitions( $definition );
57 $container = $containerBuilder->build();
58 }
59
60 return $container;
61 }
62
63 /**
64 * Init function shortcut
65 */
66 function wpify_woo_init() {
67 wpify_woo();
68 }
69
70 /**
71 * Activate function shortcut
72 */
73 function wpify_woo_activate( $network_wide ) {
74 register_uninstall_hook( __FILE__, 'wpify_woo_uninstall' );
75 wpify_woo()->activate( $network_wide );
76 }
77
78 /**
79 * Deactivate function shortcut
80 */
81 function wpify_woo_deactivate( $network_wide ) {
82 wpify_woo()->deactivate( $network_wide );
83 }
84
85 /**
86 * Uninstall function shortcut
87 */
88 function wpify_woo_uninstall() {
89 wpify_woo()->uninstall();
90 }
91
92 /**
93 * Error for older php
94 */
95 function wpify_woo_php_upgrade_notice() {
96 $info = get_plugin_data( __FILE__ );
97 $string = sprintf(
98 /* translators: 1: Plugin name, 2: Minimal required PHP version, 3: current PHP version. */
99 esc_html__( 'Opps! %1$s requires a minimum PHP version of %2$s. Your current version is: %3$s. Please contact your host to upgrade.', 'wpify-woo' ),
100 $info['Name'],
101 WPIFY_WOO_MIN_PHP_VERSION,
102 PHP_VERSION
103 );
104 ?>
105 <div class="error notice">
106 <p><?php echo esc_html( $string ); ?></p>
107 </div>
108 <?php
109 }
110
111 /**
112 * Error if vendors autoload is missing
113 */
114 function wpify_woo_php_vendor_missing() {
115 $info = get_plugin_data( __FILE__ );
116 /* translators: 1: Plugin name */
117 $string = sprintf( esc_html__( 'Opps! %1$s is corrupted it seems, please re-install the plugin.', 'wpify-woo' ), $info['Name'] );
118 ?>
119 <div class="error notice">
120 <p><?php echo esc_html( $string ); ?></p>
121 </div>
122 <?php
123 }
124
125 /**
126 * WooCommerce not active notice
127 */
128 function wpify_woo_woocommerce_not_active() {
129 $info = get_plugin_data( __FILE__ );
130 ?>
131 <div class="error notice">
132 <p><?php
133 /* translators: 1: Plugin name */
134 printf( esc_html__( 'Plugin %s requires WooCommerce. Please install and activate it first.', 'wpify-woo' ), esc_html( $info['Name'] ) );
135 ?></p>
136 </div>
137 <?php
138 }
139
140 /**
141 * Load plugin textdomain.
142 */
143
144 /**
145 * Check if required plugin is active
146 */
147 function wpify_woo_plugin_is_active( $plugin ) {
148 if ( is_multisite() ) {
149 $plugins = get_site_option( 'active_sitewide_plugins' );
150 if ( isset( $plugins[ $plugin ] ) ) {
151 return true;
152 }
153 }
154
155 if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) {
156 return true;
157 }
158
159 return false;
160 }
161
162 /**
163 * We want to use a fairly modern php version, feel free to increase the minimum requirement
164 */
165 if ( version_compare( PHP_VERSION, WPIFY_WOO_MIN_PHP_VERSION ) < 0 ) {
166 add_action( 'admin_notices', 'wpify_woo_php_upgrade_notice' );
167 } elseif ( ! wpify_woo_plugin_is_active( 'woocommerce/woocommerce.php' ) ) {
168 add_action( 'admin_notices', 'wpify_woo_woocommerce_not_active' );
169 } else {
170 if ( file_exists( __DIR__ . '/vendor/wpify-woo/scoper-autoload.php' ) ) {
171 include_once __DIR__ . '/vendor/wpify-woo/scoper-autoload.php';
172 include_once __DIR__ . '/vendor/autoload.php';
173
174 add_action( 'plugins_loaded', 'wpify_woo_init', 11 );
175 register_activation_hook( __FILE__, 'wpify_woo_activate' );
176 register_deactivation_hook( __FILE__, 'wpify_woo_deactivate' );
177 } else {
178 add_action( 'admin_notices', 'wpify_woo_php_vendor_missing' );
179 }
180 }
181
182 add_action( 'in_plugin_update_message-wpify-woo/wpify-woo.php', function ( $plugin_data, $response ) {
183 if ( ! empty( $response->upgrade_notice ) ) {
184 echo '<div style="background: red; color: white; padding: 10px;">' . wp_kses( $response->upgrade_notice, array(
185 'a' => array(
186 'href' => array(),
187 'title' => array()
188 )
189 ) ) . '</div>';
190 }
191 }, 10, 2 );
192
193 add_action( 'before_woocommerce_init', function () {
194 if ( class_exists( FeaturesUtil::class ) ) {
195 FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__ );
196 FeaturesUtil::get_features( true,true );
197 }
198 } );
199