PluginProbe
WP Directory Kit / 1.1.8
WP Directory Kit v1.1.8
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / includes / class-wpdirectorykit-activator.php

class-wpdirectorykit-activator.php in WP Directory Kit 1.1.8, at includes/class-wpdirectorykit-activator.php

644 lines 25.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Fired during plugin activation
5 *
6 * @link listing-themes.com
7 * @since 1.0.0
8 *
9 * @package Wpdirectorykit
10 * @subpackage Wpdirectorykit/includes
11 */
12
13 /**
14 * Fired during plugin activation.
15 *
16 * This class defines all code necessary to run during the plugin's activation.
17 *
18 * @since 1.0.0
19 * @package Wpdirectorykit
20 * @subpackage Wpdirectorykit/includes
21 * @author listing-themes.com <[email protected]>
22 */
23
24 if ( ! defined( 'ABSPATH' ) ) {
25 exit; // Exit if accessed directly.
26 }
27 class Wpdirectorykit_Activator {
28
29 public static $db_version = 3.8;
30
31 /**
32 * Short Description. (use period)
33 *
34 * Long Description.
35 *
36 * @since 1.0.0
37 */
38 public static function activate() {
39
40 $prefix = 'wdk_';
41
42 // Default options
43 add_option($prefix.'is_location_enabled', '1');
44 add_option($prefix.'is_category_enabled', '1');
45 add_option($prefix.'is_results_page_require', '1');
46 add_option($prefix.'is_address_enabled', '1');
47
48 // By default set London position
49 add_option($prefix.'default_lat', 51.505);
50 add_option($prefix.'default_lng', -0.09);
51
52 }
53
54 public static function plugins_loaded(){
55 if ( get_site_option( 'wdk_db_version' ) === false ||
56 get_site_option( 'wdk_db_version' ) < self::$db_version ) {
57 self::install();
58 }
59
60 }
61
62 // https://codex.wordpress.org/Creating_Tables_with_Plugins
63 public static function install() {
64 global $wpdb;
65
66 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
67 $charset_collate = $wpdb->get_charset_collate();
68 // For init version 1.0
69 if(get_site_option( 'wdk_db_version' ) === false)
70 {
71 // Main table for visited pages
72
73 $table_name = $wpdb->prefix . 'wdk_fields';
74
75 $sql = "CREATE TABLE IF NOT EXISTS $table_name (
76 `idfield` int(11) NOT NULL AUTO_INCREMENT,
77 `date` datetime DEFAULT NULL,
78 `lang_code` varchar(8) DEFAULT NULL,
79 `order_index` int(11) DEFAULT NULL,
80 `field_type` varchar(45) DEFAULT NULL,
81 `is_locked` tinyint(1) DEFAULT NULL,
82 `is_table_visible` tinyint(1) DEFAULT NULL,
83 `is_visible_frontend` tinyint(1) DEFAULT NULL,
84 `is_visible_dashboard` tinyint(1) DEFAULT NULL,
85 `is_hardlocked` tinyint(1) DEFAULT NULL,
86 `is_required` tinyint(1) DEFAULT NULL,
87 `is_translatable` tinyint(1) DEFAULT NULL,
88 `is_quickvisible` tinyint(1) DEFAULT NULL,
89 `max_length` int(11) DEFAULT NULL,
90 `repository_id` int(11) DEFAULT NULL,
91 `files` int(11) DEFAULT NULL,
92 `icon_id` int(11) DEFAULT NULL,
93 `columns_number` int(11) DEFAULT NULL,
94 `hubspot_id` varchar(60) DEFAULT NULL,
95 `field_label` varchar(50) DEFAULT NULL,
96 `prefix` varchar(30) DEFAULT NULL,
97 `suffix` varchar(30) DEFAULT NULL,
98 `values_list` varchar(160) DEFAULT NULL,
99 `hint` varchar(160) DEFAULT NULL,
100 PRIMARY KEY (idfield)
101 ) $charset_collate COMMENT='Custom Fields Data for WP Directory Kit';";
102
103 dbDelta( $sql );
104
105 $table_name = $wpdb->prefix . 'wdk_listings';
106
107 $sql = "CREATE TABLE IF NOT EXISTS $table_name (
108 `idlisting` int(11) NOT NULL AUTO_INCREMENT,
109 `post_id` int(11) NOT NULL,
110 `transition_id` varchar(100) DEFAULT NULL,
111 `category_id` int(11) DEFAULT NULL,
112 `location_id` int(11) DEFAULT NULL,
113 `is_primary` tinyint(1) DEFAULT NULL,
114 `last_edit_user_id` int(11) DEFAULT NULL,
115 `related_id` int(11) DEFAULT NULL,
116 `is_featured` tinyint(1) DEFAULT NULL,
117 `is_activated` tinyint(1) DEFAULT NULL,
118 `lat` decimal(9,6) DEFAULT NULL,
119 `lng` decimal(9,6) DEFAULT NULL,
120 `address` varchar(200) DEFAULT NULL,
121 `rank` int(11) DEFAULT NULL,
122 `date` datetime DEFAULT NULL,
123 `date_modified` datetime DEFAULT NULL,
124 `date_activated` datetime DEFAULT NULL,
125 `date_rank_expire` datetime DEFAULT NULL,
126 `date_alert` datetime DEFAULT NULL,
127 `date_notify` datetime DEFAULT NULL,
128 `date_repost` datetime DEFAULT NULL,
129 `date_renew` datetime DEFAULT NULL,
130 `date_activation_paid` datetime DEFAULT NULL,
131 `date_featured_paid` datetime DEFAULT NULL,
132 `date_status` datetime DEFAULT NULL,
133 `date_expire` datetime DEFAULT NULL,
134 `status` varchar(45) DEFAULT NULL,
135 `last_edit_ip` varchar(45) DEFAULT NULL,
136 `counter_views` int(11) DEFAULT NULL,
137 `reviews_stars` int(11) DEFAULT NULL,
138 `listing_images` text,
139 `affilate_id` int(11) DEFAULT NULL,
140 `not_notified_user` tinyint(1) DEFAULT NULL,
141 `hubspot_id` varchar(60) DEFAULT NULL,
142 PRIMARY KEY (idlisting),
143 UNIQUE KEY (post_id)
144 ) $charset_collate;";
145
146 dbDelta( $sql );
147
148 $table_name = $wpdb->prefix . 'wdk_listings_fields';
149
150 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
151 `idlistings_fields` int(11) NOT NULL AUTO_INCREMENT,
152 `post_id` int(11) NOT NULL,
153 `lang_code` varchar(8) COLLATE utf8_unicode_ci DEFAULT NULL,
154 PRIMARY KEY (idlistings_fields),
155 UNIQUE KEY (post_id)
156 ) $charset_collate;";
157
158 dbDelta( $sql );
159
160 $table_name = $wpdb->prefix . 'wdk_categories';
161
162 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
163 `idcategory` int(11) NOT NULL AUTO_INCREMENT,
164 `parent_id` int(11) DEFAULT NULL,
165 `page_id` int(11) DEFAULT NULL,
166 `lang_code` varchar(8) DEFAULT NULL,
167 `date` datetime DEFAULT NULL,
168 `parent_path` text,
169 `order_index` int(11) DEFAULT NULL,
170 `level` int(11) DEFAULT NULL,
171 `icon_id` int(11) DEFAULT NULL,
172 `image_id` int(11) DEFAULT NULL,
173 `font_icon_code` varchar(64) DEFAULT NULL,
174 `code` varchar(6) DEFAULT NULL,
175 `hubspot_id` varchar(60) DEFAULT NULL,
176 `category_title` varchar(160) DEFAULT NULL,
177 PRIMARY KEY (idcategory)
178 ) $charset_collate;";
179
180 dbDelta( $sql );
181
182 $table_name = $wpdb->prefix . 'wdk_locations';
183
184 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
185 `idlocation` int(11) NOT NULL AUTO_INCREMENT,
186 `parent_id` int(11) DEFAULT NULL,
187 `page_id` int(11) DEFAULT NULL,
188 `lang_code` varchar(8) DEFAULT NULL,
189 `date` datetime DEFAULT NULL,
190 `parent_path` text,
191 `order_index` int(11) DEFAULT NULL,
192 `level` int(11) DEFAULT NULL,
193 `icon_id` int(11) DEFAULT NULL,
194 `image_id` int(11) DEFAULT NULL,
195 `font_icon_code` varchar(64) DEFAULT NULL,
196 `code` varchar(6) DEFAULT NULL,
197 `hubspot_id` varchar(60) DEFAULT NULL,
198 `location_title` varchar(160) DEFAULT NULL,
199 PRIMARY KEY (idlocation)
200 ) $charset_collate;";
201
202 dbDelta( $sql );
203
204 $table_name = $wpdb->prefix . 'wdk_searchform';
205
206 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
207 `idsearchform` int(11) NOT NULL AUTO_INCREMENT,
208 `date` datetime DEFAULT NULL,
209 `searchform_name` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL,
210 `searchform_json` text COLLATE utf8_unicode_ci,
211 PRIMARY KEY (idsearchform)
212 ) $charset_collate;";
213
214 dbDelta( $sql );
215
216 $table_name = $wpdb->prefix . 'wdk_resultitem';
217
218 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
219 `idresultitem` int(11) NOT NULL AUTO_INCREMENT,
220 `date` datetime DEFAULT NULL,
221 `resultitem_name` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL,
222 `resultitem_json` text COLLATE utf8_unicode_ci,
223 PRIMARY KEY (idresultitem)
224 ) $charset_collate;";
225
226 dbDelta( $sql );
227
228 update_option( 'wdk_db_version', "1" );
229
230 }
231
232 /* version 1.1.0 db install */
233 if ( get_site_option( 'wdk_db_version' ) < '1.2' ) {
234 $table_name = $wpdb->prefix . 'wdk_messages';
235 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
236 `idmessage` int(11) NOT NULL AUTO_INCREMENT,
237 `post_id` int DEFAULT NULL,
238 `date` datetime DEFAULT NULL,
239 `user_id_sender` int DEFAULT NULL,
240 `user_id_receiver` int DEFAULT NULL,
241 `json_object` text,
242 `email_receiver` varchar(100) DEFAULT NULL,
243 `email_sender` varchar(100) DEFAULT NULL,
244 `message` text,
245 `date_from` datetime DEFAULT NULL,
246 `date_to` datetime DEFAULT NULL,
247 `is_readed` tinyint(1) DEFAULT NULL,
248 PRIMARY KEY (idmessage)
249 ) $charset_collate;";
250
251 dbDelta( $sql );
252
253 $table_name = $wpdb->prefix . 'wdk_listings_users';
254 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
255 `idlistings_users` int(11) NOT NULL AUTO_INCREMENT,
256 `post_id` int DEFAULT NULL,
257 `user_id` int DEFAULT NULL,
258 PRIMARY KEY (idlistings_users)
259 ) $charset_collate;";
260
261 dbDelta( $sql );
262 /* udpate option with db version */
263 }
264
265 /* version 1.2.0 db install */
266 if ( get_site_option( 'wdk_db_version' ) < '1.3' ) {
267
268 $table_name = $wpdb->prefix . 'wdk_categories';
269 $sql = "ALTER TABLE `$table_name` CHANGE `parent_id` `parent_id` INT(11) NULL DEFAULT '0'; ";
270 $wpdb->query($sql);
271
272 self::$db_version = 1.3;
273 /* udpate option with db version */
274 }
275
276 /* version 1.2.0 db install */
277 if ( get_site_option( 'wdk_db_version' ) < '1.4' ) {
278
279 $table_name = $wpdb->prefix . 'wdk_listings';
280 $sql = "ALTER TABLE `$table_name` ADD `is_approved` INT(1) NULL DEFAULT NULL AFTER `is_activated`; ";
281 $wpdb->query($sql);
282
283 $sql = "UPDATE `$table_name` SET `is_approved` = '1'";
284 $wpdb->query($sql);
285
286 self::$db_version = 1.4;
287 /* udpate option with db version */
288 }
289
290 if ( get_site_option( 'wdk_db_version' ) < '1.5' ) {
291
292 $table_name = $wpdb->prefix . 'wdk_listings';
293 $sql = "ALTER TABLE `$table_name` ADD `date_package_expire` DATETIME NULL AFTER `hubspot_id`, ADD `package_id` INT NULL AFTER `date_package_expire`; ";
294 $wpdb->query($sql);
295
296 self::$db_version = 1.5;
297 /* udpate option with db version */
298 }
299
300 if ( get_site_option( 'wdk_db_version' ) < '1.6' ) {
301
302 $table_name = $wpdb->prefix . 'wdk_categories';
303 $sql = "ALTER TABLE `$table_name` ADD `marker_image_id` int(11) DEFAULT NULL";
304 $wpdb->query($sql);
305
306 self::$db_version = 1.6;
307 /* udpate option with db version */
308 }
309
310 if ( get_site_option( 'wdk_db_version' ) < '1.7' ) {
311
312 $table_name = $wpdb->prefix . 'wdk_listings';
313 $sql = "ALTER TABLE `$table_name` ADD `listing_images_path` VARCHAR(200) DEFAULT ''";
314 $wpdb->query($sql);
315
316 // TODO: this column content should be generated based on listing_images or old client may have issues after update
317
318 self::$db_version = 1.7;
319 /* udpate option with db version */
320 }
321
322 if ( get_site_option( 'wdk_db_version' ) < '1.8' ) {
323
324 $table_name = $wpdb->prefix . 'wdk_listings';
325 $sql = "ALTER TABLE `$table_name` ADD `subscription_id` INT NULL; ";
326 $wpdb->query($sql);
327
328 self::$db_version = 1.8;
329 /* udpate option with db version */
330 }
331
332 if ( get_site_option( 'wdk_db_version' ) < '1.9' ) {
333
334 $table_name = $wpdb->prefix . 'wdk_fields';
335 $sql = "ALTER TABLE `$table_name` ADD `is_price_format` tinyint(1) DEFAULT NULL; ";
336 $wpdb->query($sql);
337
338 self::$db_version = 1.9;
339 /* udpate option with db version */
340 }
341
342 if ( get_site_option( 'wdk_db_version' ) < '2.0' ) {
343
344 $table_name = $wpdb->prefix . 'wdk_resultitem';
345 $sql = "ALTER TABLE `$table_name` ADD `is_multiline_enabled` tinyint(1) DEFAULT NULL; ";
346 $wpdb->query($sql);
347
348 self::$db_version = 2.0;
349 /* udpate option with db version */
350 }
351
352 if ( get_site_option( 'wdk_db_version' ) < '2.1' ) {
353
354 $table_name = $wpdb->prefix . 'wdk_listings';
355 $sql = "ALTER TABLE `$table_name` ADD `user_id_editor` INT DEFAULT NULL;";
356 $wpdb->query($sql);
357
358 $table_user_name = $wpdb->prefix . 'wdk_listings_users';
359
360 /* copy agents to new column */
361 $sql = "UPDATE
362 `$table_name` table_listings ,
363 `$table_user_name` table_users
364 SET
365 table_listings.user_id_editor = table_users.user_id
366 WHERE
367 table_listings.post_id = table_users.post_id;";
368 $wpdb->query($sql);
369
370 $sql = "TRUNCATE TABLE `$table_user_name`";
371 $wpdb->query($sql);
372
373 self::$db_version = 2.1;
374 /* udpate option with db version */
375 }
376
377 if ( get_site_option( 'wdk_db_version' ) < '2.2' ) {
378
379 $table_name = $wpdb->prefix . 'wdk_locations';
380 $sql = "ALTER TABLE `$table_name` ADD `level_0_id` INT DEFAULT NULL;";
381 $wpdb->query($sql);
382
383 $table_name = $wpdb->prefix . 'wdk_categories';
384 $sql = "ALTER TABLE `$table_name` ADD `level_0_id` INT DEFAULT NULL;";
385 $wpdb->query($sql);
386
387
388 $table_name = $wpdb->prefix . 'wdk_listings_locations';
389 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
390 `idlistings_locations` int(11) NOT NULL AUTO_INCREMENT,
391 `location_id` int DEFAULT NULL,
392 `post_id` int DEFAULT NULL,
393 PRIMARY KEY (idlistings_locations)
394 ) $charset_collate;";
395 dbDelta( $sql );
396
397 $table_name = $wpdb->prefix . 'wdk_listings_categories';
398 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
399 `idlistings_categories` int(11) NOT NULL AUTO_INCREMENT,
400 `category_id` int DEFAULT NULL,
401 `post_id` int DEFAULT NULL,
402 PRIMARY KEY (idlistings_categories)
403 ) $charset_collate;";
404 dbDelta( $sql );
405
406
407 self::$db_version = 2.2;
408 /* udpate option with db version */
409 }
410
411 if ( get_site_option( 'wdk_db_version' ) < '2.3' ) {
412
413 $table_name = $wpdb->prefix . 'wdk_listings';
414 $sql = "ALTER TABLE `$table_name` ADD `listing_plans_documents` text DEFAULT '';";
415 $wpdb->query($sql);
416
417 self::$db_version = 2.3;
418 /* udpate option with db version */
419 }
420
421 if ( get_site_option( 'wdk_db_version' ) < '2.4' ) {
422
423 $table_name = $wpdb->prefix . 'wdk_resultitem';
424 $sql = "ALTER TABLE `$table_name` ADD `is_label_disable` INT(1) NULL DEFAULT NULL";
425 $wpdb->query($sql);
426
427 self::$db_version = 2.4;
428 /* udpate option with db version */
429 }
430
431 if ( get_site_option( 'wdk_db_version' ) < '2.5' ) {
432
433 $table_name = $wpdb->prefix . 'wdk_listings';
434 $sql = "ALTER TABLE `$table_name` ADD `categories_list` VARCHAR(128) DEFAULT ''";
435 $wpdb->query($sql);
436
437 $table_name = $wpdb->prefix . 'wdk_listings';
438 $sql = "ALTER TABLE `$table_name` ADD `locations_list` VARCHAR(128) DEFAULT ''";
439 $wpdb->query($sql);
440
441
442 self::$db_version = 2.5;
443 /* udpate option with db version */
444 }
445
446 if ( get_site_option( 'wdk_db_version' ) < '2.6' ) {
447
448 $table_name = $wpdb->prefix . 'wdk_fields';
449
450 $sql = "UPDATE `$table_name` SET `is_visible_frontend` = '1'";
451 $wpdb->query($sql);
452
453 self::$db_version = 2.6;
454 /* udpate option with db version */
455 }
456
457 if ( get_site_option( 'wdk_db_version' ) < '2.7' ) {
458 $table_name = $wpdb->prefix . 'wdk_listings';
459 $sql = "ALTER TABLE `$table_name` ADD `listing_images_path_medium` VARCHAR(250) DEFAULT ''";
460 $wpdb->query($sql);
461
462 self::$db_version = 2.7;
463 /* udpate option with db version */
464 }
465
466 if ( get_site_option( 'wdk_db_version' ) < '2.8' ) {
467 // Main table for visited pages
468
469 $table_name = $wpdb->prefix . 'wdk_dependfields';
470
471 $sql = "CREATE TABLE IF NOT EXISTS $table_name (
472 `iddependfields` int(11) NOT NULL AUTO_INCREMENT,
473 `main_field` varchar(60) DEFAULT '',
474 `field_id` int(11) DEFAULT NULL,
475 `hidden_fields_list` varchar(256) DEFAULT '',
476 `date` datetime DEFAULT NULL,
477 PRIMARY KEY (iddependfields)
478 ) $charset_collate";
479
480 dbDelta( $sql );
481
482 self::$db_version = 2.8;
483 /* udpate option with db version */
484 }
485
486 if ( get_site_option( 'wdk_db_version' ) < '2.9' ) {
487 // Main table for visited pages
488 global $wpdb;
489 $wpdb->query('UPDATE '.$wpdb->prefix . 'wdk_fields SET is_price_format = 1 WHERE (idfield=6 OR idfield=7) AND field_type="NUMBER"');
490 self::$db_version = 2.9;
491 /* udpate option with db version */
492 }
493
494 if ( get_site_option( 'wdk_db_version' ) < '3.0' ) {
495
496 $table_name = $wpdb->prefix . 'wdk_fields';
497
498 $sql = "UPDATE `$table_name` SET `is_visible_dashboard` = '1'";
499 $wpdb->query($sql);
500
501 self::$db_version = 3.0;
502 /* udpate option with db version */
503 }
504
505 if ( get_site_option( 'wdk_db_version' ) < '3.1' ) {
506
507 $table_name = $wpdb->prefix . 'wdk_locations';
508 $sql = "ALTER TABLE `$table_name` ADD `icon_path` VARCHAR(100) DEFAULT ''";
509 $wpdb->query($sql);
510 $sql = "ALTER TABLE `$table_name` ADD `image_path` VARCHAR(100) DEFAULT ''";
511 $wpdb->query($sql);
512
513 $table_name = $wpdb->prefix . 'wdk_categories';
514 $sql = "ALTER TABLE `$table_name` ADD `icon_path` VARCHAR(100) DEFAULT ''";
515 $wpdb->query($sql);
516 $sql = "ALTER TABLE `$table_name` ADD `image_path` VARCHAR(100) DEFAULT ''";
517 $wpdb->query($sql);
518 $sql = "ALTER TABLE `$table_name` ADD `marker_image_path` VARCHAR(100) DEFAULT ''";
519 $wpdb->query($sql);
520
521 // TODO: this column content should be generated based on listing_images or old client may have issues after update
522
523 self::$db_version = 3.1;
524 /* udpate option with db version */
525 }
526
527 if ( get_site_option( 'wdk_db_version' ) < '3.2' ) {
528 // Main table for visited pages
529
530 $table_name = $wpdb->prefix . 'wdk_token';
531
532 $sql = "CREATE TABLE IF NOT EXISTS $table_name (
533 `idtoken` int(11) NOT NULL AUTO_INCREMENT,
534 `token` varchar(60) UNIQUE DEFAULT '',
535 `user_id` int(11) DEFAULT NULL,
536 `user_email` varchar(256) DEFAULT '',
537 `expire_date` datetime DEFAULT NULL,
538 `date` datetime DEFAULT NULL,
539 PRIMARY KEY (idtoken)
540 ) $charset_collate";
541
542 dbDelta( $sql );
543
544 self::$db_version = 3.2;
545 /* udpate option with db version */
546 }
547
548 if ( get_site_option( 'wdk_db_version' ) < '3.3' ) {
549 // Main table for visited pages
550
551
552 self::$db_version = 3.3;
553 /* udpate option with db version */
554 }
555
556 if ( get_site_option( 'wdk_db_version' ) < '3.4' ) {
557 // Main table for visited pages
558
559 $table_name = $wpdb->prefix . 'wdk_locations';
560 $sql = "ALTER TABLE `$table_name` ADD `related_svg_map` varchar(64) DEFAULT NULL;";
561 $wpdb->query($sql);
562
563 $table_name = $wpdb->prefix . 'wdk_locations';
564 $sql = "ALTER TABLE `$table_name` ADD `related_svg_map_location` varchar(128) DEFAULT NULL;";
565 $wpdb->query($sql);
566
567 $table_name = $wpdb->prefix . 'wdk_fields';
568 $sql = "ALTER TABLE `$table_name` CHANGE `values_list` `values_list` TEXT NULL DEFAULT NULL;";
569 $wpdb->query($sql);
570
571 self::$db_version = 3.4;
572 /* udpate option with db version */
573 }
574
575 if ( get_site_option( 'wdk_db_version' ) < '3.5' ) {
576 // Main table for visited pages
577
578 $table_name = $wpdb->prefix . 'wdk_categories';
579 $sql = "ALTER TABLE `$table_name` ADD `category_color` varchar(32) DEFAULT NULL;";
580 $wpdb->query($sql);
581
582 $table_name = $wpdb->prefix . 'wdk_fields';
583 $sql = "ALTER TABLE `$table_name` ADD `validation` varchar(64) DEFAULT NULL;";
584 $wpdb->query($sql);
585
586 $table_name = $wpdb->prefix . 'wdk_fields';
587 $sql = "ALTER TABLE `$table_name` ADD `min_length` INT(3) DEFAULT NULL;";
588 $wpdb->query($sql);
589
590 $table_name = $wpdb->prefix . 'wdk_listings';
591 $sql = "ALTER TABLE `$table_name` CHANGE `listing_images_path` `listing_images_path` TEXT DEFAULT '';";
592 $wpdb->query($sql);
593
594 $table_name = $wpdb->prefix . 'wdk_listings';
595 $sql = "ALTER TABLE `$table_name` CHANGE `listing_images_path_medium` `listing_images_path_medium` TEXT DEFAULT '';";
596 $wpdb->query($sql);
597
598 self::$db_version = 3.5;
599 /* udpate option with db version */
600 }
601
602 if ( get_site_option( 'wdk_db_version' ) < '3.6' ) {
603
604 $table_name = $wpdb->prefix . 'wdk_fields';
605
606 $sql = "UPDATE `$table_name` SET `is_visible_dashboard` = '1'";
607 $wpdb->query($sql);
608
609 $table_name = $wpdb->prefix . 'wdk_listings';
610 $sql = "ALTER TABLE `$table_name` CHANGE `locations_list` `locations_list` TEXT DEFAULT '';";
611 $wpdb->query($sql);
612
613 $table_name = $wpdb->prefix . 'wdk_listings';
614 $sql = "ALTER TABLE `$table_name` CHANGE `categories_list` `categories_list` TEXT DEFAULT '';";
615 $wpdb->query($sql);
616
617 self::$db_version = 3.6;
618 /* udpate option with db version */
619 }
620
621 if ( get_site_option( 'wdk_db_version' ) < '3.7' ) {
622
623 $table_name = $wpdb->prefix . 'wdk_fields';
624
625 $sql = "ALTER TABLE `$table_name` ADD `placeholder` varchar(128) DEFAULT NULL;";
626 $wpdb->query($sql);
627
628 self::$db_version = 3.7;
629 /* udpate option with db version */
630 }
631
632 if ( get_site_option( 'wdk_db_version' ) < '3.8' ) {
633
634 $table_name = $wpdb->prefix . 'wdk_messages';
635 $sql = "ALTER TABLE `$table_name` ADD `is_notified` tinyint(1) DEFAULT NULL; ";
636 $wpdb->query($sql);
637
638 self::$db_version = 3.8;
639 /* udpate option with db version */
640 }
641
642 update_option( 'wdk_db_version', self::$db_version );
643 }
644 }