| @@ -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 |
| @@ -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 |
| @@ -232,8 +240,9 @@ | ||
| 232 | 240 | Core\Services\Hooks::instance()->init(); |
| 233 | 241 | Base\Custom_Endpoint::instance()->init(); |
| 234 | 242 | |
| 235 | 243 | global $current_screen; |
| 244 | + $this->has_pro = class_exists('TimeticsPro'); | |
| 236 | 245 | |
| 237 | 246 | $this->handle_buy_pro_module(); |
| 238 | 247 | |
| 239 | 248 | if ( function_exists('WC') ) { |
| @@ -255,9 +264,25 @@ | ||
| 255 | 264 | * |
| 256 | 265 | * @return void |
| 257 | 266 | */ |
| 258 | 267 | public function admin_scripts( $handle ) { |
| 259 | - 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) { | |
| 260 | 285 | return; |
| 261 | 286 | } |
| 262 | 287 | global $wp_locale; |
| 263 | 288 | |
| @@ -264,14 +289,14 @@ | ||
| 264 | 289 | wp_enqueue_media(); |
| 265 | 290 | wp_enqueue_style( 'wp-color-picker' ); |
| 266 | 291 | wp_enqueue_style( 'timetics-admin-style', TIMETICS_ASSETS_URL . 'css/admin.css', [], TIMETICS_VERSION, 'all' ); |
| 267 | 292 | wp_enqueue_style( 'timetics-vendor', TIMETICS_ASSETS_URL . 'css/vendor.css', [], TIMETICS_VERSION, 'all' ); |
| 268 | - 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 ); | |
| 269 | 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 ); | |
| 270 | 295 | |
| 271 | 296 | $calendar_locale = timetics_get_option('calendar_locale'); |
| 272 | 297 | if (!empty($calendar_locale)) { |
| 273 | - wp_enqueue_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 ); | |
| 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 ); | |
| 274 | 299 | } |
| 275 | 300 | |
| 276 | 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 ); |
| 277 | 302 | |
| @@ -306,13 +331,15 @@ | ||
| 306 | 331 | * |
| 307 | 332 | * @return void |
| 308 | 333 | */ |
| 309 | 334 | public function frontend_scripts() { |
| 335 | + | |
| 310 | 336 | wp_register_style( 'timetics-vendor', TIMETICS_ASSETS_URL . 'css/vendor.css', [], TIMETICS_VERSION, 'all' ); |
| 311 | 337 | wp_register_style( 'timetics-frontend', TIMETICS_ASSETS_URL . 'css/frontend.css', [], TIMETICS_VERSION, 'all' ); |
| 312 | 338 | |
| 313 | - 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 ); | |
| 314 | 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 | + | |
| 315 | 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 ); |
| 316 | 343 | |
| 317 | 344 | $calendar_locale = timetics_get_option('calendar_locale'); |
| 318 | 345 | if (!empty($calendar_locale)) { |
| @@ -337,8 +364,10 @@ | ||
| 337 | 364 | 'currency' => apply_filters( 'timetics_currency', timetics_get_option( 'currency', 'USD' ) ), |
| 338 | 365 | 'stripe_configure' => $stripe_configure, |
| 339 | 366 | 'current_user_id' => get_current_user_id(), |
| 340 | 367 | 'start_of_week' => get_option( 'start_of_week', 0 ), |
| 368 | + 'currency_list' => timetics_get_currencies(), | |
| 369 | + 'locale_name' => strtolower( str_replace( '_', '-', get_locale() ) ) | |
| 341 | 370 | |
| 342 | 371 | ); |
| 343 | 372 | |
| 344 | 373 | $localize_obj = apply_filters( 'timetics_frontned_localize_data', $localize_obj ); |
| @@ -391,25 +420,33 @@ | ||
| 391 | 420 | */ |
| 392 | 421 | public function handle_buy_pro_module() { |
| 393 | 422 | $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
| 394 | 423 | |
| 424 | + | |
| 395 | 425 | if ( 'timetics' !== $page ) { |
| 396 | 426 | return; |
| 397 | 427 | } |
| 398 | 428 | |
| 429 | + | |
| 399 | 430 | /** |
| 400 | 431 | * Show banner (codename: jhanda) |
| 401 | 432 | */ |
| 402 | 433 | $filter_string = 'timetics,timetics-free-only'; |
| 403 | 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 | + | |
| 404 | 443 | \Wpmet\Libs\Banner::instance('timetics') |
| 405 | - // ->is_test(true) | |
| 444 | + ->is_test(true) | |
| 406 | 445 | ->set_filter(ltrim($filter_string, ',')) |
| 407 | - ->set_api_url('https://demo.themewinter.com/public/jhanda') | |
| 408 | - ->set_plugin_screens('edit-timetics') | |
| 409 | - ->set_plugin_screens('timetics_page_timetics_sales_report') | |
| 410 | - ->set_plugin_screens('edit-timetics-attendee') | |
| 411 | - ->set_plugin_screens('timetics_page_timetics_get_help') | |
| 446 | + ->set_api_url('https://product.themewinter.com/auth/public/jhanda') | |
| 447 | + ->set_plugin_screens('timetics') | |
| 448 | + ->set_plugin_screens('toplevel_page_timetics') | |
| 412 | 449 | ->call(); |
| 413 | 450 | // show get-help and upgrade-to-premium menu. |
| 414 | 451 | // $this->handle_get_help_and_upgrade_menu(); |
| 415 | 452 | } |