//---DC IPs---------------------------------------------------------------// //------------------------------------------------------------------------// // Usage: add_dc_ip(IP, DC) // EX: add_dc_ip('123.123.123.', 'dc1'); add_dc_ip('123.123.123.', 'dc1'); //------------------------------------------------------------------------// //---Global Tables--------------------------------------------------------// //------------------------------------------------------------------------// // Do not include default global tables // Leave off base prefix (eg: wp_) // You don't really have to register these, they will work fine without. // However registering at least your busiest ones might shave a few milliseconds off by avoiding some regexes. // // Usage: add_global_table(TABLE_NAME) // EX: add_global_table('something'); add_global_table('some_global_table'); //------------------------------------------------------------------------// //---DB Servers-----------------------------------------------------------// //------------------------------------------------------------------------// // Database servers grouped by dataset. // R can be 0 (no reads) or a positive integer indicating the order // in which to attempt communication (all locals, then all remotes) // // Usage: add_db_server(DS, DC, READ, WRITE, HOST, LAN_HOST, NAME, USER, PASS) // EX: add_db_server('global', 'dc1', 1, 1,'global.mysql.example.com:3509','global.mysql.example.lan:3509', 'global-db', 'globaluser', 'globalpassword'); // // Note: you can also place this section in a file called db-list.php in wp-content add_db_server('global', 'dc1', 1, 1, '64.120.23.72', '192.168.0.101', 'wpmu_global', 'db_user_name', 'db_user_name_pass'); add_db_server('0', 'dc1', 1, 1, '64.120.23.72', '192.168.0.101', 'wpmu_0', 'db_user_name', 'db_user_name_pass'); add_db_server('1', 'dc1', 1, 1, '64.120.23.72', '192.168.0.101', 'wpmu_1', 'db_user_name', 'db_user_name_pass'); add_db_server('2', 'dc1', 1, 1, '64.120.23.72', '192.168.0.101', 'wpmu_2', 'db_user_name', 'db_user_name_pass');
add_global_table('bp_activity'); add_global_table('bp_activity_meta'); add_global_table('bp_friends'); add_global_table('bp_groups'); add_global_table('bp_groups_groupmeta'); add_global_table('bp_groups_members'); add_global_table('bp_messages_messages'); add_global_table('bp_messages_notices'); add_global_table('bp_messages_recipients'); add_global_table('bp_notifications'); add_global_table('bp_user_blogs'); add_global_table('bp_user_blogs_blogmeta'); add_global_table('bp_xprofile_data'); add_global_table('bp_xprofile_fields'); add_global_table('bp_xprofile_groups'); add_global_table('domain_mapping'); //------------------------------------------------------------------------// //---DB Servers-----------------------------------------------------------// //------------------------------------------------------------------------// // Database servers grouped by dataset. // R can be 0 (no reads) or a positive integer indicating the order // in which to attempt communication (all locals, then all remotes) // // Usage: add_db_server(DS, DC, READ, WRITE, HOST, LAN_HOST, NAME, USER, PASS) // EX: add_db_server('global', 'dc1', 1, 1,'global.mysql.example.com:3509','global.mysql.example.lan:3509', 'global-db', 'globaluser', 'globalpassword'); // // Note: you can also place this section in a file called db-list.php in wp-content // EX: add_db_server('global', 'dc1', 1, 1,'global.mysql.example.com:3509','global.mysql.example.lan:3509', 'global-db', 'globaluser', 'globalpassword'); add_db_server('global', 'dc1', 1, 1, 'localhost', 'localhost', 'wpglobal', 'root', 'root'); add_db_server('0', 'dc1', 1, 1, 'localhost', 'localhost', 'wp0', 'root', 'root'); add_db_server('1', 'dc1', 1, 1, 'localhost', 'localhost', 'wp1', 'root', 'root');
/** * Instantiates the plugin and setup all modules. * * @since 4.0.0 * * @global wpdb $wpdb The instance of database connection. * @global domain_map $dm_map The instance of domain_map class. */ function domainmap_launch() { global $wpdb, $dm_map; // setup environment define('DOMAINMAP_BASEFILE', __FILE__); define('DOMAINMAP_ABSURL', plugins_url('/', __FILE__)); define('DOMAINMAP_ABSPATH', dirname(__FILE__)); if (!defined('DM_FORCE_PROTOCOL_ON_MAPPED_DOMAIN')) { define('DM_FORCE_PROTOCOL_ON_MAPPED_DOMAIN', false); } $prefix = isset($wpdb->base_prefix) ? $wpdb->base_prefix : $wpdb->prefix; define('DOMAINMAP_TABLE_MAP', "{$prefix}domain_mapping"); define('DOMAINMAP_TABLE_RESELLER_LOG', "{$prefix}domain_mapping_reseller_log"); // MultiDB compatibility, register global tables if (defined('MULTI_DB_VERSION') && function_exists('add_global_table')) { add_global_table('domain_mapping'); add_global_table('domain_mapping_reseller_log'); } // set up the plugin core class $dm_map = new domain_map(); // instantiate the plugin $plugin = Domainmap_Plugin::instance(); // set general modules $plugin->set_module(Domainmap_Module_System::NAME); $plugin->set_module(Domainmap_Module_Setup::NAME); $plugin->set_module(Domainmap_Module_Mapping::NAME); // CDSSO module $sunrise = defined('SUNRISE') && filter_var(SUNRISE, FILTER_VALIDATE_BOOLEAN); if ($sunrise && defined('DOMAINMAPPING_USE_CDSSO') && $plugin->get_option('map_crossautologin')) { $plugin->set_module(Domainmap_Module_Cdsso::NAME); } // conditional modules if (defined('DOING_AJAX') && DOING_AJAX) { // suppresses errors rendering to prevent unexpected issues set_error_handler('__return_true'); set_exception_handler('__return_true'); // set ajax modules $plugin->set_module(Domainmap_Module_Ajax_Map::NAME); $plugin->set_module(Domainmap_Module_Ajax_Purchase::NAME); $plugin->set_module(Domainmap_Module_Ajax_Register::NAME); } else { if (is_admin()) { // set admin modules $plugin->set_module(Domainmap_Module_Pages::NAME); $plugin->set_module(Domainmap_Module_Admin::NAME); } } }
/** * Initializes database table constants and add them to global tables if MultiDB * is used. * * @since 3.5 * * @global wpdb $wpdb */ function membership_setup_db_table_constants() { global $wpdb; // prevent double initialization if (defined('MEMBERSHIP_TABLE_LEVELS')) { return; } $global = is_multisite() && filter_var(MEMBERSHIP_GLOBAL_TABLES, FILTER_VALIDATE_BOOLEAN); $prefix = $wpdb->get_blog_prefix($global ? MEMBERSHIP_GLOBAL_MAINSITE : null); define('MEMBERSHIP_TABLE_LEVELS', "{$prefix}m_membership_levels"); define('MEMBERSHIP_TABLE_RULES', "{$prefix}m_membership_rules"); define('MEMBERSHIP_TABLE_RELATIONS', "{$prefix}m_membership_relationships"); define('MEMBERSHIP_TABLE_MEMBER_PAYMENTS', "{$prefix}m_member_payments"); define('MEMBERSHIP_TABLE_SUBSCRIPTIONS', "{$prefix}m_subscriptions"); define('MEMBERSHIP_TABLE_SUBSCRIPTION_LEVELS', "{$prefix}m_subscriptions_levels"); define('MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION', "{$prefix}m_subscription_transaction"); define('MEMBERSHIP_TABLE_SUBSCRIPTION_META', "{$prefix}m_subscriptionmeta"); define('MEMBERSHIP_TABLE_URLGROUPS', "{$prefix}m_urlgroups"); define('MEMBERSHIP_TABLE_COMMUNICATIONS', "{$prefix}m_communications"); if ($global && defined('MULTI_DB_VERSION') && function_exists('add_global_table')) { add_global_table('m_membership_levels'); add_global_table('m_membership_rules'); add_global_table('m_membership_relationships'); add_global_table('m_member_payments'); add_global_table('m_subscriptions'); add_global_table('m_subscriptions_levels'); add_global_table('m_subscription_transaction'); add_global_table('m_subscriptionmeta'); add_global_table('m_urlgroups'); add_global_table('m_communications'); } }
add_global_table('bp_messages_notices'); add_global_table('bp_messages_notices'); add_global_table('bp_messages_recipients'); add_global_table('bp_messages_threads'); add_global_table('bp_messages_threads'); add_global_table('bp_notifications'); add_global_table('bp_user_blogs'); add_global_table('bp_user_blogs_blogmeta'); add_global_table('bp_user_blogs_comments'); add_global_table('bp_user_blogs_posts'); add_global_table('bp_xprofile_data'); add_global_table('bp_xprofile_fields'); add_global_table('bp_xprofile_groups'); add_global_table('bp_xprofile_wire'); add_global_table('bp_activity'); add_global_table('bp_activity_meta'); require_once WP_CONTENT_DIR . '/db-config.php'; if (!defined('DATACENTER')) { foreach ($dc_ips as $dc_ip => $dc) { if (substr($_SERVER['SERVER_ADDR'], 0, strlen($dc_ip)) == $dc_ip) { define('DATACENTER', $dc); break; } } } if (file_exists(WP_CONTENT_DIR . '/db-list.php')) { require_once WP_CONTENT_DIR . '/db-list.php'; } // To allow extending of database class $wpdb = 'we-need-to-pre-populate-this-variable'; require_once ABSPATH . WPINC . '/wp-db.php';
function membership_db_prefix(wpdb $wpdb, $table, $useprefix = true) { $membership_prefix = ''; if ($useprefix) { $membership_prefix = 'm_'; } $global = is_multisite() && filter_var(MEMBERSHIP_GLOBAL_TABLES, FILTER_VALIDATE_BOOLEAN); $prefix = $wpdb->get_blog_prefix($global ? MEMBERSHIP_GLOBAL_MAINSITE : null); $table_name = $prefix . $membership_prefix . $table; if ($global && defined('MULTI_DB_VERSION') && function_exists('add_global_table')) { add_global_table($membership_prefix . $table); } return $table_name; }