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 | includes/models/class-wpsc-custom-field.php +35 -2 3.3.9 → 3.5.4 View file →
@@ -42,8 +42,15 @@
42 42 */
43 43 public static $cf_types;
44 44
45 45 /**
46 + * Default Custom field type
47 + *
48 + * @var array
49 + */
50 + public static $default_cf_types;
51 +
52 + /**
46 53 * Custom fields with slug indexing.
47 54 *
48 55 * @var array
49 56 */
@@ -69,9 +76,9 @@
69 76 // Get object of this class.
70 77 add_filter( 'wpsc_load_ref_classes', array( __CLASS__, 'load_ref_class' ) );
71 78
72 79 // Set custom field types.
73 - add_action( 'init', array( __CLASS__, 'set_cf_types' ) );
80 + add_action( 'init', array( __CLASS__, 'set_all_cf_types' ) );
74 81 }
75 82
76 83 /**
77 84 * Apply schema for this model
@@ -473,8 +480,9 @@
473 480 }
474 481
475 482 if ( in_array( $cf->field, array( 'ticket', 'agentonly' ) ) && $cf->type::$slug != 'cf_html' ) {
476 483 $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_tickets DROP {$cf->slug}" );
484 + $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_archived_tickets DROP {$cf->slug}" );
477 485 }
478 486
479 487 if ( $cf->field === 'customer' ) {
480 488 $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_customers DROP {$cf->slug}" );
@@ -632,9 +640,17 @@
632 640 */
633 641 public function create_ticket_tbl_col() {
634 642
635 643 global $wpdb;
636 - return $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_tickets ADD {$this->slug} {$this->type::$data_type}" );
644 + $result_archived = $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_archived_tickets ADD {$this->slug} {$this->type::$data_type}" );
645 + $result_tickets = $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_tickets ADD {$this->slug} {$this->type::$data_type}" );
646 +
647 + // Both queries must succeed.
648 + if ( $result_archived === false || $result_tickets === false ) {
649 + // Optionally, you could log or handle the error here.
650 + return false;
651 + }
652 + return true;
637 653 }
638 654
639 655 /**
640 656 * Create column for custom field in customer table
@@ -644,8 +660,25 @@
644 660 public function create_customer_tbl_col() {
645 661
646 662 global $wpdb;
647 663 return $wpdb->query( "ALTER TABLE {$wpdb->prefix}psmsc_customers ADD {$this->slug} {$this->type::$data_type}" );
664 + }
665 +
666 + /**
667 + * Set all custom field types
668 + */
669 + public static function set_all_cf_types() {
670 +
671 + self::set_default_cf_types();
672 + self::set_cf_types();
673 + }
674 +
675 + /**
676 + * Set default custom field types
677 + */
678 + public static function set_default_cf_types() {
679 +
680 + self::$default_cf_types = apply_filters( 'wpsc_default_cf_types', array() );
648 681 }
649 682
650 683 /**
651 684 * Set custom field types