/** * Checks if the thinkup_server value has been set and if it has, creates a new database connection to that server * based on the values supplied on the options page of the plugin. * * This is useful for maintaining the ability to have your WordPress and ThinkUp install on different servers. * * @global wpdb $wpdb * @return wpdb */ public static function getDatabaseConnection() { if (is_null(self::$db_connection)) { $options_array = self::getOptionsArray(); if ($options_array['thinkup_server']['value'] != '') { self::$db_connection = new wpdb($options_array['thinkup_dbusername']['value'], $options_array['thinkup_dbpw']['value'], $options_array['thinkup_db']['value'], $options_array['thinkup_server']['value']); } else { global $wpdb; self::$db_connection = $wpdb; } } return self::$db_connection; }