| @@ -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 |
| @@ -1472,23 +1482,12 @@ | ||
| 1472 | 1482 | 'allowed-search-fields' => array( 'id', 'customer', 'subject', 'threads' ), |
| 1473 | 1483 | ) |
| 1474 | 1484 | ); |
| 1475 | 1485 | |
| 1476 | - // Create a support page with the [supportcandy] shortcode. | |
| 1477 | - $support_page_id = wp_insert_post( | |
| 1478 | - array( | |
| 1479 | - 'post_title' => esc_html__( 'Support', 'supportcandy' ), | |
| 1480 | - 'post_content' => '[supportcandy]', | |
| 1481 | - 'post_status' => 'publish', | |
| 1482 | - 'post_type' => 'page', | |
| 1483 | - ) | |
| 1484 | - ); | |
| 1485 | - $support_page_id = is_wp_error( $support_page_id ) ? 0 : $support_page_id; | |
| 1486 | - | |
| 1487 | 1486 | update_option( |
| 1488 | 1487 | 'wpsc-gs-page-settings', |
| 1489 | 1488 | array( |
| 1490 | - 'support-page' => $support_page_id, | |
| 1489 | + 'support-page' => 0, | |
| 1491 | 1490 | 'open-ticket-page' => 0, |
| 1492 | 1491 | 'ticket-url-page' => 'support-page', |
| 1493 | 1492 | 'new-ticket-page' => 'default', |
| 1494 | 1493 | 'new-ticket-url' => '', |
| @@ -1820,15 +1819,8 @@ | ||
| 1820 | 1819 | 'z-index' => 900000000, |
| 1821 | 1820 | ) |
| 1822 | 1821 | ); |
| 1823 | 1822 | update_option( |
| 1824 | - 'wpsc-ap-agent-collision', | |
| 1825 | - array( | |
| 1826 | - 'header-bg-color' => '#e6e6e6', | |
| 1827 | - 'header-text-color' => '#2c3e50', | |
| 1828 | - ) | |
| 1829 | - ); | |
| 1830 | - update_option( | |
| 1831 | 1823 | 'wpsc-ap-ticket-list', |
| 1832 | 1824 | array( |
| 1833 | 1825 | 'list-header-background-color' => '#2c3e50', |
| 1834 | 1826 | 'list-header-text-color' => '#fff', |
| @@ -1853,12 +1845,12 @@ | ||
| 1853 | 1845 | // dashboard general setting. |
| 1854 | 1846 | update_option( |
| 1855 | 1847 | 'wpsc-ap-dashboard', |
| 1856 | 1848 | array( |
| 1857 | - 'card-body-bg-color' => '#f9f9f9', | |
| 1849 | + 'card-body-bg-color' => '#ffffff', | |
| 1858 | 1850 | 'card-body-svg-color' => '#777', |
| 1859 | 1851 | 'card-body-text-color' => '#2c3e50', |
| 1860 | - 'widget-body-bg-color' => '#f9f9f9', | |
| 1852 | + 'widget-body-bg-color' => '#ffffff', | |
| 1861 | 1853 | 'widget-body-svg-color' => '#777', |
| 1862 | 1854 | 'widget-body-text-color' => '#2c3e50', |
| 1863 | 1855 | ) |
| 1864 | 1856 | ); |
| @@ -2102,10 +2094,26 @@ | ||
| 2102 | 2094 | 'wpsc-acb-appearance-general', |
| 2103 | 2095 | array( |
| 2104 | 2096 | 'background-color' => '#2271b1', |
| 2105 | 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' ), | |
| 2106 | 2101 | ) |
| 2107 | 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 ); | |
| 2108 | 2116 | } |
| 2109 | 2117 | |
| 2110 | 2118 | /** |
| 2111 | 2119 | * Upgrade the version |
| @@ -2570,12 +2578,12 @@ | ||
| 2570 | 2578 | // dashboard appreance general setting. |
| 2571 | 2579 | update_option( |
| 2572 | 2580 | 'wpsc-ap-dashboard', |
| 2573 | 2581 | array( |
| 2574 | - 'card-body-bg-color' => '#f9f9f9', | |
| 2582 | + 'card-body-bg-color' => '#ffffff', | |
| 2575 | 2583 | 'card-body-svg-color' => '#777', |
| 2576 | 2584 | 'card-body-text-color' => '#2c3e50', |
| 2577 | - 'widget-body-bg-color' => '#f9f9f9', | |
| 2585 | + 'widget-body-bg-color' => '#ffffff', | |
| 2578 | 2586 | 'widget-body-svg-color' => '#777', |
| 2579 | 2587 | 'widget-body-text-color' => '#2c3e50', |
| 2580 | 2588 | ) |
| 2581 | 2589 | ); |
| @@ -2917,8 +2925,11 @@ | ||
| 2917 | 2925 | 'wpsc-acb-appearance-general', |
| 2918 | 2926 | array( |
| 2919 | 2927 | 'background-color' => '#2271b1', |
| 2920 | 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' ), | |
| 2921 | 2932 | ) |
| 2922 | 2933 | ); |
| 2923 | 2934 | } |
| 2924 | 2935 | |
| @@ -3022,8 +3033,35 @@ | ||
| 3022 | 3033 | $chatbot['custom-prompt'] = ''; |
| 3023 | 3034 | update_option( 'wpsc-ps-acb-chatbot-settings', $chatbot ); |
| 3024 | 3035 | } |
| 3025 | 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 | + | |
| 3026 | 3064 | update_option( 'wpsc-string-translation', $string_translations ); |
| 3027 | 3065 | self::set_upgrade_complete(); |
| 3028 | 3066 | } |
| 3029 | 3067 | |
| @@ -3128,8 +3166,20 @@ | ||
| 3128 | 3166 | ) |
| 3129 | 3167 | ); |
| 3130 | 3168 | if ( ! $index_exists ) { |
| 3131 | 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)" ); | |
| 3132 | 3182 | } |
| 3133 | 3183 | } |
| 3134 | 3184 | } |
| 3135 | 3185 | endif; |