PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.49
Timetics – Appointment Booking Calendar & Scheduling v1.0.49
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 +157 -9 1.0.21.0.49 View file →
@@ -13,9 +13,8 @@
13 13 *
14 14 * @since 1.0.0
15 15 */
16 16 final class Bootstrap {
17 -
18 17 /**
19 18 * @var Bootstrap The Actual Timetics instance
20 19 * @since 1.0.0
21 20 */
@@ -20,8 +19,13 @@
20 19 * @since 1.0.0
21 20 */
22 21 private static $instance;
23 22
23 +
24 + private $file;
25 + public $version;
26 + private $has_pro;
27 +
24 28 /**
25 29 * Throw Error While Trying To Clone Object
26 30 *
27 31 * @since 1.0.0
@@ -27,9 +31,9 @@
27 31 * @since 1.0.0
28 32 * @return void
29 33 */
30 34 public function __clone() {
31 - _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' );
32 36 }
33 37
34 38 /**
35 39 * Disabling Un-serialization Of This Class
@@ -34,9 +38,9 @@
34 38 /**
35 39 * Disabling Un-serialization Of This Class
36 40 */
37 41 public function __wakeup() {
38 - _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' );
39 43 }
40 44
41 45 /**
42 46 * The actual TimeTics instance
@@ -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
@@ -219,8 +227,9 @@
219 227
220 228 // Register scripts and styles first
221 229 if ( $this->is_request( 'admin' ) ) {
222 230 add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] );
231 + add_action( 'admin_footer', [ $this, 'admin_helpscout_beacon' ] );
223 232 }
224 233
225 234 if ( $this->is_request( 'frontend' ) ) {
226 235 add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
@@ -230,17 +239,52 @@
230 239 Core\Admin\Menu::instance()->init();
231 240 Core\Base::instance()->init();
232 241 Core\Services\Hooks::instance()->init();
233 242 Base\Custom_Endpoint::instance()->init();
243 +
244 + global $current_screen;
245 + $this->has_pro = class_exists('TimeticsPro');
246 +
247 + $this->handle_buy_pro_module();
248 +
249 + if ( function_exists('WC') ) {
250 + Core\Integrations\Woocommerce\Hooks::instance()->init();
251 + }
234 252 }
235 253
236 254 /**
255 + * demo url for set pro button
256 + *
257 + * @return void
258 + */
259 + public function demo_url(){
260 + return "https://arraytics.com/timetics/";
261 + }
262 +
263 + /**
237 264 * Register scripts and styles for admin
238 265 *
239 266 * @return void
240 267 */
241 268 public function admin_scripts( $handle ) {
242 - if ( 'toplevel_page_timetics' !== $handle ) {
269 +
270 + if('plugins.php' === $handle){
271 +
272 + 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 );
273 + wp_enqueue_script( 'timetics-feedback-modal', TIMETICS_ASSETS_URL . 'js/feedback-modal.js', [], TIMETICS_VERSION, true );
274 + wp_register_style( 'timetics-feedback-modal', TIMETICS_ASSETS_URL . 'css/feedback-modal.css', [], TIMETICS_VERSION, 'all' );
275 + wp_enqueue_style( 'timetics-feedback-modal', TIMETICS_ASSETS_URL . 'css/feedback-modal.css', [], TIMETICS_VERSION, 'all' );
276 +
277 + $feedback_obj = array(
278 + 'site_url' => site_url(),
279 + 'admin_email' => get_option( 'admin_email' )
280 + );
281 +
282 + wp_localize_script( 'timetics-feedback-modal', 'timetics_feedback', $feedback_obj );
283 +
284 + }
285 +
286 + if ( 'toplevel_page_timetics' !== $handle) {
243 287 return;
244 288 }
245 289 global $wp_locale;
246 290
@@ -247,13 +291,19 @@
247 291 wp_enqueue_media();
248 292 wp_enqueue_style( 'wp-color-picker' );
249 293 wp_enqueue_style( 'timetics-admin-style', TIMETICS_ASSETS_URL . 'css/admin.css', [], TIMETICS_VERSION, 'all' );
250 294 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 295 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 );
296 + wp_enqueue_script( 'timetics-packages', TIMETICS_ASSETS_URL . 'js/packages.js', [ 'timetics-flatpickr-scripts' ], TIMETICS_VERSION, true );
253 297
298 + $calendar_locale = timetics_get_option('calendar_locale');
299 + if (!empty($calendar_locale)) {
300 + 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 );
301 + }
302 +
254 303 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 );
255 304
305 +
256 306 $localize_obj = array(
257 307 'site_url' => site_url(),
258 308 'admin_url' => admin_url(),
259 309 'nonce' => wp_create_nonce( 'wp_rest' ),
@@ -262,14 +312,20 @@
262 312 'date_format' => get_option( 'date_format' ),
263 313 'date_format_string' => date_i18n( get_option( 'date_format' ) ),
264 314 'time_format' => get_option( 'time_format' ),
265 315 'time_format_string' => date_i18n( get_option( 'time_format' ) ),
266 - 'start_of_week' => $wp_locale->get_weekday( get_option( 'start_of_week' ) ),
316 + 'start_of_week' => get_option( 'start_of_week', 0 ),
317 +
267 318 'default_timezone' => timetics_get_default_timezone(),
268 319 'currency_list' => timetics_get_currencies(),
269 320 'current_user_id' => get_current_user_id(),
270 321 'timeticsPro' => class_exists('TimeticsPro') ? true : false,
322 + 'demo_url' => $this->demo_url(),
323 + 'current_user' => timetics_get_current_user(),
271 324 );
325 +
326 + $localize_obj = apply_filters( 'timetics_admin_localize_data', $localize_obj );
327 +
272 328 wp_localize_script( 'timetics-dashboard-scripts', 'timetics', $localize_obj );
273 329 }
274 330
275 331 /**
@@ -277,15 +333,22 @@
277 333 *
278 334 * @return void
279 335 */
280 336 public function frontend_scripts() {
337 +
281 338 wp_register_style( 'timetics-vendor', TIMETICS_ASSETS_URL . 'css/vendor.css', [], TIMETICS_VERSION, 'all' );
282 339 wp_register_style( 'timetics-frontend', TIMETICS_ASSETS_URL . 'css/frontend.css', [], TIMETICS_VERSION, 'all' );
283 340
284 - 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 );
285 341 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 );
342 + wp_enqueue_script( 'timetics-packages', TIMETICS_ASSETS_URL . 'js/packages.js', [ 'timetics-flatpickr-scripts' ], TIMETICS_VERSION, true );
343 +
286 344 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 );
287 345
346 + $calendar_locale = timetics_get_option('calendar_locale');
347 + if (!empty($calendar_locale)) {
348 + 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 );
349 + }
350 +
288 351 // load text domain
289 352 wp_set_script_translations( 'timetics-frontend-scripts', 'timetics', TIMETICS_PLUGIN_DIR . 'languages/' );
290 353
291 354 global $wp_locale;
@@ -295,16 +358,23 @@
295 358 $stripe_configure = $stripe_pub_key && $stripe_secret_key;
296 359
297 360 $localize_obj = array(
298 361 'site_url' => site_url(),
362 + 'nonce' => wp_create_nonce( 'wp_rest' ),
299 363 'date_format' => get_option( 'date_format' ),
300 364 'time_format' => get_option( 'time_format' ),
301 365 'stripe_pub_key' => $stripe_pub_key,
302 - 'currency' => timetics_get_option( 'currency', 'USD' ),
366 + 'currency' => apply_filters( 'timetics_currency', timetics_get_option( 'currency', 'USD' ) ),
303 367 'stripe_configure' => $stripe_configure,
304 - 'start_of_week' => $wp_locale->get_weekday( get_option( 'start_of_week' ) ),
368 + 'current_user_id' => get_current_user_id(),
369 + 'start_of_week' => get_option( 'start_of_week', 0 ),
370 + 'currency_list' => timetics_get_currencies(),
371 + 'locale_name' => strtolower( str_replace( '_', '-', get_locale() ) )
305 372
306 373 );
374 +
375 + $localize_obj = apply_filters( 'timetics_frontned_localize_data', $localize_obj );
376 +
307 377 wp_localize_script( 'timetics-frontend-scripts', 'timetics', $localize_obj );
308 378 }
309 379
310 380 /**
@@ -342,8 +412,86 @@
342 412 $is_rest_request = ( false !== strpos( $server_request, $rest_prefix ) );
343 413
344 414 return apply_filters( 'timetics_is_rest_api_request', $is_rest_request );
345 415 }
416 +
417 +
418 + /**
419 + * Show buy-pro menu if pro plugin not active
420 + *
421 + * @return void
422 + */
423 + public function handle_buy_pro_module() {
424 + $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
425 +
426 +
427 + if ( 'timetics' !== $page ) {
428 + return;
429 + }
430 +
431 +
432 + /**
433 + * Show banner (codename: jhanda)
434 + */
435 + $filter_string = 'timetics,timetics-free-only';
436 +
437 + if( $this->has_pro ) {
438 +
439 + $filter_string .= ',timetics-pro';
440 + $filter_string = str_replace(',timetics-free-only', '', $filter_string);
441 +
442 + }
443 +
444 +
445 + \Wpmet\Libs\Banner::instance('timetics')
446 + ->is_test(true)
447 + ->set_filter(ltrim($filter_string, ','))
448 + ->set_api_url('https://banner.themefunction.com/public/jhanda')
449 + ->set_plugin_screens('timetics')
450 + ->set_plugin_screens('toplevel_page_timetics')
451 + ->call();
452 + // show get-help and upgrade-to-premium menu.
453 + // $this->handle_get_help_and_upgrade_menu();
454 + }
455 +
456 + /**
457 + * Add HelpScout script to admin footer
458 + *
459 + * @return void
460 + */
461 + public function admin_helpscout_beacon() {
462 + $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
463 + $is_timetics_screen = false;
464 +
465 + if ( $screen ) {
466 + $screen_id = isset( $screen->id ) ? $screen->id : '';
467 +
468 + // Check: only load on Timetics top-level admin page
469 + if ( 'toplevel_page_timetics' === $screen_id ) {
470 + $is_timetics_screen = true;
471 + }
472 + }
473 +
474 + // Allow overriding detection via filter.
475 + $is_timetics_screen = apply_filters( 'timetics_is_admin_screen', $is_timetics_screen, $screen );
476 +
477 + if ( ! $is_timetics_screen ) {
478 + return;
479 + }
480 + ?>
481 + <script type="text/javascript">!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://beacon-v2.helpscout.net",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)a();else if(e.attachEvent)e.attachEvent("onload",a);else e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){});</script>
482 + <script type="text/javascript">
483 + window.Beacon('config', {
484 + color: "#0060e5",
485 + });
486 + window.Beacon('init', '4be24aa2-ee50-483c-a90c-db4216664d65');
487 + window.Beacon('on', 'ready', function(){
488 + window.Beacon('show');
489 + });
490 +
491 + </script>
492 + <?php
493 + }
346 494
347 495 }
348 496
349 497 /**