PluginProbe
WP Directory Kit / 1.2.3
WP Directory Kit v1.2.3
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 1.4.0 1.4.1 All 35 releases
wpdirectorykit / includes / class-wpdirectorykit-activator.php

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

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