-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathgppa-custom-database.php
44 lines (36 loc) · 1.31 KB
/
gppa-custom-database.php
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
<?php
/**
* Gravity Perks // Populate Anything // Custom Database
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*
* Instruction Video: https://www.loom.com/share/f9bf62e358dd4c54ab346998c5f3b516
*
* By default, Populate Anything will only show the database that the current WordPress
* installation is on.
*
* The following snippet allows registering additional an additional database with custom credentials.
*
* You can add multiple databases by adjusting the class names and adding additional
* `gp_populate_anything()->register_object_type()` calls.
*/
class GPPA_Object_Type_Database_Testing extends GPPA_Object_Type_Database {
const DB_NAME = 'testing';
const DB_USER = DB_USER;
const DB_PASSWORD = DB_PASSWORD;
const DB_HOST = DB_HOST;
public $wpdb_instance;
public function get_label() {
return esc_html__( 'Database: ', 'gp-populate-anything' ) . self::DB_NAME;
}
public function get_db() {
if ( ! isset( $this->wpdb_instance ) ) {
$this->wpdb_instance = new wpdb( self::DB_USER, self::DB_PASSWORD, self::DB_NAME, self::DB_HOST );
}
return $this->wpdb_instance;
}
}
add_action('init', function() {
if ( class_exists( 'GP_Populate_Anything' ) ) {
gp_populate_anything()->register_object_type( 'database-testing', 'GPPA_Object_Type_Database_Testing' );
}
});