PluginProbe
Open Close Store for WooCommerce – Business Hours Schedules Manager / trunk
Open Close Store for WooCommerce – Business Hours Schedules Manager vtrunk
5.0.1 trunk 2.5.7 2.5.8 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.2.0 3.2.1 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.3 4.1.4 All 73 releases
woc-open-close / woc-open-close.php

woc-open-close.php in Open Close Store for WooCommerce – Business Hours Schedules Manager trunk, at woc-open-close.php

375 lines 11.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: StackWC Open Close Store for WooCommerce
4 * Plugin URI: https://stackwc.com/plugins/woc-open-close/
5 * Description: Easily schedule your WooCommerce store's open and close times with flexible daily shifts, countdown timers, and status notifications.
6 * Version: 5.0.4
7 * Author: StackWC
8 * Author URI: https://stackwc.com
9 * Text Domain: woc-open-close
10 * Domain Path: /languages
11 * Requires at least: 5.3
12 * Requires PHP: 7.4
13 * License: GPLv3
14 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
15 * WC requires at least: 7.2
16 * WC tested up to: 11.0
17 * Requires Plugins: woocommerce
18 *
19 * Disclaimer: This plugin is not affiliated with or endorsed by WooCommerce or Automattic.
20 * "WooCommerce" is a trademark of Automattic Inc. This is an independent plugin.
21 */
22 if ( ! defined( 'ABSPATH' ) ) {
23 exit;
24 }
25
26 defined( 'WOOOPENCLOSE_PLUGIN_URL' ) || define( 'WOOOPENCLOSE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
27 defined( 'WOOOPENCLOSE_PLUGIN_DIR' ) || define( 'WOOOPENCLOSE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
28 defined( 'WOOOPENCLOSE_PLUGIN_FILE' ) || define( 'WOOOPENCLOSE_PLUGIN_FILE', plugin_basename( __FILE__ ) );
29 defined( 'WOOOPENCLOSE_TICKET_URL' ) || define( 'WOOOPENCLOSE_TICKET_URL', 'https://stackwc.com/support/' );
30 defined( 'WOOOPENCLOSE_PLUGIN_LINK' ) || define( 'WOOOPENCLOSE_PLUGIN_LINK', 'https://stackwc.com/plugins/woc-open-close/' );
31 defined( 'WOOOPENCLOSE_PRO_LINK' ) || define( 'WOOOPENCLOSE_PRO_LINK', 'https://stackwc.com/plugins/woc-open-close/' );
32 defined( 'WOOOPENCLOSE_DOCS_URL' ) || define( 'WOOOPENCLOSE_DOCS_URL', 'https://stackwc.com/plugins/woc-open-close/' );
33 defined( 'WOOOPENCLOSE_WP_REVIEW_URL' ) || define( 'WOOOPENCLOSE_WP_REVIEW_URL', 'https://wordpress.org/support/plugin/woc-open-close/reviews/' );
34 defined( 'WOOOPENCLOSE_VERSION' ) || define( 'WOOOPENCLOSE_VERSION', '5.0.4' );
35
36 if ( ! function_exists( 'wooopenclose_declare_woocommerce_compatibility' ) ) {
37 /**
38 * Declare WooCommerce feature compatibility.
39 *
40 * @return void
41 */
42 function wooopenclose_declare_woocommerce_compatibility() {
43 if ( class_exists( '\\Automattic\\WooCommerce\\Utilities\\FeaturesUtil' ) ) {
44 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
45 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
46 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'analytics', __FILE__, true );
47 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'product_block_editor', __FILE__, true );
48 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'product_block_templates', __FILE__, true );
49 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'product_editor', __FILE__, true );
50 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'product_custom_fields', __FILE__, true );
51 }
52 }
53 }
54 add_action( 'before_woocommerce_init', 'wooopenclose_declare_woocommerce_compatibility' );
55
56 if ( ! function_exists( 'wooopenclose_is_plugin_active' ) ) {
57 /**
58 * Check if a plugin is active.
59 *
60 * @param string $plugin Plugin basename.
61 *
62 * @return bool
63 */
64 function wooopenclose_is_plugin_active( $plugin ) {
65 return function_exists( 'is_plugin_active' )
66 ? is_plugin_active( $plugin )
67 : in_array( $plugin, apply_filters( 'active_plugins', (array) get_option( 'active_plugins', array() ) ), true ) // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
68 || ( is_multisite() && array_key_exists( $plugin, (array) get_site_option( 'active_sitewide_plugins', array() ) ) );
69 }
70 }
71
72 if ( ! wooopenclose_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
73 return;
74 }
75
76 if ( ! class_exists( 'WOOOPENCLOSE_Main' ) ) {
77 /**
78 * Main plugin bootstrap.
79 */
80 class WOOOPENCLOSE_Main {
81 /**
82 * Singleton instance.
83 *
84 * @var WOOOPENCLOSE_Main|null
85 */
86 protected static $_instance = null;
87
88 /**
89 * Constructor.
90 */
91 public function __construct() {
92 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
93 add_action( 'wp_enqueue_scripts', array( $this, 'front_scripts' ) );
94 $this->define_classes_functions();
95 add_action( 'widgets_init', array( $this, 'register_widgets' ) );
96 }
97
98 /**
99 * Localized script data.
100 *
101 * @return array
102 */
103 public function localize_scripts() {
104 return apply_filters( 'woc_filters_localize_scripts', array( // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
105 'ajaxurl' => admin_url( 'admin-ajax.php' ),
106 'nonce' => wp_create_nonce( 'woc-verify' ),
107 'copyText' => esc_html__( 'Copied !', 'woc-open-close' ),
108 'removeConf' => esc_html__( 'Are you really want to remove this schedule?', 'woc-open-close' ),
109 'trashConfirmText' => esc_html__( 'Are you sure to delete this Schedule?', 'woc-open-close' ),
110 'activeConfirmText' => esc_html__( 'Are you sure to Make this Schedule active?', 'woc-open-close' ),
111 ) );
112 }
113
114 /**
115 * Load core classes.
116 *
117 * @return void
118 */
119 public function define_classes_functions() {
120 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/classes/class-functions.php';
121 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/functions.php';
122 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/classes/class-hooks.php';
123 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/classes/class-columns.php';
124 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/classes/class-widget-schedule.php';
125 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/classes/class-schedule.php';
126 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/classes/class-woc-upsell.php';
127
128 add_action( 'init', array( $this, 'wpc_load_settings_file' ), 5 );
129 }
130
131 /**
132 * Load settings classes on init.
133 *
134 * @return void
135 */
136 public function wpc_load_settings_file() {
137 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/classes/class-settings.php';
138 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/classes/class-post-meta.php';
139 }
140
141 /**
142 * Register widgets.
143 *
144 * @return void
145 */
146 public function register_widgets() {
147 register_widget( 'WOOOPENCLOSE_WIDGET_Schedule' );
148 }
149
150 /**
151 * Singleton accessor.
152 *
153 * @return WOOOPENCLOSE_Main
154 */
155 public static function instance() {
156 if ( is_null( self::$_instance ) ) {
157 self::$_instance = new self();
158 }
159
160 return self::$_instance;
161 }
162
163 /**
164 * Enqueue admin assets.
165 *
166 * @return void
167 */
168 public function admin_scripts( $hook = '' ) {
169 $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
170 $is_plugin_screen = false;
171
172 if ( is_string( $hook ) && false !== strpos( $hook, 'woc_hour' ) ) {
173 $is_plugin_screen = true;
174 }
175
176 if ( $screen ) {
177 if ( isset( $screen->post_type ) && 'woc_hour' === $screen->post_type ) {
178 $is_plugin_screen = true;
179 }
180
181 if ( isset( $screen->id ) && (
182 false !== strpos( (string) $screen->id, 'woc_hour' )
183 || in_array( $screen->id, array( 'widgets' ), true )
184 ) ) {
185 $is_plugin_screen = true;
186 }
187 }
188
189 if ( ! $is_plugin_screen ) {
190 return;
191 }
192
193 wp_enqueue_script( 'jquery-ui-sortable' );
194 wp_enqueue_script(
195 'jquery-time-picker',
196 WOOOPENCLOSE_PLUGIN_URL . 'assets/jquery-timepicker.js',
197 array( 'jquery' ),
198 WOOOPENCLOSE_VERSION,
199 true
200 );
201 wp_enqueue_script(
202 'jquery-chosen',
203 WOOOPENCLOSE_PLUGIN_URL . 'assets/chosen.jquery.min.js',
204 array( 'jquery' ),
205 WOOOPENCLOSE_VERSION,
206 true
207 );
208 wp_enqueue_script(
209 'wooopenclose-admin',
210 WOOOPENCLOSE_PLUGIN_URL . 'assets/admin/js/scripts.js',
211 array( 'jquery' ),
212 WOOOPENCLOSE_VERSION,
213 true
214 );
215 wp_localize_script( 'wooopenclose-admin', 'wooopenclose', $this->localize_scripts() );
216 wp_enqueue_script(
217 'wooopenclose-global',
218 WOOOPENCLOSE_PLUGIN_URL . 'assets/scripts.js',
219 array( 'jquery' ),
220 WOOOPENCLOSE_VERSION,
221 true
222 );
223 wp_localize_script( 'wooopenclose-global', 'wooopenclose', $this->localize_scripts() );
224 wp_enqueue_style(
225 'wooopenclose-admin',
226 WOOOPENCLOSE_PLUGIN_URL . 'assets/admin/css/style.css',
227 array( 'pb_settings' ),
228 WOOOPENCLOSE_VERSION
229 );
230 wp_enqueue_style(
231 'wooopenclose-schedules',
232 WOOOPENCLOSE_PLUGIN_URL . 'assets/admin/css/schedule-style.css',
233 array(),
234 WOOOPENCLOSE_VERSION
235 );
236 wp_enqueue_style(
237 'wooopenclose-tool-tip',
238 WOOOPENCLOSE_PLUGIN_URL . 'assets/hint.min.css',
239 array(),
240 WOOOPENCLOSE_VERSION
241 );
242 wp_enqueue_style(
243 'jquery-timepicker',
244 WOOOPENCLOSE_PLUGIN_URL . 'assets/jquery-timepicker.css',
245 array(),
246 WOOOPENCLOSE_VERSION
247 );
248 wp_enqueue_style(
249 'jquery-chosen',
250 WOOOPENCLOSE_PLUGIN_URL . 'assets/chosen.min.css',
251 array(),
252 WOOOPENCLOSE_VERSION
253 );
254 }
255
256 /**
257 * Enqueue frontend assets.
258 *
259 * @return void
260 */
261 public function front_scripts() {
262 wp_enqueue_script(
263 'jbox-popup',
264 WOOOPENCLOSE_PLUGIN_URL . 'assets/front/js/jBox.all.min.js',
265 array( 'jquery' ),
266 WOOOPENCLOSE_VERSION,
267 true
268 );
269 wp_enqueue_script(
270 'wooopenclose-front',
271 WOOOPENCLOSE_PLUGIN_URL . 'assets/front/js/scripts.js',
272 array( 'jquery' ),
273 WOOOPENCLOSE_VERSION,
274 true
275 );
276 wp_localize_script( 'wooopenclose-front', 'wooopenclose', $this->localize_scripts() );
277 wp_enqueue_style( 'dashicons' );
278 wp_enqueue_style(
279 'wooopenclose-core',
280 WOOOPENCLOSE_PLUGIN_URL . 'assets/front/css/pb-core-styles.css',
281 array(),
282 WOOOPENCLOSE_VERSION
283 );
284 wp_enqueue_style(
285 'jbox-popup',
286 WOOOPENCLOSE_PLUGIN_URL . 'assets/front/css/jBox.all.css',
287 array(),
288 WOOOPENCLOSE_VERSION
289 );
290 wp_enqueue_style(
291 'wooopenclose-front',
292 WOOOPENCLOSE_PLUGIN_URL . 'assets/front/css/style.css',
293 array(),
294 WOOOPENCLOSE_VERSION
295 );
296 wp_enqueue_style(
297 'wooopenclose-tool-tip',
298 WOOOPENCLOSE_PLUGIN_URL . 'assets/hint.min.css',
299 array(),
300 WOOOPENCLOSE_VERSION
301 );
302 }
303 }
304 }
305
306 if ( ! function_exists( 'wpdk_init_woc_open_close' ) ) {
307 /**
308 * Initialize WPDK client.
309 *
310 * @return void
311 */
312 function wpdk_init_woc_open_close() {
313 if ( ! function_exists( 'get_plugins' ) ) {
314 include_once ABSPATH . '/wp-admin/includes/plugin.php';
315 }
316 if ( ! class_exists( 'WPDK\\Client' ) ) {
317 require_once WOOOPENCLOSE_PLUGIN_DIR . 'includes/wp-dev-kit/classes/class-client.php';
318 }
319 global $wooopenclose_wpdk;
320 $wooopenclose_wpdk = new WPDK\Client(
321 'Store Open Close for WooCommerce',
322 'woc-open-close',
323 15,
324 __FILE__
325 );
326 do_action( 'wpdk_init_woc_open_close', $wooopenclose_wpdk );
327 }
328 }
329
330 global $wooopenclose_wpdk;
331 wpdk_init_woc_open_close();
332
333 if ( ! function_exists( 'woc_fs' ) ) {
334 /**
335 * Freemius SDK accessor (free / opt-in only).
336 *
337 * @return Freemius
338 */
339 function woc_fs() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
340 global $woc_fs;
341
342 if ( ! isset( $woc_fs ) ) {
343 require_once WOOOPENCLOSE_PLUGIN_DIR . 'vendor/freemius/start.php';
344
345 $woc_fs = fs_dynamic_init( array( // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
346 'id' => '18995',
347 'slug' => 'woc-open-close',
348 'premium_slug' => 'woc-open-close-pro',
349 'type' => 'plugin',
350 'public_key' => 'pk_a10d0fa041ae68bffb3bb467dc60e',
351 'is_premium' => false,
352 'premium_suffix' => 'Pro',
353 'has_addons' => false,
354 'has_paid_plans' => true,
355 'has_affiliation' => false,
356 'menu' => array(
357 'first-path' => 'plugins.php',
358 'contact' => false,
359 'support' => false,
360 'account' => false,
361 ),
362 'is_live' => true,
363 'is_org_compliant' => true,
364 ) );
365 }
366
367 return $woc_fs;
368 }
369
370 woc_fs();
371 do_action( 'woc_fs_loaded' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
372 }
373
374 WOOOPENCLOSE_Main::instance();
375