bp_forums_load_bbpress

Bootstrap bbPress 1.x, and manipulate globals to integrate with BuddyPress.

Description

(bool|null) bp_forums_load_bbpress(); 

Returns (bool|null)

Returns false on failure.


Usage

  1. if ( !function_exists( 'bp_forums_load_bbpress' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bp-forums-bbpress-sa.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_forums_load_bbpress(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bp-forums-bbpress-sa.php  
  1. function bp_forums_load_bbpress() { 
  2. global $wpdb, $wp_roles, $current_user, $wp_users_object; 
  3. global $bb, $bbdb, $bb_table_prefix, $bb_current_user; 
  4. global $bb_roles, $wp_taxonomy_object, $bb_queries; 
  5.  
  6. // Return if we've already run this function. 
  7. if ( is_object( $bbdb ) ) 
  8. return; 
  9.  
  10. if ( !bp_forums_is_installed_correctly() ) 
  11. return false; 
  12.  
  13. $bp =buddypress); 
  14.  
  15. define( 'BB_PATH', $bp->plugin_dir . '/bp-forums/bbpress/' ); 
  16. define( 'BACKPRESS_PATH', $bp->plugin_dir . '/bp-forums/bbpress/bb-includes/backpress/' ); 
  17. define( 'BB_URL', $bp->plugin_url . 'bp-forums/bbpress/' ); 
  18. define( 'BB_INC', 'bb-includes/' ); 
  19.  
  20. require( BB_PATH . BB_INC . 'class.bb-query.php' ); 
  21. require( BB_PATH . BB_INC . 'class.bb-walker.php' ); 
  22.  
  23. require( BB_PATH . BB_INC . 'functions.bb-core.php' ); 
  24. require( BB_PATH . BB_INC . 'functions.bb-forums.php' ); 
  25. require( BB_PATH . BB_INC . 'functions.bb-topics.php' ); 
  26. require( BB_PATH . BB_INC . 'functions.bb-posts.php' ); 
  27. require( BB_PATH . BB_INC . 'functions.bb-topic-tags.php' ); 
  28. require( BB_PATH . BB_INC . 'functions.bb-capabilities.php' ); 
  29. require( BB_PATH . BB_INC . 'functions.bb-meta.php' ); 
  30. require( BB_PATH . BB_INC . 'functions.bb-pluggable.php' ); 
  31. require( BB_PATH . BB_INC . 'functions.bb-formatting.php' ); 
  32. require( BB_PATH . BB_INC . 'functions.bb-template.php' ); 
  33.  
  34. require( BACKPRESS_PATH . 'class.wp-taxonomy.php' ); 
  35. require( BB_PATH . BB_INC . 'class.bb-taxonomy.php' ); 
  36.  
  37. require( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' ); 
  38.  
  39. $bb = new stdClass(); 
  40. require( bp_get_option( 'bb-config-location' ) ); 
  41.  
  42. // Setup the global database connection. 
  43.  
  44. // Set the table names. 
  45. $bbdb->forums = $bb_table_prefix . 'forums'; 
  46. $bbdb->meta = $bb_table_prefix . 'meta'; 
  47. $bbdb->posts = $bb_table_prefix . 'posts'; 
  48. $bbdb->terms = $bb_table_prefix . 'terms'; 
  49. $bbdb->term_relationships = $bb_table_prefix . 'term_relationships'; 
  50. $bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy'; 
  51. $bbdb->topics = $bb_table_prefix . 'topics'; 
  52.  
  53. if ( isset( $bb->custom_user_table ) ) 
  54. $bbdb->users = $bb->custom_user_table; 
  55. else 
  56. $bbdb->users = $wpdb->users; 
  57.  
  58. if ( isset( $bb->custom_user_meta_table ) ) 
  59. $bbdb->usermeta = $bb->custom_user_meta_table; 
  60. else 
  61. $bbdb->usermeta = $wpdb->usermeta; 
  62.  
  63. $bbdb->prefix = $bb_table_prefix; 
  64.  
  65. define( 'BB_INSTALLING', false ); 
  66.  
  67. if ( is_object( $wp_roles ) ) { 
  68. $bb_roles = $wp_roles; 
  69. bb_init_roles( $bb_roles ); 
  70.  
  71. /** 
  72. * Fires during the bootstrap setup for bbPress 1.x. 
  73. * @since 1.1.0 
  74. */ 
  75.  
  76. /** 
  77. * Fires during the bootstrap setup for bbPress 1.x. 
  78. * @since 1.1.0 
  79. */ 
  80.  
  81. /** 
  82. * Fires during the bootstrap setup for bbPress 1.x. 
  83. * @since 1.1.0 
  84. */ 
  85.  
  86. $bb_current_user = $current_user; 
  87. $wp_users_object = new BP_Forums_BB_Auth; 
  88.  
  89. if ( !isset( $wp_taxonomy_object ) ) 
  90. $wp_taxonomy_object = new BB_Taxonomy( $bbdb ); 
  91.  
  92. $wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' ); 
  93.  
  94. // Set a site id if there isn't one already. 
  95. if ( !isset( $bb->site_id ) ) 
  96. $bb->site_id = bp_get_root_blog_id(); 
  97.  
  98. // Check if the tables are installed, if not, install them. 
  99. if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) ) { 
  100. require( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' ); 
  101.  
  102. // Backticks and "IF NOT EXISTS" break the dbDelta function. 
  103. bp_bb_dbDelta( str_replace( ' IF NOT EXISTS', '', str_replace( '`', '', $bb_queries ) ) ); 
  104.  
  105. require( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' ); 
  106.  
  107. // Set the site admins as the keymasters. 
  108. $site_admins = get_site_option( 'site_admins', array('admin') ); 
  109. foreach ( (array) $site_admins as $site_admin ) 
  110. bp_update_user_meta( bp_core_get_userid( $site_admin ), $bb_table_prefix . 'capabilities', array( 'keymaster' => true ) ); 
  111.  
  112. // Create the first forum. 
  113. bb_new_forum( array( 'forum_name' => 'Default Forum' ) ); 
  114.  
  115. // Set the site URI. 
  116. bb_update_option( 'uri', BB_URL ); 
  117.  
  118. /** 
  119. * Fires inside an anonymous function that is run on bbPress shutdown. 
  120. * @since 1.1.0 
  121. */ 
  122. register_shutdown_function( function() { do_action( 'bb_shutdown' ); } );