-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathdb.php
More file actions
59 lines (51 loc) · 2.04 KB
/
db.php
File metadata and controls
59 lines (51 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/*
Plugin Name: PostgreSQL for WordPress (PG4WP)
Plugin URI: https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress
Description: PG4WP is a special plugin enabling WordPress to use a PostgreSQL database.
Version: v3.0.0
Author: PostgreSQL-For-Wordpress
Author URI: https://github.com/PostgreSQL-For-Wordpress
License: GPLv2 or newer.
*/
// Ensure we only load this config once
if(!defined('PG4WP_ROOT')) {
// You can choose the driver to load here
if (!defined('DB_DRIVER')) {
define('DB_DRIVER', 'pgsql');
}
// Set this to 'true' and check that `pg4wp` is writable if you want debug logs to be written
if (!defined('PG4WP_DEBUG')) {
define('PG4WP_DEBUG', false);
}
if (!defined('PG4WP_LOG_ERRORS')) {
// If you just want to log queries that generate errors, leave PG4WP_DEBUG to "false"
// and set this to true
define('PG4WP_LOG_ERRORS', true);
}
// This defines the directory where PG4WP files are loaded from
// 3 places checked : wp-content, wp-content/plugins and the base directory
if(file_exists(ABSPATH . 'wp-content/pg4wp')) {
define('PG4WP_ROOT', ABSPATH . 'wp-content/pg4wp');
} elseif(file_exists(ABSPATH . 'wp-content/plugins/pg4wp')) {
define('PG4WP_ROOT', ABSPATH . 'wp-content/plugins/pg4wp');
} elseif(file_exists(ABSPATH . 'pg4wp')) {
define('PG4WP_ROOT', ABSPATH . 'pg4wp');
} else {
die('PG4WP file directory not found');
}
// Logs are put in the pg4wp directory
if (!defined('PG4WP_LOG')) {
define('PG4WP_LOG', PG4WP_ROOT . '/logs/');
}
// Check if the logs directory is needed and exists or create it if possible
if((PG4WP_DEBUG || PG4WP_LOG_ERRORS) && !file_exists(PG4WP_LOG) && is_writable(dirname(PG4WP_LOG))) {
mkdir(PG4WP_LOG);
}
// Default to public schema
if (!defined('DB_SCHEMA')) {
define('DB_SCHEMA', 'public');
}
// Here happens all the magic
require_once(PG4WP_ROOT . '/core.php');
} // Protection against multiple loading