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

870 lines 34.6 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 $sql = "ALTER TABLE `$table_name` CHANGE `parent_id` `parent_id` INT(11) NULL DEFAULT '0'; ";
274 $wpdb->query($sql);
275
276 self::$db_version = 1.3;
277 /* udpate option with db version */
278 }
279
280 /* version 1.2.0 db install */
281 if ( get_site_option( 'wdk_db_version' ) < '1.4' ) {
282
283 $table_name = $wpdb->prefix . 'wdk_listings';
284 $sql = "ALTER TABLE `$table_name` ADD `is_approved` INT(1) NULL DEFAULT NULL AFTER `is_activated`; ";
285 $wpdb->query($sql);
286
287 $sql = "UPDATE `$table_name` SET `is_approved` = '1'";
288 $wpdb->query($sql);
289
290 self::$db_version = 1.4;
291 /* udpate option with db version */
292 }
293
294 if ( get_site_option( 'wdk_db_version' ) < '1.5' ) {
295
296 $table_name = $wpdb->prefix . 'wdk_listings';
297 $sql = "ALTER TABLE `$table_name` ADD `date_package_expire` DATETIME NULL AFTER `hubspot_id`, ADD `package_id` INT NULL AFTER `date_package_expire`; ";
298 $wpdb->query($sql);
299
300 self::$db_version = 1.5;
301 /* udpate option with db version */
302 }
303
304 if ( get_site_option( 'wdk_db_version' ) < '1.6' ) {
305
306 $table_name = $wpdb->prefix . 'wdk_categories';
307 $sql = "ALTER TABLE `$table_name` ADD `marker_image_id` int(11) DEFAULT NULL";
308 $wpdb->query($sql);
309
310 self::$db_version = 1.6;
311 /* udpate option with db version */
312 }
313
314 if ( get_site_option( 'wdk_db_version' ) < '1.7' ) {
315
316 $table_name = $wpdb->prefix . 'wdk_listings';
317 $sql = "ALTER TABLE `$table_name` ADD `listing_images_path` VARCHAR(200) DEFAULT ''";
318 $wpdb->query($sql);
319
320 // TODO: this column content should be generated based on listing_images or old client may have issues after update
321
322 self::$db_version = 1.7;
323 /* udpate option with db version */
324 }
325
326 if ( get_site_option( 'wdk_db_version' ) < '1.8' ) {
327
328 $table_name = $wpdb->prefix . 'wdk_listings';
329 $sql = "ALTER TABLE `$table_name` ADD `subscription_id` INT NULL; ";
330 $wpdb->query($sql);
331
332 self::$db_version = 1.8;
333 /* udpate option with db version */
334 }
335
336 if ( get_site_option( 'wdk_db_version' ) < '1.9' ) {
337
338 $table_name = $wpdb->prefix . 'wdk_fields';
339 $sql = "ALTER TABLE `$table_name` ADD `is_price_format` tinyint(1) DEFAULT NULL; ";
340 $wpdb->query($sql);
341
342 self::$db_version = 1.9;
343 /* udpate option with db version */
344 }
345
346 if ( get_site_option( 'wdk_db_version' ) < '2.0' ) {
347
348 $table_name = $wpdb->prefix . 'wdk_resultitem';
349 $sql = "ALTER TABLE `$table_name` ADD `is_multiline_enabled` tinyint(1) DEFAULT NULL; ";
350 $wpdb->query($sql);
351
352 self::$db_version = 2.0;
353 /* udpate option with db version */
354 }
355
356 if ( get_site_option( 'wdk_db_version' ) < '2.1' ) {
357
358 $table_name = $wpdb->prefix . 'wdk_listings';
359 $sql = "ALTER TABLE `$table_name` ADD `user_id_editor` INT DEFAULT NULL;";
360 $wpdb->query($sql);
361
362 $table_user_name = $wpdb->prefix . 'wdk_listings_users';
363
364 /* copy agents to new column */
365 $sql = "UPDATE
366 `$table_name` table_listings ,
367 `$table_user_name` table_users
368 SET
369 table_listings.user_id_editor = table_users.user_id
370 WHERE
371 table_listings.post_id = table_users.post_id;";
372 $wpdb->query($sql);
373
374 $sql = "TRUNCATE TABLE `$table_user_name`";
375 $wpdb->query($sql);
376
377 self::$db_version = 2.1;
378 /* udpate option with db version */
379 }
380
381 if ( get_site_option( 'wdk_db_version' ) < '2.2' ) {
382
383 $table_name = $wpdb->prefix . 'wdk_locations';
384 $sql = "ALTER TABLE `$table_name` ADD `level_0_id` INT DEFAULT NULL;";
385 $wpdb->query($sql);
386
387 $table_name = $wpdb->prefix . 'wdk_categories';
388 $sql = "ALTER TABLE `$table_name` ADD `level_0_id` INT DEFAULT NULL;";
389 $wpdb->query($sql);
390
391
392 $table_name = $wpdb->prefix . 'wdk_listings_locations';
393 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
394 `idlistings_locations` int(11) NOT NULL AUTO_INCREMENT,
395 `location_id` int DEFAULT NULL,
396 `post_id` int DEFAULT NULL,
397 PRIMARY KEY (idlistings_locations)
398 ) $charset_collate;";
399 dbDelta( $sql );
400
401 $table_name = $wpdb->prefix . 'wdk_listings_categories';
402 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
403 `idlistings_categories` int(11) NOT NULL AUTO_INCREMENT,
404 `category_id` int DEFAULT NULL,
405 `post_id` int DEFAULT NULL,
406 PRIMARY KEY (idlistings_categories)
407 ) $charset_collate;";
408 dbDelta( $sql );
409
410
411 self::$db_version = 2.2;
412 /* udpate option with db version */
413 }
414
415 if ( get_site_option( 'wdk_db_version' ) < '2.3' ) {
416
417 $table_name = $wpdb->prefix . 'wdk_listings';
418 $sql = "ALTER TABLE `$table_name` ADD `listing_plans_documents` text DEFAULT '';";
419 $wpdb->query($sql);
420
421 self::$db_version = 2.3;
422 /* udpate option with db version */
423 }
424
425 if ( get_site_option( 'wdk_db_version' ) < '2.4' ) {
426
427 $table_name = $wpdb->prefix . 'wdk_resultitem';
428 $sql = "ALTER TABLE `$table_name` ADD `is_label_disable` INT(1) NULL DEFAULT NULL";
429 $wpdb->query($sql);
430
431 self::$db_version = 2.4;
432 /* udpate option with db version */
433 }
434
435 if ( get_site_option( 'wdk_db_version' ) < '2.5' ) {
436
437 $table_name = $wpdb->prefix . 'wdk_listings';
438 $sql = "ALTER TABLE `$table_name` ADD `categories_list` VARCHAR(128) DEFAULT ''";
439 $wpdb->query($sql);
440
441 $table_name = $wpdb->prefix . 'wdk_listings';
442 $sql = "ALTER TABLE `$table_name` ADD `locations_list` VARCHAR(128) DEFAULT ''";
443 $wpdb->query($sql);
444
445
446 self::$db_version = 2.5;
447 /* udpate option with db version */
448 }
449
450 if ( get_site_option( 'wdk_db_version' ) < '2.6' ) {
451
452 $table_name = $wpdb->prefix . 'wdk_fields';
453
454 $sql = "UPDATE `$table_name` SET `is_visible_frontend` = '1'";
455 $wpdb->query($sql);
456
457 self::$db_version = 2.6;
458 /* udpate option with db version */
459 }
460
461 if ( get_site_option( 'wdk_db_version' ) < '2.7' ) {
462 $table_name = $wpdb->prefix . 'wdk_listings';
463 $sql = "ALTER TABLE `$table_name` ADD `listing_images_path_medium` VARCHAR(250) DEFAULT ''";
464 $wpdb->query($sql);
465
466 self::$db_version = 2.7;
467 /* udpate option with db version */
468 }
469
470 if ( get_site_option( 'wdk_db_version' ) < '2.8' ) {
471 // Main table for visited pages
472
473 $table_name = $wpdb->prefix . 'wdk_dependfields';
474
475 $sql = "CREATE TABLE IF NOT EXISTS $table_name (
476 `iddependfields` int(11) NOT NULL AUTO_INCREMENT,
477 `main_field` varchar(60) DEFAULT '',
478 `field_id` int(11) DEFAULT NULL,
479 `hidden_fields_list` varchar(256) DEFAULT '',
480 `date` datetime DEFAULT NULL,
481 PRIMARY KEY (iddependfields)
482 ) $charset_collate";
483
484 dbDelta( $sql );
485
486 self::$db_version = 2.8;
487 /* udpate option with db version */
488 }
489
490 if ( get_site_option( 'wdk_db_version' ) < '2.9' ) {
491 // Main table for visited pages
492 global $wpdb;
493 $wpdb->query('UPDATE '.$wpdb->prefix . 'wdk_fields SET is_price_format = 1 WHERE (idfield=6 OR idfield=7) AND field_type="NUMBER"');
494 self::$db_version = 2.9;
495 /* udpate option with db version */
496 }
497
498 if ( get_site_option( 'wdk_db_version' ) < '3.0' ) {
499
500 $table_name = $wpdb->prefix . 'wdk_fields';
501
502 $sql = "UPDATE `$table_name` SET `is_visible_dashboard` = '1'";
503 $wpdb->query($sql);
504
505 self::$db_version = 3.0;
506 /* udpate option with db version */
507 }
508
509 if ( get_site_option( 'wdk_db_version' ) < '3.1' ) {
510
511 $table_name = $wpdb->prefix . 'wdk_locations';
512 $sql = "ALTER TABLE `$table_name` ADD `icon_path` VARCHAR(100) DEFAULT ''";
513 $wpdb->query($sql);
514 $sql = "ALTER TABLE `$table_name` ADD `image_path` VARCHAR(100) DEFAULT ''";
515 $wpdb->query($sql);
516
517 $table_name = $wpdb->prefix . 'wdk_categories';
518 $sql = "ALTER TABLE `$table_name` ADD `icon_path` VARCHAR(100) DEFAULT ''";
519 $wpdb->query($sql);
520 $sql = "ALTER TABLE `$table_name` ADD `image_path` VARCHAR(100) DEFAULT ''";
521 $wpdb->query($sql);
522 $sql = "ALTER TABLE `$table_name` ADD `marker_image_path` VARCHAR(100) DEFAULT ''";
523 $wpdb->query($sql);
524
525 // TODO: this column content should be generated based on listing_images or old client may have issues after update
526
527 self::$db_version = 3.1;
528 /* udpate option with db version */
529 }
530
531 if ( get_site_option( 'wdk_db_version' ) < '3.2' ) {
532 // Main table for visited pages
533
534 $table_name = $wpdb->prefix . 'wdk_token';
535
536 $sql = "CREATE TABLE IF NOT EXISTS $table_name (
537 `idtoken` int(11) NOT NULL AUTO_INCREMENT,
538 `token` varchar(60) UNIQUE DEFAULT '',
539 `user_id` int(11) DEFAULT NULL,
540 `user_email` varchar(256) DEFAULT '',
541 `expire_date` datetime DEFAULT NULL,
542 `date` datetime DEFAULT NULL,
543 PRIMARY KEY (idtoken)
544 ) $charset_collate";
545
546 dbDelta( $sql );
547
548 self::$db_version = 3.2;
549 /* udpate option with db version */
550 }
551
552 if ( get_site_option( 'wdk_db_version' ) < '3.3' ) {
553 // Main table for visited pages
554
555
556 self::$db_version = 3.3;
557 /* udpate option with db version */
558 }
559
560 if ( get_site_option( 'wdk_db_version' ) < '3.4' ) {
561 // Main table for visited pages
562
563 $table_name = $wpdb->prefix . 'wdk_locations';
564 $sql = "ALTER TABLE `$table_name` ADD `related_svg_map` varchar(64) DEFAULT NULL;";
565 $wpdb->query($sql);
566
567 $table_name = $wpdb->prefix . 'wdk_locations';
568 $sql = "ALTER TABLE `$table_name` ADD `related_svg_map_location` varchar(128) DEFAULT NULL;";
569 $wpdb->query($sql);
570
571 $table_name = $wpdb->prefix . 'wdk_fields';
572 $sql = "ALTER TABLE `$table_name` CHANGE `values_list` `values_list` TEXT NULL DEFAULT NULL;";
573 $wpdb->query($sql);
574
575 self::$db_version = 3.4;
576 /* udpate option with db version */
577 }
578
579 if ( get_site_option( 'wdk_db_version' ) < '3.5' ) {
580 // Main table for visited pages
581
582 $table_name = $wpdb->prefix . 'wdk_categories';
583 $sql = "ALTER TABLE `$table_name` ADD `category_color` varchar(32) DEFAULT NULL;";
584 $wpdb->query($sql);
585
586 $table_name = $wpdb->prefix . 'wdk_fields';
587 $sql = "ALTER TABLE `$table_name` ADD `validation` varchar(64) DEFAULT NULL;";
588 $wpdb->query($sql);
589
590 $table_name = $wpdb->prefix . 'wdk_fields';
591 $sql = "ALTER TABLE `$table_name` ADD `min_length` INT(3) DEFAULT NULL;";
592 $wpdb->query($sql);
593
594 $table_name = $wpdb->prefix . 'wdk_listings';
595 $sql = "ALTER TABLE `$table_name` CHANGE `listing_images_path` `listing_images_path` TEXT DEFAULT '';";
596 $wpdb->query($sql);
597
598 $table_name = $wpdb->prefix . 'wdk_listings';
599 $sql = "ALTER TABLE `$table_name` CHANGE `listing_images_path_medium` `listing_images_path_medium` TEXT DEFAULT '';";
600 $wpdb->query($sql);
601
602 self::$db_version = 3.5;
603 /* udpate option with db version */
604 }
605
606 if ( get_site_option( 'wdk_db_version' ) < '3.6' ) {
607
608 $table_name = $wpdb->prefix . 'wdk_fields';
609
610 $sql = "UPDATE `$table_name` SET `is_visible_dashboard` = '1'";
611 $wpdb->query($sql);
612
613 $table_name = $wpdb->prefix . 'wdk_listings';
614 $sql = "ALTER TABLE `$table_name` CHANGE `locations_list` `locations_list` TEXT DEFAULT '';";
615 $wpdb->query($sql);
616
617 $table_name = $wpdb->prefix . 'wdk_listings';
618 $sql = "ALTER TABLE `$table_name` CHANGE `categories_list` `categories_list` TEXT DEFAULT '';";
619 $wpdb->query($sql);
620
621 self::$db_version = 3.6;
622 /* udpate option with db version */
623 }
624
625 if ( get_site_option( 'wdk_db_version' ) < '3.7' ) {
626
627 $table_name = $wpdb->prefix . 'wdk_fields';
628
629 $sql = "ALTER TABLE `$table_name` ADD `placeholder` varchar(128) DEFAULT NULL;";
630 $wpdb->query($sql);
631
632 self::$db_version = 3.7;
633 /* udpate option with db version */
634 }
635
636 if ( get_site_option( 'wdk_db_version' ) < '3.8' ) {
637
638 $table_name = $wpdb->prefix . 'wdk_messages';
639 $sql = "ALTER TABLE `$table_name` ADD `is_notified` tinyint(1) DEFAULT NULL; ";
640 $wpdb->query($sql);
641
642 self::$db_version = 3.8;
643 /* udpate option with db version */
644 }
645
646 if ( get_site_option( 'wdk_db_version' ) < '3.9' ) {
647
648 $table_name = $wpdb->prefix . 'wdk_users';
649
650 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
651 `idusers` int(11) NOT NULL AUTO_INCREMENT,
652 `cacheduser_user_id` int(11) DEFAULT NULL,
653 `cacheduser_profile_url` text DEFAULT NULL,
654 `cacheduser_display_name` text DEFAULT NULL,
655 `cacheduser_email` text DEFAULT NULL,
656 `cacheduser_avatar_url` text DEFAULT NULL,
657 `cacheduser_wdk_address` text DEFAULT NULL,
658 `cacheduser_wdk_phone` text DEFAULT NULL,
659 `cacheduser_wdk_city` text DEFAULT NULL,
660 `cacheduser_wdk_company_name` text DEFAULT NULL,
661 `cacheduser_wdk_facebook` text DEFAULT NULL,
662 `cacheduser_wdk_youtube` text DEFAULT NULL,
663 `cacheduser_wdk_linkedin` text DEFAULT NULL,
664 `cacheduser_wdk_twitter` text DEFAULT NULL,
665 `cacheduser_wdk_instagram` text DEFAULT NULL,
666 `cacheduser_wdk_whatsapp` text DEFAULT NULL,
667 `cacheduser_wdk_viber` text DEFAULT NULL,
668 `cacheduser_wdk_iban` text DEFAULT NULL,
669 `cacheduser_wdk_position_title` text DEFAULT NULL,
670 `cacheduser_wdk_telegram` text DEFAULT NULL,
671 `cacheduser_roles` text DEFAULT NULL,
672 `cacheduser_description` text DEFAULT NULL,
673 `cacheduser_user_url` text DEFAULT NULL,
674 `cacheduser_json_data` text DEFAULT NULL,
675 `cacheduser_date_updated` datetime DEFAULT NULL,
676 PRIMARY KEY (idusers)
677 ) $charset_collate;";
678
679 dbDelta( $sql );
680
681 self::$db_version = 3.9;
682 /* udpate option with db version */
683 }
684
685 if ( get_site_option( 'wdk_db_version' ) < '4.0' ) {
686
687 $table_name = $wpdb->prefix . 'wdk_listings';
688 $sql = "ALTER TABLE `$table_name` ADD `listing_related_ids` VARCHAR(512) DEFAULT ''";
689 $wpdb->query($sql);
690
691 $table_name = $wpdb->prefix . 'wdk_listings';
692 $sql = "ALTER TABLE `$table_name` ADD `sublisting_order` INT(11) DEFAULT NULL";
693 $wpdb->query($sql);
694
695 $table_name = $wpdb->prefix . 'wdk_listings';
696 $sql = "ALTER TABLE `$table_name` ADD `listing_parent_post_id` INT(11) DEFAULT NULL";
697 $wpdb->query($sql);
698
699 /* disable elmentor experement feature */
700 update_option( 'elementor_experiment-landing-pages', 'inactive' );
701 update_option( 'elementor_experiment-e_dom_optimization', 'inactive');
702
703 self::$db_version = 4.0;
704 /* udpate option with db version */
705 }
706
707 if ( get_site_option( 'wdk_db_version' ) < '4.1' ) {
708
709 $table_name = $wpdb->prefix . 'wdk_dependfields';
710 $sql = "ALTER TABLE `$table_name` CHANGE `hidden_fields_list` `hidden_fields_list` TEXT NULL DEFAULT NULL;";
711 $wpdb->query($sql);
712
713 self::$db_version = 4.1;
714 /* udpate option with db version */
715 }
716
717 if ( get_site_option( 'wdk_db_version' ) < '4.2' ) {
718
719 self::$db_version = 4.2;
720 /* udpate option with db version */
721 }
722
723 if ( get_site_option( 'wdk_db_version' ) < '4.3' ) {
724 $table_name = $wpdb->prefix . 'wdk_editlog';
725
726 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
727 `ideditlog` int(11) NOT NULL AUTO_INCREMENT,
728 `post_id` int(11) DEFAULT NULL,
729 `user_id` int(11) DEFAULT NULL,
730 `date` datetime DEFAULT NULL,
731 `ip` text DEFAULT NULL,
732 `comment` text DEFAULT NULL,
733 PRIMARY KEY (ideditlog)
734 ) $charset_collate;";
735
736 dbDelta( $sql );
737 self::$db_version = 4.3;
738 /* udpate option with db version */
739 }
740
741 if ( get_site_option( 'wdk_db_version' ) < '4.4' ) {
742
743 /* disable elmentor experement feature */
744 update_option( 'elementor_experiment-e_font_icon_svg', 'inactive');
745
746 self::$db_version = 4.4;
747 /* udpate option with db version */
748 }
749
750 if ( get_site_option( 'wdk_db_version' ) < '4.5' ) {
751
752 /* disable elmentor experement feature */
753 update_option( 'wdk_is_featured_enabled', '1');
754 update_option( 'wdk_is_rank_enabled', '1');
755 update_option( 'wdk_is_user_editor_enabled', '1');
756 update_option( 'wdk_is_post_content_enable', '1');
757 update_option( 'wdk_is_alt_agent_enabled', '1');
758
759 $table_name = $wpdb->prefix . 'wdk_users';
760 $sql = "ALTER TABLE `$table_name` ADD `cacheduser_agency_name` text DEFAULT ''";
761 $wpdb->query($sql);
762
763 self::$db_version = 4.5;
764 /* udpate option with db version */
765 }
766
767 if ( get_site_option( 'wdk_db_version' ) < '4.6' ) {
768
769 $table_name = $wpdb->prefix . 'wdk_fields';
770 $sql = "ALTER TABLE `$table_name` ADD `empty_value` text DEFAULT ''";
771 $wpdb->query($sql);
772
773 self::$db_version = 4.6;
774 /* udpate option with db version */
775 }
776
777 if ( get_site_option( 'wdk_db_version' ) < '4.7' ) {
778
779 $table_name = $wpdb->prefix . 'wdk_fields';
780 $sql = "ALTER TABLE `$table_name` ADD `date_format` text DEFAULT ''";
781 $wpdb->query($sql);
782
783 self::$db_version = 4.7;
784 /* udpate option with db version */
785 }
786
787 if ( get_site_option( 'wdk_db_version' ) < '4.8' ) {
788
789 $table_name = $wpdb->prefix . 'wdk_categories';
790 $sql = "ALTER TABLE `$table_name` ADD `titles_for_search` text DEFAULT '';";
791 $wpdb->query($sql);
792
793 $table_name = $wpdb->prefix . 'wdk_locations';
794 $sql = "ALTER TABLE `$table_name` ADD `titles_for_search` text DEFAULT '';";
795 $wpdb->query($sql);
796
797 self::$db_version = 4.8;
798 /* udpate option with db version */
799 }
800
801 if ( get_site_option( 'wdk_db_version' ) < '4.9' ) {
802
803 $table_name = $wpdb->prefix . 'wdk_users';
804 $sql = "ALTER TABLE `$table_name` ADD `cacheduser_user_login` text DEFAULT ''";
805 $wpdb->query($sql);
806
807 $sql = "ALTER TABLE `$table_name` ADD `cacheduser_wdk_slug` text DEFAULT ''";
808 $wpdb->query($sql);
809
810 self::$db_version = 4.9;
811 /* udpate option with db version */
812 }
813
814
815 if ( get_site_option( 'wdk_db_version' ) < '5.0' ) {
816
817 $table_name = $wpdb->prefix . 'wdk_fields';
818 $sql = "ALTER TABLE `$table_name` ADD `autosuggestion` varchar(64) DEFAULT NULL;";
819 $wpdb->query($sql);
820
821 self::$db_version = 5.0;
822 /* udpate option with db version */
823 }
824
825 if ( get_site_option( 'wdk_db_version' ) < '5.1' ) {
826
827 $table_name = $wpdb->prefix . 'wdk_resultitem';
828 $sql = "ALTER TABLE `$table_name` ADD `is_show_agent_details` INT(1) NULL DEFAULT NULL";
829 $wpdb->query($sql);
830
831 $table_name = $wpdb->prefix . 'wdk_listings';
832 $sql = "ALTER TABLE `$table_name` ADD `user_id_editor_display_name` VARCHAR(128) DEFAULT ''";
833 $wpdb->query($sql);
834
835 $table_name = $wpdb->prefix . 'wdk_listings';
836 $sql = "ALTER TABLE `$table_name` ADD `user_id_editor_user_login` VARCHAR(128) DEFAULT ''";
837 $wpdb->query($sql);
838
839 $table_name = $wpdb->prefix . 'wdk_listings';
840 $sql = "ALTER TABLE `$table_name` ADD `user_id_editor_wdk_slug` VARCHAR(128) DEFAULT ''";
841 $wpdb->query($sql);
842
843 $table_name = $wpdb->prefix . 'wdk_listings';
844 $sql = "ALTER TABLE `$table_name` ADD `user_id_editor_avatar` VARCHAR(256) DEFAULT ''";
845 $wpdb->query($sql);
846
847 self::$db_version = 5.1;
848 /* udpate option with db version */
849 }
850
851 if ( get_site_option( 'wdk_db_version' ) < '5.2' ) {
852
853 $table_name = $wpdb->prefix . 'wdk_listings';
854 $sql = "ALTER TABLE `$table_name` ADD `counter_results_views` INT(111) DEFAULT 0";
855 $wpdb->query($sql);
856
857 self::$db_version = 5.2;
858 /* udpate option with db version */
859 }
860
861 if ( get_site_option( 'wdk_db_version' ) < '5.3' ) {
862 update_option( 'wdk_enable_filter_zero_decimal', '1');
863
864 self::$db_version = 5.3;
865 /* udpate option with db version */
866 }
867
868 update_option( 'wdk_db_version', self::$db_version );
869 }
870 }