PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
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.5.9, at includes/class-wpdirectorykit-activator.php

950 lines 36.0 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 = 5.3;
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 update_option( 'elementor_experiment-e_element_cache', 'inactive');
56 update_option( 'elementor_element_cache_ttl', 'disable');
57 }
58
59 public static function plugins_loaded(){
60 if ( get_site_option( 'wdk_db_version' ) === false ||
61 get_site_option( 'wdk_db_version' ) < self::$db_version ) {
62 self::install();
63 }
64 }
65
66 // https://codex.wordpress.org/Creating_Tables_with_Plugins
67 public static function install() {
68 global $wpdb;
69
70 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
71 $charset_collate = $wpdb->get_charset_collate();
72 // For init version 1.0
73 if(get_site_option( 'wdk_db_version' ) === false)
74 {
75 // Main table for visited pages
76
77 $table_name = $wpdb->prefix . 'wdk_fields';
78
79 $sql = "CREATE TABLE IF NOT EXISTS $table_name (
80 `idfield` int(11) NOT NULL AUTO_INCREMENT,
81 `date` datetime DEFAULT NULL,
82 `lang_code` varchar(8) DEFAULT NULL,
83 `order_index` int(11) DEFAULT NULL,
84 `field_type` varchar(45) DEFAULT NULL,
85 `is_locked` tinyint(1) DEFAULT NULL,
86 `is_table_visible` tinyint(1) DEFAULT NULL,
87 `is_visible_frontend` tinyint(1) DEFAULT NULL,
88 `is_visible_dashboard` tinyint(1) DEFAULT NULL,
89 `is_hardlocked` tinyint(1) DEFAULT NULL,
90 `is_required` tinyint(1) DEFAULT NULL,
91 `is_translatable` tinyint(1) DEFAULT NULL,
92 `is_quickvisible` tinyint(1) DEFAULT NULL,
93 `max_length` int(11) DEFAULT NULL,
94 `repository_id` int(11) DEFAULT NULL,
95 `files` int(11) DEFAULT NULL,
96 `icon_id` int(11) DEFAULT NULL,
97 `columns_number` int(11) DEFAULT NULL,
98 `hubspot_id` varchar(60) DEFAULT NULL,
99 `field_label` varchar(50) DEFAULT NULL,
100 `prefix` varchar(30) DEFAULT NULL,
101 `suffix` varchar(30) DEFAULT NULL,
102 `values_list` varchar(160) DEFAULT NULL,
103 `hint` varchar(160) DEFAULT NULL,
104 PRIMARY KEY (idfield)
105 ) $charset_collate COMMENT='Custom Fields Data for WP Directory Kit';";
106
107 dbDelta( $sql );
108
109 $table_name = $wpdb->prefix . 'wdk_listings';
110
111 $sql = "CREATE TABLE IF NOT EXISTS $table_name (
112 `idlisting` int(11) NOT NULL AUTO_INCREMENT,
113 `post_id` int(11) NOT NULL,
114 `transition_id` varchar(100) DEFAULT NULL,
115 `category_id` int(11) DEFAULT NULL,
116 `location_id` int(11) DEFAULT NULL,
117 `is_primary` tinyint(1) DEFAULT NULL,
118 `last_edit_user_id` int(11) DEFAULT NULL,
119 `related_id` int(11) DEFAULT NULL,
120 `is_featured` tinyint(1) DEFAULT NULL,
121 `is_activated` tinyint(1) DEFAULT NULL,
122 `lat` decimal(9,6) DEFAULT NULL,
123 `lng` decimal(9,6) DEFAULT NULL,
124 `address` varchar(200) DEFAULT NULL,
125 `rank` int(11) DEFAULT NULL,
126 `date` datetime DEFAULT NULL,
127 `date_modified` datetime DEFAULT NULL,
128 `date_activated` datetime DEFAULT NULL,
129 `date_rank_expire` datetime DEFAULT NULL,
130 `date_alert` datetime DEFAULT NULL,
131 `date_notify` datetime DEFAULT NULL,
132 `date_repost` datetime DEFAULT NULL,
133 `date_renew` datetime DEFAULT NULL,
134 `date_activation_paid` datetime DEFAULT NULL,
135 `date_featured_paid` datetime DEFAULT NULL,
136 `date_status` datetime DEFAULT NULL,
137 `date_expire` datetime DEFAULT NULL,
138 `status` varchar(45) DEFAULT NULL,
139 `last_edit_ip` varchar(45) DEFAULT NULL,
140 `counter_views` int(11) DEFAULT NULL,
141 `reviews_stars` int(11) DEFAULT NULL,
142 `listing_images` text,
143 `affilate_id` int(11) DEFAULT NULL,
144 `not_notified_user` tinyint(1) DEFAULT NULL,
145 `hubspot_id` varchar(60) DEFAULT NULL,
146 PRIMARY KEY (idlisting),
147 UNIQUE KEY (post_id)
148 ) $charset_collate;";
149
150 dbDelta( $sql );
151
152 $table_name = $wpdb->prefix . 'wdk_listings_fields';
153
154 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
155 `idlistings_fields` int(11) NOT NULL AUTO_INCREMENT,
156 `post_id` int(11) NOT NULL,
157 `lang_code` varchar(8) COLLATE utf8_unicode_ci DEFAULT NULL,
158 PRIMARY KEY (idlistings_fields),
159 UNIQUE KEY (post_id)
160 ) $charset_collate;";
161
162 dbDelta( $sql );
163
164 $table_name = $wpdb->prefix . 'wdk_categories';
165
166 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
167 `idcategory` int(11) NOT NULL AUTO_INCREMENT,
168 `parent_id` int(11) DEFAULT NULL,
169 `page_id` int(11) DEFAULT NULL,
170 `lang_code` varchar(8) DEFAULT NULL,
171 `date` datetime DEFAULT NULL,
172 `parent_path` text,
173 `order_index` int(11) DEFAULT NULL,
174 `level` int(11) DEFAULT NULL,
175 `icon_id` int(11) DEFAULT NULL,
176 `image_id` int(11) DEFAULT NULL,
177 `font_icon_code` varchar(64) DEFAULT NULL,
178 `code` varchar(6) DEFAULT NULL,
179 `hubspot_id` varchar(60) DEFAULT NULL,
180 `category_title` varchar(160) DEFAULT NULL,
181 PRIMARY KEY (idcategory)
182 ) $charset_collate;";
183
184 dbDelta( $sql );
185
186 $table_name = $wpdb->prefix . 'wdk_locations';
187
188 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
189 `idlocation` int(11) NOT NULL AUTO_INCREMENT,
190 `parent_id` int(11) DEFAULT NULL,
191 `page_id` int(11) DEFAULT NULL,
192 `lang_code` varchar(8) DEFAULT NULL,
193 `date` datetime DEFAULT NULL,
194 `parent_path` text,
195 `order_index` int(11) DEFAULT NULL,
196 `level` int(11) DEFAULT NULL,
197 `icon_id` int(11) DEFAULT NULL,
198 `image_id` int(11) DEFAULT NULL,
199 `font_icon_code` varchar(64) DEFAULT NULL,
200 `code` varchar(6) DEFAULT NULL,
201 `hubspot_id` varchar(60) DEFAULT NULL,
202 `location_title` varchar(160) DEFAULT NULL,
203 PRIMARY KEY (idlocation)
204 ) $charset_collate;";
205
206 dbDelta( $sql );
207
208 $table_name = $wpdb->prefix . 'wdk_searchform';
209
210 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
211 `idsearchform` int(11) NOT NULL AUTO_INCREMENT,
212 `date` datetime DEFAULT NULL,
213 `searchform_name` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL,
214 `searchform_json` text COLLATE utf8_unicode_ci,
215 PRIMARY KEY (idsearchform)
216 ) $charset_collate;";
217
218 dbDelta( $sql );
219
220 $table_name = $wpdb->prefix . 'wdk_resultitem';
221
222 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
223 `idresultitem` int(11) NOT NULL AUTO_INCREMENT,
224 `date` datetime DEFAULT NULL,
225 `resultitem_name` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL,
226 `resultitem_json` text COLLATE utf8_unicode_ci,
227 PRIMARY KEY (idresultitem)
228 ) $charset_collate;";
229
230 dbDelta( $sql );
231
232 update_option( 'wdk_db_version', "1" );
233
234 }
235
236 /* version 1.1.0 db install */
237 if ( get_site_option( 'wdk_db_version' ) < '1.2' ) {
238 $table_name = $wpdb->prefix . 'wdk_messages';
239 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
240 `idmessage` int(11) NOT NULL AUTO_INCREMENT,
241 `post_id` int DEFAULT NULL,
242 `date` datetime DEFAULT NULL,
243 `user_id_sender` int DEFAULT NULL,
244 `user_id_receiver` int DEFAULT NULL,
245 `json_object` text,
246 `email_receiver` varchar(100) DEFAULT NULL,
247 `email_sender` varchar(100) DEFAULT NULL,
248 `message` text,
249 `date_from` datetime DEFAULT NULL,
250 `date_to` datetime DEFAULT NULL,
251 `is_readed` tinyint(1) DEFAULT NULL,
252 PRIMARY KEY (idmessage)
253 ) $charset_collate;";
254
255 dbDelta( $sql );
256
257 $table_name = $wpdb->prefix . 'wdk_listings_users';
258 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
259 `idlistings_users` int(11) NOT NULL AUTO_INCREMENT,
260 `post_id` int DEFAULT NULL,
261 `user_id` int DEFAULT NULL,
262 PRIMARY KEY (idlistings_users)
263 ) $charset_collate;";
264
265 dbDelta( $sql );
266 /* udpate option with db version */
267 }
268
269 /* version 1.2.0 db install */
270 if ( get_site_option( 'wdk_db_version' ) < '1.3' ) {
271
272 $table_name = $wpdb->prefix . 'wdk_categories';
273 $wpdb->query($wpdb->prepare("ALTER TABLE `{$table_name}` CHANGE `parent_id` `parent_id` INT(11) NULL DEFAULT %d;", 0));
274
275 self::$db_version = 1.3;
276 /* udpate option with db version */
277 }
278
279 /* version 1.2.0 db install */
280 if ( get_site_option( 'wdk_db_version' ) < '1.4' ) {
281
282 $table_name = $wpdb->prefix . 'wdk_listings';
283 $wpdb->query($wpdb->prepare(
284 "ALTER TABLE `{$table_name}` ADD `is_approved` INT(1) NULL DEFAULT NULL AFTER `is_activated`;"
285 ));
286
287 $wpdb->query($wpdb->prepare(
288 "UPDATE `{$table_name}` SET `is_approved` = %d",
289 1
290 ));
291
292
293 self::$db_version = 1.4;
294 /* udpate option with db version */
295 }
296
297 if ( get_site_option( 'wdk_db_version' ) < '1.5' ) {
298
299 $table_name = $wpdb->prefix . 'wdk_listings';
300 $wpdb->query($wpdb->prepare(
301 "ALTER TABLE `{$table_name}` ADD `date_package_expire` DATETIME NULL AFTER `hubspot_id`, ADD `package_id` INT NULL AFTER `date_package_expire`;"
302 ));
303
304
305 self::$db_version = 1.5;
306 /* udpate option with db version */
307 }
308
309 if ( get_site_option( 'wdk_db_version' ) < '1.6' ) {
310
311 $table_name = $wpdb->prefix . 'wdk_categories';
312 $wpdb->query($wpdb->prepare(
313 "ALTER TABLE `{$table_name}` ADD `marker_image_id` int(11) DEFAULT NULL"));
314
315
316 self::$db_version = 1.6;
317 /* udpate option with db version */
318 }
319
320 if ( get_site_option( 'wdk_db_version' ) < '1.7' ) {
321
322 $table_name = $wpdb->prefix . 'wdk_listings';
323 $wpdb->query($wpdb->prepare(
324 "ALTER TABLE `{$table_name}` ADD `listing_images_path` VARCHAR(200) DEFAULT ''"
325 ));
326
327
328 // TODO: this column content should be generated based on listing_images or old client may have issues after update
329
330 self::$db_version = 1.7;
331 /* udpate option with db version */
332 }
333
334 if ( get_site_option( 'wdk_db_version' ) < '1.8' ) {
335
336 $table_name = $wpdb->prefix . 'wdk_listings';
337 $wpdb->query($wpdb->prepare(
338 "ALTER TABLE `{$table_name}` ADD `subscription_id` INT NULL;"
339 ));
340
341
342 self::$db_version = 1.8;
343 /* udpate option with db version */
344 }
345
346 if ( get_site_option( 'wdk_db_version' ) < '1.9' ) {
347
348 $table_name = $wpdb->prefix . 'wdk_fields';
349 $wpdb->query($wpdb->prepare(
350 "ALTER TABLE `{$table_name}` ADD `is_price_format` tinyint(1) DEFAULT NULL;"
351 ));
352
353
354 self::$db_version = 1.9;
355 /* udpate option with db version */
356 }
357
358 if ( get_site_option( 'wdk_db_version' ) < '2.0' ) {
359
360 $table_name = $wpdb->prefix . 'wdk_resultitem';
361 $wpdb->query($wpdb->prepare(
362 "ALTER TABLE `{$table_name}` ADD `is_multiline_enabled` tinyint(1) DEFAULT NULL;"
363 ));
364
365
366 self::$db_version = 2.0;
367 /* udpate option with db version */
368 }
369
370 if ( get_site_option( 'wdk_db_version' ) < '2.1' ) {
371
372 $table_name = $wpdb->prefix . 'wdk_listings';
373 $wpdb->query($wpdb->prepare(
374 "ALTER TABLE `{$table_name}` ADD `user_id_editor` INT DEFAULT NULL;"
375 ));
376
377 $table_user_name = $wpdb->prefix . 'wdk_listings_users';
378
379 /* copy agents to new column */
380 $wpdb->query($wpdb->prepare(
381 "UPDATE %1\$s table_listings, %2\$s table_users
382 SET table_listings.user_id_editor = table_users.user_id
383 WHERE table_listings.post_id = table_users.post_id;",
384 $table_name,
385 $table_user_name
386 ));
387
388 $wpdb->query($wpdb->prepare(
389 "TRUNCATE TABLE `{$table_name}`"
390 ));
391
392
393 self::$db_version = 2.1;
394 /* udpate option with db version */
395 }
396
397 if ( get_site_option( 'wdk_db_version' ) < '2.2' ) {
398
399 $table_name = $wpdb->prefix . 'wdk_locations';
400 $wpdb->query($wpdb->prepare(
401 "ALTER TABLE `{$table_name}` ADD `level_0_id` INT DEFAULT NULL;"
402 ));
403
404 $table_name = $wpdb->prefix . 'wdk_categories';
405 $wpdb->query($wpdb->prepare(
406 "ALTER TABLE `{$table_name}` ADD `level_0_id` INT DEFAULT NULL;"
407 ));
408
409 $table_name = $wpdb->prefix . 'wdk_listings_locations';
410 $sql = $wpdb->prepare(
411 "CREATE TABLE IF NOT EXISTS `{$table_name}` (
412 `idlistings_locations` int(11) NOT NULL AUTO_INCREMENT,
413 `location_id` int DEFAULT NULL,
414 `post_id` int DEFAULT NULL,
415 PRIMARY KEY (idlistings_locations)
416 ) $charset_collate;"
417 );
418 dbDelta( $sql );
419
420 $table_name = $wpdb->prefix . 'wdk_listings_categories';
421 $sql = $wpdb->prepare(
422 "CREATE TABLE IF NOT EXISTS `{$table_name}` (
423 `idlistings_categories` int(11) NOT NULL AUTO_INCREMENT,
424 `category_id` int DEFAULT NULL,
425 `post_id` int DEFAULT NULL,
426 PRIMARY KEY (idlistings_categories)
427 ) $charset_collate;"
428 );
429 dbDelta( $sql );
430
431
432
433
434 self::$db_version = 2.2;
435 /* udpate option with db version */
436 }
437
438 if ( get_site_option( 'wdk_db_version' ) < '2.3' ) {
439
440 $table_name = $wpdb->prefix . 'wdk_listings';
441 $wpdb->query($wpdb->prepare(
442 "ALTER TABLE `{$table_name}` ADD `listing_plans_documents` text DEFAULT '';"
443 ));
444
445
446 self::$db_version = 2.3;
447 /* udpate option with db version */
448 }
449
450 if ( get_site_option( 'wdk_db_version' ) < '2.4' ) {
451
452 $table_name = $wpdb->prefix . 'wdk_resultitem';
453 $wpdb->query($wpdb->prepare(
454 "ALTER TABLE `{$table_name}` ADD `is_label_disable` INT(1) NULL DEFAULT NULL"
455 ));
456
457
458 self::$db_version = 2.4;
459 /* udpate option with db version */
460 }
461
462 if ( get_site_option( 'wdk_db_version' ) < '2.5' ) {
463
464 $table_name = $wpdb->prefix . 'wdk_listings';
465 $wpdb->query($wpdb->prepare(
466 "ALTER TABLE `{$table_name}` ADD `categories_list` VARCHAR(128) DEFAULT ''"
467 ));
468
469 $wpdb->query($wpdb->prepare(
470 "ALTER TABLE `{$table_name}` ADD `locations_list` VARCHAR(128) DEFAULT ''"
471 ));
472
473
474
475 self::$db_version = 2.5;
476 /* udpate option with db version */
477 }
478
479 if ( get_site_option( 'wdk_db_version' ) < '2.6' ) {
480
481 $table_name = $wpdb->prefix . 'wdk_fields';
482 $wpdb->query($wpdb->prepare(
483 "UPDATE `{$table_name}` SET `is_visible_frontend` = %d",
484 1
485 ));
486
487
488
489 self::$db_version = 2.6;
490 /* udpate option with db version */
491 }
492
493 if ( get_site_option( 'wdk_db_version' ) < '2.7' ) {
494 $table_name = $wpdb->prefix . 'wdk_listings';
495 $wpdb->query($wpdb->prepare(
496 "ALTER TABLE `{$table_name}` ADD `listing_images_path_medium` VARCHAR(250) DEFAULT ''"
497 ));
498
499
500 self::$db_version = 2.7;
501 /* udpate option with db version */
502 }
503
504 if ( get_site_option( 'wdk_db_version' ) < '2.8' ) {
505 // Main table for visited pages
506
507 $table_name = $wpdb->prefix . 'wdk_dependfields';
508
509 $sql = $sql = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
510 `iddependfields` int(11) NOT NULL AUTO_INCREMENT,
511 `main_field` varchar(60) DEFAULT '',
512 `field_id` int(11) DEFAULT NULL,
513 `hidden_fields_list` varchar(256) DEFAULT '',
514 `date` datetime DEFAULT NULL,
515 PRIMARY KEY (iddependfields)
516 ) $charset_collate";
517
518 dbDelta( $sql );
519
520 self::$db_version = 2.8;
521 /* udpate option with db version */
522 }
523
524 if ( get_site_option( 'wdk_db_version' ) < '2.9' ) {
525 // Main table for visited pages
526 global $wpdb;
527 $table_name = $wpdb->prefix . 'wdk_fields';
528 $wpdb->query($wpdb->prepare(
529 "UPDATE `{$table_name}` SET is_price_format = %d WHERE (idfield=%d OR idfield=%d) AND field_type=%s",
530 1,
531 6,
532 7,
533 'NUMBER'
534 ));
535
536 self::$db_version = 2.9;
537 /* udpate option with db version */
538 }
539
540 if ( get_site_option( 'wdk_db_version' ) < '3.0' ) {
541
542 $table_name = $wpdb->prefix . 'wdk_fields';
543
544 $wpdb->query($wpdb->prepare(
545 "UPDATE `{$table_name}` SET is_visible_dashboard = %d",
546 1
547 ));
548
549
550 self::$db_version = 3.0;
551 /* udpate option with db version */
552 }
553
554 if ( get_site_option( 'wdk_db_version' ) < '3.1' ) {
555
556 $table_name = $wpdb->prefix . 'wdk_locations';
557 $wpdb->query($wpdb->prepare(
558 "ALTER TABLE `{$table_name}` ADD `icon_path` VARCHAR(100) DEFAULT ''"
559 ));
560 $wpdb->query($wpdb->prepare(
561 "ALTER TABLE `{$table_name}` ADD `image_path` VARCHAR(100) DEFAULT ''"
562 ));
563
564 $table_name = $wpdb->prefix . 'wdk_categories';
565 $wpdb->query($wpdb->prepare(
566 "ALTER TABLE `{$table_name}` ADD `icon_path` VARCHAR(100) DEFAULT ''"
567 ));
568 $wpdb->query($wpdb->prepare(
569 "ALTER TABLE `{$table_name}` ADD `image_path` VARCHAR(100) DEFAULT ''"
570 ));
571 $wpdb->query($wpdb->prepare(
572 "ALTER TABLE `{$table_name}` ADD `marker_image_path` VARCHAR(100) DEFAULT ''"
573 ));
574
575
576
577 // TODO: this column content should be generated based on listing_images or old client may have issues after update
578
579 self::$db_version = 3.1;
580 /* udpate option with db version */
581 }
582
583 if ( get_site_option( 'wdk_db_version' ) < '3.2' ) {
584 // Main table for visited pages
585
586 $table_name = $wpdb->prefix . 'wdk_token';
587
588 $sql = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
589 `idtoken` int(11) NOT NULL AUTO_INCREMENT,
590 `token` varchar(60) UNIQUE DEFAULT '',
591 `user_id` int(11) DEFAULT NULL,
592 `user_email` varchar(256) DEFAULT '',
593 `expire_date` datetime DEFAULT NULL,
594 `date` datetime DEFAULT NULL,
595 PRIMARY KEY (idtoken)
596 ) $charset_collate";
597
598 dbDelta( $sql );
599
600 self::$db_version = 3.2;
601 /* udpate option with db version */
602 }
603
604 if ( get_site_option( 'wdk_db_version' ) < '3.3' ) {
605 // Main table for visited pages
606
607
608 self::$db_version = 3.3;
609 /* udpate option with db version */
610 }
611
612 if ( get_site_option( 'wdk_db_version' ) < '3.4' ) {
613 // Main table for visited pages
614
615 $table_name = $wpdb->prefix . 'wdk_locations';
616 $wpdb->query($wpdb->prepare(
617 "ALTER TABLE `{$table_name}` ADD `related_svg_map` varchar(64) DEFAULT NULL;"
618 ));
619
620 $table_name = $wpdb->prefix . 'wdk_locations';
621 $wpdb->query($wpdb->prepare(
622 "ALTER TABLE `{$table_name}` ADD `related_svg_map_location` varchar(128) DEFAULT NULL;"
623 ));
624
625 $table_name = $wpdb->prefix . 'wdk_fields';
626 $wpdb->query($wpdb->prepare(
627 "ALTER TABLE `{$table_name}` CHANGE `values_list` `values_list` TEXT NULL DEFAULT NULL;"
628 ));
629
630 self::$db_version = 3.4;
631 /* udpate option with db version */
632 }
633
634 if ( get_site_option( 'wdk_db_version' ) < '3.5' ) {
635 // Main table for visited pages
636
637 $table_name = $wpdb->prefix . 'wdk_categories';
638 $wpdb->query($wpdb->prepare(
639 "ALTER TABLE `{$table_name}` ADD `category_color` varchar(32) DEFAULT NULL;"
640 ));
641
642 $table_name = $wpdb->prefix . 'wdk_fields';
643 $wpdb->query($wpdb->prepare(
644 "ALTER TABLE `{$table_name}` ADD `validation` varchar(64) DEFAULT NULL;"
645 ));
646
647 $table_name = $wpdb->prefix . 'wdk_fields';
648 $wpdb->query($wpdb->prepare(
649 "ALTER TABLE `{$table_name}` ADD `min_length` INT(3) DEFAULT NULL;"
650 ));
651
652 $table_name = $wpdb->prefix . 'wdk_listings';
653 $wpdb->query($wpdb->prepare(
654 "ALTER TABLE `{$table_name}` CHANGE `listing_images_path` `listing_images_path` TEXT DEFAULT '';"
655 ));
656
657 $table_name = $wpdb->prefix . 'wdk_listings';
658 $wpdb->query($wpdb->prepare(
659 "ALTER TABLE `{$table_name}` CHANGE `listing_images_path_medium` `listing_images_path_medium` TEXT DEFAULT '';"
660 ));
661
662 self::$db_version = 3.5;
663 /* udpate option with db version */
664 }
665
666 if ( get_site_option( 'wdk_db_version' ) < '3.6' ) {
667
668 $table_name = $wpdb->prefix . 'wdk_fields';
669
670 $wpdb->query($wpdb->prepare(
671 "UPDATE `{$table_name}` SET `is_visible_dashboard` = '1'"
672 ));
673
674 $table_name = $wpdb->prefix . 'wdk_listings';
675 $wpdb->query($wpdb->prepare(
676 "ALTER TABLE `{$table_name}` CHANGE `locations_list` `locations_list` TEXT DEFAULT '';"
677 ));
678
679 $table_name = $wpdb->prefix . 'wdk_listings';
680 $wpdb->query($wpdb->prepare(
681 "ALTER TABLE `{$table_name}` CHANGE `categories_list` `categories_list` TEXT DEFAULT '';"
682 ));
683
684 self::$db_version = 3.6;
685 /* udpate option with db version */
686 }
687
688 if ( get_site_option( 'wdk_db_version' ) < '3.7' ) {
689
690 $table_name = $wpdb->prefix . 'wdk_fields';
691
692 $wpdb->query($wpdb->prepare(
693 "ALTER TABLE `{$table_name}` ADD `placeholder` varchar(128) DEFAULT NULL;"
694 ));
695
696 self::$db_version = 3.7;
697 /* udpate option with db version */
698 }
699
700 if ( get_site_option( 'wdk_db_version' ) < '3.8' ) {
701
702 $table_name = $wpdb->prefix . 'wdk_messages';
703 $wpdb->query($wpdb->prepare(
704 "ALTER TABLE `{$table_name}` ADD `is_notified` tinyint(1) DEFAULT NULL; "
705 ));
706
707 self::$db_version = 3.8;
708 /* udpate option with db version */
709 }
710
711 if ( get_site_option( 'wdk_db_version' ) < '3.9' ) {
712
713 $table_name = $wpdb->prefix . 'wdk_users';
714
715 $sql = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
716 `idusers` int(11) NOT NULL AUTO_INCREMENT,
717 `cacheduser_user_id` int(11) DEFAULT NULL,
718 `cacheduser_profile_url` text DEFAULT NULL,
719 `cacheduser_display_name` text DEFAULT NULL,
720 `cacheduser_email` text DEFAULT NULL,
721 `cacheduser_avatar_url` text DEFAULT NULL,
722 `cacheduser_wdk_address` text DEFAULT NULL,
723 `cacheduser_wdk_phone` text DEFAULT NULL,
724 `cacheduser_wdk_city` text DEFAULT NULL,
725 `cacheduser_wdk_company_name` text DEFAULT NULL,
726 `cacheduser_wdk_facebook` text DEFAULT NULL,
727 `cacheduser_wdk_youtube` text DEFAULT NULL,
728 `cacheduser_wdk_linkedin` text DEFAULT NULL,
729 `cacheduser_wdk_twitter` text DEFAULT NULL,
730 `cacheduser_wdk_instagram` text DEFAULT NULL,
731 `cacheduser_wdk_whatsapp` text DEFAULT NULL,
732 `cacheduser_wdk_viber` text DEFAULT NULL,
733 `cacheduser_wdk_iban` text DEFAULT NULL,
734 `cacheduser_wdk_position_title` text DEFAULT NULL,
735 `cacheduser_wdk_telegram` text DEFAULT NULL,
736 `cacheduser_roles` text DEFAULT NULL,
737 `cacheduser_description` text DEFAULT NULL,
738 `cacheduser_user_url` text DEFAULT NULL,
739 `cacheduser_json_data` text DEFAULT NULL,
740 `cacheduser_date_updated` datetime DEFAULT NULL,
741 PRIMARY KEY (idusers)
742 ) $charset_collate;";
743
744 dbDelta( $sql );
745
746 self::$db_version = 3.9;
747 /* udpate option with db version */
748 }
749
750 if ( get_site_option( 'wdk_db_version' ) < '4.0' ) {
751
752 $table_name = $wpdb->prefix . 'wdk_listings';
753 $wpdb->query($wpdb->prepare(
754 "ALTER TABLE `{$table_name}` ADD `listing_related_ids` VARCHAR(512) DEFAULT ''"
755 ));
756
757 $wpdb->query($wpdb->prepare(
758 "ALTER TABLE `{$table_name}` ADD `sublisting_order` INT(11) DEFAULT NULL"
759 ));
760
761 $wpdb->query($wpdb->prepare(
762 "ALTER TABLE `{$table_name}` ADD `listing_parent_post_id` INT(11) DEFAULT NULL"
763 ));
764
765 /* disable elmentor experement feature */
766 update_option( 'elementor_experiment-landing-pages', 'inactive' );
767 update_option( 'elementor_experiment-e_dom_optimization', 'inactive');
768
769 self::$db_version = 4.0;
770 /* udpate option with db version */
771 }
772
773 if ( get_site_option( 'wdk_db_version' ) < '4.1' ) {
774
775 $table_name = $wpdb->prefix . 'wdk_dependfields';
776 $wpdb->query($wpdb->prepare(
777 "ALTER TABLE `{$table_name}` CHANGE `hidden_fields_list` `hidden_fields_list` TEXT NULL DEFAULT NULL;"
778 ));
779
780 self::$db_version = 4.1;
781 /* udpate option with db version */
782 }
783
784 if ( get_site_option( 'wdk_db_version' ) < '4.2' ) {
785
786 self::$db_version = 4.2;
787 /* udpate option with db version */
788 }
789
790 if ( get_site_option( 'wdk_db_version' ) < '4.3' ) {
791 $table_name = $wpdb->prefix . 'wdk_editlog';
792
793 $sql = $wpdb->prepare(
794 "CREATE TABLE IF NOT EXISTS `{$table_name}` (
795 `ideditlog` int(11) NOT NULL AUTO_INCREMENT,
796 `post_id` int(11) DEFAULT NULL,
797 `user_id` int(11) DEFAULT NULL,
798 `date` datetime DEFAULT NULL,
799 `ip` text DEFAULT NULL,
800 `comment` text DEFAULT NULL,
801 PRIMARY KEY (ideditlog)
802 ) $charset_collate;"
803 );
804
805 dbDelta( $sql );
806 self::$db_version = 4.3;
807 /* udpate option with db version */
808 }
809
810 if ( get_site_option( 'wdk_db_version' ) < '4.4' ) {
811
812 /* disable elmentor experement feature */
813 update_option( 'elementor_experiment-e_font_icon_svg', 'inactive');
814
815 self::$db_version = 4.4;
816 /* udpate option with db version */
817 }
818
819 if ( get_site_option( 'wdk_db_version' ) < '4.5' ) {
820
821 /* disable elmentor experement feature */
822 update_option( 'wdk_is_featured_enabled', '1');
823 update_option( 'wdk_is_rank_enabled', '1');
824 update_option( 'wdk_is_user_editor_enabled', '1');
825 update_option( 'wdk_is_post_content_enable', '1');
826 update_option( 'wdk_is_alt_agent_enabled', '1');
827
828 $table_name = $wpdb->prefix . 'wdk_users';
829 $wpdb->query($wpdb->prepare(
830 "ALTER TABLE `{$table_name}` ADD `cacheduser_agency_name` text DEFAULT ''"
831 ));
832
833 self::$db_version = 4.5;
834 /* udpate option with db version */
835 }
836
837 if ( get_site_option( 'wdk_db_version' ) < '4.6' ) {
838
839 $table_name = $wpdb->prefix . 'wdk_fields';
840 $wpdb->query($wpdb->prepare(
841 "ALTER TABLE `{$table_name}` ADD `empty_value` text DEFAULT ''"
842 ));
843
844 self::$db_version = 4.6;
845 /* udpate option with db version */
846 }
847
848 if ( get_site_option( 'wdk_db_version' ) < '4.7' ) {
849
850 $table_name = $wpdb->prefix . 'wdk_fields';
851 $wpdb->query($wpdb->prepare(
852 "ALTER TABLE `{$table_name}` ADD `date_format` text DEFAULT ''"
853 ));
854
855 self::$db_version = 4.7;
856 /* udpate option with db version */
857 }
858
859 if ( get_site_option( 'wdk_db_version' ) < '4.8' ) {
860
861 $table_name = $wpdb->prefix . 'wdk_categories';
862 $wpdb->query($wpdb->prepare(
863 "ALTER TABLE `{$table_name}` ADD `titles_for_search` text DEFAULT '';"
864 ));
865
866 $table_name = $wpdb->prefix . 'wdk_locations';
867 $wpdb->query($wpdb->prepare(
868 "ALTER TABLE `{$table_name}` ADD `titles_for_search` text DEFAULT '';"
869 ));
870
871 self::$db_version = 4.8;
872 /* udpate option with db version */
873 }
874
875 if ( get_site_option( 'wdk_db_version' ) < '4.9' ) {
876
877 $table_name = $wpdb->prefix . 'wdk_users';
878 $wpdb->query($wpdb->prepare(
879 "ALTER TABLE `{$table_name}` ADD `cacheduser_user_login` text DEFAULT ''"
880 ));
881
882 $wpdb->query($wpdb->prepare(
883 "ALTER TABLE `{$table_name}` ADD `cacheduser_wdk_slug` text DEFAULT ''"
884 ));
885
886 self::$db_version = 4.9;
887 /* udpate option with db version */
888 }
889
890
891 if ( get_site_option( 'wdk_db_version' ) < '5.0' ) {
892
893 $table_name = $wpdb->prefix . 'wdk_fields';
894 $wpdb->query($wpdb->prepare(
895 "ALTER TABLE `{$table_name}` ADD `autosuggestion` varchar(64) DEFAULT NULL;"
896 ));
897
898 self::$db_version = 5.0;
899 /* udpate option with db version */
900 }
901
902 if ( get_site_option( 'wdk_db_version' ) < '5.1' ) {
903
904 $table_name = $wpdb->prefix . 'wdk_resultitem';
905 $wpdb->query($wpdb->prepare(
906 "ALTER TABLE `{$table_name}` ADD `is_show_agent_details` INT(1) NULL DEFAULT NULL"
907 ));
908
909 $table_name = $wpdb->prefix . 'wdk_listings';
910 $wpdb->query($wpdb->prepare(
911 "ALTER TABLE `{$table_name}` ADD `user_id_editor_display_name` VARCHAR(128) DEFAULT ''"
912 ));
913
914 $wpdb->query($wpdb->prepare(
915 "ALTER TABLE `{$table_name}` ADD `user_id_editor_user_login` VARCHAR(128) DEFAULT ''"
916 ));
917
918 $wpdb->query($wpdb->prepare(
919 "ALTER TABLE `{$table_name}` ADD `user_id_editor_wdk_slug` VARCHAR(128) DEFAULT ''"
920 ));
921
922 $wpdb->query($wpdb->prepare(
923 "ALTER TABLE `{$table_name}` ADD `user_id_editor_avatar` VARCHAR(256) DEFAULT ''"
924 ));
925
926 self::$db_version = 5.1;
927 /* udpate option with db version */
928 }
929
930 if ( get_site_option( 'wdk_db_version' ) < '5.2' ) {
931
932 $table_name = $wpdb->prefix . 'wdk_listings';
933 $wpdb->query($wpdb->prepare(
934 "ALTER TABLE `{$table_name}` ADD `counter_results_views` INT(111) DEFAULT 0"
935 ));
936
937 self::$db_version = 5.2;
938 /* udpate option with db version */
939 }
940
941 if ( get_site_option( 'wdk_db_version' ) < '5.3' ) {
942 update_option( 'wdk_enable_filter_zero_decimal', '1');
943
944 self::$db_version = 5.3;
945 /* udpate option with db version */
946 }
947
948 update_option( 'wdk_db_version', self::$db_version );
949 }
950 }