/**
 * Bootstrap bbPress 1.x, and manipulate globals to integrate with BuddyPress.
 *
 * @return bool|null Returns false on failure.
 */
function bp_forums_load_bbpress()
{
    global $wpdb, $wp_roles, $current_user, $wp_users_object;
    global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
    global $bb_roles, $wp_taxonomy_object, $bb_queries;
    // Return if we've already run this function.
    if (is_object($bbdb)) {
        return;
    }
    if (!bp_forums_is_installed_correctly()) {
        return false;
    }
    $bp = buddypress();
    define('BB_PATH', $bp->plugin_dir . '/bp-forums/bbpress/');
    define('BACKPRESS_PATH', $bp->plugin_dir . '/bp-forums/bbpress/bb-includes/backpress/');
    define('BB_URL', $bp->plugin_url . 'bp-forums/bbpress/');
    define('BB_INC', 'bb-includes/');
    require BB_PATH . BB_INC . 'class.bb-query.php';
    require BB_PATH . BB_INC . 'class.bb-walker.php';
    require BB_PATH . BB_INC . 'functions.bb-core.php';
    require BB_PATH . BB_INC . 'functions.bb-forums.php';
    require BB_PATH . BB_INC . 'functions.bb-topics.php';
    require BB_PATH . BB_INC . 'functions.bb-posts.php';
    require BB_PATH . BB_INC . 'functions.bb-topic-tags.php';
    require BB_PATH . BB_INC . 'functions.bb-capabilities.php';
    require BB_PATH . BB_INC . 'functions.bb-meta.php';
    require BB_PATH . BB_INC . 'functions.bb-pluggable.php';
    require BB_PATH . BB_INC . 'functions.bb-formatting.php';
    require BB_PATH . BB_INC . 'functions.bb-template.php';
    require BACKPRESS_PATH . 'class.wp-taxonomy.php';
    require BB_PATH . BB_INC . 'class.bb-taxonomy.php';
    require BB_PATH . 'bb-admin/includes/functions.bb-admin.php';
    $bb = new stdClass();
    require bp_get_option('bb-config-location');
    // Setup the global database connection
    $bbdb = new BPDB(BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST);
    // Set the table names
    $bbdb->forums = $bb_table_prefix . 'forums';
    $bbdb->meta = $bb_table_prefix . 'meta';
    $bbdb->posts = $bb_table_prefix . 'posts';
    $bbdb->terms = $bb_table_prefix . 'terms';
    $bbdb->term_relationships = $bb_table_prefix . 'term_relationships';
    $bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
    $bbdb->topics = $bb_table_prefix . 'topics';
    if (isset($bb->custom_user_table)) {
        $bbdb->users = $bb->custom_user_table;
    } else {
        $bbdb->users = $wpdb->users;
    }
    if (isset($bb->custom_user_meta_table)) {
        $bbdb->usermeta = $bb->custom_user_meta_table;
    } else {
        $bbdb->usermeta = $wpdb->usermeta;
    }
    $bbdb->prefix = $bb_table_prefix;
    define('BB_INSTALLING', false);
    if (is_object($wp_roles)) {
        $bb_roles = $wp_roles;
        bb_init_roles($bb_roles);
    }
    /**
     * Fires during the bootstrap setup for bbPress 1.x.
     *
     * @since 1.1.0
     */
    do_action('bb_got_roles');
    /**
     * Fires during the bootstrap setup for bbPress 1.x.
     *
     * @since 1.1.0
     */
    do_action('bb_init');
    /**
     * Fires during the bootstrap setup for bbPress 1.x.
     *
     * @since 1.1.0
     */
    do_action('init_roles');
    $bb_current_user = $current_user;
    $wp_users_object = new BP_Forums_BB_Auth();
    if (!isset($wp_taxonomy_object)) {
        $wp_taxonomy_object = new BB_Taxonomy($bbdb);
    }
    $wp_taxonomy_object->register_taxonomy('bb_topic_tag', 'bb_topic');
    // Set a site id if there isn't one already
    if (!isset($bb->site_id)) {
        $bb->site_id = bp_get_root_blog_id();
    }
    // Check if the tables are installed, if not, install them
    if (!($tables_installed = (bool) $bbdb->get_results('DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A))) {
        require BB_PATH . 'bb-admin/includes/defaults.bb-schema.php';
        // Backticks and "IF NOT EXISTS" break the dbDelta function.
        bp_bb_dbDelta(str_replace(' IF NOT EXISTS', '', str_replace('`', '', $bb_queries)));
        require BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php';
        bb_update_db_version();
        // Set the site admins as the keymasters
        $site_admins = get_site_option('site_admins', array('admin'));
        foreach ((array) $site_admins as $site_admin) {
            bp_update_user_meta(bp_core_get_userid($site_admin), $bb_table_prefix . 'capabilities', array('keymaster' => true));
        }
        // Create the first forum.
        bb_new_forum(array('forum_name' => 'Default Forum'));
        // Set the site URI
        bb_update_option('uri', BB_URL);
    }
    /**
     * Fires inside an anonymous function that is run on bbPress shutdown.
     *
     * @since 1.1.0
     */
    register_shutdown_function(create_function('', 'do_action("bb_shutdown");'));
}
Example #2
0
}
// WP_Taxonomy
if (!class_exists('WP_Taxonomy')) {
    require_once BACKPRESS_PATH . 'class.wp-taxonomy.php';
}
if (!class_exists('BB_Taxonomy')) {
    require_once BB_PATH . BB_INC . 'class.bb-taxonomy.php';
}
if (!isset($wp_taxonomy_object)) {
    // Clean slate
    $wp_taxonomy_object = new BB_Taxonomy($bbdb);
} elseif (!is_a($wp_taxonomy_object, 'BB_Taxonomy')) {
    // exists, but it's not good enough, translate it
    // preserve the references
    $tax =& $wp_taxonomy_object->taxonomies;
    $wp_taxonomy_object = new BB_Taxonomy($bbdb);
    $wp_taxonomy_object->taxonomies =& $tax;
    unset($tax);
}
$wp_taxonomy_object->register_taxonomy('bb_topic_tag', 'bb_topic');
do_action('bb_options_loaded');
/**
 * Load deprecated constants and functions
 */
// Skip loading of deprecated stuff unless specifically requested
if (BB_LOAD_DEPRECATED) {
    /**
     * Define deprecated constants for plugin compatibility
     * $deprecated_constants below is a complete array of old constants and their replacements
     */
    $deprecated_constants = array('BBPATH' => 'BB_PATH', 'BBINC' => 'BB_INC', 'BBLANG' => 'BB_LANG', 'BBLANGDIR' => 'BB_LANG_DIR', 'BBPLUGINDIR' => 'BB_PLUGIN_DIR', 'BBPLUGINURL' => 'BB_PLUGIN_URL', 'BBTHEMEDIR' => 'BB_THEME_DIR', 'BBTHEMEURL' => 'BB_THEME_URL', 'BBHASH' => 'BB_HASH');
Example #3
0
}
// nxt_Taxonomy
if (!class_exists('nxt_Taxonomy')) {
    require_once BACKPRESS_PATH . 'class.nxt-taxonomy.php';
}
if (!class_exists('BB_Taxonomy')) {
    require_once BB_PATH . BB_INC . 'class.bb-taxonomy.php';
}
if (!isset($nxt_taxonomy_object)) {
    // Clean slate
    $nxt_taxonomy_object = new BB_Taxonomy($bbdb);
} elseif (!is_a($nxt_taxonomy_object, 'BB_Taxonomy')) {
    // exists, but it's not good enough, translate it
    // preserve the references
    $tax =& $nxt_taxonomy_object->taxonomies;
    $nxt_taxonomy_object = new BB_Taxonomy($bbdb);
    $nxt_taxonomy_object->taxonomies =& $tax;
    unset($tax);
}
$nxt_taxonomy_object->register_taxonomy('bb_topic_tag', 'bb_topic');
$nxt_taxonomy_object->register_taxonomy('bb_subscribe', 'bb_user');
do_action('bb_options_loaded');
/**
 * Load deprecated constants and functions
 */
// Skip loading of deprecated stuff unless specifically requested
if (BB_LOAD_DEPRECATED) {
    /**
     * Define deprecated constants for plugin compatibility
     * $deprecated_constants below is a complete array of old constants and their replacements
     */
Example #4
0
function bp_forums_load_bbpress() {
	global $bp, $wpdb, $wp_roles, $current_user, $wp_users_object;
	global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
	global $bb_roles, $wp_taxonomy_object;

	/* Return if we've already run this function. */
	if ( is_object( $bbdb ) && is_object( $bb_roles ) )
		return;

	if ( !bp_forums_is_installed_correctly() )
		return false;

	define( 'BB_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/' );
	define( 'BACKPRESS_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-includes/backpress/' );
	define( 'BB_URL', BP_PLUGIN_URL . '/bp-forums/bbpress/' );
	define( 'BB_INC', 'bb-includes/' );

	require_once( BB_PATH . BB_INC . 'class.bb-query.php' );
	require_once( BB_PATH . BB_INC . 'class.bb-walker.php' );

	require_once( BB_PATH . BB_INC . 'functions.bb-core.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-forums.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-topics.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-posts.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-topic-tags.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-capabilities.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-meta.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-pluggable.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-formatting.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-template.php' );

	require_once( BACKPRESS_PATH . 'class.wp-taxonomy.php' );
	require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' );

	$bb = new stdClass();
	require_once( $bp->forums->bbconfig );

	// Setup the global database connection
	$bbdb = new BPDB ( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST );

	/* Set the table names */
	$bbdb->forums = $bb_table_prefix . 'forums';
	$bbdb->meta = $bb_table_prefix . 'meta';
	$bbdb->posts = $bb_table_prefix . 'posts';
	$bbdb->terms = $bb_table_prefix . 'terms';
	$bbdb->term_relationships = $bb_table_prefix . 'term_relationships';
	$bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
	$bbdb->topics = $bb_table_prefix . 'topics';

	if ( isset( $bb->custom_user_table ) )
		$bbdb->users = $bb->custom_user_table;
	else
		$bbdb->users = $wpdb->users;

	if ( isset( $bb->custom_user_meta_table ) )
		$bbdb->usermeta = $bb->custom_user_meta_table;
	else
		$bbdb->usermeta = $wpdb->usermeta;

	$bbdb->prefix = $bb_table_prefix;

	define( 'BB_INSTALLING', false );

	/* This must be loaded before functionss.bb-admin.php otherwise we get a function conflict. */
	if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) )
		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );

	require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );

	if ( is_object( $wp_roles ) ) {
		$bb_roles = $wp_roles;
		bb_init_roles( $bb_roles );
	}

	do_action( 'bb_got_roles' );
	do_action( 'bb_init' );
	do_action( 'init_roles' );

	$bb_current_user = $current_user;
	$wp_users_object = new BP_Forums_BB_Auth;

	if ( !isset( $wp_taxonomy_object ) )
		$wp_taxonomy_object = new BB_Taxonomy( $bbdb );

	$wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' );

	// Set a site id if there isn't one already
	if ( !isset( $bb->site_id ) )
		$bb->site_id = BP_ROOT_BLOG;

	/* Check if the tables are installed, if not, install them */
	if ( !$tables_installed ) {
		require_once( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' );

		/* Backticks and "IF NOT EXISTS" break the dbDelta function. */
		dbDelta( str_replace( ' IF NOT EXISTS', '', str_replace( '`', '', $bb_queries ) ) );

		require_once( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' );
		bb_update_db_version();

		/* Set the site admins as the keymasters */
		$site_admins = get_site_option( 'site_admins', array('admin') );
		foreach ( (array)$site_admins as $site_admin )
			update_user_meta( bp_core_get_userid( $site_admin ), $bb_table_prefix . 'capabilities', array( 'keymaster' => true ) );

		// Create the first forum.
		bb_new_forum( array( 'forum_name' => 'Default Forum' ) );

		// Set the site URI
		bb_update_option( 'uri', BB_URL );
	}

	register_shutdown_function( create_function( '', 'do_action("bb_shutdown");' ) );
}