Test Failed
Push — master ( c797fe...35af2c )
by Stiofan
21:54
created
geodirectory-admin/admin_db_install.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@  discard block
 block discarded – undo
6 6
  * @package GeoDirectory
7 7
  */
8 8
 if (!function_exists('geodir_create_tables')) {
9
-    /**
10
-     * Creates custom db tables for storing GeoDirectory plugin data.
11
-     *
12
-     * @since 1.0.0
13
-     * @package GeoDirectory
14
-     * @global object $wpdb WordPress Database object.
15
-     * @global string $plugin_prefix GeoDirectory plugin table prefix.
16
-     */
17
-    function geodir_create_tables()
18
-    {
19
-
20
-        global $wpdb, $plugin_prefix;
21
-
22
-        $wpdb->hide_errors();
23
-
24
-        $collate = '';
25
-        if ($wpdb->has_cap('collation')) {
26
-            if (!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
27
-            if (!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
28
-        }
9
+	/**
10
+	 * Creates custom db tables for storing GeoDirectory plugin data.
11
+	 *
12
+	 * @since 1.0.0
13
+	 * @package GeoDirectory
14
+	 * @global object $wpdb WordPress Database object.
15
+	 * @global string $plugin_prefix GeoDirectory plugin table prefix.
16
+	 */
17
+	function geodir_create_tables()
18
+	{
19
+
20
+		global $wpdb, $plugin_prefix;
21
+
22
+		$wpdb->hide_errors();
23
+
24
+		$collate = '';
25
+		if ($wpdb->has_cap('collation')) {
26
+			if (!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
27
+			if (!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
28
+		}
29 29
 
30 30
 		/**
31 31
 		 * Include any functions needed for upgrades.
@@ -36,31 +36,31 @@  discard block
 block discarded – undo
36 36
 
37 37
 
38 38
 // rename tables if we need to
39
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_countries'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_countries'") == 0) {
40
-            $wpdb->query("RENAME TABLE geodir_countries TO " . $wpdb->prefix . "geodir_countries");
41
-        }
42
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_fields'") == 0) {
43
-            $wpdb->query("RENAME TABLE geodir_custom_fields TO " . $wpdb->prefix . "geodir_custom_fields");
44
-        }
45
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_icon'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_icon'") == 0) {
46
-            $wpdb->query("RENAME TABLE geodir_post_icon TO " . $wpdb->prefix . "geodir_post_icon");
47
-        }
48
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_attachments'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_attachments'") == 0) {
49
-            $wpdb->query("RENAME TABLE geodir_attachments TO " . $wpdb->prefix . "geodir_attachments");
50
-        }
51
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_review'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_review'") == 0) {
52
-            $wpdb->query("RENAME TABLE geodir_post_review TO " . $wpdb->prefix . "geodir_post_review");
53
-        }
54
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_sort_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_sort_fields'") == 0) {
55
-            $wpdb->query("RENAME TABLE geodir_custom_sort_fields TO " . $wpdb->prefix . "geodir_custom_sort_fields");
56
-        }
57
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_gd_place_detail'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_gd_place_detail'") == 0) {
58
-            $wpdb->query("RENAME TABLE geodir_gd_place_detail TO " . $wpdb->prefix . "geodir_gd_place_detail");
59
-        }
60
-
61
-
62
-        // Table for storing Countries
63
-        $GEODIR_COUNTRIES_TABLE = "CREATE TABLE " . GEODIR_COUNTRIES_TABLE . " (
39
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_countries'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_countries'") == 0) {
40
+			$wpdb->query("RENAME TABLE geodir_countries TO " . $wpdb->prefix . "geodir_countries");
41
+		}
42
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_fields'") == 0) {
43
+			$wpdb->query("RENAME TABLE geodir_custom_fields TO " . $wpdb->prefix . "geodir_custom_fields");
44
+		}
45
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_icon'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_icon'") == 0) {
46
+			$wpdb->query("RENAME TABLE geodir_post_icon TO " . $wpdb->prefix . "geodir_post_icon");
47
+		}
48
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_attachments'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_attachments'") == 0) {
49
+			$wpdb->query("RENAME TABLE geodir_attachments TO " . $wpdb->prefix . "geodir_attachments");
50
+		}
51
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_review'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_review'") == 0) {
52
+			$wpdb->query("RENAME TABLE geodir_post_review TO " . $wpdb->prefix . "geodir_post_review");
53
+		}
54
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_sort_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_sort_fields'") == 0) {
55
+			$wpdb->query("RENAME TABLE geodir_custom_sort_fields TO " . $wpdb->prefix . "geodir_custom_sort_fields");
56
+		}
57
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_gd_place_detail'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_gd_place_detail'") == 0) {
58
+			$wpdb->query("RENAME TABLE geodir_gd_place_detail TO " . $wpdb->prefix . "geodir_gd_place_detail");
59
+		}
60
+
61
+
62
+		// Table for storing Countries
63
+		$GEODIR_COUNTRIES_TABLE = "CREATE TABLE " . GEODIR_COUNTRIES_TABLE . " (
64 64
 						CountryId smallint AUTO_INCREMENT NOT NULL ,
65 65
 						Country varchar (50) NOT NULL ,
66 66
 						FIPS104 varchar (2) NOT NULL ,
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
 						Comment varchar (255) NULL ,
80 80
 						PRIMARY KEY  (CountryId)) $collate ";
81 81
 
82
-        /**
83
-         * Filter the SQL query that creates/updates the country DB table structure.
84
-         *
85
-         * @since 1.0.0
86
-         * @param string $sql The SQL insert query string.
87
-         */
88
-        $GEODIR_COUNTRIES_TABLE = apply_filters('geodir_before_country_table_create', $GEODIR_COUNTRIES_TABLE);
89
-        dbDelta($GEODIR_COUNTRIES_TABLE);
82
+		/**
83
+		 * Filter the SQL query that creates/updates the country DB table structure.
84
+		 *
85
+		 * @since 1.0.0
86
+		 * @param string $sql The SQL insert query string.
87
+		 */
88
+		$GEODIR_COUNTRIES_TABLE = apply_filters('geodir_before_country_table_create', $GEODIR_COUNTRIES_TABLE);
89
+		dbDelta($GEODIR_COUNTRIES_TABLE);
90 90
 
91 91
 
92
-        $country_table_empty = $wpdb->get_var("SELECT COUNT(CountryId) FROM " . GEODIR_COUNTRIES_TABLE . "");
92
+		$country_table_empty = $wpdb->get_var("SELECT COUNT(CountryId) FROM " . GEODIR_COUNTRIES_TABLE . "");
93 93
 
94
-        if ($country_table_empty == 0) {
94
+		if ($country_table_empty == 0) {
95 95
 
96
-            $countries_insert = "INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (`CountryId`, `Country`, `FIPS104`, `ISO2`, `ISO3`, `ISON`, `Internet`, `Capital`, `MapReference`, `NationalitySingular`, `NationalityPlural`, `Currency`, `CurrencyCode`, `Population`, `Title`, `COMMENT`) VALUES
96
+			$countries_insert = "INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (`CountryId`, `Country`, `FIPS104`, `ISO2`, `ISO3`, `ISON`, `Internet`, `Capital`, `MapReference`, `NationalitySingular`, `NationalityPlural`, `Currency`, `CurrencyCode`, `Population`, `Title`, `COMMENT`) VALUES
97 97
 	(1, 'Afghanistan', 'AF', 'AF', 'AFG', '4', 'AF', 'Kabul ', 'Asia ', 'Afghan', 'Afghans', 'Afghani ', 'AFA', 26813057, 'Afghanistan', ''),
98 98
 	(2, 'Albania', 'AL', 'AL', 'ALB', '8', 'AL', 'Tirana ', 'Europe ', 'Albanian', 'Albanians', 'Lek ', 'ALL', 3510484, 'Albania', ''),
99 99
 	(3, 'Algeria', 'AG', 'DZ', 'DZA', '12', 'DZ', 'Algiers ', 'Africa ', 'Algerian', 'Algerians', 'Algerian Dinar ', 'DZD', 31736053, 'Algeria', ''),
@@ -371,21 +371,21 @@  discard block
 block discarded – undo
371 371
     (281, 'South Sudan', '--', 'SS', '-- ', '--', 'SS', '', '', '', '', 'South Sudanese pound', 'SSP', 12340000, 'South Sudan', ''),
372 372
     (282, 'Isle of Man', '--', 'IM', '-- ', '--', 'IM', '', '', '', '', 'Manx pound', 'IMP', 84497, 'Isle of Man', '')";
373 373
 
374
-            /**
375
-             * Filter the SQL query that inserts the country DB table data.
376
-             *
377
-             * @since 1.0.0
378
-             * @param string $sql The SQL insert query string.
379
-             */
380
-            $countries_insert = apply_filters('geodir_before_country_data_insert', $countries_insert);
381
-            $wpdb->query($countries_insert);
374
+			/**
375
+			 * Filter the SQL query that inserts the country DB table data.
376
+			 *
377
+			 * @since 1.0.0
378
+			 * @param string $sql The SQL insert query string.
379
+			 */
380
+			$countries_insert = apply_filters('geodir_before_country_data_insert', $countries_insert);
381
+			$wpdb->query($countries_insert);
382 382
 
383
-        }
383
+		}
384 384
 
385 385
 
386
-        // Table for storing location attribute - these are user defined
386
+		// Table for storing location attribute - these are user defined
387 387
 
388
-        $icon_table = "CREATE TABLE " . GEODIR_ICON_TABLE . " (
388
+		$icon_table = "CREATE TABLE " . GEODIR_ICON_TABLE . " (
389 389
 						id int NOT NULL AUTO_INCREMENT,
390 390
 						post_id int( 10 ) NOT NULL,
391 391
 						post_title varchar(254) NOT NULL,
@@ -394,19 +394,19 @@  discard block
 block discarded – undo
394 394
 						PRIMARY KEY  (id)
395 395
 						) $collate ";
396 396
 
397
-        /**
398
-         * Filter the SQL query that creates/updates the post_icon DB table structure.
399
-         *
400
-         * @since 1.0.0
401
-         * @param string $sql The SQL insert query string.
402
-         */
403
-        $icon_table = apply_filters('geodir_before_icon_table_create', $icon_table);
397
+		/**
398
+		 * Filter the SQL query that creates/updates the post_icon DB table structure.
399
+		 *
400
+		 * @since 1.0.0
401
+		 * @param string $sql The SQL insert query string.
402
+		 */
403
+		$icon_table = apply_filters('geodir_before_icon_table_create', $icon_table);
404 404
 
405
-        dbDelta($icon_table);
405
+		dbDelta($icon_table);
406 406
 
407
-        // Table for storing post custom fields - these are user defined
407
+		// Table for storing post custom fields - these are user defined
408 408
 
409
-        $post_custom_fields = "CREATE TABLE " . GEODIR_CUSTOM_FIELDS_TABLE . " (
409
+		$post_custom_fields = "CREATE TABLE " . GEODIR_CUSTOM_FIELDS_TABLE . " (
410 410
 							  id int(11) NOT NULL AUTO_INCREMENT,
411 411
 							  post_type varchar(100) NULL,
412 412
 							  data_type varchar(100) NULL DEFAULT NULL,
@@ -442,18 +442,18 @@  discard block
 block discarded – undo
442 442
 							  PRIMARY KEY  (id)
443 443
 							  ) $collate";
444 444
 
445
-        /**
446
-         * Filter the SQL query that creates/updates the custom_fields DB table structure.
447
-         *
448
-         * @since 1.0.0
449
-         * @param string $sql The SQL insert query string.
450
-         */
451
-        $post_custom_fields = apply_filters('geodir_before_custom_field_table_create', $post_custom_fields);
445
+		/**
446
+		 * Filter the SQL query that creates/updates the custom_fields DB table structure.
447
+		 *
448
+		 * @since 1.0.0
449
+		 * @param string $sql The SQL insert query string.
450
+		 */
451
+		$post_custom_fields = apply_filters('geodir_before_custom_field_table_create', $post_custom_fields);
452 452
 
453
-        dbDelta($post_custom_fields);
453
+		dbDelta($post_custom_fields);
454 454
 
455
-        // Table for storing place attribute - these are user defined
456
-        $post_detail = "CREATE TABLE " . $plugin_prefix . "gd_place_detail (
455
+		// Table for storing place attribute - these are user defined
456
+		$post_detail = "CREATE TABLE " . $plugin_prefix . "gd_place_detail (
457 457
 						post_id int(11) NOT NULL,
458 458
 						post_title text NULL DEFAULT NULL,
459 459
 						post_status varchar(20) NULL DEFAULT NULL,
@@ -482,22 +482,22 @@  discard block
 block discarded – undo
482 482
 						KEY is_featured (is_featured)
483 483
 						) $collate ";
484 484
 
485
-        /**
486
-         * Filter the SQL query that creates/updates the post_detail DB table structure.
487
-         *
488
-         * @since 1.0.0
489
-         * @param string $sql The SQL insert query string.
490
-         */
491
-        $post_detail = apply_filters('geodir_before_post_detail_table_create', $post_detail);
485
+		/**
486
+		 * Filter the SQL query that creates/updates the post_detail DB table structure.
487
+		 *
488
+		 * @since 1.0.0
489
+		 * @param string $sql The SQL insert query string.
490
+		 */
491
+		$post_detail = apply_filters('geodir_before_post_detail_table_create', $post_detail);
492 492
 
493
-        dbDelta($post_detail);
493
+		dbDelta($post_detail);
494 494
 
495
-        // alter post_title
496
-        //$wpdb->query("ALTER TABLE ".$wpdb->prefix."geodir_gd_place_detail MODIFY `post_title` text NULL");
495
+		// alter post_title
496
+		//$wpdb->query("ALTER TABLE ".$wpdb->prefix."geodir_gd_place_detail MODIFY `post_title` text NULL");
497 497
 
498
-        // Table for storing place images - these are user defined
498
+		// Table for storing place images - these are user defined
499 499
 
500
-        $attechment_table = "CREATE TABLE " . GEODIR_ATTACHMENT_TABLE . " (
500
+		$attechment_table = "CREATE TABLE " . GEODIR_ATTACHMENT_TABLE . " (
501 501
 						ID int(11) NOT NULL AUTO_INCREMENT,
502 502
 						post_id int(11) NOT NULL,
503 503
 						user_id int(11) DEFAULT NULL,
@@ -513,18 +513,18 @@  discard block
 block discarded – undo
513 513
 						PRIMARY KEY  (ID)
514 514
 						) $collate ";
515 515
 
516
-        /**
517
-         * Filter the SQL query that creates/updates the attachments DB table structure.
518
-         *
519
-         * @since 1.0.0
520
-         * @param string $sql The SQL insert query string.
521
-         */
522
-        $attechment_table = apply_filters('geodir_before_attachment_table_create', $attechment_table);
516
+		/**
517
+		 * Filter the SQL query that creates/updates the attachments DB table structure.
518
+		 *
519
+		 * @since 1.0.0
520
+		 * @param string $sql The SQL insert query string.
521
+		 */
522
+		$attechment_table = apply_filters('geodir_before_attachment_table_create', $attechment_table);
523 523
 
524
-        dbDelta($attechment_table);
524
+		dbDelta($attechment_table);
525 525
 
526 526
 
527
-        $custom_sort_fields_table = "CREATE TABLE " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " (
527
+		$custom_sort_fields_table = "CREATE TABLE " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " (
528 528
 			id int(11) NOT NULL AUTO_INCREMENT,
529 529
 			post_type varchar(255) NOT NULL,
530 530
 			data_type varchar(255) NOT NULL,
@@ -542,18 +542,18 @@  discard block
 block discarded – undo
542 542
 			PRIMARY KEY  (id)
543 543
 			) $collate ";
544 544
 
545
-        /**
546
-         * Filter the SQL query that creates/updates the custom_sort_fields DB table structure.
547
-         *
548
-         * @since 1.0.0
549
-         * @param string $sql The SQL insert query string.
550
-         */
551
-        $custom_sort_fields_table = apply_filters('geodir_before_sort_fields_table_create', $custom_sort_fields_table);
545
+		/**
546
+		 * Filter the SQL query that creates/updates the custom_sort_fields DB table structure.
547
+		 *
548
+		 * @since 1.0.0
549
+		 * @param string $sql The SQL insert query string.
550
+		 */
551
+		$custom_sort_fields_table = apply_filters('geodir_before_sort_fields_table_create', $custom_sort_fields_table);
552 552
 
553
-        dbDelta($custom_sort_fields_table);
553
+		dbDelta($custom_sort_fields_table);
554 554
 
555 555
 
556
-            $review_table = "CREATE TABLE " . GEODIR_REVIEW_TABLE . " (
556
+			$review_table = "CREATE TABLE " . GEODIR_REVIEW_TABLE . " (
557 557
 			id int(11) NOT NULL AUTO_INCREMENT,
558 558
 			post_id int(11) DEFAULT NULL,
559 559
 			post_title varchar( 255 ) NULL DEFAULT NULL,
@@ -577,51 +577,51 @@  discard block
 block discarded – undo
577 577
 			PRIMARY KEY  (id)
578 578
 			) $collate  ";
579 579
 
580
-            /**
581
-             * Filter the SQL query that creates the review DB table structure.
582
-             *
583
-             * @since 1.0.0
584
-             * @param string $sql The SQL insert query string.
585
-             */
586
-            $review_table = apply_filters('geodir_before_review_table_create', $review_table);
587
-            dbDelta($review_table);
580
+			/**
581
+			 * Filter the SQL query that creates the review DB table structure.
582
+			 *
583
+			 * @since 1.0.0
584
+			 * @param string $sql The SQL insert query string.
585
+			 */
586
+			$review_table = apply_filters('geodir_before_review_table_create', $review_table);
587
+			dbDelta($review_table);
588 588
 
589 589
 
590 590
 
591
-        // Alter terms table
592
-        $term_icon_column = $wpdb->get_var("SHOW COLUMNS FROM $wpdb->terms where field='term_icon'");
593
-        if (!$term_icon_column) {
594
-            $wpdb->query("ALTER TABLE $wpdb->terms ADD `term_icon` TEXT NULL DEFAULT NULL");
595
-        }
591
+		// Alter terms table
592
+		$term_icon_column = $wpdb->get_var("SHOW COLUMNS FROM $wpdb->terms where field='term_icon'");
593
+		if (!$term_icon_column) {
594
+			$wpdb->query("ALTER TABLE $wpdb->terms ADD `term_icon` TEXT NULL DEFAULT NULL");
595
+		}
596 596
 
597
-        //require_once(geodir_plugin_path() . '/upgrade.php');
597
+		//require_once(geodir_plugin_path() . '/upgrade.php');
598 598
 
599 599
 
600
-    }
600
+	}
601 601
 } // END MAIN FUNCTION geodir_tables_install
