PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.4
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.4
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
← All changes | class-wpsc-installation.php +178 -102 3.5.2 → 3.5.4 View file →
@@ -232,8 +232,9 @@
232 232 source VARCHAR(200) NOT NULL,
233 233 source_id BIGINT NOT NULL DEFAULT 0,
234 234 ticket_id BIGINT NOT NULL DEFAULT 0,
235 235 customer_id BIGINT NOT NULL DEFAULT 0,
236 + uploaded_by VARCHAR(64) NOT NULL DEFAULT '',
236 237 PRIMARY KEY (id)
237 238 ) $collate;
238 239 CREATE TABLE {$wpdb->prefix}psmsc_agents (
239 240 id BIGINT NOT NULL AUTO_INCREMENT,
@@ -332,9 +333,11 @@
332 333 feature VARCHAR(50) NOT NULL,
333 334 tokens INT NOT NULL,
334 335 prompt LONGTEXT NOT NULL,
335 336 date_created DATETIME NOT NULL,
336 - PRIMARY KEY (id)
337 + PRIMARY KEY (id),
338 + KEY customer (customer),
339 + KEY date_created (date_created)
337 340 ) $collate;
338 341 CREATE TABLE {$wpdb->prefix}psmsc_ai_training (
339 342 id BIGINT NOT NULL AUTO_INCREMENT,
340 343 status VARCHAR(20) NOT NULL,
@@ -368,9 +371,10 @@
368 371 date_created DATETIME NOT NULL,
369 372 PRIMARY KEY (id),
370 373 UNIQUE KEY session_id (session_id),
371 374 KEY visitor_id (visitor_id),
372 - KEY status (status)
375 + KEY status (status),
376 + KEY date_created (date_created)
373 377 ) $collate;
374 378 CREATE TABLE {$wpdb->prefix}psmsc_acb_messages (
375 379 id BIGINT NOT NULL AUTO_INCREMENT,
376 380 session_id CHAR(36) NOT NULL,
@@ -404,8 +408,14 @@
404 408 $column_exists = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}psmsc_archived_tickets LIKE 'ticket_summary'" );
405 409 if ( empty( $column_exists ) ) {
406 410 $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_archived_tickets ADD ticket_summary TEXT NULL" );
407 411 }
412 +
413 + // Attachment ownership: add 'uploaded_by' column to attachments table.
414 + $column_exists = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}psmsc_attachments LIKE 'uploaded_by'" );
415 + if ( empty( $column_exists ) ) {
416 + $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_attachments ADD uploaded_by VARCHAR(64) NOT NULL DEFAULT ''" );
417 + }
408 418 }
409 419
410 420 /**
411 421 * First time installation
@@ -814,104 +824,110 @@
814 824 )
815 825 );
816 826 $string_translations[ 'wpsc-cf-name-' . $wpdb->insert_id ] = $name;
817 827
818 - // Insert default category.
819 - $name = __( 'General', 'supportcandy' );
820 - $wpdb->insert(
821 - $wpdb->prefix . 'psmsc_categories',
822 - array(
823 - 'name' => $name,
824 - 'load_order' => 1,
825 - )
826 - );
827 - $string_translations[ 'wpsc-category-' . $wpdb->insert_id ] = $name;
828 + // Insert default category, guarded against re-running initial_setup().
829 + if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_categories LIMIT 1" ) ) {
830 + $name = __( 'General', 'supportcandy' );
831 + $wpdb->insert(
832 + $wpdb->prefix . 'psmsc_categories',
833 + array(
834 + 'name' => $name,
835 + 'load_order' => 1,
836 + )
837 + );
838 + $string_translations[ 'wpsc-category-' . $wpdb->insert_id ] = $name;
839 + }
828 840
829 - // Insert default statuses.
830 - $name = __( 'Open', 'supportcandy' );
831 - $wpdb->insert(
832 - $wpdb->prefix . 'psmsc_statuses',
833 - array(
834 - 'name' => $name,
835 - 'color' => '#ec1010',
836 - 'bg_color' => '#ffe7e1',
837 - 'load_order' => 1,
838 - )
839 - );
840 - $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
841 + // Insert default statuses, guarded against re-running initial_setup().
842 + if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_statuses LIMIT 1" ) ) {
843 + $name = __( 'Open', 'supportcandy' );
844 + $wpdb->insert(
845 + $wpdb->prefix . 'psmsc_statuses',
846 + array(
847 + 'name' => $name,
848 + 'color' => '#ec1010',
849 + 'bg_color' => '#ffe7e1',
850 + 'load_order' => 1,
851 + )
852 + );
853 + $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
841 854
842 - $name = __( 'Awaiting customer reply', 'supportcandy' );
843 - $wpdb->insert(
844 - $wpdb->prefix . 'psmsc_statuses',
845 - array(
846 - 'name' => $name,
847 - 'color' => '#8222E6',
848 - 'bg_color' => '#E9D3FF',
849 - 'load_order' => 2,
850 - )
851 - );
852 - $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
855 + $name = __( 'Awaiting customer reply', 'supportcandy' );
856 + $wpdb->insert(
857 + $wpdb->prefix . 'psmsc_statuses',
858 + array(
859 + 'name' => $name,
860 + 'color' => '#8222E6',
861 + 'bg_color' => '#E9D3FF',
862 + 'load_order' => 2,
863 + )
864 + );
865 + $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
853 866
854 - $name = __( 'Awaiting agent reply', 'supportcandy' );
855 - $wpdb->insert(
856 - $wpdb->prefix . 'psmsc_statuses',
857 - array(
858 - 'name' => $name,
859 - 'color' => '#EB961C',
860 - 'bg_color' => '#FFEBCE',
861 - 'load_order' => 3,
862 - )
863 - );
864 - $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
867 + $name = __( 'Awaiting agent reply', 'supportcandy' );
868 + $wpdb->insert(
869 + $wpdb->prefix . 'psmsc_statuses',
870 + array(
871 + 'name' => $name,
872 + 'color' => '#EB961C',
873 + 'bg_color' => '#FFEBCE',
874 + 'load_order' => 3,
875 + )
876 + );
877 + $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
865 878
866 - $name = __( 'Closed', 'supportcandy' );
867 - $wpdb->insert(
868 - $wpdb->prefix . 'psmsc_statuses',
869 - array(
870 - 'name' => $name,
871 - 'color' => '#22940d',
872 - 'bg_color' => '#c1ffcf',
873 - 'load_order' => 4,
874 - )
875 - );
876 - $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
879 + $name = __( 'Closed', 'supportcandy' );
880 + $wpdb->insert(
881 + $wpdb->prefix . 'psmsc_statuses',
882 + array(
883 + 'name' => $name,
884 + 'color' => '#22940d',
885 + 'bg_color' => '#c1ffcf',
886 + 'load_order' => 4,
887 + )
888 + );
889 + $string_translations[ 'wpsc-status-' . $wpdb->insert_id ] = $name;
890 + }
877 891
878 - // Insert default priorities.
879 - $name = __( 'Low', 'supportcandy' );
880 - $wpdb->insert(
881 - $wpdb->prefix . 'psmsc_priorities',
882 - array(
883 - 'name' => $name,
884 - 'color' => '#22940d',
885 - 'bg_color' => '#c1ffcf',
886 - 'load_order' => 1,
887 - )
888 - );
889 - $string_translations[ 'wpsc-priority-' . $wpdb->insert_id ] = $name;
892 + // Insert default priorities, guarded against re-running initial_setup().
893 + if ( ! $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}psmsc_priorities LIMIT 1" ) ) {
894 + $name = __( 'Low', 'supportcandy' );
895 + $wpdb->insert(
896 + $wpdb->prefix . 'psmsc_priorities',
897 + array(
898 + 'name' => $name,
899 + 'color' => '#22940d',
900 + 'bg_color' => '#c1ffcf',
901 + 'load_order' => 1,
902 + )
903 + );
904 + $string_translations[ 'wpsc-priority-' . $wpdb->insert_id ] = $name;
890 905
891 - $name = __( 'Medium', 'supportcandy' );
892 - $wpdb->insert(
893 - $wpdb->prefix . 'psmsc_priorities',
894 - array(
895 - 'name' => $name,
896 - 'color' => '#EB961C',
897 - 'bg_color' => '#FFEBCE',
898 - 'load_order' => 2,
899 - )
900 - );
901 - $string_translations[ 'wpsc-priority-' . $wpdb->insert_id ] = $name;
906 + $name = __( 'Medium', 'supportcandy' );
907 + $wpdb->insert(
908 + $wpdb->prefix . 'psmsc_priorities',
909 + array(
910 + 'name' => $name,
911 + 'color' => '#EB961C',
912 + 'bg_color' => '#FFEBCE',
913 + 'load_order' => 2,
914 + )
915 + );
916 + $string_translations[ 'wpsc-priority-' . $wpdb->insert_id ] = $name;
902 917
903 - $name = __( 'High', 'supportcandy' );
904 - $wpdb->insert(
905 - $wpdb->prefix . 'psmsc_priorities',
906 - array(
907 - 'name' => $name,
908 - 'color' => '#ec1010',
909 - 'bg_color' => '#ffe7e1',
910 - 'load_order' => 3,
911 - )
912 - );
913 - $string_translations[ 'wpsc-priority-' . $wpdb->insert_id ] = $name;
918 + $name = __( 'High', 'supportcandy' );
919 + $wpdb->insert(
920 + $wpdb->prefix . 'psmsc_priorities',
921 + array(
922 + 'name' => $name,
923 + 'color' => '#ec1010',
924 + 'bg_color' => '#ffe7e1',
925 + 'load_order' => 3,
926 + )
927 + );
928 + $string_translations[ 'wpsc-priority-' . $wpdb->insert_id ] = $name;
929 + }
914 930
915 931 // company working hrs.
916 932 for ( $i = 1; $i <= 7; $i++ ) {
917 933 $wpdb->insert(
@@ -1803,15 +1819,8 @@
1803 1819 'z-index' => 900000000,
1804 1820 )
1805 1821 );
1806 1822 update_option(
1807 - 'wpsc-ap-agent-collision',
1808 - array(
1809 - 'header-bg-color' => '#e6e6e6',
1810 - 'header-text-color' => '#2c3e50',
1811 - )
1812 - );
1813 - update_option(
1814 1823 'wpsc-ap-ticket-list',
1815 1824 array(
1816 1825 'list-header-background-color' => '#2c3e50',
1817 1826 'list-header-text-color' => '#fff',
@@ -1836,12 +1845,12 @@
1836 1845 // dashboard general setting.
1837 1846 update_option(
1838 1847 'wpsc-ap-dashboard',
1839 1848 array(
1840 - 'card-body-bg-color' => '#f9f9f9',
1849 + 'card-body-bg-color' => '#ffffff',
1841 1850 'card-body-svg-color' => '#777',
1842 1851 'card-body-text-color' => '#2c3e50',
1843 - 'widget-body-bg-color' => '#f9f9f9',
1852 + 'widget-body-bg-color' => '#ffffff',
1844 1853 'widget-body-svg-color' => '#777',
1845 1854 'widget-body-text-color' => '#2c3e50',
1846 1855 )
1847 1856 );
@@ -2075,8 +2084,9 @@
2075 2084 'sessions-per-page' => 30,
2076 2085 'popup-delay-status' => '0',
2077 2086 'popup-delay' => 10,
2078 2087 'popup-display-limit' => 3,
2088 + 'custom-prompt' => '',
2079 2089 )
2080 2090 );
2081 2091
2082 2092 // default chatbot appearance settings.
@@ -2084,10 +2094,26 @@
2084 2094 'wpsc-acb-appearance-general',
2085 2095 array(
2086 2096 'background-color' => '#2271b1',
2087 2097 'icon-color' => '#ffffff',
2098 + 'header-text' => __( 'AI Chatbot', 'supportcandy' ),
2099 + 'greeting-text' => __( 'Hey, I\'m your assistant. How can I help you today?', 'supportcandy' ),
2100 + 'warning-text' => __( 'AI can make mistakes. Check important info.', 'supportcandy' ),
2088 2101 )
2089 2102 );
2103 +
2104 + // Onboarding wizard: seed pending state for this fresh install and flag a
2105 + // one-time redirect so WPSC_Onboarding shows the wizard on the next admin
2106 + // page load. Existing sites being upgraded never reach this method, so the
2107 + // wizard never auto-appears for them.
2108 + update_option(
2109 + 'wpsc-onboarding-wizard',
2110 + array(
2111 + 'status' => 'pending',
2112 + 'steps' => array(),
2113 + )
2114 + );
2115 + set_transient( 'wpsc_onboarding_redirect', 1, 5 * MINUTE_IN_SECONDS );
2090 2116 }
2091 2117
2092 2118 /**
2093 2119 * Upgrade the version
@@ -2552,12 +2578,12 @@
2552 2578 // dashboard appreance general setting.
2553 2579 update_option(
2554 2580 'wpsc-ap-dashboard',
2555 2581 array(
2556 - 'card-body-bg-color' => '#f9f9f9',
2582 + 'card-body-bg-color' => '#ffffff',
2557 2583 'card-body-svg-color' => '#777',
2558 2584 'card-body-text-color' => '#2c3e50',
2559 - 'widget-body-bg-color' => '#f9f9f9',
2585 + 'widget-body-bg-color' => '#ffffff',
2560 2586 'widget-body-svg-color' => '#777',
2561 2587 'widget-body-text-color' => '#2c3e50',
2562 2588 )
2563 2589 );
@@ -2888,8 +2914,9 @@
2888 2914 'sessions-per-page' => 30,
2889 2915 'popup-delay-status' => '0',
2890 2916 'popup-delay' => 10,
2891 2917 'popup-display-limit' => 3,
2918 + 'custom-prompt' => '',
2892 2919 )
2893 2920 );
2894 2921 }
2895 2922
@@ -2898,8 +2925,11 @@
2898 2925 'wpsc-acb-appearance-general',
2899 2926 array(
2900 2927 'background-color' => '#2271b1',
2901 2928 'icon-color' => '#ffffff',
2929 + 'header-text' => __( 'AI Chatbot', 'supportcandy' ),
2930 + 'greeting-text' => __( 'Hey, I\'m your assistant. How can I help you today?', 'supportcandy' ),
2931 + 'warning-text' => __( 'AI can make mistakes. Check important info.', 'supportcandy' ),
2902 2932 )
2903 2933 );
2904 2934 }
2905 2935
@@ -2996,8 +3026,42 @@
2996 3026 $chatbot['popup-display-limit'] = 3;
2997 3027 update_option( 'wpsc-ps-acb-chatbot-settings', $chatbot );
2998 3028 }
2999 3029
3030 + if ( version_compare( self::$current_version, '3.5.3', '<' ) ) {
3031 +
3032 + $chatbot = get_option( 'wpsc-ps-acb-chatbot-settings' );
3033 + $chatbot['custom-prompt'] = '';
3034 + update_option( 'wpsc-ps-acb-chatbot-settings', $chatbot );
3035 + }
3036 +
3037 + if ( version_compare( self::$current_version, '3.5.4', '<' ) ) {
3038 +
3039 + $appearance = get_option( 'wpsc-acb-appearance-general' );
3040 + if ( is_array( $appearance ) ) {
3041 + if ( ! isset( $appearance['header-text'] ) ) {
3042 + $appearance['header-text'] = __( 'AI Chatbot', 'supportcandy' );
3043 + }
3044 + if ( ! isset( $appearance['greeting-text'] ) ) {
3045 + $appearance['greeting-text'] = __( 'Hey, I\'m your assistant. How can I help you today?', 'supportcandy' );
3046 + }
3047 + if ( ! isset( $appearance['warning-text'] ) ) {
3048 + $appearance['warning-text'] = __( 'AI can make mistakes. Check important info.', 'supportcandy' );
3049 + }
3050 + update_option( 'wpsc-acb-appearance-general', $appearance );
3051 + }
3052 +
3053 + self::create_indexing();
3054 +
3055 + update_option(
3056 + 'wpsc-onboarding-wizard',
3057 + array(
3058 + 'status' => 'completed',
3059 + 'steps' => array(),
3060 + )
3061 + );
3062 + }
3063 +
3000 3064 update_option( 'wpsc-string-translation', $string_translations );
3001 3065 self::set_upgrade_complete();
3002 3066 }
3003 3067
@@ -3102,8 +3166,20 @@
3102 3166 )
3103 3167 );
3104 3168 if ( ! $index_exists ) {
3105 3169 $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_archived_threads ADD INDEX {$index_name} (ticket)" );
3170 + }
3171 +
3172 + // Create index on AI training table.
3173 + $index_name = 'idx_doc_source_source_provider_source_id';
3174 + $index_exists = $wpdb->get_var(
3175 + $wpdb->prepare(
3176 + "SHOW INDEX FROM {$wpdb->prefix}psmsc_ai_training WHERE Key_name = %s",
3177 + $index_name
3178 + )
3179 + );
3180 + if ( ! $index_exists ) {
3181 + $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_ai_training ADD INDEX {$index_name} (doc_source, source, provider, source_id)" );
3106 3182 }
3107 3183 }
3108 3184 }
3109 3185 endif;