| @@ -22,8 +22,9 @@ | ||
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | private $file; |
| 25 | 25 | public $version; |
| 26 | + private $has_pro; | |
| 26 | 27 | |
| 27 | 28 | /** |
| 28 | 29 | * Throw Error While Trying To Clone Object |
| 29 | 30 | * |
| @@ -209,8 +210,12 @@ | ||
| 209 | 210 | /** |
| 210 | 211 | * Core helpers. |
| 211 | 212 | */ |
| 212 | 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'; | |
| 213 | 218 | } |
| 214 | 219 | |
| 215 | 220 | /** |
| 216 | 221 | * Initialize All Components |
| @@ -222,8 +227,9 @@ | ||
| 222 | 227 | |
| 223 | 228 | // Register scripts and styles first |
| 224 | 229 | if ( $this->is_request( 'admin' ) ) { |
| 225 | 230 | add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] ); |
| 231 | + add_action( 'admin_footer', [ $this, 'admin_helpscout_beacon' ] ); | |
| 226 | 232 | } |
| 227 | 233 | |
| 228 | 234 | if ( $this->is_request( 'frontend' ) ) { |
| 229 | 235 | add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) ); |
| @@ -235,8 +241,9 @@ | ||
| 235 | 241 | Core\Services\Hooks::instance()->init(); |
| 236 | 242 | Base\Custom_Endpoint::instance()->init(); |
| 237 | 243 | |
| 238 | 244 | global $current_screen; |
| 245 | + $this->has_pro = class_exists('TimeticsPro'); | |
| 239 | 246 | |
| 240 | 247 | $this->handle_buy_pro_module(); |
| 241 | 248 | |
| 242 | 249 | if ( function_exists('WC') ) { |
| @@ -258,9 +265,26 @@ | ||
| 258 | 265 | * |
| 259 | 266 | * @return void |
| 260 | 267 | */ |
| 261 | 268 | public function admin_scripts( $handle ) { |
| 262 | - 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) { | |
| 263 | 287 | return; |
| 264 | 288 | } |
| 265 | 289 | global $wp_locale; |
| 266 | 290 | |
| @@ -267,14 +291,14 @@ | ||
| 267 | 291 | wp_enqueue_media(); |
| 268 | 292 | wp_enqueue_style( 'wp-color-picker' ); |
| 269 | 293 | wp_enqueue_style( 'timetics-admin-style', TIMETICS_ASSETS_URL . 'css/admin.css', [], TIMETICS_VERSION, 'all' ); |
| 270 | 294 | wp_enqueue_style( 'timetics-vendor', TIMETICS_ASSETS_URL . 'css/vendor.css', [], TIMETICS_VERSION, 'all' ); |
| 271 | - 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 ); | |
| 272 | 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 ); | |
| 273 | 297 | |
| 274 | 298 | $calendar_locale = timetics_get_option('calendar_locale'); |
| 275 | 299 | if (!empty($calendar_locale)) { |
| 276 | - 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 ); | |
| 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 ); | |
| 277 | 301 | } |
| 278 | 302 | |
| 279 | 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 ); |
| 280 | 304 | |
| @@ -309,13 +333,15 @@ | ||
| 309 | 333 | * |
| 310 | 334 | * @return void |
| 311 | 335 | */ |
| 312 | 336 | public function frontend_scripts() { |
| 337 | + | |
| 313 | 338 | wp_register_style( 'timetics-vendor', TIMETICS_ASSETS_URL . 'css/vendor.css', [], TIMETICS_VERSION, 'all' ); |
| 314 | 339 | wp_register_style( 'timetics-frontend', TIMETICS_ASSETS_URL . 'css/frontend.css', [], TIMETICS_VERSION, 'all' ); |
| 315 | 340 | |
| 316 | - 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 ); | |
| 317 | 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 | + | |
| 318 | 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 ); |
| 319 | 345 | |
| 320 | 346 | $calendar_locale = timetics_get_option('calendar_locale'); |
| 321 | 347 | if (!empty($calendar_locale)) { |
| @@ -396,28 +422,75 @@ | ||
| 396 | 422 | */ |
| 397 | 423 | public function handle_buy_pro_module() { |
| 398 | 424 | $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
| 399 | 425 | |
| 426 | + | |
| 400 | 427 | if ( 'timetics' !== $page ) { |
| 401 | 428 | return; |
| 402 | 429 | } |
| 403 | 430 | |
| 431 | + | |
| 404 | 432 | /** |
| 405 | 433 | * Show banner (codename: jhanda) |
| 406 | 434 | */ |
| 407 | 435 | $filter_string = 'timetics,timetics-free-only'; |
| 408 | 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 | + | |
| 409 | 445 | \Wpmet\Libs\Banner::instance('timetics') |
| 410 | - // ->is_test(true) | |
| 446 | + ->is_test(true) | |
| 411 | 447 | ->set_filter(ltrim($filter_string, ',')) |
| 412 | - ->set_api_url('https://demo.themewinter.com/public/jhanda') | |
| 413 | - ->set_plugin_screens('edit-timetics') | |
| 414 | - ->set_plugin_screens('timetics_page_timetics_sales_report') | |
| 415 | - ->set_plugin_screens('edit-timetics-attendee') | |
| 416 | - ->set_plugin_screens('timetics_page_timetics_get_help') | |
| 448 | + ->set_api_url('https://banner.themefunction.com/public/jhanda') | |
| 449 | + ->set_plugin_screens('timetics') | |
| 450 | + ->set_plugin_screens('toplevel_page_timetics') | |
| 417 | 451 | ->call(); |
| 418 | 452 | // show get-help and upgrade-to-premium menu. |
| 419 | 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 | |
| 420 | 493 | } |
| 421 | 494 | |
| 422 | 495 | } |
| 423 | 496 | |