PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.2
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.2
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / admin / class-wpsc-ai-legacy-compat.php

class-wpsc-ai-legacy-compat.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.5.2, at includes/admin/class-wpsc-ai-legacy-compat.php

74 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly!
4 }
5
6 if ( ! class_exists( 'WPSC_Ai_Legacy_Compat' ) ) :
7
8 /**
9 * AI Assistant / AI ChatBot used to ship inside the "Productivity Suite" add-on and now
10 * ship with core instead. An outdated Productivity Suite install still bundles its own
11 * copy of these features and will load it (under its own 'wpsc-ps-settings' toggle)
12 * during its own bootstrap, before this class ever runs.
13 *
14 * Rather than also loading core's copy and hoping load order keeps the two from
15 * colliding, this class checks - after every plugin has finished loading - whether
16 * that outdated copy is actually active, and if so, defers to it instead.
17 */
18 final class WPSC_Ai_Legacy_Compat {
19
20 /**
21 * Feature names currently deferred to an outdated Productivity Suite copy.
22 *
23 * @var array
24 */
25 private static $deferred_features = array();
26
27 /**
28 * Initialize the class
29 *
30 * @return void
31 */
32 public static function init() {
33
34 add_action( 'plugins_loaded', array( __CLASS__, 'load' ), 20 );
35 }
36
37 /**
38 * Load AI assistant / AI chatbot classes, deferring to an outdated Productivity
39 * Suite copy of either feature if one is already active and enabled.
40 *
41 * @return void
42 */
43 public static function load() {
44
45 $ps_path = defined( 'WPSC_PS_ABSPATH' ) ? WPSC_PS_ABSPATH : false;
46 $ps_settings = $ps_path ? get_option( 'wpsc-ps-settings', array() ) : array();
47
48 $defer_ai_assistant = $ps_path && is_dir( $ps_path . 'includes/ai-assistant' ) && ! empty( $ps_settings['ai-assistant'] );
49 $defer_ai_chatbot = $ps_path && is_dir( $ps_path . 'includes/ai-chatbot' ) && ! empty( $ps_settings['ai-chatbot'] );
50
51 if ( ! $defer_ai_assistant ) {
52 foreach ( glob( __DIR__ . '/ai-assistant/*.php' ) as $filename ) {
53 include_once $filename;
54 }
55 }
56
57 if ( ! $defer_ai_chatbot ) {
58 foreach ( glob( __DIR__ . '/ai-chatbot/*.php' ) as $filename ) {
59 include_once $filename;
60 }
61 }
62
63 if ( $defer_ai_assistant || $defer_ai_chatbot ) {
64
65 $ps_settings['ai-assistant'] = 0;
66 $ps_settings['ai-chatbot'] = 0;
67 update_option( 'wpsc-ps-settings', $ps_settings );
68 }
69 }
70 }
71 endif;
72
73 WPSC_Ai_Legacy_Compat::init();
74