| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Sellkit\Core\Update; |
| 4 | 4 | |
| 5 | 5 | use Sellkit\Core\Install; |
| 6 | +use Sellkit\Database; | |
| 6 | 7 | |
| 7 | 8 | defined( 'ABSPATH' ) || die(); |
| 8 | 9 | |
| 9 | 10 | /** |
| @@ -19,6 +20,74 @@ | ||
| 19 | 20 | * @since 1.1.0 |
| 20 | 21 | */ |
| 21 | 22 | public function check_database_tables() { |
| 22 | 23 | Install::check_database_tables(); |
| 24 | + } | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * Add ip to contact segmentation column. | |
| 28 | + * | |
| 29 | + * @since 1.2.1 | |
| 30 | + */ | |
| 31 | + public function add_ip_column_to_contact_segmentation() { | |
| 32 | + global $wpdb; | |
| 33 | + | |
| 34 | + $prefix = $wpdb->prefix . Database::DATABASE_PREFIX; | |
| 35 | + | |
| 36 | + if ( ! function_exists( 'check_column' ) ) { | |
| 37 | + require_once ABSPATH . 'wp-admin/install-helper.php'; | |
| 38 | + } | |
| 39 | + | |
| 40 | + if ( ! empty( check_column( "{$prefix}contact_segmentation", 'ip', 'varchar(255)' ) ) ) { | |
| 41 | + return; | |
| 42 | + } | |
| 43 | + | |
| 44 | + $wpdb->query("ALTER TABLE {$prefix}contact_segmentation ADD ip VARCHAR (255) NULL DEFAULT NULL"); // phpcs:ignore | |
| 45 | + } | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Add url query string to contact segmentation column. | |
| 49 | + * | |
| 50 | + * @since 1.2.3 | |
| 51 | + */ | |
| 52 | + public function add_url_query_string_column_to_contact_segmentation() { | |
| 53 | + global $wpdb; | |
| 54 | + | |
| 55 | + $prefix = $wpdb->prefix . Database::DATABASE_PREFIX; | |
| 56 | + | |
| 57 | + if ( ! function_exists( 'check_column' ) ) { | |
| 58 | + require_once ABSPATH . '/wp-admin/install-helper.php'; | |
| 59 | + } | |
| 60 | + | |
| 61 | + if ( ! empty( check_column( "{$prefix}contact_segmentation", 'url_query_string', 'longtext' ) ) ) { | |
| 62 | + return; | |
| 63 | + } | |
| 64 | + | |
| 65 | + $wpdb->query("ALTER TABLE {$prefix}contact_segmentation ADD url_query_string longtext NULL DEFAULT NULL"); // phpcs:ignore | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Adds funnel contact table. | |
| 70 | + * | |
| 71 | + * @since 1.5.0 | |
| 72 | + */ | |
| 73 | + public function add_funnel_contact_table() { | |
| 74 | + global $wpdb; | |
| 75 | + | |
| 76 | + $is_testcase_site = strpos( site_url(), 'artbees.team' ); // It should be removed. | |
| 77 | + | |
| 78 | + if ( | |
| 79 | + in_array( 'funnel_contact', $wpdb->tables, true ) && | |
| 80 | + ! $is_testcase_site // It should be removed. | |
| 81 | + ) { | |
| 82 | + return; | |
| 83 | + } | |
| 84 | + | |
| 85 | + // phpcs:disable | |
| 86 | + if ( $is_testcase_site ) { | |
| 87 | + $wpdb->query( "DROP TABLE IF EXISTS $wpdb->prefix" . Database::DATABASE_PREFIX . "funnel_contact" ); // It should be removed. | |
| 88 | + } | |
| 89 | + // phpcs:enable | |
| 90 | + | |
| 91 | + Database::create_new_table( 'funnel_contact' ); | |
| 23 | 92 | } |
| 24 | 93 | } |