PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.38
Timetics – Appointment Booking Calendar & Scheduling v1.0.38
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
← All changes | bootstrap.php +126 -13 1.0.01.0.38 View file →
@@ -5,10 +5,8 @@
5 5 * @package Timetics
6 6 */
7 7 namespace Timetics;
8 8
9 -use ElementsKit_Lite\Widgets\Init\Enqueue_Scripts;
10 -
11 9 defined( 'ABSPATH' ) || exit;
12 10
13 11 /**
14 12 * Bootstrap class.
@@ -15,9 +13,8 @@
15 13 *
16 14 * @since 1.0.0
17 15 */
18 16 final class Bootstrap {
19 -
20 17 /**
21 18 * @var Bootstrap The Actual Timetics instance
22 19 * @since 1.0.0
23 20 */
@@ -22,8 +19,13 @@
22 19 * @since 1.0.0
23 20 */
24 21 private static $instance;
25 22
23 +
24 + private $file;
25 + public $version;
26 + private $has_pro;
27 +
26 28 /**
27 29 * Throw Error While Trying To Clone Object
28 30 *
29 31 * @since 1.0.0
@@ -29,9 +31,9 @@
29 31 * @since 1.0.0
30 32 * @return void
31 33 */
32 34 public function __clone() {
33 - _doing_it_wrong( __FUNCTION__, __( 'Cloning is forbidden.', 'timetics' ), '1.0.0' );
35 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'timetics' ), '1.0.0' );
34 36 }
35 37
36 38 /**
37 39 * Disabling Un-serialization Of This Class
@@ -36,9 +38,9 @@
36 38 /**
37 39 * Disabling Un-serialization Of This Class
38 40 */
39 41 public function __wakeup() {
40 - _doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.', 'timetics' ), '1.0.0' );
42 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing instances of this class is forbidden.', 'timetics' ), '1.0.0' );
41 43 }
42 44
43 45 /**
44 46 * The actual TimeTics instance
@@ -164,8 +166,10 @@
164 166 self::$instance->define( 'TIMETICS_ASSETS_URL', $this->get_assets_url() );
165 167
166 168 // Plugin Assets Directory Path
167 169 self::$instance->define( 'TIMETICS_ASSETS_DIR', $this->get_assets_dir() );
170 +
171 +
168 172 }
169 173
170 174 /**
171 175 * Define constant if not already set.
@@ -206,8 +210,12 @@
206 210 /**
207 211 * Core helpers.
208 212 */
209 213 require_once TIMETICS_PLUGIN_DIR . 'utils/global-helper.php';
214 + require_once TIMETICS_PLUGIN_DIR . 'core/staffs/calendars/CalendarSyncFacade.php';
215 + require_once TIMETICS_PLUGIN_DIR . 'core/staffs/calendars/CalendarSyncFactory.php';
216 + require_once TIMETICS_PLUGIN_DIR . 'core/staffs/calendars/CalendarSyncInterface.php';
217 + require_once TIMETICS_PLUGIN_DIR . 'core/staffs/calendars/GoogleCalendarSync.php';
210 218 }
211 219
212 220 /**
213 221 * Initialize All Components
@@ -230,30 +238,70 @@
230 238 Core\Admin\Menu::instance()->init();
231 239 Core\Base::instance()->init();
232 240 Core\Services\Hooks::instance()->init();
233 241 Base\Custom_Endpoint::instance()->init();
242 +
243 + global $current_screen;
244 + $this->has_pro = class_exists('TimeticsPro');
245 +
246 + $this->handle_buy_pro_module();
247 +
248 + if ( function_exists('WC') ) {
249 + Core\Integrations\Woocommerce\Hooks::instance()->init();
250 + }
234 251 }
235 252
236 253 /**
254 + * demo url for set pro button
255 + *
256 + * @return void
257 + */
258 + public function demo_url(){
259 + return "https://arraytics.com/timetics/";
260 + }
261 +
262 + /**
237 263 * Register scripts and styles for admin
238 264 *
239 265 * @return void
240 266 */
241 267 public function admin_scripts( $handle ) {
242 - if ( 'toplevel_page_timetics' !== $handle ) {
268 +
269 + if('plugins.php' === $handle){
270 +
271 + wp_register_script( 'timetics-feedback-modal', TIMETICS_ASSETS_URL . 'js/feedback-modal.js', [ 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true );
272 + wp_enqueue_script( 'timetics-feedback-modal', TIMETICS_ASSETS_URL . 'js/feedback-modal.js', [], TIMETICS_VERSION, true );
273 + wp_register_style( 'timetics-feedback-modal', TIMETICS_ASSETS_URL . 'css/feedback-modal.css', [], TIMETICS_VERSION, 'all' );
274 + wp_enqueue_style( 'timetics-feedback-modal', TIMETICS_ASSETS_URL . 'css/feedback-modal.css', [], TIMETICS_VERSION, 'all' );
275 +
276 + $feedback_obj = array(
277 + 'site_url' => site_url()
278 + );
279 +
280 + wp_localize_script( 'timetics-feedback-modal', 'timetics_feedback', $feedback_obj );
281 +
282 + }
283 +
284 + if ( 'toplevel_page_timetics' !== $handle) {
243 285 return;
244 286 }
245 287 global $wp_locale;
246 288
247 289 wp_enqueue_media();
248 -
290 + wp_enqueue_style( 'wp-color-picker' );
249 291 wp_enqueue_style( 'timetics-admin-style', TIMETICS_ASSETS_URL . 'css/admin.css', [], TIMETICS_VERSION, 'all' );
250 292 wp_enqueue_style( 'timetics-vendor', TIMETICS_ASSETS_URL . 'css/vendor.css', [], TIMETICS_VERSION, 'all' );
251 - wp_enqueue_script( 'timetics-antd-scripts', TIMETICS_ASSETS_URL . 'js/vendors/antd.js', [ 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true );
252 293 wp_enqueue_script( 'timetics-flatpickr-scripts', TIMETICS_ASSETS_URL . 'js/vendors/flatpickr.js', [ 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true );
294 + wp_enqueue_script( 'timetics-packages', TIMETICS_ASSETS_URL . 'js/packages.js', [ 'timetics-flatpickr-scripts' ], TIMETICS_VERSION, true );
253 295
254 - wp_enqueue_script( 'timetics-dashboard-scripts', TIMETICS_ASSETS_URL . 'js/dashboard.js', [ 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true );
296 + $calendar_locale = timetics_get_option('calendar_locale');
297 + if (!empty($calendar_locale)) {
298 + wp_enqueue_script( 'calendar-locale', TIMETICS_ASSETS_URL . "js/local/{$calendar_locale}.js", [ 'jquery', 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true );
299 + }
255 300
301 + wp_enqueue_script( 'timetics-dashboard-scripts', TIMETICS_ASSETS_URL . 'js/dashboard.js', [ 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data', 'wp-color-picker' ], TIMETICS_VERSION, true );
302 +
303 +
256 304 $localize_obj = array(
257 305 'site_url' => site_url(),
258 306 'admin_url' => admin_url(),
259 307 'nonce' => wp_create_nonce( 'wp_rest' ),
@@ -262,13 +310,20 @@
262 310 'date_format' => get_option( 'date_format' ),
263 311 'date_format_string' => date_i18n( get_option( 'date_format' ) ),
264 312 'time_format' => get_option( 'time_format' ),
265 313 'time_format_string' => date_i18n( get_option( 'time_format' ) ),
266 - 'start_of_week' => $wp_locale->get_weekday( get_option( 'start_of_week' ) ),
314 + 'start_of_week' => get_option( 'start_of_week', 0 ),
315 +
267 316 'default_timezone' => timetics_get_default_timezone(),
268 317 'currency_list' => timetics_get_currencies(),
269 318 'current_user_id' => get_current_user_id(),
319 + 'timeticsPro' => class_exists('TimeticsPro') ? true : false,
320 + 'demo_url' => $this->demo_url(),
321 + 'current_user' => timetics_get_current_user(),
270 322 );
323 +
324 + $localize_obj = apply_filters( 'timetics_admin_localize_data', $localize_obj );
325 +
271 326 wp_localize_script( 'timetics-dashboard-scripts', 'timetics', $localize_obj );
272 327 }
273 328
274 329 /**
@@ -276,29 +331,48 @@
276 331 *
277 332 * @return void
278 333 */
279 334 public function frontend_scripts() {
335 +
280 336 wp_register_style( 'timetics-vendor', TIMETICS_ASSETS_URL . 'css/vendor.css', [], TIMETICS_VERSION, 'all' );
281 337 wp_register_style( 'timetics-frontend', TIMETICS_ASSETS_URL . 'css/frontend.css', [], TIMETICS_VERSION, 'all' );
282 338
283 - wp_register_script( 'timetics-antd-scripts', TIMETICS_ASSETS_URL . 'js/vendors/antd.js', [ 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true );
284 339 wp_register_script( 'timetics-flatpickr-scripts', TIMETICS_ASSETS_URL . 'js/vendors/flatpickr.js', [ 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true );
340 + wp_enqueue_script( 'timetics-packages', TIMETICS_ASSETS_URL . 'js/packages.js', [ 'timetics-flatpickr-scripts' ], TIMETICS_VERSION, true );
341 +
285 342 wp_register_script( 'timetics-frontend-scripts', TIMETICS_ASSETS_URL . 'js/frontend.js', [ 'jquery', 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true );
343 +
344 + $calendar_locale = timetics_get_option('calendar_locale');
345 + if (!empty($calendar_locale)) {
346 + wp_register_script( 'calendar-locale', "https://npmcdn.com/flatpickr/dist/l10n/{$calendar_locale}.js", [ 'jquery', 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true );
347 + }
348 +
349 + // load text domain
350 + wp_set_script_translations( 'timetics-frontend-scripts', 'timetics', TIMETICS_PLUGIN_DIR . 'languages/' );
351 +
286 352 global $wp_locale;
287 353
288 354 $stripe_pub_key = timetics_get_option( 'stripe_pub_key' );
289 355 $stripe_secret_key = timetics_get_option( 'stripe_secret_key' );
290 356 $stripe_configure = $stripe_pub_key && $stripe_secret_key;
291 -
357 +
292 358 $localize_obj = array(
293 359 'site_url' => site_url(),
360 + 'nonce' => wp_create_nonce( 'wp_rest' ),
294 361 'date_format' => get_option( 'date_format' ),
295 362 'time_format' => get_option( 'time_format' ),
296 363 'stripe_pub_key' => $stripe_pub_key,
297 - 'currency' => timetics_get_option( 'currency', 'USD' ),
364 + 'currency' => apply_filters( 'timetics_currency', timetics_get_option( 'currency', 'USD' ) ),
298 365 'stripe_configure' => $stripe_configure,
366 + 'current_user_id' => get_current_user_id(),
367 + 'start_of_week' => get_option( 'start_of_week', 0 ),
368 + 'currency_list' => timetics_get_currencies(),
369 + 'locale_name' => strtolower( str_replace( '_', '-', get_locale() ) )
299 370
300 371 );
372 +
373 + $localize_obj = apply_filters( 'timetics_frontned_localize_data', $localize_obj );
374 +
301 375 wp_localize_script( 'timetics-frontend-scripts', 'timetics', $localize_obj );
302 376 }
303 377
304 378 /**
@@ -336,8 +410,47 @@
336 410 $is_rest_request = ( false !== strpos( $server_request, $rest_prefix ) );
337 411
338 412 return apply_filters( 'timetics_is_rest_api_request', $is_rest_request );
339 413 }
414 +
415 +
416 + /**
417 + * Show buy-pro menu if pro plugin not active
418 + *
419 + * @return void
420 + */
421 + public function handle_buy_pro_module() {
422 + $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
423 +
424 +
425 + if ( 'timetics' !== $page ) {
426 + return;
427 + }
428 +
429 +
430 + /**
431 + * Show banner (codename: jhanda)
432 + */
433 + $filter_string = 'timetics,timetics-free-only';
434 +
435 + if( $this->has_pro ) {
436 +
437 + $filter_string .= ',timetics-pro';
438 + $filter_string = str_replace(',timetics-free-only', '', $filter_string);
439 +
440 + }
441 +
442 +
443 + \Wpmet\Libs\Banner::instance('timetics')
444 + ->is_test(true)
445 + ->set_filter(ltrim($filter_string, ','))
446 + ->set_api_url('https://product.themewinter.com/auth/public/jhanda')
447 + ->set_plugin_screens('timetics')
448 + ->set_plugin_screens('toplevel_page_timetics')
449 + ->call();
450 + // show get-help and upgrade-to-premium menu.
451 + // $this->handle_get_help_and_upgrade_menu();
452 + }
340 453
341 454 }
342 455
343 456 /**