PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.9.15
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.9.15
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / woocommerce-pos.php

woocommerce-pos.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.9.15, at woocommerce-pos.php

195 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: WCPOS – Point of Sale for WooCommerce
4 * Plugin URI: https://wordpress.org/plugins/woocommerce-pos/
5 * Description: A simple front-end for taking WooCommerce orders at the Point of Sale. Requires <a href="http://wordpress.org/plugins/woocommerce/">WooCommerce</a>.
6 * Version: 1.9.15
7 * Author: kilbot
8 * Author URI: http://wcpos.com
9 * Text Domain: woocommerce-pos
10 * License: GPL-3.0+
11 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
12 * Domain Path: /languages
13 * Requires at least: 5.6
14 * Tested up to: 7.0
15 * Requires PHP: 7.4
16 * Requires Plugins: woocommerce
17 * WC tested up to: 10.8.0
18 * WC requires at least: 5.3.
19 *
20 * @see http://wcpos.com
21 * @package WCPOS\WooCommercePOS
22 */
23
24 namespace WCPOS\WooCommercePOS;
25
26 // Define plugin constants (use define() with checks to avoid conflicts when Pro plugin is active).
27 if ( ! \defined( __NAMESPACE__ . '\VERSION' ) ) {
28 \define( __NAMESPACE__ . '\VERSION', '1.9.15' );
29 }
30 if ( ! \defined( __NAMESPACE__ . '\TRANSLATION_VERSION' ) ) {
31 \define( __NAMESPACE__ . '\TRANSLATION_VERSION', '2026.7.8' );
32 }
33 if ( ! \defined( __NAMESPACE__ . '\PLUGIN_NAME' ) ) {
34 \define( __NAMESPACE__ . '\PLUGIN_NAME', 'woocommerce-pos' );
35 }
36 if ( ! \defined( __NAMESPACE__ . '\SHORT_NAME' ) ) {
37 \define( __NAMESPACE__ . '\SHORT_NAME', 'wcpos' );
38 }
39 if ( ! \defined( __NAMESPACE__ . '\PLUGIN_FILE' ) ) {
40 \define( __NAMESPACE__ . '\PLUGIN_FILE', plugin_basename( __FILE__ ) ); // 'woocommerce-pos/woocommerce-pos.php'
41 }
42 if ( ! \defined( __NAMESPACE__ . '\PLUGIN_PATH' ) ) {
43 \define( __NAMESPACE__ . '\PLUGIN_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
44 }
45 if ( ! \defined( __NAMESPACE__ . '\PLUGIN_URL' ) ) {
46 \define( __NAMESPACE__ . '\PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
47 }
48
49 // Minimum requirements.
50 if ( ! \defined( __NAMESPACE__ . '\WC_MIN_VERSION' ) ) {
51 \define( __NAMESPACE__ . '\WC_MIN_VERSION', '5.3' );
52 }
53 if ( ! \defined( __NAMESPACE__ . '\PHP_MIN_VERSION' ) ) {
54 \define( __NAMESPACE__ . '\PHP_MIN_VERSION', '7.4' );
55 }
56 if ( ! \defined( __NAMESPACE__ . '\MIN_PRO_VERSION' ) ) {
57 \define( __NAMESPACE__ . '\MIN_PRO_VERSION', '1.8.7' );
58 }
59
60 // If Pro plugin is active, bail out early to avoid conflicts.
61 // Pro includes all free plugin functionality, so there's no need to initialize both.
62 // We check the option directly since Pro may not have loaded yet (alphabetical order).
63 $wcpos_pro_plugin_file = 'woocommerce-pos-pro/woocommerce-pos-pro.php'; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- namespaced file scope.
64 $wcpos_active_plugins = get_option( 'active_plugins', array() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- namespaced file scope.
65 $wcpos_pro_is_active = \in_array( $wcpos_pro_plugin_file, $wcpos_active_plugins, true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- namespaced file scope.
66
67 // Also check network-activated plugins on multisite.
68 if ( ! $wcpos_pro_is_active && is_multisite() ) {
69 $wcpos_network_plugins = get_site_option( 'active_sitewide_plugins', array() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- namespaced file scope.
70 $wcpos_pro_is_active = isset( $wcpos_network_plugins[ $wcpos_pro_plugin_file ] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- namespaced file scope.
71 }
72
73 if ( $wcpos_pro_is_active ) {
74 return;
75 }
76
77 /**
78 * Load .env flags for development.
79 *
80 * @param string $file The path to the .env file.
81 */
82 function wcpos_load_env( $file ): void { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- namespaced.
83 if ( ! file_exists( $file ) ) {
84 return;
85 }
86
87 $lines = file( $file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
88 foreach ( $lines as $line ) {
89 if ( 0 === strpos( trim( $line ), '#' ) ) {
90 continue;
91 }
92
93 list($name, $value) = explode( '=', $line, 2 );
94 $name = trim( $name );
95 $value = trim( $value );
96
97 if ( ! \array_key_exists( $name, $_SERVER ) && ! \array_key_exists( $name, $_ENV ) ) {
98 putenv( \sprintf( '%s=%s', $name, $value ) );
99 $_ENV[ $name ] = $value;
100 }
101 }
102 }
103
104 /**
105 * Autoload vendor and prefixed libraries.
106 */
107 function wcpos_load_autoloaders(): void { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- namespaced.
108 $vendor_autoload = __DIR__ . '/vendor/autoload.php';
109 $vendor_prefixed_autoload = __DIR__ . '/vendor_prefixed/autoload.php';
110
111 if ( file_exists( $vendor_autoload ) ) {
112 require_once $vendor_autoload;
113 }
114 if ( file_exists( $vendor_prefixed_autoload ) ) {
115 require_once $vendor_prefixed_autoload;
116 require_once __DIR__ . '/includes/Vendor_Prefixed_Polyfills.php';
117 }
118 }
119
120 wcpos_load_autoloaders();
121
122 if ( \defined( 'WP_CLI' ) && WP_CLI ) {
123 \WP_CLI::add_command( 'wcpos anon-id', \WCPOS\WooCommercePOS\CLI\Anon_ID_Command::class );
124 }
125
126 // Environment variables.
127 wcpos_load_env( __DIR__ . '/.env' );
128
129 // Error handling for autoload failure.
130 if ( ! class_exists( Activator::class ) || ! class_exists( Deactivator::class ) ) {
131 add_action(
132 'admin_notices',
133 function (): void {
134 ?>
135 <div class="notice notice-error">
136 <p><?php esc_html_e( 'The WCPOS plugin failed to load correctly.', 'woocommerce-pos' ); ?></p>
137 </div>
138 <?php
139 }
140 );
141
142 return; // Exit early if classes are not found.
143 }
144
145 // Activate plugin.
146 new Activator();
147
148 // Deactivate plugin.
149 new Deactivator();
150
151 // Declare WooCommerce feature compatibility.
152 add_action(
153 'before_woocommerce_init',
154 function (): void {
155 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
156 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
157 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'product_instance_caching', __FILE__, true );
158 }
159 }
160 );
161
162 // Caching can cause all sorts of issues with the POS, so we attempt to disable caching for POS templates.
163 add_action(
164 'plugins_loaded',
165 function (): void {
166 // Check request URI as early as possible.
167 if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
168 return;
169 }
170
171 if ( preg_match( '#^/(wcpos-login|wcpos-checkout)(/|$)#i', sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ) {
172 // 1) Hard kill all LSCache features (cache + optimisation).
173 if ( ! \defined( 'LITESPEED_DISABLE_ALL' ) ) {
174 \define( 'LITESPEED_DISABLE_ALL', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- third-party constant.
175 }
176
177 // 2) Belt-and-braces: mark the response non-cacheable for older LSCache versions.
178 if ( ! \defined( 'LSCACHE_NO_CACHE' ) ) {
179 \define( 'LSCACHE_NO_CACHE', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- third-party constant.
180 }
181
182 // 3) Disable W3 Total Cache minify
183 if ( ! \defined( 'DONOTMINIFY' ) ) {
184 \define( 'DONOTMINIFY', 'true' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- third-party constant.
185 }
186
187 // 4) Disable WP Super Cache
188 if ( ! \defined( 'DONOTCACHEPAGE' ) ) {
189 \define( 'DONOTCACHEPAGE', 'true' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- third-party constant.
190 }
191 }
192 },
193 0
194 );
195