602 602
 
603 603
 if (!function_exists('geodir_create_default_fields')) {
604
-    /**
605
-     * Inserts default custom fields table data into database.
606
-     *
607
-     * @since 1.0.0
608
-     * @package GeoDirectory
609
-     */
610
-    function geodir_create_default_fields()
611
-    {
612
-
613
-        $fields = geodir_default_custom_fields('gd_place');
614
-
615
-        /**
616
-         * Filter the array of default custom fields DB table data.
617
-         *
618
-         * @since 1.0.0
619
-         * @param string $fields The default custom fields as an array.
620
-         */
621
-        $fields = apply_filters('geodir_before_default_custom_fields_saved', $fields);
622
-        foreach ($fields as $field_index => $field) {
623
-            geodir_custom_field_save($field);
624
-
625
-        }
626
-    }
604
+	/**
605
+	 * Inserts default custom fields table data into database.
606
+	 *
607
+	 * @since 1.0.0
608
+	 * @package GeoDirectory
609
+	 */
610
+	function geodir_create_default_fields()
611
+	{
612
+
613
+		$fields = geodir_default_custom_fields('gd_place');
614
+
615
+		/**
616
+		 * Filter the array of default custom fields DB table data.
617
+		 *
618
+		 * @since 1.0.0
619
+		 * @param string $fields The default custom fields as an array.
620
+		 */
621
+		$fields = apply_filters('geodir_before_default_custom_fields_saved', $fields);
622
+		foreach ($fields as $field_index => $field) {
623
+			geodir_custom_field_save($field);
624
+
625
+		}
626
+	}
627 627
 }
628 628
\ No newline at end of file
Please login to merge, or discard this patch.